Skip to content

Commit

Permalink
feat(Context-Based Restrictions): add service group support to operat…
Browse files Browse the repository at this point in the history
…ions (#277)

Signed-off-by: Dylan <Dylan.Yu@ibm.com>
  • Loading branch information
JonahFarc committed Sep 13, 2023
1 parent 05cccd0 commit 8ecdfa5
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 50 deletions.
86 changes: 66 additions & 20 deletions contextbasedrestrictionsv1/context_based_restrictions_v1.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corp. 2022.
* (C) Copyright IBM Corp. 2023.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,7 +15,7 @@
*/

/*
* IBM OpenAPI SDK Code Generator Version: 3.57.1-4c556507-20220928-143422
* IBM OpenAPI SDK Code Generator Version: 3.79.0-2eb6af3d-20230905-174838
*/

// Package contextbasedrestrictionsv1 : Operations and models for the ContextBasedRestrictionsV1 service
Expand Down Expand Up @@ -1047,10 +1047,6 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) ListAvailableService

// ListAvailableServiceOperationsWithContext is an alternate form of the ListAvailableServiceOperations method which supports a Context parameter
func (contextBasedRestrictions *ContextBasedRestrictionsV1) ListAvailableServiceOperationsWithContext(ctx context.Context, listAvailableServiceOperationsOptions *ListAvailableServiceOperationsOptions) (result *OperationsList, response *core.DetailedResponse, err error) {
err = core.ValidateNotNil(listAvailableServiceOperationsOptions, "listAvailableServiceOperationsOptions cannot be nil")
if err != nil {
return
}
err = core.ValidateStruct(listAvailableServiceOperationsOptions, "listAvailableServiceOperationsOptions")
if err != nil {
return
Expand Down Expand Up @@ -1080,7 +1076,15 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) ListAvailableService
builder.AddHeader("Transaction-Id", fmt.Sprint(*listAvailableServiceOperationsOptions.TransactionID))
}

builder.AddQuery("service_name", fmt.Sprint(*listAvailableServiceOperationsOptions.ServiceName))
if listAvailableServiceOperationsOptions.ServiceName != nil {
builder.AddQuery("service_name", fmt.Sprint(*listAvailableServiceOperationsOptions.ServiceName))
}
if listAvailableServiceOperationsOptions.ServiceGroupID != nil {
builder.AddQuery("service_group_id", fmt.Sprint(*listAvailableServiceOperationsOptions.ServiceGroupID))
}
if listAvailableServiceOperationsOptions.ResourceType != nil {
builder.AddQuery("resource_type", fmt.Sprint(*listAvailableServiceOperationsOptions.ResourceType))
}

request, err := builder.Build()
if err != nil {
Expand Down Expand Up @@ -1345,6 +1349,7 @@ type CreateRuleOptions struct {
// The `Transaction-Id` header behaves as the `X-Correlation-Id` header. It is supported for backward compatibility
// with other IBM platform services that support the `Transaction-Id` header only. If both `X-Correlation-Id` and
// `Transaction-Id` are provided, `X-Correlation-Id` has the precedence over `Transaction-Id`.
// Deprecated: this field is deprecated and may be removed in a future release.
TransactionID *string `json:"Transaction-Id,omitempty"`

// Allows users to set headers on API requests
Expand Down Expand Up @@ -1404,6 +1409,7 @@ func (_options *CreateRuleOptions) SetXCorrelationID(xCorrelationID string) *Cre
}

// SetTransactionID : Allow user to set TransactionID
// Deprecated: this method is deprecated and may be removed in a future release.
func (_options *CreateRuleOptions) SetTransactionID(transactionID string) *CreateRuleOptions {
_options.TransactionID = core.StringPtr(transactionID)
return _options
Expand Down Expand Up @@ -1441,6 +1447,7 @@ type CreateZoneOptions struct {
// The `Transaction-Id` header behaves as the `X-Correlation-Id` header. It is supported for backward compatibility
// with other IBM platform services that support the `Transaction-Id` header only. If both `X-Correlation-Id` and
// `Transaction-Id` are provided, `X-Correlation-Id` has the precedence over `Transaction-Id`.
// Deprecated: this field is deprecated and may be removed in a future release.
TransactionID *string `json:"Transaction-Id,omitempty"`

// Allows users to set headers on API requests
Expand Down Expand Up @@ -1489,6 +1496,7 @@ func (_options *CreateZoneOptions) SetXCorrelationID(xCorrelationID string) *Cre
}

// SetTransactionID : Allow user to set TransactionID
// Deprecated: this method is deprecated and may be removed in a future release.
func (_options *CreateZoneOptions) SetTransactionID(transactionID string) *CreateZoneOptions {
_options.TransactionID = core.StringPtr(transactionID)
return _options
Expand All @@ -1513,6 +1521,7 @@ type DeleteRuleOptions struct {
// The `Transaction-Id` header behaves as the `X-Correlation-Id` header. It is supported for backward compatibility
// with other IBM platform services that support the `Transaction-Id` header only. If both `X-Correlation-Id` and
// `Transaction-Id` are provided, `X-Correlation-Id` has the precedence over `Transaction-Id`.
// Deprecated: this field is deprecated and may be removed in a future release.
TransactionID *string `json:"Transaction-Id,omitempty"`

// Allows users to set headers on API requests
Expand All @@ -1539,6 +1548,7 @@ func (_options *DeleteRuleOptions) SetXCorrelationID(xCorrelationID string) *Del
}

// SetTransactionID : Allow user to set TransactionID
// Deprecated: this method is deprecated and may be removed in a future release.
func (_options *DeleteRuleOptions) SetTransactionID(transactionID string) *DeleteRuleOptions {
_options.TransactionID = core.StringPtr(transactionID)
return _options
Expand All @@ -1563,6 +1573,7 @@ type DeleteZoneOptions struct {
// The `Transaction-Id` header behaves as the `X-Correlation-Id` header. It is supported for backward compatibility
// with other IBM platform services that support the `Transaction-Id` header only. If both `X-Correlation-Id` and
// `Transaction-Id` are provided, `X-Correlation-Id` has the precedence over `Transaction-Id`.
// Deprecated: this field is deprecated and may be removed in a future release.
TransactionID *string `json:"Transaction-Id,omitempty"`

// Allows users to set headers on API requests
Expand All @@ -1589,6 +1600,7 @@ func (_options *DeleteZoneOptions) SetXCorrelationID(xCorrelationID string) *Del
}

// SetTransactionID : Allow user to set TransactionID
// Deprecated: this method is deprecated and may be removed in a future release.
func (_options *DeleteZoneOptions) SetTransactionID(transactionID string) *DeleteZoneOptions {
_options.TransactionID = core.StringPtr(transactionID)
return _options
Expand All @@ -1613,6 +1625,7 @@ type GetAccountSettingsOptions struct {
// The `Transaction-Id` header behaves as the `X-Correlation-Id` header. It is supported for backward compatibility
// with other IBM platform services that support the `Transaction-Id` header only. If both `X-Correlation-Id` and
// `Transaction-Id` are provided, `X-Correlation-Id` has the precedence over `Transaction-Id`.
// Deprecated: this field is deprecated and may be removed in a future release.
TransactionID *string `json:"Transaction-Id,omitempty"`

// Allows users to set headers on API requests
Expand All @@ -1639,6 +1652,7 @@ func (_options *GetAccountSettingsOptions) SetXCorrelationID(xCorrelationID stri
}

// SetTransactionID : Allow user to set TransactionID
// Deprecated: this method is deprecated and may be removed in a future release.
func (_options *GetAccountSettingsOptions) SetTransactionID(transactionID string) *GetAccountSettingsOptions {
_options.TransactionID = core.StringPtr(transactionID)
return _options
Expand All @@ -1663,6 +1677,7 @@ type GetRuleOptions struct {
// The `Transaction-Id` header behaves as the `X-Correlation-Id` header. It is supported for backward compatibility
// with other IBM platform services that support the `Transaction-Id` header only. If both `X-Correlation-Id` and
// `Transaction-Id` are provided, `X-Correlation-Id` has the precedence over `Transaction-Id`.
// Deprecated: this field is deprecated and may be removed in a future release.
TransactionID *string `json:"Transaction-Id,omitempty"`

// Allows users to set headers on API requests
Expand All @@ -1689,6 +1704,7 @@ func (_options *GetRuleOptions) SetXCorrelationID(xCorrelationID string) *GetRul
}

// SetTransactionID : Allow user to set TransactionID
// Deprecated: this method is deprecated and may be removed in a future release.
func (_options *GetRuleOptions) SetTransactionID(transactionID string) *GetRuleOptions {
_options.TransactionID = core.StringPtr(transactionID)
return _options
Expand All @@ -1713,6 +1729,7 @@ type GetZoneOptions struct {
// The `Transaction-Id` header behaves as the `X-Correlation-Id` header. It is supported for backward compatibility
// with other IBM platform services that support the `Transaction-Id` header only. If both `X-Correlation-Id` and
// `Transaction-Id` are provided, `X-Correlation-Id` has the precedence over `Transaction-Id`.
// Deprecated: this field is deprecated and may be removed in a future release.
TransactionID *string `json:"Transaction-Id,omitempty"`

// Allows users to set headers on API requests
Expand All @@ -1739,6 +1756,7 @@ func (_options *GetZoneOptions) SetXCorrelationID(xCorrelationID string) *GetZon
}

// SetTransactionID : Allow user to set TransactionID
// Deprecated: this method is deprecated and may be removed in a future release.
func (_options *GetZoneOptions) SetTransactionID(transactionID string) *GetZoneOptions {
_options.TransactionID = core.StringPtr(transactionID)
return _options
Expand All @@ -1752,9 +1770,6 @@ func (options *GetZoneOptions) SetHeaders(param map[string]string) *GetZoneOptio

// ListAvailableServiceOperationsOptions : The ListAvailableServiceOperations options.
type ListAvailableServiceOperationsOptions struct {
// The name of the service.
ServiceName *string `json:"service_name" validate:"required"`

// The supplied or generated value of this header is logged for a request and repeated in a response header for the
// corresponding response. The same value is used for downstream requests and retries of those requests. If a value of
// this headers is not supplied in a request, the service generates a random (version 4) UUID.
Expand All @@ -1763,23 +1778,25 @@ type ListAvailableServiceOperationsOptions struct {
// The `Transaction-Id` header behaves as the `X-Correlation-Id` header. It is supported for backward compatibility
// with other IBM platform services that support the `Transaction-Id` header only. If both `X-Correlation-Id` and
// `Transaction-Id` are provided, `X-Correlation-Id` has the precedence over `Transaction-Id`.
// Deprecated: this field is deprecated and may be removed in a future release.
TransactionID *string `json:"Transaction-Id,omitempty"`

// The name of the service.
ServiceName *string `json:"service_name,omitempty"`

// The id of the service group.
ServiceGroupID *string `json:"service_group_id,omitempty"`

// The type of resource.
ResourceType *string `json:"resource_type,omitempty"`

// Allows users to set headers on API requests
Headers map[string]string
}

// NewListAvailableServiceOperationsOptions : Instantiate ListAvailableServiceOperationsOptions
func (*ContextBasedRestrictionsV1) NewListAvailableServiceOperationsOptions(serviceName string) *ListAvailableServiceOperationsOptions {
return &ListAvailableServiceOperationsOptions{
ServiceName: core.StringPtr(serviceName),
}
}

// SetServiceName : Allow user to set ServiceName
func (_options *ListAvailableServiceOperationsOptions) SetServiceName(serviceName string) *ListAvailableServiceOperationsOptions {
_options.ServiceName = core.StringPtr(serviceName)
return _options
func (*ContextBasedRestrictionsV1) NewListAvailableServiceOperationsOptions() *ListAvailableServiceOperationsOptions {
return &ListAvailableServiceOperationsOptions{}
}

// SetXCorrelationID : Allow user to set XCorrelationID
Expand All @@ -1789,11 +1806,30 @@ func (_options *ListAvailableServiceOperationsOptions) SetXCorrelationID(xCorrel
}

// SetTransactionID : Allow user to set TransactionID
// Deprecated: this method is deprecated and may be removed in a future release.
func (_options *ListAvailableServiceOperationsOptions) SetTransactionID(transactionID string) *ListAvailableServiceOperationsOptions {
_options.TransactionID = core.StringPtr(transactionID)
return _options
}

// SetServiceName : Allow user to set ServiceName
func (_options *ListAvailableServiceOperationsOptions) SetServiceName(serviceName string) *ListAvailableServiceOperationsOptions {
_options.ServiceName = core.StringPtr(serviceName)
return _options
}

// SetServiceGroupID : Allow user to set ServiceGroupID
func (_options *ListAvailableServiceOperationsOptions) SetServiceGroupID(serviceGroupID string) *ListAvailableServiceOperationsOptions {
_options.ServiceGroupID = core.StringPtr(serviceGroupID)
return _options
}

// SetResourceType : Allow user to set ResourceType
func (_options *ListAvailableServiceOperationsOptions) SetResourceType(resourceType string) *ListAvailableServiceOperationsOptions {
_options.ResourceType = core.StringPtr(resourceType)
return _options
}

// SetHeaders : Allow user to set Headers
func (options *ListAvailableServiceOperationsOptions) SetHeaders(param map[string]string) *ListAvailableServiceOperationsOptions {
options.Headers = param
Expand All @@ -1810,6 +1846,7 @@ type ListAvailableServicerefTargetsOptions struct {
// The `Transaction-Id` header behaves as the `X-Correlation-Id` header. It is supported for backward compatibility
// with other IBM platform services that support the `Transaction-Id` header only. If both `X-Correlation-Id` and
// `Transaction-Id` are provided, `X-Correlation-Id` has the precedence over `Transaction-Id`.
// Deprecated: this field is deprecated and may be removed in a future release.
TransactionID *string `json:"Transaction-Id,omitempty"`

// Specifies the types of services to retrieve.
Expand Down Expand Up @@ -1838,6 +1875,7 @@ func (_options *ListAvailableServicerefTargetsOptions) SetXCorrelationID(xCorrel
}

// SetTransactionID : Allow user to set TransactionID
// Deprecated: this method is deprecated and may be removed in a future release.
func (_options *ListAvailableServicerefTargetsOptions) SetTransactionID(transactionID string) *ListAvailableServicerefTargetsOptions {
_options.TransactionID = core.StringPtr(transactionID)
return _options
Expand Down Expand Up @@ -1868,6 +1906,7 @@ type ListRulesOptions struct {
// The `Transaction-Id` header behaves as the `X-Correlation-Id` header. It is supported for backward compatibility
// with other IBM platform services that support the `Transaction-Id` header only. If both `X-Correlation-Id` and
// `Transaction-Id` are provided, `X-Correlation-Id` has the precedence over `Transaction-Id`.
// Deprecated: this field is deprecated and may be removed in a future release.
TransactionID *string `json:"Transaction-Id,omitempty"`

// The `region` resource attribute.
Expand Down Expand Up @@ -1933,6 +1972,7 @@ func (_options *ListRulesOptions) SetXCorrelationID(xCorrelationID string) *List
}

// SetTransactionID : Allow user to set TransactionID
// Deprecated: this method is deprecated and may be removed in a future release.
func (_options *ListRulesOptions) SetTransactionID(transactionID string) *ListRulesOptions {
_options.TransactionID = core.StringPtr(transactionID)
return _options
Expand Down Expand Up @@ -2017,6 +2057,7 @@ type ListZonesOptions struct {
// The `Transaction-Id` header behaves as the `X-Correlation-Id` header. It is supported for backward compatibility
// with other IBM platform services that support the `Transaction-Id` header only. If both `X-Correlation-Id` and
// `Transaction-Id` are provided, `X-Correlation-Id` has the precedence over `Transaction-Id`.
// Deprecated: this field is deprecated and may be removed in a future release.
TransactionID *string `json:"Transaction-Id,omitempty"`

// The name of the zone.
Expand Down Expand Up @@ -2050,6 +2091,7 @@ func (_options *ListZonesOptions) SetXCorrelationID(xCorrelationID string) *List
}

// SetTransactionID : Allow user to set TransactionID
// Deprecated: this method is deprecated and may be removed in a future release.
func (_options *ListZonesOptions) SetTransactionID(transactionID string) *ListZonesOptions {
_options.TransactionID = core.StringPtr(transactionID)
return _options
Expand Down Expand Up @@ -2176,6 +2218,7 @@ type ReplaceRuleOptions struct {
// The `Transaction-Id` header behaves as the `X-Correlation-Id` header. It is supported for backward compatibility
// with other IBM platform services that support the `Transaction-Id` header only. If both `X-Correlation-Id` and
// `Transaction-Id` are provided, `X-Correlation-Id` has the precedence over `Transaction-Id`.
// Deprecated: this field is deprecated and may be removed in a future release.
TransactionID *string `json:"Transaction-Id,omitempty"`

// Allows users to set headers on API requests
Expand Down Expand Up @@ -2250,6 +2293,7 @@ func (_options *ReplaceRuleOptions) SetXCorrelationID(xCorrelationID string) *Re
}

// SetTransactionID : Allow user to set TransactionID
// Deprecated: this method is deprecated and may be removed in a future release.
func (_options *ReplaceRuleOptions) SetTransactionID(transactionID string) *ReplaceRuleOptions {
_options.TransactionID = core.StringPtr(transactionID)
return _options
Expand Down Expand Up @@ -2294,6 +2338,7 @@ type ReplaceZoneOptions struct {
// The `Transaction-Id` header behaves as the `X-Correlation-Id` header. It is supported for backward compatibility
// with other IBM platform services that support the `Transaction-Id` header only. If both `X-Correlation-Id` and
// `Transaction-Id` are provided, `X-Correlation-Id` has the precedence over `Transaction-Id`.
// Deprecated: this field is deprecated and may be removed in a future release.
TransactionID *string `json:"Transaction-Id,omitempty"`

// Allows users to set headers on API requests
Expand Down Expand Up @@ -2357,6 +2402,7 @@ func (_options *ReplaceZoneOptions) SetXCorrelationID(xCorrelationID string) *Re
}

// SetTransactionID : Allow user to set TransactionID
// Deprecated: this method is deprecated and may be removed in a future release.
func (_options *ReplaceZoneOptions) SetTransactionID(transactionID string) *ReplaceZoneOptions {
_options.TransactionID = core.StringPtr(transactionID)
return _options
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// +build examples

/**
* (C) Copyright IBM Corp. 2022.
* (C) Copyright IBM Corp. 2023.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -461,9 +461,8 @@ var _ = Describe(`ContextBasedRestrictionsV1 Examples Tests`, func() {
fmt.Println("\nListAvailableServiceOperations() result:")
// begin-list_available_service_operations

listAvailableServiceOperationsOptions := contextBasedRestrictionsService.NewListAvailableServiceOperationsOptions(
"containers-kubernetes",
)
listAvailableServiceOperationsOptions := contextBasedRestrictionsService.NewListAvailableServiceOperationsOptions()
listAvailableServiceOperationsOptions.SetServiceName("containers-kubernetes")

operationsList, response, err := contextBasedRestrictionsService.ListAvailableServiceOperations(listAvailableServiceOperationsOptions)
if err != nil {
Expand Down

0 comments on commit 8ecdfa5

Please sign in to comment.