From 7a2cb4931c9123eca2fef85eef8be83b646fc218 Mon Sep 17 00:00:00 2001 From: Norbert Biczo Date: Fri, 18 Aug 2023 11:44:23 +0200 Subject: [PATCH 01/27] feat: bump Go versions (#271) Signed-off-by: Norbert Biczo Signed-off-by: manu.k.m --- .travis.yml | 4 ++-- README.md | 2 +- go.mod | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 18f0e458..fb02f193 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,9 @@ language: go dist: jammy go: -- 1.18.x - 1.19.x - 1.20.x +- 1.21.x notifications: email: true @@ -37,5 +37,5 @@ deploy: script: npm run semantic-release skip_cleanup: true on: - go: '1.18.x' + go: '1.19.x' branch: main diff --git a/README.md b/README.md index 18c342ab..aa76e9fc 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ Service Name | Package name * An [IBM Cloud][ibm-cloud-onboarding] account. * An IAM API key to allow the SDK to access your account. Create one [here](https://cloud.ibm.com/iam/apikeys). -* Go version 1.18 or above. +* Go version 1.19 or above. ## Installation The current version of this SDK: 0.45.0 diff --git a/go.mod b/go.mod index 8e0f91b6..6804ff89 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/IBM/platform-services-go-sdk -go 1.18 +go 1.19 require ( github.com/IBM/go-sdk-core/v5 v5.13.2 From 07d0c4f79a845c67a71757bb0d2f66f26a739564 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 18 Aug 2023 09:49:27 +0000 Subject: [PATCH 02/27] Update version 0.45.0 -> 0.46.0 [skip ci] Signed-off-by: manu.k.m --- .bumpversion.cfg | 2 +- README.md | 4 ++-- common/version.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 7955007b..81a65eca 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.45.0 +current_version = 0.46.0 commit = True message = Update version {current_version} -> {new_version} [skip ci] diff --git a/README.md b/README.md index aa76e9fc..365e9096 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![CLA assistant](https://cla-assistant.io/readme/badge/IBM/platform-services-go-sdk)](https://cla-assistant.io/IBM/platform-services-go-sdk) -# IBM Cloud Platform Services Go SDK Version 0.45.0 +# IBM Cloud Platform Services Go SDK Version 0.46.0 Go client library to interact with various [IBM Cloud Platform Service APIs](https://cloud.ibm.com/docs?tab=api-docs&category=platform_services). @@ -86,7 +86,7 @@ Service Name | Package name * Go version 1.19 or above. ## Installation -The current version of this SDK: 0.45.0 +The current version of this SDK: 0.46.0 ### Go modules If your application uses Go modules for dependency management (recommended), just add an import for each service diff --git a/common/version.go b/common/version.go index 31d951cf..2281c83b 100644 --- a/common/version.go +++ b/common/version.go @@ -17,4 +17,4 @@ package common // Version of the SDK -const Version = "0.45.0" +const Version = "0.46.0" From 15d15f3b1054a942f1035aa73d9aaa8dada95525 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 18 Aug 2023 09:49:27 +0000 Subject: [PATCH 03/27] chore(release): 0.46.0 release notes [skip ci] # [0.46.0](https://github.com/IBM/platform-services-go-sdk/compare/v0.45.0...v0.46.0) (2023-08-18) ### Features * bump Go versions ([#271](https://github.com/IBM/platform-services-go-sdk/issues/271)) ([d5e0092](https://github.com/IBM/platform-services-go-sdk/commit/d5e009266f93f130743de2a9e91d38219508d3c6)) Signed-off-by: manu.k.m --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f962b5a..fab3b81f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [0.46.0](https://github.com/IBM/platform-services-go-sdk/compare/v0.45.0...v0.46.0) (2023-08-18) + + +### Features + +* bump Go versions ([#271](https://github.com/IBM/platform-services-go-sdk/issues/271)) ([d5e0092](https://github.com/IBM/platform-services-go-sdk/commit/d5e009266f93f130743de2a9e91d38219508d3c6)) + # [0.45.0](https://github.com/IBM/platform-services-go-sdk/compare/v0.44.0...v0.45.0) (2023-08-15) From 5334e873931a5c1d772c0a711f3e68160f1b9eb2 Mon Sep 17 00:00:00 2001 From: "manu.k.m" Date: Thu, 24 Aug 2023 22:06:57 +0530 Subject: [PATCH 04/27] feat(Usage Reports): add billing snapshot config service to usage reports Signed-off-by: manu.k.m --- usagereportsv4/usage_reports_v4.go | 1509 +++++++++++++++++++++-- usagereportsv4/usage_reports_v4_test.go | 1216 ++++++++++++++++-- 2 files changed, 2526 insertions(+), 199 deletions(-) diff --git a/usagereportsv4/usage_reports_v4.go b/usagereportsv4/usage_reports_v4.go index 18af7f7e..cbf496a7 100644 --- a/usagereportsv4/usage_reports_v4.go +++ b/usagereportsv4/usage_reports_v4.go @@ -15,7 +15,7 @@ */ /* - * IBM OpenAPI SDK Code Generator Version: 3.64.1-cee95189-20230124-211647 + * IBM OpenAPI SDK Code Generator Version: 3.75.0-726bc7e3-20230713-221716 */ // Package usagereportsv4 : Operations and models for the UsageReportsV4 service @@ -178,7 +178,7 @@ func (usageReports *UsageReportsV4) GetAccountSummaryWithContext(ctx context.Con } pathParamsMap := map[string]string{ - "account_id": *getAccountSummaryOptions.AccountID, + "account_id": *getAccountSummaryOptions.AccountID, "billingmonth": *getAccountSummaryOptions.Billingmonth, } @@ -240,7 +240,7 @@ func (usageReports *UsageReportsV4) GetAccountUsageWithContext(ctx context.Conte } pathParamsMap := map[string]string{ - "account_id": *getAccountUsageOptions.AccountID, + "account_id": *getAccountUsageOptions.AccountID, "billingmonth": *getAccountUsageOptions.Billingmonth, } @@ -309,9 +309,9 @@ func (usageReports *UsageReportsV4) GetResourceGroupUsageWithContext(ctx context } pathParamsMap := map[string]string{ - "account_id": *getResourceGroupUsageOptions.AccountID, + "account_id": *getResourceGroupUsageOptions.AccountID, "resource_group_id": *getResourceGroupUsageOptions.ResourceGroupID, - "billingmonth": *getResourceGroupUsageOptions.Billingmonth, + "billingmonth": *getResourceGroupUsageOptions.Billingmonth, } builder := core.NewRequestBuilder(core.GET) @@ -379,7 +379,7 @@ func (usageReports *UsageReportsV4) GetResourceUsageAccountWithContext(ctx conte } pathParamsMap := map[string]string{ - "account_id": *getResourceUsageAccountOptions.AccountID, + "account_id": *getResourceUsageAccountOptions.AccountID, "billingmonth": *getResourceUsageAccountOptions.Billingmonth, } @@ -472,9 +472,9 @@ func (usageReports *UsageReportsV4) GetResourceUsageResourceGroupWithContext(ctx } pathParamsMap := map[string]string{ - "account_id": *getResourceUsageResourceGroupOptions.AccountID, + "account_id": *getResourceUsageResourceGroupOptions.AccountID, "resource_group_id": *getResourceUsageResourceGroupOptions.ResourceGroupID, - "billingmonth": *getResourceUsageResourceGroupOptions.Billingmonth, + "billingmonth": *getResourceUsageResourceGroupOptions.Billingmonth, } builder := core.NewRequestBuilder(core.GET) @@ -560,9 +560,9 @@ func (usageReports *UsageReportsV4) GetResourceUsageOrgWithContext(ctx context.C } pathParamsMap := map[string]string{ - "account_id": *getResourceUsageOrgOptions.AccountID, + "account_id": *getResourceUsageOrgOptions.AccountID, "organization_id": *getResourceUsageOrgOptions.OrganizationID, - "billingmonth": *getResourceUsageOrgOptions.Billingmonth, + "billingmonth": *getResourceUsageOrgOptions.Billingmonth, } builder := core.NewRequestBuilder(core.GET) @@ -648,9 +648,9 @@ func (usageReports *UsageReportsV4) GetOrgUsageWithContext(ctx context.Context, } pathParamsMap := map[string]string{ - "account_id": *getOrgUsageOptions.AccountID, + "account_id": *getOrgUsageOptions.AccountID, "organization_id": *getOrgUsageOptions.OrganizationID, - "billingmonth": *getOrgUsageOptions.Billingmonth, + "billingmonth": *getOrgUsageOptions.Billingmonth, } builder := core.NewRequestBuilder(core.GET) @@ -699,79 +699,1120 @@ func (usageReports *UsageReportsV4) GetOrgUsageWithContext(ctx context.Context, return } +// CreateReportsSnapshotConfig : Setup the snapshot configuration +// Snapshots of the billing reports would be taken on a periodic interval and stored based on the configuration setup by +// the customer for the given Account Id. +func (usageReports *UsageReportsV4) CreateReportsSnapshotConfig(createReportsSnapshotConfigOptions *CreateReportsSnapshotConfigOptions) (result *SnapshotConfig, response *core.DetailedResponse, err error) { + return usageReports.CreateReportsSnapshotConfigWithContext(context.Background(), createReportsSnapshotConfigOptions) +} + +// CreateReportsSnapshotConfigWithContext is an alternate form of the CreateReportsSnapshotConfig method which supports a Context parameter +func (usageReports *UsageReportsV4) CreateReportsSnapshotConfigWithContext(ctx context.Context, createReportsSnapshotConfigOptions *CreateReportsSnapshotConfigOptions) (result *SnapshotConfig, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createReportsSnapshotConfigOptions, "createReportsSnapshotConfigOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(createReportsSnapshotConfigOptions, "createReportsSnapshotConfigOptions") + if err != nil { + return + } + + builder := core.NewRequestBuilder(core.POST) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = usageReports.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(usageReports.Service.Options.URL, `/v1/billing-reports-snapshot-config`, nil) + if err != nil { + return + } + + for headerName, headerValue := range createReportsSnapshotConfigOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("usage_reports", "V4", "CreateReportsSnapshotConfig") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") + + body := make(map[string]interface{}) + if createReportsSnapshotConfigOptions.AccountID != nil { + body["account_id"] = createReportsSnapshotConfigOptions.AccountID + } + if createReportsSnapshotConfigOptions.Interval != nil { + body["interval"] = createReportsSnapshotConfigOptions.Interval + } + if createReportsSnapshotConfigOptions.CosBucket != nil { + body["cos_bucket"] = createReportsSnapshotConfigOptions.CosBucket + } + if createReportsSnapshotConfigOptions.CosLocation != nil { + body["cos_location"] = createReportsSnapshotConfigOptions.CosLocation + } + if createReportsSnapshotConfigOptions.CosReportsFolder != nil { + body["cos_reports_folder"] = createReportsSnapshotConfigOptions.CosReportsFolder + } + if createReportsSnapshotConfigOptions.ReportTypes != nil { + body["report_types"] = createReportsSnapshotConfigOptions.ReportTypes + } + if createReportsSnapshotConfigOptions.Versioning != nil { + body["versioning"] = createReportsSnapshotConfigOptions.Versioning + } + _, err = builder.SetBodyContentJSON(body) + if err != nil { + return + } + + request, err := builder.Build() + if err != nil { + return + } + + var rawResponse map[string]json.RawMessage + response, err = usageReports.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotConfig) + if err != nil { + return + } + response.Result = result + } + + return +} + +// GetReportsSnapshotConfig : Fetch the snapshot configuration +// Returns the configuration of snapshot of the billing reports setup by the customer for the given Account Id. +func (usageReports *UsageReportsV4) GetReportsSnapshotConfig(getReportsSnapshotConfigOptions *GetReportsSnapshotConfigOptions) (result *SnapshotConfig, response *core.DetailedResponse, err error) { + return usageReports.GetReportsSnapshotConfigWithContext(context.Background(), getReportsSnapshotConfigOptions) +} + +// GetReportsSnapshotConfigWithContext is an alternate form of the GetReportsSnapshotConfig method which supports a Context parameter +func (usageReports *UsageReportsV4) GetReportsSnapshotConfigWithContext(ctx context.Context, getReportsSnapshotConfigOptions *GetReportsSnapshotConfigOptions) (result *SnapshotConfig, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getReportsSnapshotConfigOptions, "getReportsSnapshotConfigOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(getReportsSnapshotConfigOptions, "getReportsSnapshotConfigOptions") + if err != nil { + return + } + + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = usageReports.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(usageReports.Service.Options.URL, `/v1/billing-reports-snapshot-config`, nil) + if err != nil { + return + } + + for headerName, headerValue := range getReportsSnapshotConfigOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("usage_reports", "V4", "GetReportsSnapshotConfig") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + + builder.AddQuery("account_id", fmt.Sprint(*getReportsSnapshotConfigOptions.AccountID)) + + request, err := builder.Build() + if err != nil { + return + } + + var rawResponse map[string]json.RawMessage + response, err = usageReports.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotConfig) + if err != nil { + return + } + response.Result = result + } + + return +} + +// UpdateReportsSnapshotConfig : Update the snapshot configuration +// Updates the configuration of snapshot of the billing reports setup by the customer for the given Account Id. +func (usageReports *UsageReportsV4) UpdateReportsSnapshotConfig(updateReportsSnapshotConfigOptions *UpdateReportsSnapshotConfigOptions) (result *SnapshotConfig, response *core.DetailedResponse, err error) { + return usageReports.UpdateReportsSnapshotConfigWithContext(context.Background(), updateReportsSnapshotConfigOptions) +} + +// UpdateReportsSnapshotConfigWithContext is an alternate form of the UpdateReportsSnapshotConfig method which supports a Context parameter +func (usageReports *UsageReportsV4) UpdateReportsSnapshotConfigWithContext(ctx context.Context, updateReportsSnapshotConfigOptions *UpdateReportsSnapshotConfigOptions) (result *SnapshotConfig, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(updateReportsSnapshotConfigOptions, "updateReportsSnapshotConfigOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(updateReportsSnapshotConfigOptions, "updateReportsSnapshotConfigOptions") + if err != nil { + return + } + + builder := core.NewRequestBuilder(core.PATCH) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = usageReports.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(usageReports.Service.Options.URL, `/v1/billing-reports-snapshot-config`, nil) + if err != nil { + return + } + + for headerName, headerValue := range updateReportsSnapshotConfigOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("usage_reports", "V4", "UpdateReportsSnapshotConfig") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") + + body := make(map[string]interface{}) + if updateReportsSnapshotConfigOptions.AccountID != nil { + body["account_id"] = updateReportsSnapshotConfigOptions.AccountID + } + if updateReportsSnapshotConfigOptions.Interval != nil { + body["interval"] = updateReportsSnapshotConfigOptions.Interval + } + if updateReportsSnapshotConfigOptions.CosBucket != nil { + body["cos_bucket"] = updateReportsSnapshotConfigOptions.CosBucket + } + if updateReportsSnapshotConfigOptions.CosLocation != nil { + body["cos_location"] = updateReportsSnapshotConfigOptions.CosLocation + } + if updateReportsSnapshotConfigOptions.CosReportsFolder != nil { + body["cos_reports_folder"] = updateReportsSnapshotConfigOptions.CosReportsFolder + } + if updateReportsSnapshotConfigOptions.ReportTypes != nil { + body["report_types"] = updateReportsSnapshotConfigOptions.ReportTypes + } + if updateReportsSnapshotConfigOptions.Versioning != nil { + body["versioning"] = updateReportsSnapshotConfigOptions.Versioning + } + _, err = builder.SetBodyContentJSON(body) + if err != nil { + return + } + + request, err := builder.Build() + if err != nil { + return + } + + var rawResponse map[string]json.RawMessage + response, err = usageReports.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotConfig) + if err != nil { + return + } + response.Result = result + } + + return +} + +// DeleteReportsSnapshotConfig : Delete the snapshot configuration +// Delete the configuration of snapshot of the billing reports setup by the customer for the given Account Id. +func (usageReports *UsageReportsV4) DeleteReportsSnapshotConfig(deleteReportsSnapshotConfigOptions *DeleteReportsSnapshotConfigOptions) (response *core.DetailedResponse, err error) { + return usageReports.DeleteReportsSnapshotConfigWithContext(context.Background(), deleteReportsSnapshotConfigOptions) +} + +// DeleteReportsSnapshotConfigWithContext is an alternate form of the DeleteReportsSnapshotConfig method which supports a Context parameter +func (usageReports *UsageReportsV4) DeleteReportsSnapshotConfigWithContext(ctx context.Context, deleteReportsSnapshotConfigOptions *DeleteReportsSnapshotConfigOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteReportsSnapshotConfigOptions, "deleteReportsSnapshotConfigOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(deleteReportsSnapshotConfigOptions, "deleteReportsSnapshotConfigOptions") + if err != nil { + return + } + + builder := core.NewRequestBuilder(core.DELETE) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = usageReports.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(usageReports.Service.Options.URL, `/v1/billing-reports-snapshot-config`, nil) + if err != nil { + return + } + + for headerName, headerValue := range deleteReportsSnapshotConfigOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("usage_reports", "V4", "DeleteReportsSnapshotConfig") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + + builder.AddQuery("account_id", fmt.Sprint(*deleteReportsSnapshotConfigOptions.AccountID)) + + request, err := builder.Build() + if err != nil { + return + } + + response, err = usageReports.Service.Request(request, nil) + + return +} + +// GetReportsSnapshot : Fetch the current or past snapshots +// Returns the billing reports snapshots captured for the given Account Id in the specific time period. +func (usageReports *UsageReportsV4) GetReportsSnapshot(getReportsSnapshotOptions *GetReportsSnapshotOptions) (result *SnapshotList, response *core.DetailedResponse, err error) { + return usageReports.GetReportsSnapshotWithContext(context.Background(), getReportsSnapshotOptions) +} + +// GetReportsSnapshotWithContext is an alternate form of the GetReportsSnapshot method which supports a Context parameter +func (usageReports *UsageReportsV4) GetReportsSnapshotWithContext(ctx context.Context, getReportsSnapshotOptions *GetReportsSnapshotOptions) (result *SnapshotList, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getReportsSnapshotOptions, "getReportsSnapshotOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(getReportsSnapshotOptions, "getReportsSnapshotOptions") + if err != nil { + return + } + + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = usageReports.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(usageReports.Service.Options.URL, `/v1/billing-reports-snapshots`, nil) + if err != nil { + return + } + + for headerName, headerValue := range getReportsSnapshotOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("usage_reports", "V4", "GetReportsSnapshot") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + + builder.AddQuery("account_id", fmt.Sprint(*getReportsSnapshotOptions.AccountID)) + builder.AddQuery("month", fmt.Sprint(*getReportsSnapshotOptions.Month)) + if getReportsSnapshotOptions.DateFrom != nil { + builder.AddQuery("date_from", fmt.Sprint(*getReportsSnapshotOptions.DateFrom)) + } + if getReportsSnapshotOptions.DateTo != nil { + builder.AddQuery("date_to", fmt.Sprint(*getReportsSnapshotOptions.DateTo)) + } + + request, err := builder.Build() + if err != nil { + return + } + + var rawResponse map[string]json.RawMessage + response, err = usageReports.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotList) + if err != nil { + return + } + response.Result = result + } + + return +} + // AccountSummary : A summary of charges and credits for an account. type AccountSummary struct { // The ID of the account. AccountID *string `json:"account_id" validate:"required"` - // The list of account resources for the month. - AccountResources []Resource `json:"account_resources,omitempty"` + // The list of account resources for the month. + AccountResources []Resource `json:"account_resources,omitempty"` + + // The month in which usages were incurred. Represented in yyyy-mm format. + Month *string `json:"month" validate:"required"` + + // Country. + BillingCountryCode *string `json:"billing_country_code" validate:"required"` + + // The currency in which the account is billed. + BillingCurrencyCode *string `json:"billing_currency_code" validate:"required"` + + // Charges related to cloud resources. + Resources *ResourcesSummary `json:"resources" validate:"required"` + + // The list of offers applicable for the account for the month. + Offers []Offer `json:"offers" validate:"required"` + + // Support-related charges. + Support []SupportSummary `json:"support" validate:"required"` + + // The list of support resources for the month. + SupportResources []interface{} `json:"support_resources,omitempty"` + + // A summary of charges and credits related to a subscription. + Subscription *SubscriptionSummary `json:"subscription" validate:"required"` +} + +// UnmarshalAccountSummary unmarshals an instance of AccountSummary from the specified map of raw messages. +func UnmarshalAccountSummary(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(AccountSummary) + err = core.UnmarshalPrimitive(m, "account_id", &obj.AccountID) + if err != nil { + return + } + err = core.UnmarshalModel(m, "account_resources", &obj.AccountResources, UnmarshalResource) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "month", &obj.Month) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "billing_country_code", &obj.BillingCountryCode) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "billing_currency_code", &obj.BillingCurrencyCode) + if err != nil { + return + } + err = core.UnmarshalModel(m, "resources", &obj.Resources, UnmarshalResourcesSummary) + if err != nil { + return + } + err = core.UnmarshalModel(m, "offers", &obj.Offers, UnmarshalOffer) + if err != nil { + return + } + err = core.UnmarshalModel(m, "support", &obj.Support, UnmarshalSupportSummary) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "support_resources", &obj.SupportResources) + if err != nil { + return + } + err = core.UnmarshalModel(m, "subscription", &obj.Subscription, UnmarshalSubscriptionSummary) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// AccountUsage : The aggregated usage and charges for all the plans in the account. +type AccountUsage struct { + // The ID of the account. + AccountID *string `json:"account_id" validate:"required"` + + // The target country pricing that should be used. + PricingCountry *string `json:"pricing_country" validate:"required"` + + // The currency for the cost fields in the resources, plans and metrics. + CurrencyCode *string `json:"currency_code" validate:"required"` + + // The month. + Month *string `json:"month" validate:"required"` + + // All the resource used in the account. + Resources []Resource `json:"resources" validate:"required"` + + // The value of the account's currency in USD. + CurrencyRate *float64 `json:"currency_rate,omitempty"` +} + +// UnmarshalAccountUsage unmarshals an instance of AccountUsage from the specified map of raw messages. +func UnmarshalAccountUsage(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(AccountUsage) + err = core.UnmarshalPrimitive(m, "account_id", &obj.AccountID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "pricing_country", &obj.PricingCountry) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "currency_code", &obj.CurrencyCode) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "month", &obj.Month) + if err != nil { + return + } + err = core.UnmarshalModel(m, "resources", &obj.Resources, UnmarshalResource) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "currency_rate", &obj.CurrencyRate) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// CreateReportsSnapshotConfigOptions : The CreateReportsSnapshotConfig options. +type CreateReportsSnapshotConfigOptions struct { + // Account ID for which billing report snapshot is configured. + AccountID *string `json:"account_id" validate:"required"` + + // Frequency of taking the snapshot of the billing reports. + Interval *string `json:"interval" validate:"required"` + + // The name of the COS bucket to store the snapshot of the billing reports. + CosBucket *string `json:"cos_bucket" validate:"required"` + + // Region of the COS instance. + CosLocation *string `json:"cos_location" validate:"required"` + + // The billing reports root folder to store the billing reports snapshots. Defaults to "IBMCloud-Billing-Reports". + CosReportsFolder *string `json:"cos_reports_folder,omitempty"` + + // The type of billing reports to take snapshot of. Possible values are [account_summary, enterprise_summary, + // account_resource_instance_usage]. + ReportTypes []string `json:"report_types,omitempty"` + + // A new version of report is created or the existing report version is overwritten with every update. Defaults to + // "new". + Versioning *string `json:"versioning,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// Constants associated with the CreateReportsSnapshotConfigOptions.Interval property. +// Frequency of taking the snapshot of the billing reports. +const ( + CreateReportsSnapshotConfigOptionsIntervalDailyConst = "daily" +) + +// Constants associated with the CreateReportsSnapshotConfigOptions.ReportTypes property. +const ( + CreateReportsSnapshotConfigOptionsReportTypesAccountResourceInstanceUsageConst = "account_resource_instance_usage" + CreateReportsSnapshotConfigOptionsReportTypesAccountSummaryConst = "account_summary" + CreateReportsSnapshotConfigOptionsReportTypesEnterpriseSummaryConst = "enterprise_summary" +) + +// Constants associated with the CreateReportsSnapshotConfigOptions.Versioning property. +// A new version of report is created or the existing report version is overwritten with every update. Defaults to +// "new". +const ( + CreateReportsSnapshotConfigOptionsVersioningNewConst = "new" + CreateReportsSnapshotConfigOptionsVersioningOverwriteConst = "overwrite" +) + +// NewCreateReportsSnapshotConfigOptions : Instantiate CreateReportsSnapshotConfigOptions +func (*UsageReportsV4) NewCreateReportsSnapshotConfigOptions(accountID string, interval string, cosBucket string, cosLocation string) *CreateReportsSnapshotConfigOptions { + return &CreateReportsSnapshotConfigOptions{ + AccountID: core.StringPtr(accountID), + Interval: core.StringPtr(interval), + CosBucket: core.StringPtr(cosBucket), + CosLocation: core.StringPtr(cosLocation), + } +} + +// SetAccountID : Allow user to set AccountID +func (_options *CreateReportsSnapshotConfigOptions) SetAccountID(accountID string) *CreateReportsSnapshotConfigOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetInterval : Allow user to set Interval +func (_options *CreateReportsSnapshotConfigOptions) SetInterval(interval string) *CreateReportsSnapshotConfigOptions { + _options.Interval = core.StringPtr(interval) + return _options +} + +// SetCosBucket : Allow user to set CosBucket +func (_options *CreateReportsSnapshotConfigOptions) SetCosBucket(cosBucket string) *CreateReportsSnapshotConfigOptions { + _options.CosBucket = core.StringPtr(cosBucket) + return _options +} + +// SetCosLocation : Allow user to set CosLocation +func (_options *CreateReportsSnapshotConfigOptions) SetCosLocation(cosLocation string) *CreateReportsSnapshotConfigOptions { + _options.CosLocation = core.StringPtr(cosLocation) + return _options +} + +// SetCosReportsFolder : Allow user to set CosReportsFolder +func (_options *CreateReportsSnapshotConfigOptions) SetCosReportsFolder(cosReportsFolder string) *CreateReportsSnapshotConfigOptions { + _options.CosReportsFolder = core.StringPtr(cosReportsFolder) + return _options +} + +// SetReportTypes : Allow user to set ReportTypes +func (_options *CreateReportsSnapshotConfigOptions) SetReportTypes(reportTypes []string) *CreateReportsSnapshotConfigOptions { + _options.ReportTypes = reportTypes + return _options +} + +// SetVersioning : Allow user to set Versioning +func (_options *CreateReportsSnapshotConfigOptions) SetVersioning(versioning string) *CreateReportsSnapshotConfigOptions { + _options.Versioning = core.StringPtr(versioning) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *CreateReportsSnapshotConfigOptions) SetHeaders(param map[string]string) *CreateReportsSnapshotConfigOptions { + options.Headers = param + return options +} + +// DeleteReportsSnapshotConfigOptions : The DeleteReportsSnapshotConfig options. +type DeleteReportsSnapshotConfigOptions struct { + // Account ID for which the billing report snapshot is configured. + AccountID *string `json:"account_id" validate:"required"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewDeleteReportsSnapshotConfigOptions : Instantiate DeleteReportsSnapshotConfigOptions +func (*UsageReportsV4) NewDeleteReportsSnapshotConfigOptions(accountID string) *DeleteReportsSnapshotConfigOptions { + return &DeleteReportsSnapshotConfigOptions{ + AccountID: core.StringPtr(accountID), + } +} + +// SetAccountID : Allow user to set AccountID +func (_options *DeleteReportsSnapshotConfigOptions) SetAccountID(accountID string) *DeleteReportsSnapshotConfigOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *DeleteReportsSnapshotConfigOptions) SetHeaders(param map[string]string) *DeleteReportsSnapshotConfigOptions { + options.Headers = param + return options +} + +// Discount : Information about a discount that is associated with a metric. +type Discount struct { + // The reference ID of the discount. + Ref *string `json:"ref" validate:"required"` + + // The name of the discount indicating category. + Name *string `json:"name,omitempty"` + + // The name of the discount. + DisplayName *string `json:"display_name,omitempty"` + + // The discount percentage. + Discount *float64 `json:"discount" validate:"required"` +} + +// UnmarshalDiscount unmarshals an instance of Discount from the specified map of raw messages. +func UnmarshalDiscount(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(Discount) + err = core.UnmarshalPrimitive(m, "ref", &obj.Ref) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "display_name", &obj.DisplayName) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "discount", &obj.Discount) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// GetAccountSummaryOptions : The GetAccountSummary options. +type GetAccountSummaryOptions struct { + // Account ID for which the usage report is requested. + AccountID *string `json:"account_id" validate:"required,ne="` + + // The billing month for which the usage report is requested. Format is yyyy-mm. + Billingmonth *string `json:"billingmonth" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetAccountSummaryOptions : Instantiate GetAccountSummaryOptions +func (*UsageReportsV4) NewGetAccountSummaryOptions(accountID string, billingmonth string) *GetAccountSummaryOptions { + return &GetAccountSummaryOptions{ + AccountID: core.StringPtr(accountID), + Billingmonth: core.StringPtr(billingmonth), + } +} + +// SetAccountID : Allow user to set AccountID +func (_options *GetAccountSummaryOptions) SetAccountID(accountID string) *GetAccountSummaryOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetBillingmonth : Allow user to set Billingmonth +func (_options *GetAccountSummaryOptions) SetBillingmonth(billingmonth string) *GetAccountSummaryOptions { + _options.Billingmonth = core.StringPtr(billingmonth) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetAccountSummaryOptions) SetHeaders(param map[string]string) *GetAccountSummaryOptions { + options.Headers = param + return options +} + +// GetReportsSnapshotConfigOptions : The GetReportsSnapshotConfig options. +type GetReportsSnapshotConfigOptions struct { + // Account ID for which the billing report snapshot is configured. + AccountID *string `json:"account_id" validate:"required"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetReportsSnapshotConfigOptions : Instantiate GetReportsSnapshotConfigOptions +func (*UsageReportsV4) NewGetReportsSnapshotConfigOptions(accountID string) *GetReportsSnapshotConfigOptions { + return &GetReportsSnapshotConfigOptions{ + AccountID: core.StringPtr(accountID), + } +} + +// SetAccountID : Allow user to set AccountID +func (_options *GetReportsSnapshotConfigOptions) SetAccountID(accountID string) *GetReportsSnapshotConfigOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetReportsSnapshotConfigOptions) SetHeaders(param map[string]string) *GetReportsSnapshotConfigOptions { + options.Headers = param + return options +} + +// GetReportsSnapshotOptions : The GetReportsSnapshot options. +type GetReportsSnapshotOptions struct { + // Account ID for which the billing report snapshot is requested. + AccountID *string `json:"account_id" validate:"required"` + + // The month for which billing report snapshot is requested. Format is yyyy-mm. + Month *string `json:"month" validate:"required"` + + // Timestamp in milliseconds for which billing report snapshot is requested. + DateFrom *int64 `json:"date_from,omitempty"` + + // Timestamp in milliseconds for which billing report snapshot is requested. + DateTo *int64 `json:"date_to,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetReportsSnapshotOptions : Instantiate GetReportsSnapshotOptions +func (*UsageReportsV4) NewGetReportsSnapshotOptions(accountID string, month string) *GetReportsSnapshotOptions { + return &GetReportsSnapshotOptions{ + AccountID: core.StringPtr(accountID), + Month: core.StringPtr(month), + } +} + +// SetAccountID : Allow user to set AccountID +func (_options *GetReportsSnapshotOptions) SetAccountID(accountID string) *GetReportsSnapshotOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetMonth : Allow user to set Month +func (_options *GetReportsSnapshotOptions) SetMonth(month string) *GetReportsSnapshotOptions { + _options.Month = core.StringPtr(month) + return _options +} + +// SetDateFrom : Allow user to set DateFrom +func (_options *GetReportsSnapshotOptions) SetDateFrom(dateFrom int64) *GetReportsSnapshotOptions { + _options.DateFrom = core.Int64Ptr(dateFrom) + return _options +} + +// SetDateTo : Allow user to set DateTo +func (_options *GetReportsSnapshotOptions) SetDateTo(dateTo int64) *GetReportsSnapshotOptions { + _options.DateTo = core.Int64Ptr(dateTo) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetReportsSnapshotOptions) SetHeaders(param map[string]string) *GetReportsSnapshotOptions { + options.Headers = param + return options +} + +// SnapshotConfigHistoryItem : SnapshotConfigHistoryItem struct +type SnapshotConfigHistoryItem struct { + // Timestamp in milliseconds when the snapshot configuration was created. + StartTime *int64 `json:"start_time,omitempty"` + + // Timestamp in milliseconds when the snapshot configuration ends. + EndTime *int64 `json:"end_time,omitempty"` + + // Account that updated the billing snapshot configuration. + UpdatedBy *string `json:"updated_by,omitempty"` + + // Account ID for which billing report snapshot is configured. + AccountID *string `json:"account_id,omitempty"` + + // Status of the billing snapshot configuration. Possible values are [enabled, disabled]. + State *string `json:"state,omitempty"` + + // Type of account. Possible values [enterprise, account]. + AccountType *string `json:"account_type,omitempty"` + + // Frequency of taking the snapshot of the billing reports. + Interval *string `json:"interval,omitempty"` + + // A new version of report is created or the existing report version is overwritten with every update. + Versioning *string `json:"versioning,omitempty"` + + // The type of billing reports to take snapshot of. Possible values are [account_summary, enterprise_summary, + // account_resource_instance_usage]. + ReportTypes []string `json:"report_types,omitempty"` + + // Compression format of the snapshot report. + Compression *string `json:"compression,omitempty"` + + // Type of content stored in snapshot report. + ContentType *string `json:"content_type,omitempty"` + + // The billing reports root folder to store the billing reports snapshots. Defaults to "IBMCloud-Billing-Reports". + CosReportsFolder *string `json:"cos_reports_folder,omitempty"` + + // The name of the COS bucket to store the snapshot of the billing reports. + CosBucket *string `json:"cos_bucket,omitempty"` + + // Region of the COS instance. + CosLocation *string `json:"cos_location,omitempty"` + + // The endpoint of the COS instance. + CosEndpoint *string `json:"cos_endpoint,omitempty"` +} + +// Constants associated with the SnapshotConfigHistoryItem.State property. +// Status of the billing snapshot configuration. Possible values are [enabled, disabled]. +const ( + SnapshotConfigHistoryItemStateDisabledConst = "disabled" + SnapshotConfigHistoryItemStateEnabledConst = "enabled" +) + +// Constants associated with the SnapshotConfigHistoryItem.AccountType property. +// Type of account. Possible values [enterprise, account]. +const ( + SnapshotConfigHistoryItemAccountTypeAccountConst = "account" + SnapshotConfigHistoryItemAccountTypeEnterpriseConst = "enterprise" +) + +// Constants associated with the SnapshotConfigHistoryItem.Interval property. +// Frequency of taking the snapshot of the billing reports. +const ( + SnapshotConfigHistoryItemIntervalDailyConst = "daily" +) + +// Constants associated with the SnapshotConfigHistoryItem.Versioning property. +// A new version of report is created or the existing report version is overwritten with every update. +const ( + SnapshotConfigHistoryItemVersioningNewConst = "new" + SnapshotConfigHistoryItemVersioningOverwriteConst = "overwrite" +) + +// Constants associated with the SnapshotConfigHistoryItem.ReportTypes property. +const ( + SnapshotConfigHistoryItemReportTypesAccountResourceInstanceUsageConst = "account_resource_instance_usage" + SnapshotConfigHistoryItemReportTypesAccountSummaryConst = "account_summary" + SnapshotConfigHistoryItemReportTypesEnterpriseSummaryConst = "enterprise_summary" +) + +// UnmarshalSnapshotConfigHistoryItem unmarshals an instance of SnapshotConfigHistoryItem from the specified map of raw messages. +func UnmarshalSnapshotConfigHistoryItem(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotConfigHistoryItem) + err = core.UnmarshalPrimitive(m, "start_time", &obj.StartTime) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "end_time", &obj.EndTime) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "updated_by", &obj.UpdatedBy) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "account_id", &obj.AccountID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "state", &obj.State) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "account_type", &obj.AccountType) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "interval", &obj.Interval) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "versioning", &obj.Versioning) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "report_types", &obj.ReportTypes) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "compression", &obj.Compression) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "content_type", &obj.ContentType) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "cos_reports_folder", &obj.CosReportsFolder) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "cos_bucket", &obj.CosBucket) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "cos_location", &obj.CosLocation) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "cos_endpoint", &obj.CosEndpoint) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// SnapshotList : List of billing reports snapshots. +type SnapshotList struct { + // Number of total snapshots. + Count *int64 `json:"count,omitempty"` + + // Reference to the first page of the search query. + First *SnapshotListFirst `json:"first,omitempty"` + + // Reference to the next page of the search query if any. + Next *SnapshotListNext `json:"next,omitempty"` + + Snapshots []SnapshotListSnapshotsItem `json:"snapshots,omitempty"` +} + +// UnmarshalSnapshotList unmarshals an instance of SnapshotList from the specified map of raw messages. +func UnmarshalSnapshotList(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotList) + err = core.UnmarshalPrimitive(m, "count", &obj.Count) + if err != nil { + return + } + err = core.UnmarshalModel(m, "first", &obj.First, UnmarshalSnapshotListFirst) + if err != nil { + return + } + err = core.UnmarshalModel(m, "next", &obj.Next, UnmarshalSnapshotListNext) + if err != nil { + return + } + err = core.UnmarshalModel(m, "snapshots", &obj.Snapshots, UnmarshalSnapshotListSnapshotsItem) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// SnapshotListFirst : Reference to the first page of the search query. +type SnapshotListFirst struct { + Href *string `json:"href,omitempty"` +} + +// UnmarshalSnapshotListFirst unmarshals an instance of SnapshotListFirst from the specified map of raw messages. +func UnmarshalSnapshotListFirst(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotListFirst) + err = core.UnmarshalPrimitive(m, "href", &obj.Href) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// SnapshotListNext : Reference to the next page of the search query if any. +type SnapshotListNext struct { + Href *string `json:"href,omitempty"` +} - // The month in which usages were incurred. Represented in yyyy-mm format. - Month *string `json:"month" validate:"required"` +// UnmarshalSnapshotListNext unmarshals an instance of SnapshotListNext from the specified map of raw messages. +func UnmarshalSnapshotListNext(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotListNext) + err = core.UnmarshalPrimitive(m, "href", &obj.Href) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} - // Country. - BillingCountryCode *string `json:"billing_country_code" validate:"required"` +// SnapshotListSnapshotsItem : Snapshot Schema. +type SnapshotListSnapshotsItem struct { + // Account ID for which billing report snapshot is configured. + AccountID *string `json:"account_id,omitempty"` - // The currency in which the account is billed. - BillingCurrencyCode *string `json:"billing_currency_code" validate:"required"` + // Month of captured snapshot. + Month *string `json:"month,omitempty"` - // Charges related to cloud resources. - Resources *ResourcesSummary `json:"resources" validate:"required"` + // Type of account. Possible values are [enterprise, account]. + AccountType *string `json:"account_type,omitempty"` - // The list of offers applicable for the account for the month. - Offers []Offer `json:"offers" validate:"required"` + // Timestamp of snapshot processed. + ExpectedProcessedAt *int64 `json:"expected_processed_at,omitempty"` - // Support-related charges. - Support []SupportSummary `json:"support" validate:"required"` + // Status of the billing snapshot configuration. Possible values are [enabled, disabled]. + State *string `json:"state,omitempty"` - // The list of support resources for the month. - SupportResources []interface{} `json:"support_resources,omitempty"` + // Period of billing in snapshot. + BillingPeriod *SnapshotListSnapshotsItemBillingPeriod `json:"billing_period,omitempty"` - // A summary of charges and credits related to a subscription. - Subscription *SubscriptionSummary `json:"subscription" validate:"required"` + // Id of the snapshot captured. + SnapshotID *string `json:"snapshot_id,omitempty"` + + // Character encoding used. + Charset *string `json:"charset,omitempty"` + + // Compression format of the snapshot report. + Compression *string `json:"compression,omitempty"` + + // Type of content stored in snapshot report. + ContentType *string `json:"content_type,omitempty"` + + // The name of the COS bucket to store the snapshot of the billing reports. + Bucket *string `json:"bucket,omitempty"` + + // Version of the snapshot. + Version *string `json:"version,omitempty"` + + // Date and time of creation of snapshot. + CreatedOn *string `json:"created_on,omitempty"` + + // List of report types configured for the snapshot. + ReportTypes []SnapshotListSnapshotsItemReportTypesItem `json:"report_types,omitempty"` + + // List of location of reports. + Files []SnapshotListSnapshotsItemFilesItem `json:"files,omitempty"` + + // Timestamp at which snapshot is captured. + ProcessedAt *int64 `json:"processed_at,omitempty"` } -// UnmarshalAccountSummary unmarshals an instance of AccountSummary from the specified map of raw messages. -func UnmarshalAccountSummary(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(AccountSummary) +// Constants associated with the SnapshotListSnapshotsItem.AccountType property. +// Type of account. Possible values are [enterprise, account]. +const ( + SnapshotListSnapshotsItemAccountTypeAccountConst = "account" + SnapshotListSnapshotsItemAccountTypeEnterpriseConst = "enterprise" +) + +// Constants associated with the SnapshotListSnapshotsItem.State property. +// Status of the billing snapshot configuration. Possible values are [enabled, disabled]. +const ( + SnapshotListSnapshotsItemStateDisabledConst = "disabled" + SnapshotListSnapshotsItemStateEnabledConst = "enabled" +) + +// UnmarshalSnapshotListSnapshotsItem unmarshals an instance of SnapshotListSnapshotsItem from the specified map of raw messages. +func UnmarshalSnapshotListSnapshotsItem(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotListSnapshotsItem) err = core.UnmarshalPrimitive(m, "account_id", &obj.AccountID) if err != nil { return } - err = core.UnmarshalModel(m, "account_resources", &obj.AccountResources, UnmarshalResource) + err = core.UnmarshalPrimitive(m, "month", &obj.Month) if err != nil { return } - err = core.UnmarshalPrimitive(m, "month", &obj.Month) + err = core.UnmarshalPrimitive(m, "account_type", &obj.AccountType) if err != nil { return } - err = core.UnmarshalPrimitive(m, "billing_country_code", &obj.BillingCountryCode) + err = core.UnmarshalPrimitive(m, "expected_processed_at", &obj.ExpectedProcessedAt) if err != nil { return } - err = core.UnmarshalPrimitive(m, "billing_currency_code", &obj.BillingCurrencyCode) + err = core.UnmarshalPrimitive(m, "state", &obj.State) if err != nil { return } - err = core.UnmarshalModel(m, "resources", &obj.Resources, UnmarshalResourcesSummary) + err = core.UnmarshalModel(m, "billing_period", &obj.BillingPeriod, UnmarshalSnapshotListSnapshotsItemBillingPeriod) if err != nil { return } - err = core.UnmarshalModel(m, "offers", &obj.Offers, UnmarshalOffer) + err = core.UnmarshalPrimitive(m, "snapshot_id", &obj.SnapshotID) if err != nil { return } - err = core.UnmarshalModel(m, "support", &obj.Support, UnmarshalSupportSummary) + err = core.UnmarshalPrimitive(m, "charset", &obj.Charset) if err != nil { return } - err = core.UnmarshalPrimitive(m, "support_resources", &obj.SupportResources) + err = core.UnmarshalPrimitive(m, "compression", &obj.Compression) if err != nil { return } - err = core.UnmarshalModel(m, "subscription", &obj.Subscription, UnmarshalSubscriptionSummary) + err = core.UnmarshalPrimitive(m, "content_type", &obj.ContentType) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "bucket", &obj.Bucket) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "version", &obj.Version) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "created_on", &obj.CreatedOn) + if err != nil { + return + } + err = core.UnmarshalModel(m, "report_types", &obj.ReportTypes, UnmarshalSnapshotListSnapshotsItemReportTypesItem) + if err != nil { + return + } + err = core.UnmarshalModel(m, "files", &obj.Files, UnmarshalSnapshotListSnapshotsItemFilesItem) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "processed_at", &obj.ProcessedAt) if err != nil { return } @@ -779,51 +1820,98 @@ func UnmarshalAccountSummary(m map[string]json.RawMessage, result interface{}) ( return } -// AccountUsage : The aggregated usage and charges for all the plans in the account. -type AccountUsage struct { - // The ID of the account. - AccountID *string `json:"account_id" validate:"required"` +// SnapshotListSnapshotsItemBillingPeriod : Period of billing in snapshot. +type SnapshotListSnapshotsItemBillingPeriod struct { + // Date and time of start of billing in the respective snapshot. + Start *string `json:"start,omitempty"` - // The target country pricing that should be used. - PricingCountry *string `json:"pricing_country" validate:"required"` + // Date and time of end of billing in the respective snapshot. + End *string `json:"end,omitempty"` +} - // The currency for the cost fields in the resources, plans and metrics. - CurrencyCode *string `json:"currency_code" validate:"required"` +// UnmarshalSnapshotListSnapshotsItemBillingPeriod unmarshals an instance of SnapshotListSnapshotsItemBillingPeriod from the specified map of raw messages. +func UnmarshalSnapshotListSnapshotsItemBillingPeriod(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotListSnapshotsItemBillingPeriod) + err = core.UnmarshalPrimitive(m, "start", &obj.Start) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "end", &obj.End) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} - // The month. - Month *string `json:"month" validate:"required"` +// SnapshotListSnapshotsItemFilesItem : SnapshotListSnapshotsItemFilesItem struct +type SnapshotListSnapshotsItemFilesItem struct { + // The type of billing report stored. Possible values are [account_summary, enterprise_summary, + // account_resource_instance_usage]. + ReportTypes *string `json:"report_types,omitempty"` - // All the resource used in the account. - Resources []Resource `json:"resources" validate:"required"` + // Absolute path of the billing report in the COS instance. + Location *string `json:"location,omitempty"` - // The value of the account's currency in USD. - CurrencyRate *float64 `json:"currency_rate,omitempty"` + // Account ID for which billing report is captured. + AccountID *string `json:"account_id,omitempty"` } -// UnmarshalAccountUsage unmarshals an instance of AccountUsage from the specified map of raw messages. -func UnmarshalAccountUsage(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(AccountUsage) - err = core.UnmarshalPrimitive(m, "account_id", &obj.AccountID) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "pricing_country", &obj.PricingCountry) +// Constants associated with the SnapshotListSnapshotsItemFilesItem.ReportTypes property. +// The type of billing report stored. Possible values are [account_summary, enterprise_summary, +// account_resource_instance_usage]. +const ( + SnapshotListSnapshotsItemFilesItemReportTypesAccountResourceInstanceUsageConst = "account_resource_instance_usage" + SnapshotListSnapshotsItemFilesItemReportTypesAccountSummaryConst = "account_summary" + SnapshotListSnapshotsItemFilesItemReportTypesEnterpriseSummaryConst = "enterprise_summary" +) + +// UnmarshalSnapshotListSnapshotsItemFilesItem unmarshals an instance of SnapshotListSnapshotsItemFilesItem from the specified map of raw messages. +func UnmarshalSnapshotListSnapshotsItemFilesItem(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotListSnapshotsItemFilesItem) + err = core.UnmarshalPrimitive(m, "report_types", &obj.ReportTypes) if err != nil { return } - err = core.UnmarshalPrimitive(m, "currency_code", &obj.CurrencyCode) + err = core.UnmarshalPrimitive(m, "location", &obj.Location) if err != nil { return } - err = core.UnmarshalPrimitive(m, "month", &obj.Month) + err = core.UnmarshalPrimitive(m, "account_id", &obj.AccountID) if err != nil { return } - err = core.UnmarshalModel(m, "resources", &obj.Resources, UnmarshalResource) + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// SnapshotListSnapshotsItemReportTypesItem : SnapshotListSnapshotsItemReportTypesItem struct +type SnapshotListSnapshotsItemReportTypesItem struct { + // The type of billing report of the snapshot. Possible values are [account_summary, enterprise_summary, + // account_resource_instance_usage]. + Type *string `json:"type,omitempty"` + + // Version of the snapshot. + Version *string `json:"version,omitempty"` +} + +// Constants associated with the SnapshotListSnapshotsItemReportTypesItem.Type property. +// The type of billing report of the snapshot. Possible values are [account_summary, enterprise_summary, +// account_resource_instance_usage]. +const ( + SnapshotListSnapshotsItemReportTypesItemTypeAccountResourceInstanceUsageConst = "account_resource_instance_usage" + SnapshotListSnapshotsItemReportTypesItemTypeAccountSummaryConst = "account_summary" + SnapshotListSnapshotsItemReportTypesItemTypeEnterpriseSummaryConst = "enterprise_summary" +) + +// UnmarshalSnapshotListSnapshotsItemReportTypesItem unmarshals an instance of SnapshotListSnapshotsItemReportTypesItem from the specified map of raw messages. +func UnmarshalSnapshotListSnapshotsItemReportTypesItem(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotListSnapshotsItemReportTypesItem) + err = core.UnmarshalPrimitive(m, "type", &obj.Type) if err != nil { return } - err = core.UnmarshalPrimitive(m, "currency_rate", &obj.CurrencyRate) + err = core.UnmarshalPrimitive(m, "version", &obj.Version) if err != nil { return } @@ -831,37 +1919,149 @@ func UnmarshalAccountUsage(m map[string]json.RawMessage, result interface{}) (er return } -// Discount : Information about a discount that is associated with a metric. -type Discount struct { - // The reference ID of the discount. - Ref *string `json:"ref" validate:"required"` +// SnapshotConfig : Billing reports snapshot configuration. +type SnapshotConfig struct { + // Account ID for which billing report snapshot is configured. + AccountID *string `json:"account_id,omitempty"` - // The name of the discount indicating category. - Name *string `json:"name,omitempty"` + // Status of the billing snapshot configuration. Possible values are [enabled, disabled]. + State *string `json:"state,omitempty"` - // The name of the discount. - DisplayName *string `json:"display_name,omitempty"` + // Type of account. Possible values are [enterprise, account]. + AccountType *string `json:"account_type,omitempty"` - // The discount percentage. - Discount *float64 `json:"discount" validate:"required"` + // Frequency of taking the snapshot of the billing reports. + Interval *string `json:"interval,omitempty"` + + // A new version of report is created or the existing report version is overwritten with every update. + Versioning *string `json:"versioning,omitempty"` + + // The type of billing reports to take snapshot of. Possible values are [account_summary, enterprise_summary, + // account_resource_instance_usage]. + ReportTypes []string `json:"report_types,omitempty"` + + // Compression format of the snapshot report. + Compression *string `json:"compression,omitempty"` + + // Type of content stored in snapshot report. + ContentType *string `json:"content_type,omitempty"` + + // The billing reports root folder to store the billing reports snapshots. Defaults to "IBMCloud-Billing-Reports". + CosReportsFolder *string `json:"cos_reports_folder,omitempty"` + + // The name of the COS bucket to store the snapshot of the billing reports. + CosBucket *string `json:"cos_bucket,omitempty"` + + // Region of the COS instance. + CosLocation *string `json:"cos_location,omitempty"` + + // The endpoint of the COS instance. + CosEndpoint *string `json:"cos_endpoint,omitempty"` + + // Timestamp in milliseconds when the snapshot configuration was created. + CreatedAt *int64 `json:"created_at,omitempty"` + + // Timestamp in milliseconds when the snapshot configuration was last updated. + LastUpdatedAt *int64 `json:"last_updated_at,omitempty"` + + // List of previous versions of the snapshot configurations. + History []SnapshotConfigHistoryItem `json:"history,omitempty"` } -// UnmarshalDiscount unmarshals an instance of Discount from the specified map of raw messages. -func UnmarshalDiscount(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(Discount) - err = core.UnmarshalPrimitive(m, "ref", &obj.Ref) +// Constants associated with the SnapshotConfig.State property. +// Status of the billing snapshot configuration. Possible values are [enabled, disabled]. +const ( + SnapshotConfigStateDisabledConst = "disabled" + SnapshotConfigStateEnabledConst = "enabled" +) + +// Constants associated with the SnapshotConfig.AccountType property. +// Type of account. Possible values are [enterprise, account]. +const ( + SnapshotConfigAccountTypeAccountConst = "account" + SnapshotConfigAccountTypeEnterpriseConst = "enterprise" +) + +// Constants associated with the SnapshotConfig.Interval property. +// Frequency of taking the snapshot of the billing reports. +const ( + SnapshotConfigIntervalDailyConst = "daily" +) + +// Constants associated with the SnapshotConfig.Versioning property. +// A new version of report is created or the existing report version is overwritten with every update. +const ( + SnapshotConfigVersioningNewConst = "new" + SnapshotConfigVersioningOverwriteConst = "overwrite" +) + +// Constants associated with the SnapshotConfig.ReportTypes property. +const ( + SnapshotConfigReportTypesAccountResourceInstanceUsageConst = "account_resource_instance_usage" + SnapshotConfigReportTypesAccountSummaryConst = "account_summary" + SnapshotConfigReportTypesEnterpriseSummaryConst = "enterprise_summary" +) + +// UnmarshalSnapshotConfig unmarshals an instance of SnapshotConfig from the specified map of raw messages. +func UnmarshalSnapshotConfig(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotConfig) + err = core.UnmarshalPrimitive(m, "account_id", &obj.AccountID) if err != nil { return } - err = core.UnmarshalPrimitive(m, "name", &obj.Name) + err = core.UnmarshalPrimitive(m, "state", &obj.State) if err != nil { return } - err = core.UnmarshalPrimitive(m, "display_name", &obj.DisplayName) + err = core.UnmarshalPrimitive(m, "account_type", &obj.AccountType) if err != nil { return } - err = core.UnmarshalPrimitive(m, "discount", &obj.Discount) + err = core.UnmarshalPrimitive(m, "interval", &obj.Interval) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "versioning", &obj.Versioning) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "report_types", &obj.ReportTypes) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "compression", &obj.Compression) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "content_type", &obj.ContentType) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "cos_reports_folder", &obj.CosReportsFolder) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "cos_bucket", &obj.CosBucket) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "cos_location", &obj.CosLocation) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "cos_endpoint", &obj.CosEndpoint) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "last_updated_at", &obj.LastUpdatedAt) + if err != nil { + return + } + err = core.UnmarshalModel(m, "history", &obj.History, UnmarshalSnapshotConfigHistoryItem) if err != nil { return } @@ -869,40 +2069,105 @@ func UnmarshalDiscount(m map[string]json.RawMessage, result interface{}) (err er return } -// GetAccountSummaryOptions : The GetAccountSummary options. -type GetAccountSummaryOptions struct { - // Account ID for which the usage report is requested. - AccountID *string `json:"account_id" validate:"required,ne="` +// UpdateReportsSnapshotConfigOptions : The UpdateReportsSnapshotConfig options. +type UpdateReportsSnapshotConfigOptions struct { + // Account ID for which billing report snapshot is configured. + AccountID *string `json:"account_id" validate:"required"` - // The billing month for which the usage report is requested. Format is yyyy-mm. - Billingmonth *string `json:"billingmonth" validate:"required,ne="` + // Frequency of taking the snapshot of the billing reports. + Interval *string `json:"interval,omitempty"` + + // The name of the COS bucket to store the snapshot of the billing reports. + CosBucket *string `json:"cos_bucket,omitempty"` + + // Region of the COS instance. + CosLocation *string `json:"cos_location,omitempty"` + + // The billing reports root folder to store the billing reports snapshots. + CosReportsFolder *string `json:"cos_reports_folder,omitempty"` + + // The type of billing reports to take snapshot of. Possible values are [account_summary, enterprise_summary, + // account_resource_instance_usage]. + ReportTypes []string `json:"report_types,omitempty"` + + // A new version of report is created or the existing report version is overwritten with every update. + Versioning *string `json:"versioning,omitempty"` // Allows users to set headers on API requests Headers map[string]string } -// NewGetAccountSummaryOptions : Instantiate GetAccountSummaryOptions -func (*UsageReportsV4) NewGetAccountSummaryOptions(accountID string, billingmonth string) *GetAccountSummaryOptions { - return &GetAccountSummaryOptions{ +// Constants associated with the UpdateReportsSnapshotConfigOptions.Interval property. +// Frequency of taking the snapshot of the billing reports. +const ( + UpdateReportsSnapshotConfigOptionsIntervalDailyConst = "daily" +) + +// Constants associated with the UpdateReportsSnapshotConfigOptions.ReportTypes property. +const ( + UpdateReportsSnapshotConfigOptionsReportTypesAccountResourceInstanceUsageConst = "account_resource_instance_usage" + UpdateReportsSnapshotConfigOptionsReportTypesAccountSummaryConst = "account_summary" + UpdateReportsSnapshotConfigOptionsReportTypesEnterpriseSummaryConst = "enterprise_summary" +) + +// Constants associated with the UpdateReportsSnapshotConfigOptions.Versioning property. +// A new version of report is created or the existing report version is overwritten with every update. +const ( + UpdateReportsSnapshotConfigOptionsVersioningNewConst = "new" + UpdateReportsSnapshotConfigOptionsVersioningOverwriteConst = "overwrite" +) + +// NewUpdateReportsSnapshotConfigOptions : Instantiate UpdateReportsSnapshotConfigOptions +func (*UsageReportsV4) NewUpdateReportsSnapshotConfigOptions(accountID string) *UpdateReportsSnapshotConfigOptions { + return &UpdateReportsSnapshotConfigOptions{ AccountID: core.StringPtr(accountID), - Billingmonth: core.StringPtr(billingmonth), } } // SetAccountID : Allow user to set AccountID -func (_options *GetAccountSummaryOptions) SetAccountID(accountID string) *GetAccountSummaryOptions { +func (_options *UpdateReportsSnapshotConfigOptions) SetAccountID(accountID string) *UpdateReportsSnapshotConfigOptions { _options.AccountID = core.StringPtr(accountID) return _options } -// SetBillingmonth : Allow user to set Billingmonth -func (_options *GetAccountSummaryOptions) SetBillingmonth(billingmonth string) *GetAccountSummaryOptions { - _options.Billingmonth = core.StringPtr(billingmonth) +// SetInterval : Allow user to set Interval +func (_options *UpdateReportsSnapshotConfigOptions) SetInterval(interval string) *UpdateReportsSnapshotConfigOptions { + _options.Interval = core.StringPtr(interval) + return _options +} + +// SetCosBucket : Allow user to set CosBucket +func (_options *UpdateReportsSnapshotConfigOptions) SetCosBucket(cosBucket string) *UpdateReportsSnapshotConfigOptions { + _options.CosBucket = core.StringPtr(cosBucket) + return _options +} + +// SetCosLocation : Allow user to set CosLocation +func (_options *UpdateReportsSnapshotConfigOptions) SetCosLocation(cosLocation string) *UpdateReportsSnapshotConfigOptions { + _options.CosLocation = core.StringPtr(cosLocation) + return _options +} + +// SetCosReportsFolder : Allow user to set CosReportsFolder +func (_options *UpdateReportsSnapshotConfigOptions) SetCosReportsFolder(cosReportsFolder string) *UpdateReportsSnapshotConfigOptions { + _options.CosReportsFolder = core.StringPtr(cosReportsFolder) + return _options +} + +// SetReportTypes : Allow user to set ReportTypes +func (_options *UpdateReportsSnapshotConfigOptions) SetReportTypes(reportTypes []string) *UpdateReportsSnapshotConfigOptions { + _options.ReportTypes = reportTypes + return _options +} + +// SetVersioning : Allow user to set Versioning +func (_options *UpdateReportsSnapshotConfigOptions) SetVersioning(versioning string) *UpdateReportsSnapshotConfigOptions { + _options.Versioning = core.StringPtr(versioning) return _options } // SetHeaders : Allow user to set Headers -func (options *GetAccountSummaryOptions) SetHeaders(param map[string]string) *GetAccountSummaryOptions { +func (options *UpdateReportsSnapshotConfigOptions) SetHeaders(param map[string]string) *UpdateReportsSnapshotConfigOptions { options.Headers = param return options } @@ -928,7 +2193,7 @@ type GetAccountUsageOptions struct { // NewGetAccountUsageOptions : Instantiate GetAccountUsageOptions func (*UsageReportsV4) NewGetAccountUsageOptions(accountID string, billingmonth string) *GetAccountUsageOptions { return &GetAccountUsageOptions{ - AccountID: core.StringPtr(accountID), + AccountID: core.StringPtr(accountID), Billingmonth: core.StringPtr(billingmonth), } } @@ -987,9 +2252,9 @@ type GetOrgUsageOptions struct { // NewGetOrgUsageOptions : Instantiate GetOrgUsageOptions func (*UsageReportsV4) NewGetOrgUsageOptions(accountID string, organizationID string, billingmonth string) *GetOrgUsageOptions { return &GetOrgUsageOptions{ - AccountID: core.StringPtr(accountID), + AccountID: core.StringPtr(accountID), OrganizationID: core.StringPtr(organizationID), - Billingmonth: core.StringPtr(billingmonth), + Billingmonth: core.StringPtr(billingmonth), } } @@ -1053,9 +2318,9 @@ type GetResourceGroupUsageOptions struct { // NewGetResourceGroupUsageOptions : Instantiate GetResourceGroupUsageOptions func (*UsageReportsV4) NewGetResourceGroupUsageOptions(accountID string, resourceGroupID string, billingmonth string) *GetResourceGroupUsageOptions { return &GetResourceGroupUsageOptions{ - AccountID: core.StringPtr(accountID), + AccountID: core.StringPtr(accountID), ResourceGroupID: core.StringPtr(resourceGroupID), - Billingmonth: core.StringPtr(billingmonth), + Billingmonth: core.StringPtr(billingmonth), } } @@ -1140,7 +2405,7 @@ type GetResourceUsageAccountOptions struct { // NewGetResourceUsageAccountOptions : Instantiate GetResourceUsageAccountOptions func (*UsageReportsV4) NewGetResourceUsageAccountOptions(accountID string, billingmonth string) *GetResourceUsageAccountOptions { return &GetResourceUsageAccountOptions{ - AccountID: core.StringPtr(accountID), + AccountID: core.StringPtr(accountID), Billingmonth: core.StringPtr(billingmonth), } } @@ -1265,9 +2530,9 @@ type GetResourceUsageOrgOptions struct { // NewGetResourceUsageOrgOptions : Instantiate GetResourceUsageOrgOptions func (*UsageReportsV4) NewGetResourceUsageOrgOptions(accountID string, organizationID string, billingmonth string) *GetResourceUsageOrgOptions { return &GetResourceUsageOrgOptions{ - AccountID: core.StringPtr(accountID), + AccountID: core.StringPtr(accountID), OrganizationID: core.StringPtr(organizationID), - Billingmonth: core.StringPtr(billingmonth), + Billingmonth: core.StringPtr(billingmonth), } } @@ -1385,9 +2650,9 @@ type GetResourceUsageResourceGroupOptions struct { // NewGetResourceUsageResourceGroupOptions : Instantiate GetResourceUsageResourceGroupOptions func (*UsageReportsV4) NewGetResourceUsageResourceGroupOptions(accountID string, resourceGroupID string, billingmonth string) *GetResourceUsageResourceGroupOptions { return &GetResourceUsageResourceGroupOptions{ - AccountID: core.StringPtr(accountID), + AccountID: core.StringPtr(accountID), ResourceGroupID: core.StringPtr(resourceGroupID), - Billingmonth: core.StringPtr(billingmonth), + Billingmonth: core.StringPtr(billingmonth), } } @@ -2393,13 +3658,11 @@ func UnmarshalSupportSummary(m map[string]json.RawMessage, result interface{}) ( return } -// // GetResourceUsageAccountPager can be used to simplify the use of the "GetResourceUsageAccount" method. -// type GetResourceUsageAccountPager struct { - hasNext bool - options *GetResourceUsageAccountOptions - client *UsageReportsV4 + hasNext bool + options *GetResourceUsageAccountOptions + client *UsageReportsV4 pageContext struct { next *string } @@ -2480,13 +3743,11 @@ func (pager *GetResourceUsageAccountPager) GetAll() (allItems []InstanceUsage, e return pager.GetAllWithContext(context.Background()) } -// // GetResourceUsageResourceGroupPager can be used to simplify the use of the "GetResourceUsageResourceGroup" method. -// type GetResourceUsageResourceGroupPager struct { - hasNext bool - options *GetResourceUsageResourceGroupOptions - client *UsageReportsV4 + hasNext bool + options *GetResourceUsageResourceGroupOptions + client *UsageReportsV4 pageContext struct { next *string } @@ -2567,13 +3828,11 @@ func (pager *GetResourceUsageResourceGroupPager) GetAll() (allItems []InstanceUs return pager.GetAllWithContext(context.Background()) } -// // GetResourceUsageOrgPager can be used to simplify the use of the "GetResourceUsageOrg" method. -// type GetResourceUsageOrgPager struct { - hasNext bool - options *GetResourceUsageOrgOptions - client *UsageReportsV4 + hasNext bool + options *GetResourceUsageOrgOptions + client *UsageReportsV4 pageContext struct { next *string } diff --git a/usagereportsv4/usage_reports_v4_test.go b/usagereportsv4/usage_reports_v4_test.go index 66e2e6c2..f929f6fd 100644 --- a/usagereportsv4/usage_reports_v4_test.go +++ b/usagereportsv4/usage_reports_v4_test.go @@ -66,14 +66,13 @@ var _ = Describe(`UsageReportsV4`, func() { Context(`Using external config, construct service client instances`, func() { // Map containing environment variables used in testing. var testEnvironment = map[string]string{ - "USAGE_REPORTS_URL": "https://usagereportsv4/api", + "USAGE_REPORTS_URL": "https://usagereportsv4/api", "USAGE_REPORTS_AUTH_TYPE": "noauth", } It(`Create service client using external config successfully`, func() { SetTestEnvironment(testEnvironment) - usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4UsingExternalConfig(&usagereportsv4.UsageReportsV4Options{ - }) + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4UsingExternalConfig(&usagereportsv4.UsageReportsV4Options{}) Expect(usageReportsService).ToNot(BeNil()) Expect(serviceErr).To(BeNil()) ClearTestEnvironment(testEnvironment) @@ -102,8 +101,7 @@ var _ = Describe(`UsageReportsV4`, func() { }) It(`Create service client using external config and set url programatically successfully`, func() { SetTestEnvironment(testEnvironment) - usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4UsingExternalConfig(&usagereportsv4.UsageReportsV4Options{ - }) + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4UsingExternalConfig(&usagereportsv4.UsageReportsV4Options{}) err := usageReportsService.SetServiceURL("https://testService/api") Expect(err).To(BeNil()) Expect(usageReportsService).ToNot(BeNil()) @@ -121,13 +119,12 @@ var _ = Describe(`UsageReportsV4`, func() { Context(`Using external config, construct service client instances with error: Invalid Auth`, func() { // Map containing environment variables used in testing. var testEnvironment = map[string]string{ - "USAGE_REPORTS_URL": "https://usagereportsv4/api", + "USAGE_REPORTS_URL": "https://usagereportsv4/api", "USAGE_REPORTS_AUTH_TYPE": "someOtherAuth", } SetTestEnvironment(testEnvironment) - usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4UsingExternalConfig(&usagereportsv4.UsageReportsV4Options{ - }) + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4UsingExternalConfig(&usagereportsv4.UsageReportsV4Options{}) It(`Instantiate service client with error`, func() { Expect(usageReportsService).To(BeNil()) @@ -138,7 +135,7 @@ var _ = Describe(`UsageReportsV4`, func() { Context(`Using external config, construct service client instances with error: Invalid URL`, func() { // Map containing environment variables used in testing. var testEnvironment = map[string]string{ - "USAGE_REPORTS_AUTH_TYPE": "NOAuth", + "USAGE_REPORTS_AUTH_TYPE": "NOAuth", } SetTestEnvironment(testEnvironment) @@ -1162,14 +1159,14 @@ var _ = Describe(`UsageReportsV4`, func() { nextObject := new(usagereportsv4.InstancesUsageNext) nextObject.Href = core.StringPtr("ibm.com?_start=abc-123") responseObject.Next = nextObject - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(Equal(core.StringPtr("abc-123"))) }) It(`Invoke GetNextStart without a "Next" property in the response`, func() { responseObject := new(usagereportsv4.InstancesUsage) - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -1179,7 +1176,7 @@ var _ = Describe(`UsageReportsV4`, func() { nextObject := new(usagereportsv4.InstancesUsageNext) nextObject.Href = core.StringPtr("ibm.com") responseObject.Next = nextObject - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -1217,17 +1214,17 @@ var _ = Describe(`UsageReportsV4`, func() { Expect(usageReportsService).ToNot(BeNil()) getResourceUsageAccountOptionsModel := &usagereportsv4.GetResourceUsageAccountOptions{ - AccountID: core.StringPtr("testString"), - Billingmonth: core.StringPtr("testString"), - Names: core.BoolPtr(true), - AcceptLanguage: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(1)), - ResourceGroupID: core.StringPtr("testString"), - OrganizationID: core.StringPtr("testString"), + AccountID: core.StringPtr("testString"), + Billingmonth: core.StringPtr("testString"), + Names: core.BoolPtr(true), + AcceptLanguage: core.StringPtr("testString"), + Limit: core.Int64Ptr(int64(1)), + ResourceGroupID: core.StringPtr("testString"), + OrganizationID: core.StringPtr("testString"), ResourceInstanceID: core.StringPtr("testString"), - ResourceID: core.StringPtr("testString"), - PlanID: core.StringPtr("testString"), - Region: core.StringPtr("testString"), + ResourceID: core.StringPtr("testString"), + PlanID: core.StringPtr("testString"), + Region: core.StringPtr("testString"), } pager, err := usageReportsService.NewGetResourceUsageAccountPager(getResourceUsageAccountOptionsModel) @@ -1252,17 +1249,17 @@ var _ = Describe(`UsageReportsV4`, func() { Expect(usageReportsService).ToNot(BeNil()) getResourceUsageAccountOptionsModel := &usagereportsv4.GetResourceUsageAccountOptions{ - AccountID: core.StringPtr("testString"), - Billingmonth: core.StringPtr("testString"), - Names: core.BoolPtr(true), - AcceptLanguage: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(1)), - ResourceGroupID: core.StringPtr("testString"), - OrganizationID: core.StringPtr("testString"), + AccountID: core.StringPtr("testString"), + Billingmonth: core.StringPtr("testString"), + Names: core.BoolPtr(true), + AcceptLanguage: core.StringPtr("testString"), + Limit: core.Int64Ptr(int64(1)), + ResourceGroupID: core.StringPtr("testString"), + OrganizationID: core.StringPtr("testString"), ResourceInstanceID: core.StringPtr("testString"), - ResourceID: core.StringPtr("testString"), - PlanID: core.StringPtr("testString"), - Region: core.StringPtr("testString"), + ResourceID: core.StringPtr("testString"), + PlanID: core.StringPtr("testString"), + Region: core.StringPtr("testString"), } pager, err := usageReportsService.NewGetResourceUsageAccountPager(getResourceUsageAccountOptionsModel) @@ -1570,14 +1567,14 @@ var _ = Describe(`UsageReportsV4`, func() { nextObject := new(usagereportsv4.InstancesUsageNext) nextObject.Href = core.StringPtr("ibm.com?_start=abc-123") responseObject.Next = nextObject - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(Equal(core.StringPtr("abc-123"))) }) It(`Invoke GetNextStart without a "Next" property in the response`, func() { responseObject := new(usagereportsv4.InstancesUsage) - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -1587,7 +1584,7 @@ var _ = Describe(`UsageReportsV4`, func() { nextObject := new(usagereportsv4.InstancesUsageNext) nextObject.Href = core.StringPtr("ibm.com") responseObject.Next = nextObject - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -1625,16 +1622,16 @@ var _ = Describe(`UsageReportsV4`, func() { Expect(usageReportsService).ToNot(BeNil()) getResourceUsageResourceGroupOptionsModel := &usagereportsv4.GetResourceUsageResourceGroupOptions{ - AccountID: core.StringPtr("testString"), - ResourceGroupID: core.StringPtr("testString"), - Billingmonth: core.StringPtr("testString"), - Names: core.BoolPtr(true), - AcceptLanguage: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(1)), + AccountID: core.StringPtr("testString"), + ResourceGroupID: core.StringPtr("testString"), + Billingmonth: core.StringPtr("testString"), + Names: core.BoolPtr(true), + AcceptLanguage: core.StringPtr("testString"), + Limit: core.Int64Ptr(int64(1)), ResourceInstanceID: core.StringPtr("testString"), - ResourceID: core.StringPtr("testString"), - PlanID: core.StringPtr("testString"), - Region: core.StringPtr("testString"), + ResourceID: core.StringPtr("testString"), + PlanID: core.StringPtr("testString"), + Region: core.StringPtr("testString"), } pager, err := usageReportsService.NewGetResourceUsageResourceGroupPager(getResourceUsageResourceGroupOptionsModel) @@ -1659,16 +1656,16 @@ var _ = Describe(`UsageReportsV4`, func() { Expect(usageReportsService).ToNot(BeNil()) getResourceUsageResourceGroupOptionsModel := &usagereportsv4.GetResourceUsageResourceGroupOptions{ - AccountID: core.StringPtr("testString"), - ResourceGroupID: core.StringPtr("testString"), - Billingmonth: core.StringPtr("testString"), - Names: core.BoolPtr(true), - AcceptLanguage: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(1)), + AccountID: core.StringPtr("testString"), + ResourceGroupID: core.StringPtr("testString"), + Billingmonth: core.StringPtr("testString"), + Names: core.BoolPtr(true), + AcceptLanguage: core.StringPtr("testString"), + Limit: core.Int64Ptr(int64(1)), ResourceInstanceID: core.StringPtr("testString"), - ResourceID: core.StringPtr("testString"), - PlanID: core.StringPtr("testString"), - Region: core.StringPtr("testString"), + ResourceID: core.StringPtr("testString"), + PlanID: core.StringPtr("testString"), + Region: core.StringPtr("testString"), } pager, err := usageReportsService.NewGetResourceUsageResourceGroupPager(getResourceUsageResourceGroupOptionsModel) @@ -1976,14 +1973,14 @@ var _ = Describe(`UsageReportsV4`, func() { nextObject := new(usagereportsv4.InstancesUsageNext) nextObject.Href = core.StringPtr("ibm.com?_start=abc-123") responseObject.Next = nextObject - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(Equal(core.StringPtr("abc-123"))) }) It(`Invoke GetNextStart without a "Next" property in the response`, func() { responseObject := new(usagereportsv4.InstancesUsage) - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -1993,7 +1990,7 @@ var _ = Describe(`UsageReportsV4`, func() { nextObject := new(usagereportsv4.InstancesUsageNext) nextObject.Href = core.StringPtr("ibm.com") responseObject.Next = nextObject - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -2031,16 +2028,16 @@ var _ = Describe(`UsageReportsV4`, func() { Expect(usageReportsService).ToNot(BeNil()) getResourceUsageOrgOptionsModel := &usagereportsv4.GetResourceUsageOrgOptions{ - AccountID: core.StringPtr("testString"), - OrganizationID: core.StringPtr("testString"), - Billingmonth: core.StringPtr("testString"), - Names: core.BoolPtr(true), - AcceptLanguage: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(1)), + AccountID: core.StringPtr("testString"), + OrganizationID: core.StringPtr("testString"), + Billingmonth: core.StringPtr("testString"), + Names: core.BoolPtr(true), + AcceptLanguage: core.StringPtr("testString"), + Limit: core.Int64Ptr(int64(1)), ResourceInstanceID: core.StringPtr("testString"), - ResourceID: core.StringPtr("testString"), - PlanID: core.StringPtr("testString"), - Region: core.StringPtr("testString"), + ResourceID: core.StringPtr("testString"), + PlanID: core.StringPtr("testString"), + Region: core.StringPtr("testString"), } pager, err := usageReportsService.NewGetResourceUsageOrgPager(getResourceUsageOrgOptionsModel) @@ -2065,16 +2062,16 @@ var _ = Describe(`UsageReportsV4`, func() { Expect(usageReportsService).ToNot(BeNil()) getResourceUsageOrgOptionsModel := &usagereportsv4.GetResourceUsageOrgOptions{ - AccountID: core.StringPtr("testString"), - OrganizationID: core.StringPtr("testString"), - Billingmonth: core.StringPtr("testString"), - Names: core.BoolPtr(true), - AcceptLanguage: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(1)), + AccountID: core.StringPtr("testString"), + OrganizationID: core.StringPtr("testString"), + Billingmonth: core.StringPtr("testString"), + Names: core.BoolPtr(true), + AcceptLanguage: core.StringPtr("testString"), + Limit: core.Int64Ptr(int64(1)), ResourceInstanceID: core.StringPtr("testString"), - ResourceID: core.StringPtr("testString"), - PlanID: core.StringPtr("testString"), - Region: core.StringPtr("testString"), + ResourceID: core.StringPtr("testString"), + PlanID: core.StringPtr("testString"), + Region: core.StringPtr("testString"), } pager, err := usageReportsService.NewGetResourceUsageOrgPager(getResourceUsageOrgOptionsModel) @@ -2329,6 +2326,1077 @@ var _ = Describe(`UsageReportsV4`, func() { }) }) }) + Describe(`CreateReportsSnapshotConfig(createReportsSnapshotConfigOptions *CreateReportsSnapshotConfigOptions) - Operation response error`, func() { + createReportsSnapshotConfigPath := "/v1/billing-reports-snapshot-config" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createReportsSnapshotConfigPath)) + Expect(req.Method).To(Equal("POST")) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(201) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke CreateReportsSnapshotConfig with error: Operation response processing error`, func() { + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4(&usagereportsv4.UsageReportsV4Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(usageReportsService).ToNot(BeNil()) + + // Construct an instance of the CreateReportsSnapshotConfigOptions model + createReportsSnapshotConfigOptionsModel := new(usagereportsv4.CreateReportsSnapshotConfigOptions) + createReportsSnapshotConfigOptionsModel.AccountID = core.StringPtr("abc") + createReportsSnapshotConfigOptionsModel.Interval = core.StringPtr("daily") + createReportsSnapshotConfigOptionsModel.CosBucket = core.StringPtr("bucket_name") + createReportsSnapshotConfigOptionsModel.CosLocation = core.StringPtr("us-south") + createReportsSnapshotConfigOptionsModel.CosReportsFolder = core.StringPtr("IBMCloud-Billing-Reports") + createReportsSnapshotConfigOptionsModel.ReportTypes = []string{"account_summary", "enterprise_summary", "account_resource_instance_usage"} + createReportsSnapshotConfigOptionsModel.Versioning = core.StringPtr("new") + createReportsSnapshotConfigOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := usageReportsService.CreateReportsSnapshotConfig(createReportsSnapshotConfigOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + usageReportsService.EnableRetries(0, 0) + result, response, operationErr = usageReportsService.CreateReportsSnapshotConfig(createReportsSnapshotConfigOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`CreateReportsSnapshotConfig(createReportsSnapshotConfigOptions *CreateReportsSnapshotConfigOptions)`, func() { + createReportsSnapshotConfigPath := "/v1/billing-reports-snapshot-config" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createReportsSnapshotConfigPath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"account_id": "abc", "state": "enabled", "account_type": "account", "interval": "daily", "versioning": "new", "report_types": ["account_summary"], "compression": "GZIP", "content_type": "text/csv", "cos_reports_folder": "IBMCloud-Billing-Reports", "cos_bucket": "bucket_name", "cos_location": "us-south", "cos_endpoint": "https://s3.us-west.cloud-object-storage.test.appdomain.cloud", "created_at": 1687469854342, "last_updated_at": 1687469989326, "history": [{"start_time": 1687469854342, "end_time": 1687469989326, "updated_by": "IBMid-506PR16K14", "account_id": "abc", "state": "enabled", "account_type": "account", "interval": "daily", "versioning": "new", "report_types": ["account_summary"], "compression": "GZIP", "content_type": "text/csv", "cos_reports_folder": "IBMCloud-Billing-Reports", "cos_bucket": "bucket_name", "cos_location": "us-south", "cos_endpoint": "https://s3.us-west.cloud-object-storage.test.appdomain.cloud"}]}`) + })) + }) + It(`Invoke CreateReportsSnapshotConfig successfully with retries`, func() { + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4(&usagereportsv4.UsageReportsV4Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(usageReportsService).ToNot(BeNil()) + usageReportsService.EnableRetries(0, 0) + + // Construct an instance of the CreateReportsSnapshotConfigOptions model + createReportsSnapshotConfigOptionsModel := new(usagereportsv4.CreateReportsSnapshotConfigOptions) + createReportsSnapshotConfigOptionsModel.AccountID = core.StringPtr("abc") + createReportsSnapshotConfigOptionsModel.Interval = core.StringPtr("daily") + createReportsSnapshotConfigOptionsModel.CosBucket = core.StringPtr("bucket_name") + createReportsSnapshotConfigOptionsModel.CosLocation = core.StringPtr("us-south") + createReportsSnapshotConfigOptionsModel.CosReportsFolder = core.StringPtr("IBMCloud-Billing-Reports") + createReportsSnapshotConfigOptionsModel.ReportTypes = []string{"account_summary", "enterprise_summary", "account_resource_instance_usage"} + createReportsSnapshotConfigOptionsModel.Versioning = core.StringPtr("new") + createReportsSnapshotConfigOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := usageReportsService.CreateReportsSnapshotConfigWithContext(ctx, createReportsSnapshotConfigOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + usageReportsService.DisableRetries() + result, response, operationErr := usageReportsService.CreateReportsSnapshotConfig(createReportsSnapshotConfigOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = usageReportsService.CreateReportsSnapshotConfigWithContext(ctx, createReportsSnapshotConfigOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createReportsSnapshotConfigPath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"account_id": "abc", "state": "enabled", "account_type": "account", "interval": "daily", "versioning": "new", "report_types": ["account_summary"], "compression": "GZIP", "content_type": "text/csv", "cos_reports_folder": "IBMCloud-Billing-Reports", "cos_bucket": "bucket_name", "cos_location": "us-south", "cos_endpoint": "https://s3.us-west.cloud-object-storage.test.appdomain.cloud", "created_at": 1687469854342, "last_updated_at": 1687469989326, "history": [{"start_time": 1687469854342, "end_time": 1687469989326, "updated_by": "IBMid-506PR16K14", "account_id": "abc", "state": "enabled", "account_type": "account", "interval": "daily", "versioning": "new", "report_types": ["account_summary"], "compression": "GZIP", "content_type": "text/csv", "cos_reports_folder": "IBMCloud-Billing-Reports", "cos_bucket": "bucket_name", "cos_location": "us-south", "cos_endpoint": "https://s3.us-west.cloud-object-storage.test.appdomain.cloud"}]}`) + })) + }) + It(`Invoke CreateReportsSnapshotConfig successfully`, func() { + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4(&usagereportsv4.UsageReportsV4Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(usageReportsService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := usageReportsService.CreateReportsSnapshotConfig(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the CreateReportsSnapshotConfigOptions model + createReportsSnapshotConfigOptionsModel := new(usagereportsv4.CreateReportsSnapshotConfigOptions) + createReportsSnapshotConfigOptionsModel.AccountID = core.StringPtr("abc") + createReportsSnapshotConfigOptionsModel.Interval = core.StringPtr("daily") + createReportsSnapshotConfigOptionsModel.CosBucket = core.StringPtr("bucket_name") + createReportsSnapshotConfigOptionsModel.CosLocation = core.StringPtr("us-south") + createReportsSnapshotConfigOptionsModel.CosReportsFolder = core.StringPtr("IBMCloud-Billing-Reports") + createReportsSnapshotConfigOptionsModel.ReportTypes = []string{"account_summary", "enterprise_summary", "account_resource_instance_usage"} + createReportsSnapshotConfigOptionsModel.Versioning = core.StringPtr("new") + createReportsSnapshotConfigOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = usageReportsService.CreateReportsSnapshotConfig(createReportsSnapshotConfigOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke CreateReportsSnapshotConfig with error: Operation validation and request error`, func() { + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4(&usagereportsv4.UsageReportsV4Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(usageReportsService).ToNot(BeNil()) + + // Construct an instance of the CreateReportsSnapshotConfigOptions model + createReportsSnapshotConfigOptionsModel := new(usagereportsv4.CreateReportsSnapshotConfigOptions) + createReportsSnapshotConfigOptionsModel.AccountID = core.StringPtr("abc") + createReportsSnapshotConfigOptionsModel.Interval = core.StringPtr("daily") + createReportsSnapshotConfigOptionsModel.CosBucket = core.StringPtr("bucket_name") + createReportsSnapshotConfigOptionsModel.CosLocation = core.StringPtr("us-south") + createReportsSnapshotConfigOptionsModel.CosReportsFolder = core.StringPtr("IBMCloud-Billing-Reports") + createReportsSnapshotConfigOptionsModel.ReportTypes = []string{"account_summary", "enterprise_summary", "account_resource_instance_usage"} + createReportsSnapshotConfigOptionsModel.Versioning = core.StringPtr("new") + createReportsSnapshotConfigOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := usageReportsService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := usageReportsService.CreateReportsSnapshotConfig(createReportsSnapshotConfigOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the CreateReportsSnapshotConfigOptions model with no property values + createReportsSnapshotConfigOptionsModelNew := new(usagereportsv4.CreateReportsSnapshotConfigOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = usageReportsService.CreateReportsSnapshotConfig(createReportsSnapshotConfigOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(201) + })) + }) + It(`Invoke CreateReportsSnapshotConfig successfully`, func() { + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4(&usagereportsv4.UsageReportsV4Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(usageReportsService).ToNot(BeNil()) + + // Construct an instance of the CreateReportsSnapshotConfigOptions model + createReportsSnapshotConfigOptionsModel := new(usagereportsv4.CreateReportsSnapshotConfigOptions) + createReportsSnapshotConfigOptionsModel.AccountID = core.StringPtr("abc") + createReportsSnapshotConfigOptionsModel.Interval = core.StringPtr("daily") + createReportsSnapshotConfigOptionsModel.CosBucket = core.StringPtr("bucket_name") + createReportsSnapshotConfigOptionsModel.CosLocation = core.StringPtr("us-south") + createReportsSnapshotConfigOptionsModel.CosReportsFolder = core.StringPtr("IBMCloud-Billing-Reports") + createReportsSnapshotConfigOptionsModel.ReportTypes = []string{"account_summary", "enterprise_summary", "account_resource_instance_usage"} + createReportsSnapshotConfigOptionsModel.Versioning = core.StringPtr("new") + createReportsSnapshotConfigOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := usageReportsService.CreateReportsSnapshotConfig(createReportsSnapshotConfigOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetReportsSnapshotConfig(getReportsSnapshotConfigOptions *GetReportsSnapshotConfigOptions) - Operation response error`, func() { + getReportsSnapshotConfigPath := "/v1/billing-reports-snapshot-config" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getReportsSnapshotConfigPath)) + Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["account_id"]).To(Equal([]string{"abc"})) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke GetReportsSnapshotConfig with error: Operation response processing error`, func() { + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4(&usagereportsv4.UsageReportsV4Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(usageReportsService).ToNot(BeNil()) + + // Construct an instance of the GetReportsSnapshotConfigOptions model + getReportsSnapshotConfigOptionsModel := new(usagereportsv4.GetReportsSnapshotConfigOptions) + getReportsSnapshotConfigOptionsModel.AccountID = core.StringPtr("abc") + getReportsSnapshotConfigOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := usageReportsService.GetReportsSnapshotConfig(getReportsSnapshotConfigOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + usageReportsService.EnableRetries(0, 0) + result, response, operationErr = usageReportsService.GetReportsSnapshotConfig(getReportsSnapshotConfigOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetReportsSnapshotConfig(getReportsSnapshotConfigOptions *GetReportsSnapshotConfigOptions)`, func() { + getReportsSnapshotConfigPath := "/v1/billing-reports-snapshot-config" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getReportsSnapshotConfigPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["account_id"]).To(Equal([]string{"abc"})) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"account_id": "abc", "state": "enabled", "account_type": "account", "interval": "daily", "versioning": "new", "report_types": ["account_summary"], "compression": "GZIP", "content_type": "text/csv", "cos_reports_folder": "IBMCloud-Billing-Reports", "cos_bucket": "bucket_name", "cos_location": "us-south", "cos_endpoint": "https://s3.us-west.cloud-object-storage.test.appdomain.cloud", "created_at": 1687469854342, "last_updated_at": 1687469989326, "history": [{"start_time": 1687469854342, "end_time": 1687469989326, "updated_by": "IBMid-506PR16K14", "account_id": "abc", "state": "enabled", "account_type": "account", "interval": "daily", "versioning": "new", "report_types": ["account_summary"], "compression": "GZIP", "content_type": "text/csv", "cos_reports_folder": "IBMCloud-Billing-Reports", "cos_bucket": "bucket_name", "cos_location": "us-south", "cos_endpoint": "https://s3.us-west.cloud-object-storage.test.appdomain.cloud"}]}`) + })) + }) + It(`Invoke GetReportsSnapshotConfig successfully with retries`, func() { + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4(&usagereportsv4.UsageReportsV4Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(usageReportsService).ToNot(BeNil()) + usageReportsService.EnableRetries(0, 0) + + // Construct an instance of the GetReportsSnapshotConfigOptions model + getReportsSnapshotConfigOptionsModel := new(usagereportsv4.GetReportsSnapshotConfigOptions) + getReportsSnapshotConfigOptionsModel.AccountID = core.StringPtr("abc") + getReportsSnapshotConfigOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := usageReportsService.GetReportsSnapshotConfigWithContext(ctx, getReportsSnapshotConfigOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + usageReportsService.DisableRetries() + result, response, operationErr := usageReportsService.GetReportsSnapshotConfig(getReportsSnapshotConfigOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = usageReportsService.GetReportsSnapshotConfigWithContext(ctx, getReportsSnapshotConfigOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getReportsSnapshotConfigPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["account_id"]).To(Equal([]string{"abc"})) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"account_id": "abc", "state": "enabled", "account_type": "account", "interval": "daily", "versioning": "new", "report_types": ["account_summary"], "compression": "GZIP", "content_type": "text/csv", "cos_reports_folder": "IBMCloud-Billing-Reports", "cos_bucket": "bucket_name", "cos_location": "us-south", "cos_endpoint": "https://s3.us-west.cloud-object-storage.test.appdomain.cloud", "created_at": 1687469854342, "last_updated_at": 1687469989326, "history": [{"start_time": 1687469854342, "end_time": 1687469989326, "updated_by": "IBMid-506PR16K14", "account_id": "abc", "state": "enabled", "account_type": "account", "interval": "daily", "versioning": "new", "report_types": ["account_summary"], "compression": "GZIP", "content_type": "text/csv", "cos_reports_folder": "IBMCloud-Billing-Reports", "cos_bucket": "bucket_name", "cos_location": "us-south", "cos_endpoint": "https://s3.us-west.cloud-object-storage.test.appdomain.cloud"}]}`) + })) + }) + It(`Invoke GetReportsSnapshotConfig successfully`, func() { + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4(&usagereportsv4.UsageReportsV4Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(usageReportsService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := usageReportsService.GetReportsSnapshotConfig(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the GetReportsSnapshotConfigOptions model + getReportsSnapshotConfigOptionsModel := new(usagereportsv4.GetReportsSnapshotConfigOptions) + getReportsSnapshotConfigOptionsModel.AccountID = core.StringPtr("abc") + getReportsSnapshotConfigOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = usageReportsService.GetReportsSnapshotConfig(getReportsSnapshotConfigOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke GetReportsSnapshotConfig with error: Operation validation and request error`, func() { + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4(&usagereportsv4.UsageReportsV4Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(usageReportsService).ToNot(BeNil()) + + // Construct an instance of the GetReportsSnapshotConfigOptions model + getReportsSnapshotConfigOptionsModel := new(usagereportsv4.GetReportsSnapshotConfigOptions) + getReportsSnapshotConfigOptionsModel.AccountID = core.StringPtr("abc") + getReportsSnapshotConfigOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := usageReportsService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := usageReportsService.GetReportsSnapshotConfig(getReportsSnapshotConfigOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the GetReportsSnapshotConfigOptions model with no property values + getReportsSnapshotConfigOptionsModelNew := new(usagereportsv4.GetReportsSnapshotConfigOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = usageReportsService.GetReportsSnapshotConfig(getReportsSnapshotConfigOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke GetReportsSnapshotConfig successfully`, func() { + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4(&usagereportsv4.UsageReportsV4Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(usageReportsService).ToNot(BeNil()) + + // Construct an instance of the GetReportsSnapshotConfigOptions model + getReportsSnapshotConfigOptionsModel := new(usagereportsv4.GetReportsSnapshotConfigOptions) + getReportsSnapshotConfigOptionsModel.AccountID = core.StringPtr("abc") + getReportsSnapshotConfigOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := usageReportsService.GetReportsSnapshotConfig(getReportsSnapshotConfigOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`UpdateReportsSnapshotConfig(updateReportsSnapshotConfigOptions *UpdateReportsSnapshotConfigOptions) - Operation response error`, func() { + updateReportsSnapshotConfigPath := "/v1/billing-reports-snapshot-config" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(updateReportsSnapshotConfigPath)) + Expect(req.Method).To(Equal("PATCH")) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke UpdateReportsSnapshotConfig with error: Operation response processing error`, func() { + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4(&usagereportsv4.UsageReportsV4Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(usageReportsService).ToNot(BeNil()) + + // Construct an instance of the UpdateReportsSnapshotConfigOptions model + updateReportsSnapshotConfigOptionsModel := new(usagereportsv4.UpdateReportsSnapshotConfigOptions) + updateReportsSnapshotConfigOptionsModel.AccountID = core.StringPtr("abc") + updateReportsSnapshotConfigOptionsModel.Interval = core.StringPtr("daily") + updateReportsSnapshotConfigOptionsModel.CosBucket = core.StringPtr("bucket_name") + updateReportsSnapshotConfigOptionsModel.CosLocation = core.StringPtr("us-south") + updateReportsSnapshotConfigOptionsModel.CosReportsFolder = core.StringPtr("IBMCloud-Billing-Reports") + updateReportsSnapshotConfigOptionsModel.ReportTypes = []string{"account_summary", "enterprise_summary", "account_resource_instance_usage"} + updateReportsSnapshotConfigOptionsModel.Versioning = core.StringPtr("new") + updateReportsSnapshotConfigOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := usageReportsService.UpdateReportsSnapshotConfig(updateReportsSnapshotConfigOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + usageReportsService.EnableRetries(0, 0) + result, response, operationErr = usageReportsService.UpdateReportsSnapshotConfig(updateReportsSnapshotConfigOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`UpdateReportsSnapshotConfig(updateReportsSnapshotConfigOptions *UpdateReportsSnapshotConfigOptions)`, func() { + updateReportsSnapshotConfigPath := "/v1/billing-reports-snapshot-config" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(updateReportsSnapshotConfigPath)) + Expect(req.Method).To(Equal("PATCH")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"account_id": "abc", "state": "enabled", "account_type": "account", "interval": "daily", "versioning": "new", "report_types": ["account_summary"], "compression": "GZIP", "content_type": "text/csv", "cos_reports_folder": "IBMCloud-Billing-Reports", "cos_bucket": "bucket_name", "cos_location": "us-south", "cos_endpoint": "https://s3.us-west.cloud-object-storage.test.appdomain.cloud", "created_at": 1687469854342, "last_updated_at": 1687469989326, "history": [{"start_time": 1687469854342, "end_time": 1687469989326, "updated_by": "IBMid-506PR16K14", "account_id": "abc", "state": "enabled", "account_type": "account", "interval": "daily", "versioning": "new", "report_types": ["account_summary"], "compression": "GZIP", "content_type": "text/csv", "cos_reports_folder": "IBMCloud-Billing-Reports", "cos_bucket": "bucket_name", "cos_location": "us-south", "cos_endpoint": "https://s3.us-west.cloud-object-storage.test.appdomain.cloud"}]}`) + })) + }) + It(`Invoke UpdateReportsSnapshotConfig successfully with retries`, func() { + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4(&usagereportsv4.UsageReportsV4Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(usageReportsService).ToNot(BeNil()) + usageReportsService.EnableRetries(0, 0) + + // Construct an instance of the UpdateReportsSnapshotConfigOptions model + updateReportsSnapshotConfigOptionsModel := new(usagereportsv4.UpdateReportsSnapshotConfigOptions) + updateReportsSnapshotConfigOptionsModel.AccountID = core.StringPtr("abc") + updateReportsSnapshotConfigOptionsModel.Interval = core.StringPtr("daily") + updateReportsSnapshotConfigOptionsModel.CosBucket = core.StringPtr("bucket_name") + updateReportsSnapshotConfigOptionsModel.CosLocation = core.StringPtr("us-south") + updateReportsSnapshotConfigOptionsModel.CosReportsFolder = core.StringPtr("IBMCloud-Billing-Reports") + updateReportsSnapshotConfigOptionsModel.ReportTypes = []string{"account_summary", "enterprise_summary", "account_resource_instance_usage"} + updateReportsSnapshotConfigOptionsModel.Versioning = core.StringPtr("new") + updateReportsSnapshotConfigOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := usageReportsService.UpdateReportsSnapshotConfigWithContext(ctx, updateReportsSnapshotConfigOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + usageReportsService.DisableRetries() + result, response, operationErr := usageReportsService.UpdateReportsSnapshotConfig(updateReportsSnapshotConfigOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = usageReportsService.UpdateReportsSnapshotConfigWithContext(ctx, updateReportsSnapshotConfigOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(updateReportsSnapshotConfigPath)) + Expect(req.Method).To(Equal("PATCH")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"account_id": "abc", "state": "enabled", "account_type": "account", "interval": "daily", "versioning": "new", "report_types": ["account_summary"], "compression": "GZIP", "content_type": "text/csv", "cos_reports_folder": "IBMCloud-Billing-Reports", "cos_bucket": "bucket_name", "cos_location": "us-south", "cos_endpoint": "https://s3.us-west.cloud-object-storage.test.appdomain.cloud", "created_at": 1687469854342, "last_updated_at": 1687469989326, "history": [{"start_time": 1687469854342, "end_time": 1687469989326, "updated_by": "IBMid-506PR16K14", "account_id": "abc", "state": "enabled", "account_type": "account", "interval": "daily", "versioning": "new", "report_types": ["account_summary"], "compression": "GZIP", "content_type": "text/csv", "cos_reports_folder": "IBMCloud-Billing-Reports", "cos_bucket": "bucket_name", "cos_location": "us-south", "cos_endpoint": "https://s3.us-west.cloud-object-storage.test.appdomain.cloud"}]}`) + })) + }) + It(`Invoke UpdateReportsSnapshotConfig successfully`, func() { + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4(&usagereportsv4.UsageReportsV4Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(usageReportsService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := usageReportsService.UpdateReportsSnapshotConfig(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the UpdateReportsSnapshotConfigOptions model + updateReportsSnapshotConfigOptionsModel := new(usagereportsv4.UpdateReportsSnapshotConfigOptions) + updateReportsSnapshotConfigOptionsModel.AccountID = core.StringPtr("abc") + updateReportsSnapshotConfigOptionsModel.Interval = core.StringPtr("daily") + updateReportsSnapshotConfigOptionsModel.CosBucket = core.StringPtr("bucket_name") + updateReportsSnapshotConfigOptionsModel.CosLocation = core.StringPtr("us-south") + updateReportsSnapshotConfigOptionsModel.CosReportsFolder = core.StringPtr("IBMCloud-Billing-Reports") + updateReportsSnapshotConfigOptionsModel.ReportTypes = []string{"account_summary", "enterprise_summary", "account_resource_instance_usage"} + updateReportsSnapshotConfigOptionsModel.Versioning = core.StringPtr("new") + updateReportsSnapshotConfigOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = usageReportsService.UpdateReportsSnapshotConfig(updateReportsSnapshotConfigOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke UpdateReportsSnapshotConfig with error: Operation validation and request error`, func() { + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4(&usagereportsv4.UsageReportsV4Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(usageReportsService).ToNot(BeNil()) + + // Construct an instance of the UpdateReportsSnapshotConfigOptions model + updateReportsSnapshotConfigOptionsModel := new(usagereportsv4.UpdateReportsSnapshotConfigOptions) + updateReportsSnapshotConfigOptionsModel.AccountID = core.StringPtr("abc") + updateReportsSnapshotConfigOptionsModel.Interval = core.StringPtr("daily") + updateReportsSnapshotConfigOptionsModel.CosBucket = core.StringPtr("bucket_name") + updateReportsSnapshotConfigOptionsModel.CosLocation = core.StringPtr("us-south") + updateReportsSnapshotConfigOptionsModel.CosReportsFolder = core.StringPtr("IBMCloud-Billing-Reports") + updateReportsSnapshotConfigOptionsModel.ReportTypes = []string{"account_summary", "enterprise_summary", "account_resource_instance_usage"} + updateReportsSnapshotConfigOptionsModel.Versioning = core.StringPtr("new") + updateReportsSnapshotConfigOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := usageReportsService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := usageReportsService.UpdateReportsSnapshotConfig(updateReportsSnapshotConfigOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the UpdateReportsSnapshotConfigOptions model with no property values + updateReportsSnapshotConfigOptionsModelNew := new(usagereportsv4.UpdateReportsSnapshotConfigOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = usageReportsService.UpdateReportsSnapshotConfig(updateReportsSnapshotConfigOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke UpdateReportsSnapshotConfig successfully`, func() { + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4(&usagereportsv4.UsageReportsV4Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(usageReportsService).ToNot(BeNil()) + + // Construct an instance of the UpdateReportsSnapshotConfigOptions model + updateReportsSnapshotConfigOptionsModel := new(usagereportsv4.UpdateReportsSnapshotConfigOptions) + updateReportsSnapshotConfigOptionsModel.AccountID = core.StringPtr("abc") + updateReportsSnapshotConfigOptionsModel.Interval = core.StringPtr("daily") + updateReportsSnapshotConfigOptionsModel.CosBucket = core.StringPtr("bucket_name") + updateReportsSnapshotConfigOptionsModel.CosLocation = core.StringPtr("us-south") + updateReportsSnapshotConfigOptionsModel.CosReportsFolder = core.StringPtr("IBMCloud-Billing-Reports") + updateReportsSnapshotConfigOptionsModel.ReportTypes = []string{"account_summary", "enterprise_summary", "account_resource_instance_usage"} + updateReportsSnapshotConfigOptionsModel.Versioning = core.StringPtr("new") + updateReportsSnapshotConfigOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := usageReportsService.UpdateReportsSnapshotConfig(updateReportsSnapshotConfigOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`DeleteReportsSnapshotConfig(deleteReportsSnapshotConfigOptions *DeleteReportsSnapshotConfigOptions)`, func() { + deleteReportsSnapshotConfigPath := "/v1/billing-reports-snapshot-config" + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(deleteReportsSnapshotConfigPath)) + Expect(req.Method).To(Equal("DELETE")) + + Expect(req.URL.Query()["account_id"]).To(Equal([]string{"abc"})) + res.WriteHeader(204) + })) + }) + It(`Invoke DeleteReportsSnapshotConfig successfully`, func() { + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4(&usagereportsv4.UsageReportsV4Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(usageReportsService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + response, operationErr := usageReportsService.DeleteReportsSnapshotConfig(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + + // Construct an instance of the DeleteReportsSnapshotConfigOptions model + deleteReportsSnapshotConfigOptionsModel := new(usagereportsv4.DeleteReportsSnapshotConfigOptions) + deleteReportsSnapshotConfigOptionsModel.AccountID = core.StringPtr("abc") + deleteReportsSnapshotConfigOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + response, operationErr = usageReportsService.DeleteReportsSnapshotConfig(deleteReportsSnapshotConfigOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + }) + It(`Invoke DeleteReportsSnapshotConfig with error: Operation validation and request error`, func() { + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4(&usagereportsv4.UsageReportsV4Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(usageReportsService).ToNot(BeNil()) + + // Construct an instance of the DeleteReportsSnapshotConfigOptions model + deleteReportsSnapshotConfigOptionsModel := new(usagereportsv4.DeleteReportsSnapshotConfigOptions) + deleteReportsSnapshotConfigOptionsModel.AccountID = core.StringPtr("abc") + deleteReportsSnapshotConfigOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := usageReportsService.SetServiceURL("") + Expect(err).To(BeNil()) + response, operationErr := usageReportsService.DeleteReportsSnapshotConfig(deleteReportsSnapshotConfigOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the DeleteReportsSnapshotConfigOptions model with no property values + deleteReportsSnapshotConfigOptionsModelNew := new(usagereportsv4.DeleteReportsSnapshotConfigOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = usageReportsService.DeleteReportsSnapshotConfig(deleteReportsSnapshotConfigOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetReportsSnapshot(getReportsSnapshotOptions *GetReportsSnapshotOptions) - Operation response error`, func() { + getReportsSnapshotPath := "/v1/billing-reports-snapshots" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getReportsSnapshotPath)) + Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["account_id"]).To(Equal([]string{"abc"})) + Expect(req.URL.Query()["month"]).To(Equal([]string{"2023-02"})) + Expect(req.URL.Query()["date_from"]).To(Equal([]string{fmt.Sprint(int64(1675209600000))})) + Expect(req.URL.Query()["date_to"]).To(Equal([]string{fmt.Sprint(int64(1675987200000))})) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke GetReportsSnapshot with error: Operation response processing error`, func() { + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4(&usagereportsv4.UsageReportsV4Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(usageReportsService).ToNot(BeNil()) + + // Construct an instance of the GetReportsSnapshotOptions model + getReportsSnapshotOptionsModel := new(usagereportsv4.GetReportsSnapshotOptions) + getReportsSnapshotOptionsModel.AccountID = core.StringPtr("abc") + getReportsSnapshotOptionsModel.Month = core.StringPtr("2023-02") + getReportsSnapshotOptionsModel.DateFrom = core.Int64Ptr(int64(1675209600000)) + getReportsSnapshotOptionsModel.DateTo = core.Int64Ptr(int64(1675987200000)) + getReportsSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := usageReportsService.GetReportsSnapshot(getReportsSnapshotOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + usageReportsService.EnableRetries(0, 0) + result, response, operationErr = usageReportsService.GetReportsSnapshot(getReportsSnapshotOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetReportsSnapshot(getReportsSnapshotOptions *GetReportsSnapshotOptions)`, func() { + getReportsSnapshotPath := "/v1/billing-reports-snapshots" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getReportsSnapshotPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["account_id"]).To(Equal([]string{"abc"})) + Expect(req.URL.Query()["month"]).To(Equal([]string{"2023-02"})) + Expect(req.URL.Query()["date_from"]).To(Equal([]string{fmt.Sprint(int64(1675209600000))})) + Expect(req.URL.Query()["date_to"]).To(Equal([]string{fmt.Sprint(int64(1675987200000))})) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"count": 3, "first": {"href": "/v1/billing-reports-snapshots?_limit=10&account_id=272b9a4f73e11030d0ba037daee47a35&date_from=-Infinity&date_to=Infinity&month=2023-06"}, "next": {"href": "/v1/billing-reports-snapshots?_limit=10&account_id=272b9a4f73e11030d0ba037daee47a35&date_from=-Infinity&date_to=Infinity&month=2023-06"}, "snapshots": [{"account_id": "abc", "month": "2023-06", "account_type": "account", "expected_processed_at": 1687470383610, "state": "enabled", "billing_period": {"start": "2023-06-01T00:00:00.000Z", "end": "2023-06-30T23:59:59.999Z"}, "snapshot_id": "1685577600000", "charset": "UTF-8", "compression": "GZIP", "content_type": "text/csv", "bucket": "bucket_name", "version": "1.0", "created_on": "2023-06-22T21:47:28.297Z", "report_types": [{"type": "account_summary", "version": "1.0"}], "files": [{"report_types": "account_summary", "location": "june/2023-06/1685577600000/2023-06-account-summary-272b9a4f73e11030d0ba037daee47a35.csv.gz", "account_id": "abc"}], "processed_at": 1687470448297}]}`) + })) + }) + It(`Invoke GetReportsSnapshot successfully with retries`, func() { + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4(&usagereportsv4.UsageReportsV4Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(usageReportsService).ToNot(BeNil()) + usageReportsService.EnableRetries(0, 0) + + // Construct an instance of the GetReportsSnapshotOptions model + getReportsSnapshotOptionsModel := new(usagereportsv4.GetReportsSnapshotOptions) + getReportsSnapshotOptionsModel.AccountID = core.StringPtr("abc") + getReportsSnapshotOptionsModel.Month = core.StringPtr("2023-02") + getReportsSnapshotOptionsModel.DateFrom = core.Int64Ptr(int64(1675209600000)) + getReportsSnapshotOptionsModel.DateTo = core.Int64Ptr(int64(1675987200000)) + getReportsSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := usageReportsService.GetReportsSnapshotWithContext(ctx, getReportsSnapshotOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + usageReportsService.DisableRetries() + result, response, operationErr := usageReportsService.GetReportsSnapshot(getReportsSnapshotOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = usageReportsService.GetReportsSnapshotWithContext(ctx, getReportsSnapshotOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getReportsSnapshotPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["account_id"]).To(Equal([]string{"abc"})) + Expect(req.URL.Query()["month"]).To(Equal([]string{"2023-02"})) + Expect(req.URL.Query()["date_from"]).To(Equal([]string{fmt.Sprint(int64(1675209600000))})) + Expect(req.URL.Query()["date_to"]).To(Equal([]string{fmt.Sprint(int64(1675987200000))})) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"count": 3, "first": {"href": "/v1/billing-reports-snapshots?_limit=10&account_id=272b9a4f73e11030d0ba037daee47a35&date_from=-Infinity&date_to=Infinity&month=2023-06"}, "next": {"href": "/v1/billing-reports-snapshots?_limit=10&account_id=272b9a4f73e11030d0ba037daee47a35&date_from=-Infinity&date_to=Infinity&month=2023-06"}, "snapshots": [{"account_id": "abc", "month": "2023-06", "account_type": "account", "expected_processed_at": 1687470383610, "state": "enabled", "billing_period": {"start": "2023-06-01T00:00:00.000Z", "end": "2023-06-30T23:59:59.999Z"}, "snapshot_id": "1685577600000", "charset": "UTF-8", "compression": "GZIP", "content_type": "text/csv", "bucket": "bucket_name", "version": "1.0", "created_on": "2023-06-22T21:47:28.297Z", "report_types": [{"type": "account_summary", "version": "1.0"}], "files": [{"report_types": "account_summary", "location": "june/2023-06/1685577600000/2023-06-account-summary-272b9a4f73e11030d0ba037daee47a35.csv.gz", "account_id": "abc"}], "processed_at": 1687470448297}]}`) + })) + }) + It(`Invoke GetReportsSnapshot successfully`, func() { + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4(&usagereportsv4.UsageReportsV4Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(usageReportsService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := usageReportsService.GetReportsSnapshot(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the GetReportsSnapshotOptions model + getReportsSnapshotOptionsModel := new(usagereportsv4.GetReportsSnapshotOptions) + getReportsSnapshotOptionsModel.AccountID = core.StringPtr("abc") + getReportsSnapshotOptionsModel.Month = core.StringPtr("2023-02") + getReportsSnapshotOptionsModel.DateFrom = core.Int64Ptr(int64(1675209600000)) + getReportsSnapshotOptionsModel.DateTo = core.Int64Ptr(int64(1675987200000)) + getReportsSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = usageReportsService.GetReportsSnapshot(getReportsSnapshotOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke GetReportsSnapshot with error: Operation validation and request error`, func() { + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4(&usagereportsv4.UsageReportsV4Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(usageReportsService).ToNot(BeNil()) + + // Construct an instance of the GetReportsSnapshotOptions model + getReportsSnapshotOptionsModel := new(usagereportsv4.GetReportsSnapshotOptions) + getReportsSnapshotOptionsModel.AccountID = core.StringPtr("abc") + getReportsSnapshotOptionsModel.Month = core.StringPtr("2023-02") + getReportsSnapshotOptionsModel.DateFrom = core.Int64Ptr(int64(1675209600000)) + getReportsSnapshotOptionsModel.DateTo = core.Int64Ptr(int64(1675987200000)) + getReportsSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := usageReportsService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := usageReportsService.GetReportsSnapshot(getReportsSnapshotOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the GetReportsSnapshotOptions model with no property values + getReportsSnapshotOptionsModelNew := new(usagereportsv4.GetReportsSnapshotOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = usageReportsService.GetReportsSnapshot(getReportsSnapshotOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke GetReportsSnapshot successfully`, func() { + usageReportsService, serviceErr := usagereportsv4.NewUsageReportsV4(&usagereportsv4.UsageReportsV4Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(usageReportsService).ToNot(BeNil()) + + // Construct an instance of the GetReportsSnapshotOptions model + getReportsSnapshotOptionsModel := new(usagereportsv4.GetReportsSnapshotOptions) + getReportsSnapshotOptionsModel.AccountID = core.StringPtr("abc") + getReportsSnapshotOptionsModel.Month = core.StringPtr("2023-02") + getReportsSnapshotOptionsModel.DateFrom = core.Int64Ptr(int64(1675209600000)) + getReportsSnapshotOptionsModel.DateTo = core.Int64Ptr(int64(1675987200000)) + getReportsSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := usageReportsService.GetReportsSnapshot(getReportsSnapshotOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) Describe(`Model constructor tests`, func() { Context(`Using a service client instance`, func() { usageReportsService, _ := usagereportsv4.NewUsageReportsV4(&usagereportsv4.UsageReportsV4Options{ From d581b2d0125ed271f254eaf7c753b28600a6e1b1 Mon Sep 17 00:00:00 2001 From: Rajesh <78408189+Rajesh-Pirati@users.noreply.github.com> Date: Mon, 28 Aug 2023 22:21:04 +0530 Subject: [PATCH 05/27] feat(IAM Policy Management): fix template metadata as part of policies (#274) Signed-off-by: Rajesh K Pirati Signed-off-by: manu.k.m --- .../iam_policy_management_v1.go | 439 ++++++++++++++---- .../iam_policy_management_v1_examples_test.go | 31 +- ...m_policy_management_v1_integration_test.go | 26 +- .../iam_policy_management_v1_test.go | 70 +-- 4 files changed, 452 insertions(+), 114 deletions(-) diff --git a/iampolicymanagementv1/iam_policy_management_v1.go b/iampolicymanagementv1/iam_policy_management_v1.go index eed7f91d..f86bcef0 100644 --- a/iampolicymanagementv1/iam_policy_management_v1.go +++ b/iampolicymanagementv1/iam_policy_management_v1.go @@ -15,7 +15,7 @@ */ /* - * IBM OpenAPI SDK Code Generator Version: 3.71.0-316eb5da-20230504-195406 + * IBM OpenAPI SDK Code Generator Version: 3.78.0-67aec9b7-20230818-174940 */ // Package iampolicymanagementv1 : Operations and models for the IamPolicyManagementV1 service @@ -497,12 +497,12 @@ func (iamPolicyManagement *IamPolicyManagementV1) ReplacePolicyWithContext(ctx c // GetPolicy : Retrieve a policy by ID // Retrieve a policy by providing a policy ID. -func (iamPolicyManagement *IamPolicyManagementV1) GetPolicy(getPolicyOptions *GetPolicyOptions) (result *Policy, response *core.DetailedResponse, err error) { +func (iamPolicyManagement *IamPolicyManagementV1) GetPolicy(getPolicyOptions *GetPolicyOptions) (result *PolicyTemplateMetaData, response *core.DetailedResponse, err error) { return iamPolicyManagement.GetPolicyWithContext(context.Background(), getPolicyOptions) } // GetPolicyWithContext is an alternate form of the GetPolicy method which supports a Context parameter -func (iamPolicyManagement *IamPolicyManagementV1) GetPolicyWithContext(ctx context.Context, getPolicyOptions *GetPolicyOptions) (result *Policy, response *core.DetailedResponse, err error) { +func (iamPolicyManagement *IamPolicyManagementV1) GetPolicyWithContext(ctx context.Context, getPolicyOptions *GetPolicyOptions) (result *PolicyTemplateMetaData, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(getPolicyOptions, "getPolicyOptions cannot be nil") if err != nil { return @@ -545,7 +545,7 @@ func (iamPolicyManagement *IamPolicyManagementV1) GetPolicyWithContext(ctx conte return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalPolicy) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalPolicyTemplateMetaData) if err != nil { return } @@ -1413,12 +1413,12 @@ func (iamPolicyManagement *IamPolicyManagementV1) ReplaceV2PolicyWithContext(ctx // GetV2Policy : Retrieve a policy by ID // Retrieve a policy by providing a policy ID. -func (iamPolicyManagement *IamPolicyManagementV1) GetV2Policy(getV2PolicyOptions *GetV2PolicyOptions) (result *V2Policy, response *core.DetailedResponse, err error) { +func (iamPolicyManagement *IamPolicyManagementV1) GetV2Policy(getV2PolicyOptions *GetV2PolicyOptions) (result *V2PolicyTemplateMetaData, response *core.DetailedResponse, err error) { return iamPolicyManagement.GetV2PolicyWithContext(context.Background(), getV2PolicyOptions) } // GetV2PolicyWithContext is an alternate form of the GetV2Policy method which supports a Context parameter -func (iamPolicyManagement *IamPolicyManagementV1) GetV2PolicyWithContext(ctx context.Context, getV2PolicyOptions *GetV2PolicyOptions) (result *V2Policy, response *core.DetailedResponse, err error) { +func (iamPolicyManagement *IamPolicyManagementV1) GetV2PolicyWithContext(ctx context.Context, getV2PolicyOptions *GetV2PolicyOptions) (result *V2PolicyTemplateMetaData, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(getV2PolicyOptions, "getV2PolicyOptions cannot be nil") if err != nil { return @@ -1465,7 +1465,7 @@ func (iamPolicyManagement *IamPolicyManagementV1) GetV2PolicyWithContext(ctx con return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalV2Policy) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalV2PolicyTemplateMetaData) if err != nil { return } @@ -1826,6 +1826,9 @@ func (iamPolicyManagement *IamPolicyManagementV1) CreatePolicyTemplateVersionWit if createPolicyTemplateVersionOptions.Policy != nil { body["policy"] = createPolicyTemplateVersionOptions.Policy } + if createPolicyTemplateVersionOptions.Name != nil { + body["name"] = createPolicyTemplateVersionOptions.Name + } if createPolicyTemplateVersionOptions.Description != nil { body["description"] = createPolicyTemplateVersionOptions.Description } @@ -1966,6 +1969,9 @@ func (iamPolicyManagement *IamPolicyManagementV1) ReplacePolicyTemplateWithConte if replacePolicyTemplateOptions.Policy != nil { body["policy"] = replacePolicyTemplateOptions.Policy } + if replacePolicyTemplateOptions.Name != nil { + body["name"] = replacePolicyTemplateOptions.Name + } if replacePolicyTemplateOptions.Description != nil { body["description"] = replacePolicyTemplateOptions.Description } @@ -2149,9 +2155,6 @@ func (iamPolicyManagement *IamPolicyManagementV1) CommitPolicyTemplateWithContex for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } - if commitPolicyTemplateOptions.IfMatch != nil { - builder.AddHeader("If-Match", fmt.Sprint(*commitPolicyTemplateOptions.IfMatch)) - } request, err := builder.Build() if err != nil { @@ -2319,21 +2322,15 @@ type CommitPolicyTemplateOptions struct { // The policy template version. Version *string `json:"version" validate:"required,ne="` - // The revision number for updating a policy template version and must match the ETag value of the existing policy - // template version. The Etag can be retrieved using the GET - // /v1/policy_templates/{policy_template_id}/versions/{version} API and looking at the ETag response header. - IfMatch *string `json:"If-Match" validate:"required"` - // Allows users to set headers on API requests Headers map[string]string } // NewCommitPolicyTemplateOptions : Instantiate CommitPolicyTemplateOptions -func (*IamPolicyManagementV1) NewCommitPolicyTemplateOptions(policyTemplateID string, version string, ifMatch string) *CommitPolicyTemplateOptions { +func (*IamPolicyManagementV1) NewCommitPolicyTemplateOptions(policyTemplateID string, version string) *CommitPolicyTemplateOptions { return &CommitPolicyTemplateOptions{ PolicyTemplateID: core.StringPtr(policyTemplateID), Version: core.StringPtr(version), - IfMatch: core.StringPtr(ifMatch), } } @@ -2349,12 +2346,6 @@ func (_options *CommitPolicyTemplateOptions) SetVersion(version string) *CommitP return _options } -// SetIfMatch : Allow user to set IfMatch -func (_options *CommitPolicyTemplateOptions) SetIfMatch(ifMatch string) *CommitPolicyTemplateOptions { - _options.IfMatch = core.StringPtr(ifMatch) - return _options -} - // SetHeaders : Allow user to set Headers func (options *CommitPolicyTemplateOptions) SetHeaders(param map[string]string) *CommitPolicyTemplateOptions { options.Headers = param @@ -2628,6 +2619,10 @@ type CreatePolicyTemplateVersionOptions struct { // The core set of properties associated with the template's policy objet. Policy *TemplatePolicy `json:"policy" validate:"required"` + // Required field when creating a new template. Otherwise this field is optional. If the field is included it will + // change the name value for all existing versions of the template. + Name *string `json:"name,omitempty"` + // Description of the policy template. This is shown to users in the enterprise account. Use this to describe the // purpose or context of the policy for enterprise users managing IAM templates. Description *string `json:"description,omitempty"` @@ -2659,6 +2654,12 @@ func (_options *CreatePolicyTemplateVersionOptions) SetPolicy(policy *TemplatePo return _options } +// SetName : Allow user to set Name +func (_options *CreatePolicyTemplateVersionOptions) SetName(name string) *CreatePolicyTemplateVersionOptions { + _options.Name = core.StringPtr(name) + return _options +} + // SetDescription : Allow user to set Description func (_options *CreatePolicyTemplateVersionOptions) SetDescription(description string) *CreatePolicyTemplateVersionOptions { _options.Description = core.StringPtr(description) @@ -4157,9 +4158,6 @@ type Policy struct { // The policy state. State *string `json:"state,omitempty"` - - // Origin Template information. - Template *TemplateMetadata `json:"template,omitempty"` } // Constants associated with the Policy.State property. @@ -4220,10 +4218,6 @@ func UnmarshalPolicy(m map[string]json.RawMessage, result interface{}) (err erro if err != nil { return } - err = core.UnmarshalModel(m, "template", &obj.Template, UnmarshalTemplateMetadata) - if err != nil { - return - } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) return } @@ -4246,7 +4240,7 @@ type PolicyAssignment struct { Target *string `json:"target" validate:"required"` // List of objects with required properties for a policy assignment. - Options []PolicyAssignmentRequestOptionsItem `json:"options" validate:"required"` + Options []PolicyAssignmentOptions `json:"options" validate:"required"` // Policy assignment ID. ID *string `json:"id,omitempty"` @@ -4314,7 +4308,7 @@ func UnmarshalPolicyAssignment(m map[string]json.RawMessage, result interface{}) if err != nil { return } - err = core.UnmarshalModel(m, "options", &obj.Options, UnmarshalPolicyAssignmentRequestOptionsItem) + err = core.UnmarshalModel(m, "options", &obj.Options, UnmarshalPolicyAssignmentOptions) if err != nil { return } @@ -4358,8 +4352,8 @@ func UnmarshalPolicyAssignment(m map[string]json.RawMessage, result interface{}) return } -// PolicyAssignmentRequestOptionsItem : The set of properties required for a policy assignment. -type PolicyAssignmentRequestOptionsItem struct { +// PolicyAssignmentOptions : The set of properties required for a policy assignment. +type PolicyAssignmentOptions struct { // The policy subject type; either 'iam_id' or 'access_group_id'. SubjectType *string `json:"subject_type" validate:"required"` @@ -4376,16 +4370,16 @@ type PolicyAssignmentRequestOptionsItem struct { RootTemplateVersion *string `json:"root_template_version,omitempty"` } -// Constants associated with the PolicyAssignmentRequestOptionsItem.SubjectType property. +// Constants associated with the PolicyAssignmentOptions.SubjectType property. // The policy subject type; either 'iam_id' or 'access_group_id'. const ( - PolicyAssignmentRequestOptionsItemSubjectTypeAccessGroupIDConst = "access_group_id" - PolicyAssignmentRequestOptionsItemSubjectTypeIamIDConst = "iam_id" + PolicyAssignmentOptionsSubjectTypeAccessGroupIDConst = "access_group_id" + PolicyAssignmentOptionsSubjectTypeIamIDConst = "iam_id" ) -// UnmarshalPolicyAssignmentRequestOptionsItem unmarshals an instance of PolicyAssignmentRequestOptionsItem from the specified map of raw messages. -func UnmarshalPolicyAssignmentRequestOptionsItem(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(PolicyAssignmentRequestOptionsItem) +// UnmarshalPolicyAssignmentOptions unmarshals an instance of PolicyAssignmentOptions from the specified map of raw messages. +func UnmarshalPolicyAssignmentOptions(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(PolicyAssignmentOptions) err = core.UnmarshalPrimitive(m, "subject_type", &obj.SubjectType) if err != nil { return @@ -4410,23 +4404,30 @@ func UnmarshalPolicyAssignmentRequestOptionsItem(m map[string]json.RawMessage, r return } -// PolicyAssignmentResources : The policy assignment resources. -type PolicyAssignmentResources struct { - // Account ID where resources are assigned. - Target *string `json:"target,omitempty"` +// PolicyAssignmentResourcePolicy : Set of properties for the assigned resource. +type PolicyAssignmentResourcePolicy struct { + // On success, includes the policy assigned. + ResourceCreated *AssignmentResourceCreated `json:"resource_created,omitempty"` - // Set of properties for the assigned resource. - Policy *PolicyAssignmentResourcesPolicy `json:"policy,omitempty"` + // policy status. + Status *string `json:"status,omitempty"` + + // The error response from API. + ErrorMessage *ErrorResponse `json:"error_message,omitempty"` } -// UnmarshalPolicyAssignmentResources unmarshals an instance of PolicyAssignmentResources from the specified map of raw messages. -func UnmarshalPolicyAssignmentResources(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(PolicyAssignmentResources) - err = core.UnmarshalPrimitive(m, "target", &obj.Target) +// UnmarshalPolicyAssignmentResourcePolicy unmarshals an instance of PolicyAssignmentResourcePolicy from the specified map of raw messages. +func UnmarshalPolicyAssignmentResourcePolicy(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(PolicyAssignmentResourcePolicy) + err = core.UnmarshalModel(m, "resource_created", &obj.ResourceCreated, UnmarshalAssignmentResourceCreated) if err != nil { return } - err = core.UnmarshalModel(m, "policy", &obj.Policy, UnmarshalPolicyAssignmentResourcesPolicy) + err = core.UnmarshalPrimitive(m, "status", &obj.Status) + if err != nil { + return + } + err = core.UnmarshalModel(m, "error_message", &obj.ErrorMessage, UnmarshalErrorResponse) if err != nil { return } @@ -4434,23 +4435,23 @@ func UnmarshalPolicyAssignmentResources(m map[string]json.RawMessage, result int return } -// PolicyAssignmentResourcesPolicy : Set of properties for the assigned resource. -type PolicyAssignmentResourcesPolicy struct { - // On success, includes the policy assigned. - ResourceCreated *AssignmentResourceCreated `json:"resource_created" validate:"required"` +// PolicyAssignmentResources : The policy assignment resources. +type PolicyAssignmentResources struct { + // Account ID where resources are assigned. + Target *string `json:"target,omitempty"` - // The error response from API. - ErrorMessage *ErrorResponse `json:"error_message,omitempty"` + // Set of properties for the assigned resource. + Policy *PolicyAssignmentResourcePolicy `json:"policy,omitempty"` } -// UnmarshalPolicyAssignmentResourcesPolicy unmarshals an instance of PolicyAssignmentResourcesPolicy from the specified map of raw messages. -func UnmarshalPolicyAssignmentResourcesPolicy(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(PolicyAssignmentResourcesPolicy) - err = core.UnmarshalModel(m, "resource_created", &obj.ResourceCreated, UnmarshalAssignmentResourceCreated) +// UnmarshalPolicyAssignmentResources unmarshals an instance of PolicyAssignmentResources from the specified map of raw messages. +func UnmarshalPolicyAssignmentResources(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(PolicyAssignmentResources) + err = core.UnmarshalPrimitive(m, "target", &obj.Target) if err != nil { return } - err = core.UnmarshalModel(m, "error_message", &obj.ErrorMessage, UnmarshalErrorResponse) + err = core.UnmarshalModel(m, "policy", &obj.Policy, UnmarshalPolicyAssignmentResourcePolicy) if err != nil { return } @@ -4461,13 +4462,13 @@ func UnmarshalPolicyAssignmentResourcesPolicy(m map[string]json.RawMessage, resu // PolicyCollection : A collection of policies. type PolicyCollection struct { // List of policies. - Policies []Policy `json:"policies,omitempty"` + Policies []PolicyTemplateMetaData `json:"policies,omitempty"` } // UnmarshalPolicyCollection unmarshals an instance of PolicyCollection from the specified map of raw messages. func UnmarshalPolicyCollection(m map[string]json.RawMessage, result interface{}) (err error) { obj := new(PolicyCollection) - err = core.UnmarshalModel(m, "policies", &obj.Policies, UnmarshalPolicy) + err = core.UnmarshalModel(m, "policies", &obj.Policies, UnmarshalPolicyTemplateMetaData) if err != nil { return } @@ -4686,6 +4687,115 @@ func UnmarshalPolicyTemplateCollection(m map[string]json.RawMessage, result inte return } +// PolicyTemplateMetaData : The core set of properties associated with a policy. +type PolicyTemplateMetaData struct { + // The policy ID. + ID *string `json:"id,omitempty"` + + // The policy type; either 'access' or 'authorization'. + Type *string `json:"type" validate:"required"` + + // Customer-defined description. + Description *string `json:"description,omitempty"` + + // The subjects associated with a policy. + Subjects []PolicySubject `json:"subjects" validate:"required"` + + // A set of role cloud resource names (CRNs) granted by the policy. + Roles []PolicyRole `json:"roles" validate:"required"` + + // The resources associated with a policy. + Resources []PolicyResource `json:"resources" validate:"required"` + + // The href link back to the policy. + Href *string `json:"href,omitempty"` + + // The UTC timestamp when the policy was created. + CreatedAt *strfmt.DateTime `json:"created_at,omitempty"` + + // The iam ID of the entity that created the policy. + CreatedByID *string `json:"created_by_id,omitempty"` + + // The UTC timestamp when the policy was last modified. + LastModifiedAt *strfmt.DateTime `json:"last_modified_at,omitempty"` + + // The iam ID of the entity that last modified the policy. + LastModifiedByID *string `json:"last_modified_by_id,omitempty"` + + // The policy state. + State *string `json:"state,omitempty"` + + // The details of the IAM template that was used to create an enterprise-managed policy in your account. When returned, + // this indicates that the policy is created from and managed by a template in the root enterprise account. + Template *TemplateMetadata `json:"template,omitempty"` +} + +// Constants associated with the PolicyTemplateMetaData.State property. +// The policy state. +const ( + PolicyTemplateMetaDataStateActiveConst = "active" + PolicyTemplateMetaDataStateDeletedConst = "deleted" +) + +// UnmarshalPolicyTemplateMetaData unmarshals an instance of PolicyTemplateMetaData from the specified map of raw messages. +func UnmarshalPolicyTemplateMetaData(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(PolicyTemplateMetaData) + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "type", &obj.Type) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "description", &obj.Description) + if err != nil { + return + } + err = core.UnmarshalModel(m, "subjects", &obj.Subjects, UnmarshalPolicySubject) + if err != nil { + return + } + err = core.UnmarshalModel(m, "roles", &obj.Roles, UnmarshalPolicyRole) + if err != nil { + return + } + err = core.UnmarshalModel(m, "resources", &obj.Resources, UnmarshalPolicyResource) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "href", &obj.Href) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "created_by_id", &obj.CreatedByID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "last_modified_at", &obj.LastModifiedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "last_modified_by_id", &obj.LastModifiedByID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "state", &obj.State) + if err != nil { + return + } + err = core.UnmarshalModel(m, "template", &obj.Template, UnmarshalTemplateMetadata) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + // PolicyTemplateVersionsCollection : A collection of versions for a specific policy template. type PolicyTemplateVersionsCollection struct { // List of policy templates versions. @@ -4807,6 +4917,10 @@ type ReplacePolicyTemplateOptions struct { // The core set of properties associated with the template's policy objet. Policy *TemplatePolicy `json:"policy" validate:"required"` + // Required field when creating a new template. Otherwise this field is optional. If the field is included it will + // change the name value for all existing versions of the template. + Name *string `json:"name,omitempty"` + // Description of the policy template. This is shown to users in the enterprise account. Use this to describe the // purpose or context of the policy for enterprise users managing IAM templates. Description *string `json:"description,omitempty"` @@ -4852,6 +4966,12 @@ func (_options *ReplacePolicyTemplateOptions) SetPolicy(policy *TemplatePolicy) return _options } +// SetName : Allow user to set Name +func (_options *ReplacePolicyTemplateOptions) SetName(name string) *ReplacePolicyTemplateOptions { + _options.Name = core.StringPtr(name) + return _options +} + // SetDescription : Allow user to set Description func (_options *ReplacePolicyTemplateOptions) SetDescription(description string) *ReplacePolicyTemplateOptions { _options.Description = core.StringPtr(description) @@ -5363,19 +5483,29 @@ func UnmarshalSubjectAttribute(m map[string]json.RawMessage, result interface{}) return } -// TemplateMetadata : Origin Template information. +// TemplateMetadata : The details of the IAM template that was used to create an enterprise-managed policy in your account. When returned, +// this indicates that the policy is created from and managed by a template in the root enterprise account. type TemplateMetadata struct { - // Origin Template CRN. - CRN *string `json:"crn,omitempty"` + // The policy template ID. + ID *string `json:"id,omitempty"` // Template version. Version *string `json:"version,omitempty"` + + // policy assignment id. + AssignmentID *string `json:"assignment_id,omitempty"` + + // orchestrator template id. + RootID *string `json:"root_id,omitempty"` + + // orchestrator template version. + RootVersion *string `json:"root_version,omitempty"` } // UnmarshalTemplateMetadata unmarshals an instance of TemplateMetadata from the specified map of raw messages. func UnmarshalTemplateMetadata(m map[string]json.RawMessage, result interface{}) (err error) { obj := new(TemplateMetadata) - err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) + err = core.UnmarshalPrimitive(m, "id", &obj.ID) if err != nil { return } @@ -5383,6 +5513,18 @@ func UnmarshalTemplateMetadata(m map[string]json.RawMessage, result interface{}) if err != nil { return } + err = core.UnmarshalPrimitive(m, "assignment_id", &obj.AssignmentID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "root_id", &obj.RootID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "root_version", &obj.RootVersion) + if err != nil { + return + } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) return } @@ -5397,7 +5539,7 @@ type TemplatePolicy struct { Description *string `json:"description,omitempty"` // The resource attributes to which the policy grants access. - Resource *V2PolicyResource `json:"resource" validate:"required"` + Resource *V2PolicyResource `json:"resource,omitempty"` // Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or // 'time-based-conditions:weekly:custom-hours'. @@ -5418,10 +5560,9 @@ const ( ) // NewTemplatePolicy : Instantiate TemplatePolicy (Generic Model Constructor) -func (*IamPolicyManagementV1) NewTemplatePolicy(typeVar string, resource *V2PolicyResource, control *Control) (_model *TemplatePolicy, err error) { +func (*IamPolicyManagementV1) NewTemplatePolicy(typeVar string, control *Control) (_model *TemplatePolicy, err error) { _model = &TemplatePolicy{ Type: core.StringPtr(typeVar), - Resource: resource, Control: control, } err = core.ValidateStruct(_model, "required parameters") @@ -5564,9 +5705,6 @@ type V2Policy struct { // The optional count of times that policy has provided a permit, when passing query parameter // format=include_last_permit. LastPermitFrequency *int64 `json:"last_permit_frequency,omitempty"` - - // Origin Template information. - Template *TemplateMetadata `json:"template,omitempty"` } // Constants associated with the V2Policy.Type property. @@ -5650,10 +5788,6 @@ func UnmarshalV2Policy(m map[string]json.RawMessage, result interface{}) (err er if err != nil { return } - err = core.UnmarshalModel(m, "template", &obj.Template, UnmarshalTemplateMetadata) - if err != nil { - return - } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) return } @@ -5661,13 +5795,13 @@ func UnmarshalV2Policy(m map[string]json.RawMessage, result interface{}) (err er // V2PolicyCollection : A collection of policies. type V2PolicyCollection struct { // List of policies. - Policies []V2Policy `json:"policies,omitempty"` + Policies []V2PolicyTemplateMetaData `json:"policies,omitempty"` } // UnmarshalV2PolicyCollection unmarshals an instance of V2PolicyCollection from the specified map of raw messages. func UnmarshalV2PolicyCollection(m map[string]json.RawMessage, result interface{}) (err error) { obj := new(V2PolicyCollection) - err = core.UnmarshalModel(m, "policies", &obj.Policies, UnmarshalV2Policy) + err = core.UnmarshalModel(m, "policies", &obj.Policies, UnmarshalV2PolicyTemplateMetaData) if err != nil { return } @@ -5947,6 +6081,151 @@ func UnmarshalV2PolicySubjectAttribute(m map[string]json.RawMessage, result inte return } +// V2PolicyTemplateMetaData : The core set of properties associated with the policy. +type V2PolicyTemplateMetaData struct { + // The policy type; either 'access' or 'authorization'. + Type *string `json:"type" validate:"required"` + + // Description of the policy. + Description *string `json:"description,omitempty"` + + // The subject attributes for whom the policy grants access. + Subject *V2PolicySubject `json:"subject,omitempty"` + + // The resource attributes to which the policy grants access. + Resource *V2PolicyResource `json:"resource,omitempty"` + + // Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or + // 'time-based-conditions:weekly:custom-hours'. + Pattern *string `json:"pattern,omitempty"` + + // Additional access conditions associated with the policy. + Rule V2PolicyRuleIntf `json:"rule,omitempty"` + + // The policy ID. + ID *string `json:"id,omitempty"` + + // The href URL that links to the policies API by policy ID. + Href *string `json:"href,omitempty"` + + Control ControlResponseIntf `json:"control" validate:"required"` + + // The UTC timestamp when the policy was created. + CreatedAt *strfmt.DateTime `json:"created_at,omitempty"` + + // The iam ID of the entity that created the policy. + CreatedByID *string `json:"created_by_id,omitempty"` + + // The UTC timestamp when the policy was last modified. + LastModifiedAt *strfmt.DateTime `json:"last_modified_at,omitempty"` + + // The iam ID of the entity that last modified the policy. + LastModifiedByID *string `json:"last_modified_by_id,omitempty"` + + // The policy state, either 'deleted' or 'active'. + State *string `json:"state" validate:"required"` + + // The optional last permit time of policy, when passing query parameter format=include_last_permit. + LastPermitAt *string `json:"last_permit_at,omitempty"` + + // The optional count of times that policy has provided a permit, when passing query parameter + // format=include_last_permit. + LastPermitFrequency *int64 `json:"last_permit_frequency,omitempty"` + + // The details of the IAM template that was used to create an enterprise-managed policy in your account. When returned, + // this indicates that the policy is created from and managed by a template in the root enterprise account. + Template *TemplateMetadata `json:"template,omitempty"` +} + +// Constants associated with the V2PolicyTemplateMetaData.Type property. +// The policy type; either 'access' or 'authorization'. +const ( + V2PolicyTemplateMetaDataTypeAccessConst = "access" + V2PolicyTemplateMetaDataTypeAuthorizationConst = "authorization" +) + +// Constants associated with the V2PolicyTemplateMetaData.State property. +// The policy state, either 'deleted' or 'active'. +const ( + V2PolicyTemplateMetaDataStateActiveConst = "active" + V2PolicyTemplateMetaDataStateDeletedConst = "deleted" +) + +// UnmarshalV2PolicyTemplateMetaData unmarshals an instance of V2PolicyTemplateMetaData from the specified map of raw messages. +func UnmarshalV2PolicyTemplateMetaData(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(V2PolicyTemplateMetaData) + err = core.UnmarshalPrimitive(m, "type", &obj.Type) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "description", &obj.Description) + if err != nil { + return + } + err = core.UnmarshalModel(m, "subject", &obj.Subject, UnmarshalV2PolicySubject) + if err != nil { + return + } + err = core.UnmarshalModel(m, "resource", &obj.Resource, UnmarshalV2PolicyResource) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "pattern", &obj.Pattern) + if err != nil { + return + } + err = core.UnmarshalModel(m, "rule", &obj.Rule, UnmarshalV2PolicyRule) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "href", &obj.Href) + if err != nil { + return + } + err = core.UnmarshalModel(m, "control", &obj.Control, UnmarshalControlResponse) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "created_by_id", &obj.CreatedByID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "last_modified_at", &obj.LastModifiedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "last_modified_by_id", &obj.LastModifiedByID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "state", &obj.State) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "last_permit_at", &obj.LastPermitAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "last_permit_frequency", &obj.LastPermitFrequency) + if err != nil { + return + } + err = core.UnmarshalModel(m, "template", &obj.Template, UnmarshalTemplateMetadata) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + // ControlResponseControl : Specifies the type of access granted by the policy. // This model "extends" ControlResponse type ControlResponseControl struct { diff --git a/iampolicymanagementv1/iam_policy_management_v1_examples_test.go b/iampolicymanagementv1/iam_policy_management_v1_examples_test.go index 634a3084..3608c515 100644 --- a/iampolicymanagementv1/iam_policy_management_v1_examples_test.go +++ b/iampolicymanagementv1/iam_policy_management_v1_examples_test.go @@ -68,6 +68,7 @@ var _ = Describe(`IamPolicyManagementV1 Examples Tests`, func() { examplePolicyTemplateETag string examplePolicyTemplateVersion string testPolicyAssignmentId string + assignmentPolicyID string ) var shouldSkipTest = func() { @@ -941,7 +942,6 @@ var _ = Describe(`IamPolicyManagementV1 Examples Tests`, func() { commitPolicyTemplateOptions := iamPolicyManagementService.NewCommitPolicyTemplateOptions( examplePolicyTemplateID, examplePolicyTemplateVersion, - examplePolicyTemplateETag, ) response, err := iamPolicyManagementService.CommitPolicyTemplate(commitPolicyTemplateOptions) @@ -1031,6 +1031,35 @@ var _ = Describe(`IamPolicyManagementV1 Examples Tests`, func() { Expect(policyAssignmentRecord.LastModifiedAt).ToNot(BeNil()) Expect(policyAssignmentRecord.LastModifiedByID).ToNot(BeNil()) Expect(policyAssignmentRecord.Href).ToNot(BeNil()) + assignmentPolicyID = *policyAssignmentRecord.Resources[0].Policy.ResourceCreated.ID + }) + + It(`GetV2Policy to get Template meta data request example`, func() { + fmt.Println("\nGetV2Policy() result:") + // begin-get_v2_policy template metadata + + options := iamPolicyManagementService.NewGetV2PolicyOptions( + assignmentPolicyID, + ) + + policy, response, err := iamPolicyManagementService.GetV2Policy(options) + if err != nil { + panic(err) + } + b, _ := json.MarshalIndent(policy, "", " ") + fmt.Println(string(b)) + + // end-get_v2_policy + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(policy).ToNot(BeNil()) + Expect(policy.Template).ToNot(BeNil()) + Expect(policy.Template.ID).ToNot(BeNil()) + Expect(policy.Template.Version).ToNot(BeNil()) + Expect(policy.Template.AssignmentID).ToNot(BeNil()) + Expect(policy.Template.RootID).ToNot(BeNil()) + Expect(policy.Template.RootVersion).ToNot(BeNil()) }) It(`DeletePolicyTemplateVersion request example`, func() { diff --git a/iampolicymanagementv1/iam_policy_management_v1_integration_test.go b/iampolicymanagementv1/iam_policy_management_v1_integration_test.go index 3b80e7ff..a0d98ac6 100644 --- a/iampolicymanagementv1/iam_policy_management_v1_integration_test.go +++ b/iampolicymanagementv1/iam_policy_management_v1_integration_test.go @@ -66,6 +66,7 @@ var _ = Describe("IAM Policy Management - Integration Tests", func() { testPolicyTemplateVersion string = "" testPolicyAssignmentId string = "" examplePolicyTemplateName = "PolicySampleTemplateTestV1" + assignmentPolicyID string ) var shouldSkipTest = func() { @@ -900,7 +901,6 @@ var _ = Describe("IAM Policy Management - Integration Tests", func() { commitPolicyTemplateOptions := &iampolicymanagementv1.CommitPolicyTemplateOptions{ PolicyTemplateID: &testPolicyTemplateID, Version: &testPolicyTemplateVersion, - IfMatch: &testPolicyTemplateETag, } response, err := service.CommitPolicyTemplate(commitPolicyTemplateOptions) @@ -970,6 +970,30 @@ var _ = Describe("IAM Policy Management - Integration Tests", func() { Expect(policyAssignmentRecord.LastModifiedAt).ToNot(BeNil()) Expect(policyAssignmentRecord.LastModifiedByID).ToNot(BeNil()) Expect(policyAssignmentRecord.Href).ToNot(BeNil()) + + assignmentPolicyID = *policyAssignmentRecord.Resources[0].Policy.ResourceCreated.ID + }) + }) + + Describe("GetPolicyV2 - Retrieve Policy Template MetaData created from assignment", func() { + + It("Successfully retrieved a v2 access policy", func() { + shouldSkipTest() + Expect(testPolicyId).To(Not(BeNil())) + + options := service.NewGetV2PolicyOptions(assignmentPolicyID) + policy, detailedResponse, err := service.GetV2Policy(options) + Expect(err).To(BeNil()) + Expect(detailedResponse.StatusCode).To(Equal(200)) + Expect(policy).ToNot(BeNil()) + fmt.Fprintf(GinkgoWriter, "GetV2Policy() result:\n%s\n", common.ToJSON(policy)) + Expect(*policy.ID).To(Equal(assignmentPolicyID)) + Expect(policy.Template).ToNot(BeNil()) + Expect(policy.Template.ID).ToNot(BeNil()) + Expect(policy.Template.Version).ToNot(BeNil()) + Expect(policy.Template.AssignmentID).ToNot(BeNil()) + Expect(policy.Template.RootID).ToNot(BeNil()) + Expect(policy.Template.RootVersion).ToNot(BeNil()) }) }) diff --git a/iampolicymanagementv1/iam_policy_management_v1_test.go b/iampolicymanagementv1/iam_policy_management_v1_test.go index 4454ff35..e1f394bb 100644 --- a/iampolicymanagementv1/iam_policy_management_v1_test.go +++ b/iampolicymanagementv1/iam_policy_management_v1_test.go @@ -259,7 +259,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"policies": [{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "template": {"crn": "CRN", "version": "Version"}}]}`) + fmt.Fprintf(res, "%s", `{"policies": [{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "template": {"id": "ID", "version": "Version", "assignment_id": "AssignmentID", "root_id": "RootID", "root_version": "RootVersion"}}]}`) })) }) It(`Invoke ListPolicies successfully with retries`, func() { @@ -335,7 +335,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"policies": [{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "template": {"crn": "CRN", "version": "Version"}}]}`) + fmt.Fprintf(res, "%s", `{"policies": [{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "template": {"id": "ID", "version": "Version", "assignment_id": "AssignmentID", "root_id": "RootID", "root_version": "RootVersion"}}]}`) })) }) It(`Invoke ListPolicies successfully`, func() { @@ -578,7 +578,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "template": {"crn": "CRN", "version": "Version"}}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active"}`) })) }) It(`Invoke CreatePolicy successfully with retries`, func() { @@ -685,7 +685,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "template": {"crn": "CRN", "version": "Version"}}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active"}`) })) }) It(`Invoke CreatePolicy successfully`, func() { @@ -1004,7 +1004,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "template": {"crn": "CRN", "version": "Version"}}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active"}`) })) }) It(`Invoke ReplacePolicy successfully with retries`, func() { @@ -1112,7 +1112,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "template": {"crn": "CRN", "version": "Version"}}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active"}`) })) }) It(`Invoke ReplacePolicy successfully`, func() { @@ -1378,7 +1378,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "template": {"crn": "CRN", "version": "Version"}}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "template": {"id": "ID", "version": "Version", "assignment_id": "AssignmentID", "root_id": "RootID", "root_version": "RootVersion"}}`) })) }) It(`Invoke GetPolicy successfully with retries`, func() { @@ -1432,7 +1432,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "template": {"crn": "CRN", "version": "Version"}}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "template": {"id": "ID", "version": "Version", "assignment_id": "AssignmentID", "root_id": "RootID", "root_version": "RootVersion"}}`) })) }) It(`Invoke GetPolicy successfully`, func() { @@ -1680,7 +1680,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "template": {"crn": "CRN", "version": "Version"}}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active"}`) })) }) It(`Invoke UpdatePolicyState successfully with retries`, func() { @@ -1754,7 +1754,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "template": {"crn": "CRN", "version": "Version"}}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "type": "Type", "description": "Description", "subjects": [{"attributes": [{"name": "Name", "value": "Value"}]}], "roles": [{"role_id": "RoleID", "display_name": "DisplayName", "description": "Description"}], "resources": [{"attributes": [{"name": "Name", "value": "Value", "operator": "Operator"}], "tags": [{"name": "Name", "value": "Value", "operator": "Operator"}]}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active"}`) })) }) It(`Invoke UpdatePolicyState successfully`, func() { @@ -3033,7 +3033,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"policies": [{"type": "access", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "Value"}]}, "resource": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "Key", "value": "Value", "operator": "stringEquals"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "timeLessThan", "value": "anyValue"}, "id": "ID", "href": "Href", "control": {"grant": {"roles": [{"role_id": "RoleID"}]}}, "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "last_permit_at": "LastPermitAt", "last_permit_frequency": 19, "template": {"crn": "CRN", "version": "Version"}}]}`) + fmt.Fprintf(res, "%s", `{"policies": [{"type": "access", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "Value"}]}, "resource": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "Key", "value": "Value", "operator": "stringEquals"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "timeLessThan", "value": "anyValue"}, "id": "ID", "href": "Href", "control": {"grant": {"roles": [{"role_id": "RoleID"}]}}, "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "last_permit_at": "LastPermitAt", "last_permit_frequency": 19, "template": {"id": "ID", "version": "Version", "assignment_id": "AssignmentID", "root_id": "RootID", "root_version": "RootVersion"}}]}`) })) }) It(`Invoke ListV2Policies successfully with retries`, func() { @@ -3109,7 +3109,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"policies": [{"type": "access", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "Value"}]}, "resource": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "Key", "value": "Value", "operator": "stringEquals"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "timeLessThan", "value": "anyValue"}, "id": "ID", "href": "Href", "control": {"grant": {"roles": [{"role_id": "RoleID"}]}}, "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "last_permit_at": "LastPermitAt", "last_permit_frequency": 19, "template": {"crn": "CRN", "version": "Version"}}]}`) + fmt.Fprintf(res, "%s", `{"policies": [{"type": "access", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "Value"}]}, "resource": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "Key", "value": "Value", "operator": "stringEquals"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "timeLessThan", "value": "anyValue"}, "id": "ID", "href": "Href", "control": {"grant": {"roles": [{"role_id": "RoleID"}]}}, "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "last_permit_at": "LastPermitAt", "last_permit_frequency": 19, "template": {"id": "ID", "version": "Version", "assignment_id": "AssignmentID", "root_id": "RootID", "root_version": "RootVersion"}}]}`) })) }) It(`Invoke ListV2Policies successfully`, func() { @@ -3369,7 +3369,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"type": "access", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "Value"}]}, "resource": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "Key", "value": "Value", "operator": "stringEquals"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "timeLessThan", "value": "anyValue"}, "id": "ID", "href": "Href", "control": {"grant": {"roles": [{"role_id": "RoleID"}]}}, "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "last_permit_at": "LastPermitAt", "last_permit_frequency": 19, "template": {"crn": "CRN", "version": "Version"}}`) + fmt.Fprintf(res, "%s", `{"type": "access", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "Value"}]}, "resource": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "Key", "value": "Value", "operator": "stringEquals"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "timeLessThan", "value": "anyValue"}, "id": "ID", "href": "Href", "control": {"grant": {"roles": [{"role_id": "RoleID"}]}}, "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "last_permit_at": "LastPermitAt", "last_permit_frequency": 19}`) })) }) It(`Invoke CreateV2Policy successfully with retries`, func() { @@ -3493,7 +3493,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"type": "access", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "Value"}]}, "resource": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "Key", "value": "Value", "operator": "stringEquals"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "timeLessThan", "value": "anyValue"}, "id": "ID", "href": "Href", "control": {"grant": {"roles": [{"role_id": "RoleID"}]}}, "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "last_permit_at": "LastPermitAt", "last_permit_frequency": 19, "template": {"crn": "CRN", "version": "Version"}}`) + fmt.Fprintf(res, "%s", `{"type": "access", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "Value"}]}, "resource": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "Key", "value": "Value", "operator": "stringEquals"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "timeLessThan", "value": "anyValue"}, "id": "ID", "href": "Href", "control": {"grant": {"roles": [{"role_id": "RoleID"}]}}, "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "last_permit_at": "LastPermitAt", "last_permit_frequency": 19}`) })) }) It(`Invoke CreateV2Policy successfully`, func() { @@ -3880,7 +3880,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"type": "access", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "Value"}]}, "resource": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "Key", "value": "Value", "operator": "stringEquals"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "timeLessThan", "value": "anyValue"}, "id": "ID", "href": "Href", "control": {"grant": {"roles": [{"role_id": "RoleID"}]}}, "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "last_permit_at": "LastPermitAt", "last_permit_frequency": 19, "template": {"crn": "CRN", "version": "Version"}}`) + fmt.Fprintf(res, "%s", `{"type": "access", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "Value"}]}, "resource": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "Key", "value": "Value", "operator": "stringEquals"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "timeLessThan", "value": "anyValue"}, "id": "ID", "href": "Href", "control": {"grant": {"roles": [{"role_id": "RoleID"}]}}, "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "last_permit_at": "LastPermitAt", "last_permit_frequency": 19}`) })) }) It(`Invoke ReplaceV2Policy successfully with retries`, func() { @@ -4005,7 +4005,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"type": "access", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "Value"}]}, "resource": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "Key", "value": "Value", "operator": "stringEquals"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "timeLessThan", "value": "anyValue"}, "id": "ID", "href": "Href", "control": {"grant": {"roles": [{"role_id": "RoleID"}]}}, "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "last_permit_at": "LastPermitAt", "last_permit_frequency": 19, "template": {"crn": "CRN", "version": "Version"}}`) + fmt.Fprintf(res, "%s", `{"type": "access", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "Value"}]}, "resource": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "Key", "value": "Value", "operator": "stringEquals"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "timeLessThan", "value": "anyValue"}, "id": "ID", "href": "Href", "control": {"grant": {"roles": [{"role_id": "RoleID"}]}}, "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "last_permit_at": "LastPermitAt", "last_permit_frequency": 19}`) })) }) It(`Invoke ReplaceV2Policy successfully`, func() { @@ -4325,7 +4325,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"type": "access", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "Value"}]}, "resource": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "Key", "value": "Value", "operator": "stringEquals"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "timeLessThan", "value": "anyValue"}, "id": "ID", "href": "Href", "control": {"grant": {"roles": [{"role_id": "RoleID"}]}}, "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "last_permit_at": "LastPermitAt", "last_permit_frequency": 19, "template": {"crn": "CRN", "version": "Version"}}`) + fmt.Fprintf(res, "%s", `{"type": "access", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "Value"}]}, "resource": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "Key", "value": "Value", "operator": "stringEquals"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "timeLessThan", "value": "anyValue"}, "id": "ID", "href": "Href", "control": {"grant": {"roles": [{"role_id": "RoleID"}]}}, "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "last_permit_at": "LastPermitAt", "last_permit_frequency": 19, "template": {"id": "ID", "version": "Version", "assignment_id": "AssignmentID", "root_id": "RootID", "root_version": "RootVersion"}}`) })) }) It(`Invoke GetV2Policy successfully with retries`, func() { @@ -4381,7 +4381,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"type": "access", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "Value"}]}, "resource": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "Key", "value": "Value", "operator": "stringEquals"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "timeLessThan", "value": "anyValue"}, "id": "ID", "href": "Href", "control": {"grant": {"roles": [{"role_id": "RoleID"}]}}, "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "last_permit_at": "LastPermitAt", "last_permit_frequency": 19, "template": {"crn": "CRN", "version": "Version"}}`) + fmt.Fprintf(res, "%s", `{"type": "access", "description": "Description", "subject": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "Value"}]}, "resource": {"attributes": [{"key": "Key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "Key", "value": "Value", "operator": "stringEquals"}]}, "pattern": "Pattern", "rule": {"key": "Key", "operator": "timeLessThan", "value": "anyValue"}, "id": "ID", "href": "Href", "control": {"grant": {"roles": [{"role_id": "RoleID"}]}}, "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "state": "active", "last_permit_at": "LastPermitAt", "last_permit_frequency": 19, "template": {"id": "ID", "version": "Version", "assignment_id": "AssignmentID", "root_id": "RootID", "root_version": "RootVersion"}}`) })) }) It(`Invoke GetV2Policy successfully`, func() { @@ -5620,6 +5620,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { createPolicyTemplateVersionOptionsModel := new(iampolicymanagementv1.CreatePolicyTemplateVersionOptions) createPolicyTemplateVersionOptionsModel.PolicyTemplateID = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Policy = templatePolicyModel + createPolicyTemplateVersionOptionsModel.Name = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Description = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Committed = core.BoolPtr(true) createPolicyTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -5734,6 +5735,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { createPolicyTemplateVersionOptionsModel := new(iampolicymanagementv1.CreatePolicyTemplateVersionOptions) createPolicyTemplateVersionOptionsModel.PolicyTemplateID = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Policy = templatePolicyModel + createPolicyTemplateVersionOptionsModel.Name = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Description = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Committed = core.BoolPtr(true) createPolicyTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -5856,6 +5858,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { createPolicyTemplateVersionOptionsModel := new(iampolicymanagementv1.CreatePolicyTemplateVersionOptions) createPolicyTemplateVersionOptionsModel.PolicyTemplateID = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Policy = templatePolicyModel + createPolicyTemplateVersionOptionsModel.Name = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Description = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Committed = core.BoolPtr(true) createPolicyTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -5923,6 +5926,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { createPolicyTemplateVersionOptionsModel := new(iampolicymanagementv1.CreatePolicyTemplateVersionOptions) createPolicyTemplateVersionOptionsModel.PolicyTemplateID = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Policy = templatePolicyModel + createPolicyTemplateVersionOptionsModel.Name = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Description = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Committed = core.BoolPtr(true) createPolicyTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -6011,6 +6015,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { createPolicyTemplateVersionOptionsModel := new(iampolicymanagementv1.CreatePolicyTemplateVersionOptions) createPolicyTemplateVersionOptionsModel.PolicyTemplateID = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Policy = templatePolicyModel + createPolicyTemplateVersionOptionsModel.Name = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Description = core.StringPtr("testString") createPolicyTemplateVersionOptionsModel.Committed = core.BoolPtr(true) createPolicyTemplateVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -6315,6 +6320,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { replacePolicyTemplateOptionsModel.Version = core.StringPtr("testString") replacePolicyTemplateOptionsModel.IfMatch = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Policy = templatePolicyModel + replacePolicyTemplateOptionsModel.Name = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Description = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Committed = core.BoolPtr(true) replacePolicyTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -6433,6 +6439,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { replacePolicyTemplateOptionsModel.Version = core.StringPtr("testString") replacePolicyTemplateOptionsModel.IfMatch = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Policy = templatePolicyModel + replacePolicyTemplateOptionsModel.Name = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Description = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Committed = core.BoolPtr(true) replacePolicyTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -6559,6 +6566,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { replacePolicyTemplateOptionsModel.Version = core.StringPtr("testString") replacePolicyTemplateOptionsModel.IfMatch = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Policy = templatePolicyModel + replacePolicyTemplateOptionsModel.Name = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Description = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Committed = core.BoolPtr(true) replacePolicyTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -6628,6 +6636,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { replacePolicyTemplateOptionsModel.Version = core.StringPtr("testString") replacePolicyTemplateOptionsModel.IfMatch = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Policy = templatePolicyModel + replacePolicyTemplateOptionsModel.Name = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Description = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Committed = core.BoolPtr(true) replacePolicyTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -6718,6 +6727,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { replacePolicyTemplateOptionsModel.Version = core.StringPtr("testString") replacePolicyTemplateOptionsModel.IfMatch = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Policy = templatePolicyModel + replacePolicyTemplateOptionsModel.Name = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Description = core.StringPtr("testString") replacePolicyTemplateOptionsModel.Committed = core.BoolPtr(true) replacePolicyTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -7033,8 +7043,6 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(req.URL.EscapedPath()).To(Equal(commitPolicyTemplatePath)) Expect(req.Method).To(Equal("POST")) - Expect(req.Header["If-Match"]).ToNot(BeNil()) - Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) res.WriteHeader(204) })) }) @@ -7055,7 +7063,6 @@ var _ = Describe(`IamPolicyManagementV1`, func() { commitPolicyTemplateOptionsModel := new(iampolicymanagementv1.CommitPolicyTemplateOptions) commitPolicyTemplateOptionsModel.PolicyTemplateID = core.StringPtr("testString") commitPolicyTemplateOptionsModel.Version = core.StringPtr("testString") - commitPolicyTemplateOptionsModel.IfMatch = core.StringPtr("testString") commitPolicyTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -7075,7 +7082,6 @@ var _ = Describe(`IamPolicyManagementV1`, func() { commitPolicyTemplateOptionsModel := new(iampolicymanagementv1.CommitPolicyTemplateOptions) commitPolicyTemplateOptionsModel.PolicyTemplateID = core.StringPtr("testString") commitPolicyTemplateOptionsModel.Version = core.StringPtr("testString") - commitPolicyTemplateOptionsModel.IfMatch = core.StringPtr("testString") commitPolicyTemplateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := iamPolicyManagementService.SetServiceURL("") @@ -7171,7 +7177,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"assignments": [{"template_id": "TemplateID", "template_version": "TemplateVersion", "assignment_id": "AssignmentID", "target_type": "Account", "target": "Target", "options": [{"subject_type": "iam_id", "subject_id": "SubjectID", "root_requester_id": "RootRequesterID", "root_template_id": "RootTemplateID", "root_template_version": "RootTemplateVersion"}], "id": "ID", "account_id": "AccountID", "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "resources": [{"target": "Target", "policy": {"resource_created": {"id": "ID"}, "error_message": {"trace": "Trace", "errors": [{"code": "insufficent_permissions", "message": "Message", "details": {"conflicts_with": {"etag": "Etag", "role": "Role", "policy": "Policy"}}, "more_info": "MoreInfo"}], "status_code": 10}}}], "status": "in_progress"}]}`) + fmt.Fprintf(res, "%s", `{"assignments": [{"template_id": "TemplateID", "template_version": "TemplateVersion", "assignment_id": "AssignmentID", "target_type": "Account", "target": "Target", "options": [{"subject_type": "iam_id", "subject_id": "SubjectID", "root_requester_id": "RootRequesterID", "root_template_id": "RootTemplateID", "root_template_version": "RootTemplateVersion"}], "id": "ID", "account_id": "AccountID", "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "resources": [{"target": "Target", "policy": {"resource_created": {"id": "ID"}, "status": "Status", "error_message": {"trace": "Trace", "errors": [{"code": "insufficent_permissions", "message": "Message", "details": {"conflicts_with": {"etag": "Etag", "role": "Role", "policy": "Policy"}}, "more_info": "MoreInfo"}], "status_code": 10}}}], "status": "in_progress"}]}`) })) }) It(`Invoke ListPolicyAssignments successfully with retries`, func() { @@ -7233,7 +7239,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"assignments": [{"template_id": "TemplateID", "template_version": "TemplateVersion", "assignment_id": "AssignmentID", "target_type": "Account", "target": "Target", "options": [{"subject_type": "iam_id", "subject_id": "SubjectID", "root_requester_id": "RootRequesterID", "root_template_id": "RootTemplateID", "root_template_version": "RootTemplateVersion"}], "id": "ID", "account_id": "AccountID", "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "resources": [{"target": "Target", "policy": {"resource_created": {"id": "ID"}, "error_message": {"trace": "Trace", "errors": [{"code": "insufficent_permissions", "message": "Message", "details": {"conflicts_with": {"etag": "Etag", "role": "Role", "policy": "Policy"}}, "more_info": "MoreInfo"}], "status_code": 10}}}], "status": "in_progress"}]}`) + fmt.Fprintf(res, "%s", `{"assignments": [{"template_id": "TemplateID", "template_version": "TemplateVersion", "assignment_id": "AssignmentID", "target_type": "Account", "target": "Target", "options": [{"subject_type": "iam_id", "subject_id": "SubjectID", "root_requester_id": "RootRequesterID", "root_template_id": "RootTemplateID", "root_template_version": "RootTemplateVersion"}], "id": "ID", "account_id": "AccountID", "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "resources": [{"target": "Target", "policy": {"resource_created": {"id": "ID"}, "status": "Status", "error_message": {"trace": "Trace", "errors": [{"code": "insufficent_permissions", "message": "Message", "details": {"conflicts_with": {"etag": "Etag", "role": "Role", "policy": "Policy"}}, "more_info": "MoreInfo"}], "status_code": 10}}}], "status": "in_progress"}]}`) })) }) It(`Invoke ListPolicyAssignments successfully`, func() { @@ -7400,7 +7406,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"template_id": "TemplateID", "template_version": "TemplateVersion", "assignment_id": "AssignmentID", "target_type": "Account", "target": "Target", "options": [{"subject_type": "iam_id", "subject_id": "SubjectID", "root_requester_id": "RootRequesterID", "root_template_id": "RootTemplateID", "root_template_version": "RootTemplateVersion"}], "id": "ID", "account_id": "AccountID", "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "resources": [{"target": "Target", "policy": {"resource_created": {"id": "ID"}, "error_message": {"trace": "Trace", "errors": [{"code": "insufficent_permissions", "message": "Message", "details": {"conflicts_with": {"etag": "Etag", "role": "Role", "policy": "Policy"}}, "more_info": "MoreInfo"}], "status_code": 10}}}], "status": "in_progress"}`) + fmt.Fprintf(res, "%s", `{"template_id": "TemplateID", "template_version": "TemplateVersion", "assignment_id": "AssignmentID", "target_type": "Account", "target": "Target", "options": [{"subject_type": "iam_id", "subject_id": "SubjectID", "root_requester_id": "RootRequesterID", "root_template_id": "RootTemplateID", "root_template_version": "RootTemplateVersion"}], "id": "ID", "account_id": "AccountID", "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "resources": [{"target": "Target", "policy": {"resource_created": {"id": "ID"}, "status": "Status", "error_message": {"trace": "Trace", "errors": [{"code": "insufficent_permissions", "message": "Message", "details": {"conflicts_with": {"etag": "Etag", "role": "Role", "policy": "Policy"}}, "more_info": "MoreInfo"}], "status_code": 10}}}], "status": "in_progress"}`) })) }) It(`Invoke GetPolicyAssignment successfully with retries`, func() { @@ -7454,7 +7460,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"template_id": "TemplateID", "template_version": "TemplateVersion", "assignment_id": "AssignmentID", "target_type": "Account", "target": "Target", "options": [{"subject_type": "iam_id", "subject_id": "SubjectID", "root_requester_id": "RootRequesterID", "root_template_id": "RootTemplateID", "root_template_version": "RootTemplateVersion"}], "id": "ID", "account_id": "AccountID", "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "resources": [{"target": "Target", "policy": {"resource_created": {"id": "ID"}, "error_message": {"trace": "Trace", "errors": [{"code": "insufficent_permissions", "message": "Message", "details": {"conflicts_with": {"etag": "Etag", "role": "Role", "policy": "Policy"}}, "more_info": "MoreInfo"}], "status_code": 10}}}], "status": "in_progress"}`) + fmt.Fprintf(res, "%s", `{"template_id": "TemplateID", "template_version": "TemplateVersion", "assignment_id": "AssignmentID", "target_type": "Account", "target": "Target", "options": [{"subject_type": "iam_id", "subject_id": "SubjectID", "root_requester_id": "RootRequesterID", "root_template_id": "RootTemplateID", "root_template_version": "RootTemplateVersion"}], "id": "ID", "account_id": "AccountID", "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID", "resources": [{"target": "Target", "policy": {"resource_created": {"id": "ID"}, "status": "Status", "error_message": {"trace": "Trace", "errors": [{"code": "insufficent_permissions", "message": "Message", "details": {"conflicts_with": {"etag": "Etag", "role": "Role", "policy": "Policy"}}, "more_info": "MoreInfo"}], "status_code": 10}}}], "status": "in_progress"}`) })) }) It(`Invoke GetPolicyAssignment successfully`, func() { @@ -7560,16 +7566,13 @@ var _ = Describe(`IamPolicyManagementV1`, func() { // Construct an instance of the CommitPolicyTemplateOptions model policyTemplateID := "testString" version := "testString" - ifMatch := "testString" - commitPolicyTemplateOptionsModel := iamPolicyManagementService.NewCommitPolicyTemplateOptions(policyTemplateID, version, ifMatch) + commitPolicyTemplateOptionsModel := iamPolicyManagementService.NewCommitPolicyTemplateOptions(policyTemplateID, version) commitPolicyTemplateOptionsModel.SetPolicyTemplateID("testString") commitPolicyTemplateOptionsModel.SetVersion("testString") - commitPolicyTemplateOptionsModel.SetIfMatch("testString") commitPolicyTemplateOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(commitPolicyTemplateOptionsModel).ToNot(BeNil()) Expect(commitPolicyTemplateOptionsModel.PolicyTemplateID).To(Equal(core.StringPtr("testString"))) Expect(commitPolicyTemplateOptionsModel.Version).To(Equal(core.StringPtr("testString"))) - Expect(commitPolicyTemplateOptionsModel.IfMatch).To(Equal(core.StringPtr("testString"))) Expect(commitPolicyTemplateOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewControl successfully`, func() { @@ -7821,12 +7824,14 @@ var _ = Describe(`IamPolicyManagementV1`, func() { createPolicyTemplateVersionOptionsModel := iamPolicyManagementService.NewCreatePolicyTemplateVersionOptions(policyTemplateID, createPolicyTemplateVersionOptionsPolicy) createPolicyTemplateVersionOptionsModel.SetPolicyTemplateID("testString") createPolicyTemplateVersionOptionsModel.SetPolicy(templatePolicyModel) + createPolicyTemplateVersionOptionsModel.SetName("testString") createPolicyTemplateVersionOptionsModel.SetDescription("testString") createPolicyTemplateVersionOptionsModel.SetCommitted(true) createPolicyTemplateVersionOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(createPolicyTemplateVersionOptionsModel).ToNot(BeNil()) Expect(createPolicyTemplateVersionOptionsModel.PolicyTemplateID).To(Equal(core.StringPtr("testString"))) Expect(createPolicyTemplateVersionOptionsModel.Policy).To(Equal(templatePolicyModel)) + Expect(createPolicyTemplateVersionOptionsModel.Name).To(Equal(core.StringPtr("testString"))) Expect(createPolicyTemplateVersionOptionsModel.Description).To(Equal(core.StringPtr("testString"))) Expect(createPolicyTemplateVersionOptionsModel.Committed).To(Equal(core.BoolPtr(true))) Expect(createPolicyTemplateVersionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) @@ -8359,6 +8364,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { replacePolicyTemplateOptionsModel.SetVersion("testString") replacePolicyTemplateOptionsModel.SetIfMatch("testString") replacePolicyTemplateOptionsModel.SetPolicy(templatePolicyModel) + replacePolicyTemplateOptionsModel.SetName("testString") replacePolicyTemplateOptionsModel.SetDescription("testString") replacePolicyTemplateOptionsModel.SetCommitted(true) replacePolicyTemplateOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) @@ -8367,6 +8373,7 @@ var _ = Describe(`IamPolicyManagementV1`, func() { Expect(replacePolicyTemplateOptionsModel.Version).To(Equal(core.StringPtr("testString"))) Expect(replacePolicyTemplateOptionsModel.IfMatch).To(Equal(core.StringPtr("testString"))) Expect(replacePolicyTemplateOptionsModel.Policy).To(Equal(templatePolicyModel)) + Expect(replacePolicyTemplateOptionsModel.Name).To(Equal(core.StringPtr("testString"))) Expect(replacePolicyTemplateOptionsModel.Description).To(Equal(core.StringPtr("testString"))) Expect(replacePolicyTemplateOptionsModel.Committed).To(Equal(core.BoolPtr(true))) Expect(replacePolicyTemplateOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) @@ -8537,9 +8544,8 @@ var _ = Describe(`IamPolicyManagementV1`, func() { }) It(`Invoke NewTemplatePolicy successfully`, func() { typeVar := "access" - var resource *iampolicymanagementv1.V2PolicyResource = nil var control *iampolicymanagementv1.Control = nil - _, err := iamPolicyManagementService.NewTemplatePolicy(typeVar, resource, control) + _, err := iamPolicyManagementService.NewTemplatePolicy(typeVar, control) Expect(err).ToNot(BeNil()) }) It(`Invoke NewUpdatePolicyStateOptions successfully`, func() { From cd0781e9b8a88e456d45881f52f3de05288a977a Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 28 Aug 2023 16:55:59 +0000 Subject: [PATCH 06/27] Update version 0.46.0 -> 0.47.0 [skip ci] Signed-off-by: manu.k.m --- .bumpversion.cfg | 2 +- README.md | 4 ++-- common/version.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 81a65eca..5708ef3c 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.46.0 +current_version = 0.47.0 commit = True message = Update version {current_version} -> {new_version} [skip ci] diff --git a/README.md b/README.md index 365e9096..ac7965e3 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![CLA assistant](https://cla-assistant.io/readme/badge/IBM/platform-services-go-sdk)](https://cla-assistant.io/IBM/platform-services-go-sdk) -# IBM Cloud Platform Services Go SDK Version 0.46.0 +# IBM Cloud Platform Services Go SDK Version 0.47.0 Go client library to interact with various [IBM Cloud Platform Service APIs](https://cloud.ibm.com/docs?tab=api-docs&category=platform_services). @@ -86,7 +86,7 @@ Service Name | Package name * Go version 1.19 or above. ## Installation -The current version of this SDK: 0.46.0 +The current version of this SDK: 0.47.0 ### Go modules If your application uses Go modules for dependency management (recommended), just add an import for each service diff --git a/common/version.go b/common/version.go index 2281c83b..47fd1566 100644 --- a/common/version.go +++ b/common/version.go @@ -17,4 +17,4 @@ package common // Version of the SDK -const Version = "0.46.0" +const Version = "0.47.0" From d61bbea97615a2acc74cd6cc2ded3e9d93dee4b7 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 28 Aug 2023 16:55:59 +0000 Subject: [PATCH 07/27] chore(release): 0.47.0 release notes [skip ci] # [0.47.0](https://github.com/IBM/platform-services-go-sdk/compare/v0.46.0...v0.47.0) (2023-08-28) ### Features * **IAM Policy Management:** fix template metadata as part of policies ([#274](https://github.com/IBM/platform-services-go-sdk/issues/274)) ([542046f](https://github.com/IBM/platform-services-go-sdk/commit/542046f552aa1cbbdd744d5549f9357020840ff5)) Signed-off-by: manu.k.m --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fab3b81f..d8f91024 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [0.47.0](https://github.com/IBM/platform-services-go-sdk/compare/v0.46.0...v0.47.0) (2023-08-28) + + +### Features + +* **IAM Policy Management:** fix template metadata as part of policies ([#274](https://github.com/IBM/platform-services-go-sdk/issues/274)) ([542046f](https://github.com/IBM/platform-services-go-sdk/commit/542046f552aa1cbbdd744d5549f9357020840ff5)) + # [0.46.0](https://github.com/IBM/platform-services-go-sdk/compare/v0.45.0...v0.46.0) (2023-08-18) From a8e7783aa00b09130f6ff594dda31efdac609b5a Mon Sep 17 00:00:00 2001 From: "manu.k.m" Date: Fri, 1 Sep 2023 18:50:32 +0530 Subject: [PATCH 08/27] feat (Usage Reports): Temporary change Signed-off-by: manu.k.m --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 6804ff89..abb98e6a 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/IBM/platform-services-go-sdk +module github.com/manukm-ibm/platform-services-go-sdk go 1.19 From 5cac486d42cdcf781172fdbc07bf46f79ce36e28 Mon Sep 17 00:00:00 2001 From: "manu.k.m" Date: Sat, 2 Sep 2023 00:45:55 +0530 Subject: [PATCH 09/27] feat (Usage Reports): Revert temporary change Signed-off-by: manu.k.m --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index abb98e6a..6804ff89 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/manukm-ibm/platform-services-go-sdk +module github.com/IBM/platform-services-go-sdk go 1.19 From e1e7c1b9b1cb92e04776047bd208d63b006ed687 Mon Sep 17 00:00:00 2001 From: Phil Adams Date: Thu, 31 Aug 2023 15:12:29 -0500 Subject: [PATCH 10/27] fix: enable builds on windows (#273) This commit updates the project to enable builds to be performed on Windows. I also bumped the go core version to the current latest. Signed-off-by: Phil Adams Signed-off-by: manu.k.m --- CONTRIBUTING.md | 16 ++++++++++++++-- Makefile | 8 ++++---- go.mod | 2 +- go.sum | 4 ++-- update_service.md | 6 +++++- 5 files changed, 26 insertions(+), 10 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 39a48d60..157a3a8c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,6 +12,18 @@ Before that, please search for similar issues. It's possible that someone has al For general guidance on contributing to this project, please see [this link](https://github.com/IBM/ibm-cloud-sdk-common/blob/main/CONTRIBUTING_go.md) +# Prerequisites +The following tools are required in order to build this project: +* Git +* A modern version of the `make` utility. + Note: Windows users will likely need to install one of the various + [make utilities available for Windows](https://www.google.com/search?q=make+utility+for+windows). +* A version of [Go](https://www.google.com/search?q=install+golang) that is >= the +minimum version supported by the project. + +Windows users might find it more convenient to use +[`Windows Subsystem for Linux (WSL)`](https://learn.microsoft.com/en-us/windows/wsl/about) +or [`Cygwin`](https://www.cygwin.com/) when making contributions to this project. + # Updating an existing service within the SDK -For instructions on updating an existing service within the SDK, please see -[this link](update_service.md) +For instructions on updating an existing service within the SDK, please see [update_service.md](update_service.md) diff --git a/Makefile b/Makefile index fc74e857..8814f46a 100644 --- a/Makefile +++ b/Makefile @@ -9,16 +9,16 @@ all: tidy test lint travis-ci: tidy test-cov lint scan-gosec test: - ${GO} test `${GO} list ./...` + ${GO} test ./... test-cov: - ${GO} test `${GO} list ./...` ${COVERAGE} + ${GO} test ./... ${COVERAGE} test-int: - ${GO} test `${GO} list ./...` -tags=integration + ${GO} test ./... -tags=integration test-int-cov: - ${GO} test `${GO} list ./...` -tags=integration ${COVERAGE} + ${GO} test ./... -tags=integration ${COVERAGE} lint: ${LINT} run --build-tags=integration,examples --timeout 120s diff --git a/go.mod b/go.mod index 6804ff89..0646fd7a 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/IBM/platform-services-go-sdk go 1.19 require ( - github.com/IBM/go-sdk-core/v5 v5.13.2 + github.com/IBM/go-sdk-core/v5 v5.14.1 github.com/go-openapi/strfmt v0.21.5 github.com/google/uuid v1.3.0 github.com/onsi/ginkgo v1.16.5 diff --git a/go.sum b/go.sum index dd18ef01..da1a5c95 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/IBM/go-sdk-core/v5 v5.13.2 h1:C/JWnEadKzonoHFZdMX8DaSxGVqKRFhcpDXFS5bPDiA= -github.com/IBM/go-sdk-core/v5 v5.13.2/go.mod h1:gKRSB+YyKsGlRQW7v5frlLbue5afulSvrRa4O26o4MM= +github.com/IBM/go-sdk-core/v5 v5.14.1 h1:WR1r0zz+gDW++xzZjF41r9ueY4JyjS2vgZjiYs8lO3c= +github.com/IBM/go-sdk-core/v5 v5.14.1/go.mod h1:MUvIr/1mgGh198ZXL+ByKz9Qs1JoEh80v/96x8jPXNY= github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= diff --git a/update_service.md b/update_service.md index 3bb88335..e799df05 100644 --- a/update_service.md +++ b/update_service.md @@ -48,7 +48,10 @@ to your external github.com id. The id linking step will also result in an invit `github.com/IBM` org. Accept that invitation. 3. If you do not yet have "push" access to the SDK project, contact the project maintainer to request push access (you must be a member of the github.com/IBM org). -4. Make sure that your installed version of Go is >= the minimum version supported by the SDK project. +4. Make sure that you have installed the [tools required to build the project](CONTRIBUTING.md#prerequisites). +5. To update a service, make sure the following additional tools are installed: +* The [IBM OpenAPI Validator](https://github.com/IBM/openapi-validator) +* The [IBM OpenAPI SDK Generator](github.ibm.com/CloudEngineering/openapi-sdkgen) ## Initial project setup 1. Clone/fork the repo. If you have push access (see above), you can clone the repo directly (no fork). @@ -253,3 +256,4 @@ as mentioned above. - [IBM OpenAPI Validator](https://github.com/IBM/openapi-validator) - [IBM OpenAPI SDK Generator](https://github.ibm.com/CloudEngineering/openapi-sdkgen) - [Effective Go - The Go Programming Language](https://golang.org/doc/effective_go) +- [Go Documentation: Download and install](https://go.dev/doc/install) From 856b8509717062239852c203d8ea43f6b4699845 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 31 Aug 2023 20:17:31 +0000 Subject: [PATCH 11/27] Update version 0.47.0 -> 0.47.1 [skip ci] Signed-off-by: manu.k.m --- .bumpversion.cfg | 2 +- README.md | 4 ++-- common/version.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 5708ef3c..554cba83 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.47.0 +current_version = 0.47.1 commit = True message = Update version {current_version} -> {new_version} [skip ci] diff --git a/README.md b/README.md index ac7965e3..64ffffa8 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![CLA assistant](https://cla-assistant.io/readme/badge/IBM/platform-services-go-sdk)](https://cla-assistant.io/IBM/platform-services-go-sdk) -# IBM Cloud Platform Services Go SDK Version 0.47.0 +# IBM Cloud Platform Services Go SDK Version 0.47.1 Go client library to interact with various [IBM Cloud Platform Service APIs](https://cloud.ibm.com/docs?tab=api-docs&category=platform_services). @@ -86,7 +86,7 @@ Service Name | Package name * Go version 1.19 or above. ## Installation -The current version of this SDK: 0.47.0 +The current version of this SDK: 0.47.1 ### Go modules If your application uses Go modules for dependency management (recommended), just add an import for each service diff --git a/common/version.go b/common/version.go index 47fd1566..16bffd71 100644 --- a/common/version.go +++ b/common/version.go @@ -17,4 +17,4 @@ package common // Version of the SDK -const Version = "0.47.0" +const Version = "0.47.1" From 3c11693124abbe39e3867da26077b260bc42f80f Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 31 Aug 2023 20:17:31 +0000 Subject: [PATCH 12/27] chore(release): 0.47.1 release notes [skip ci] ## [0.47.1](https://github.com/IBM/platform-services-go-sdk/compare/v0.47.0...v0.47.1) (2023-08-31) ### Bug Fixes * enable builds on windows ([#273](https://github.com/IBM/platform-services-go-sdk/issues/273)) ([b39d2d5](https://github.com/IBM/platform-services-go-sdk/commit/b39d2d53b2b58b8b2b02335f6f0d878b33e8e712)) Signed-off-by: manu.k.m --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8f91024..04e9dddb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [0.47.1](https://github.com/IBM/platform-services-go-sdk/compare/v0.47.0...v0.47.1) (2023-08-31) + + +### Bug Fixes + +* enable builds on windows ([#273](https://github.com/IBM/platform-services-go-sdk/issues/273)) ([b39d2d5](https://github.com/IBM/platform-services-go-sdk/commit/b39d2d53b2b58b8b2b02335f6f0d878b33e8e712)) + # [0.47.0](https://github.com/IBM/platform-services-go-sdk/compare/v0.46.0...v0.47.0) (2023-08-28) From 435a988f6ef9d5499469a865faa03718f942a0b9 Mon Sep 17 00:00:00 2001 From: apoorva9s14 <31532417+apoorva9s14@users.noreply.github.com> Date: Fri, 1 Sep 2023 19:21:57 +0530 Subject: [PATCH 13/27] feat(Resource Controller): support resource group filter for list reclamations (#264) Co-authored-by: Phil Adams Signed-off-by: manu.k.m --- .../resource_controller_v2.go | 30 ++- .../resource_controller_v2_examples_test.go | 3 +- .../resource_controller_v2_test.go | 201 +++++++++--------- 3 files changed, 120 insertions(+), 114 deletions(-) diff --git a/resourcecontrollerv2/resource_controller_v2.go b/resourcecontrollerv2/resource_controller_v2.go index 94d490e9..d5242564 100644 --- a/resourcecontrollerv2/resource_controller_v2.go +++ b/resourcecontrollerv2/resource_controller_v2.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2021, 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. @@ -15,7 +15,7 @@ */ /* - * IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-f381b8c9-20221101-115055 + * IBM OpenAPI SDK Code Generator Version: 3.72.1-43bf8bf6-20230525-193151 */ // Package resourcecontrollerv2 : Operations and models for the ResourceControllerV2 service @@ -1962,6 +1962,9 @@ func (resourceController *ResourceControllerV2) ListReclamationsWithContext(ctx if listReclamationsOptions.ResourceInstanceID != nil { builder.AddQuery("resource_instance_id", fmt.Sprint(*listReclamationsOptions.ResourceInstanceID)) } + if listReclamationsOptions.ResourceGroupID != nil { + builder.AddQuery("resource_group_id", fmt.Sprint(*listReclamationsOptions.ResourceGroupID)) + } request, err := builder.Build() if err != nil { @@ -2749,6 +2752,9 @@ type ListReclamationsOptions struct { // The GUID of the resource instance. ResourceInstanceID *string `json:"resource_instance_id,omitempty"` + // The ID of the resource group. + ResourceGroupID *string `json:"resource_group_id,omitempty"` + // Allows users to set headers on API requests Headers map[string]string } @@ -2770,6 +2776,12 @@ func (_options *ListReclamationsOptions) SetResourceInstanceID(resourceInstanceI return _options } +// SetResourceGroupID : Allow user to set ResourceGroupID +func (_options *ListReclamationsOptions) SetResourceGroupID(resourceGroupID string) *ListReclamationsOptions { + _options.ResourceGroupID = core.StringPtr(resourceGroupID) + return _options +} + // SetHeaders : Allow user to set Headers func (options *ListReclamationsOptions) SetHeaders(param map[string]string) *ListReclamationsOptions { options.Headers = param @@ -5109,9 +5121,7 @@ func (options *UpdateResourceKeyOptions) SetHeaders(param map[string]string) *Up return options } -// // ResourceInstancesPager can be used to simplify the use of the "ListResourceInstances" method. -// type ResourceInstancesPager struct { hasNext bool options *ListResourceInstancesOptions @@ -5196,9 +5206,7 @@ func (pager *ResourceInstancesPager) GetAll() (allItems []ResourceInstance, err return pager.GetAllWithContext(context.Background()) } -// // ResourceAliasesForInstancePager can be used to simplify the use of the "ListResourceAliasesForInstance" method. -// type ResourceAliasesForInstancePager struct { hasNext bool options *ListResourceAliasesForInstanceOptions @@ -5283,9 +5291,7 @@ func (pager *ResourceAliasesForInstancePager) GetAll() (allItems []ResourceAlias return pager.GetAllWithContext(context.Background()) } -// // ResourceKeysForInstancePager can be used to simplify the use of the "ListResourceKeysForInstance" method. -// type ResourceKeysForInstancePager struct { hasNext bool options *ListResourceKeysForInstanceOptions @@ -5370,9 +5376,7 @@ func (pager *ResourceKeysForInstancePager) GetAll() (allItems []ResourceKey, err return pager.GetAllWithContext(context.Background()) } -// // ResourceKeysPager can be used to simplify the use of the "ListResourceKeys" method. -// type ResourceKeysPager struct { hasNext bool options *ListResourceKeysOptions @@ -5457,9 +5461,7 @@ func (pager *ResourceKeysPager) GetAll() (allItems []ResourceKey, err error) { return pager.GetAllWithContext(context.Background()) } -// // ResourceBindingsPager can be used to simplify the use of the "ListResourceBindings" method. -// type ResourceBindingsPager struct { hasNext bool options *ListResourceBindingsOptions @@ -5544,9 +5546,7 @@ func (pager *ResourceBindingsPager) GetAll() (allItems []ResourceBinding, err er return pager.GetAllWithContext(context.Background()) } -// // ResourceAliasesPager can be used to simplify the use of the "ListResourceAliases" method. -// type ResourceAliasesPager struct { hasNext bool options *ListResourceAliasesOptions @@ -5631,9 +5631,7 @@ func (pager *ResourceAliasesPager) GetAll() (allItems []ResourceAlias, err error return pager.GetAllWithContext(context.Background()) } -// // ResourceBindingsForAliasPager can be used to simplify the use of the "ListResourceBindingsForAlias" method. -// type ResourceBindingsForAliasPager struct { hasNext bool options *ListResourceBindingsForAliasOptions diff --git a/resourcecontrollerv2/resource_controller_v2_examples_test.go b/resourcecontrollerv2/resource_controller_v2_examples_test.go index dfffae6e..789d0f78 100644 --- a/resourcecontrollerv2/resource_controller_v2_examples_test.go +++ b/resourcecontrollerv2/resource_controller_v2_examples_test.go @@ -78,6 +78,7 @@ var _ = Describe(`ResourceControllerV2 Examples Tests`, func() { keyName string = "RcSdkKey1Go" keyUpdateName string = "RcSdkKeyUpdate1Go" targetRegion string = "global" + resourceGroupID string = "testResourceGroupID" ) var shouldSkipTest = func() { @@ -725,7 +726,7 @@ var _ = Describe(`ResourceControllerV2 Examples Tests`, func() { // begin-list_reclamations listReclamationsOptions := resourceControllerService.NewListReclamationsOptions() - listReclamationsOptions = listReclamationsOptions.SetAccountID(accountID) + listReclamationsOptions = listReclamationsOptions.SetResourceGroupID(resourceGroupID) reclamationsList, response, err := resourceControllerService.ListReclamations(listReclamationsOptions) if err != nil { panic(err) diff --git a/resourcecontrollerv2/resource_controller_v2_test.go b/resourcecontrollerv2/resource_controller_v2_test.go index c61e0755..3079448c 100644 --- a/resourcecontrollerv2/resource_controller_v2_test.go +++ b/resourcecontrollerv2/resource_controller_v2_test.go @@ -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. @@ -66,14 +66,13 @@ var _ = Describe(`ResourceControllerV2`, func() { Context(`Using external config, construct service client instances`, func() { // Map containing environment variables used in testing. var testEnvironment = map[string]string{ - "RESOURCE_CONTROLLER_URL": "https://resourcecontrollerv2/api", + "RESOURCE_CONTROLLER_URL": "https://resourcecontrollerv2/api", "RESOURCE_CONTROLLER_AUTH_TYPE": "noauth", } It(`Create service client using external config successfully`, func() { SetTestEnvironment(testEnvironment) - resourceControllerService, serviceErr := resourcecontrollerv2.NewResourceControllerV2UsingExternalConfig(&resourcecontrollerv2.ResourceControllerV2Options{ - }) + resourceControllerService, serviceErr := resourcecontrollerv2.NewResourceControllerV2UsingExternalConfig(&resourcecontrollerv2.ResourceControllerV2Options{}) Expect(resourceControllerService).ToNot(BeNil()) Expect(serviceErr).To(BeNil()) ClearTestEnvironment(testEnvironment) @@ -102,8 +101,7 @@ var _ = Describe(`ResourceControllerV2`, func() { }) It(`Create service client using external config and set url programatically successfully`, func() { SetTestEnvironment(testEnvironment) - resourceControllerService, serviceErr := resourcecontrollerv2.NewResourceControllerV2UsingExternalConfig(&resourcecontrollerv2.ResourceControllerV2Options{ - }) + resourceControllerService, serviceErr := resourcecontrollerv2.NewResourceControllerV2UsingExternalConfig(&resourcecontrollerv2.ResourceControllerV2Options{}) err := resourceControllerService.SetServiceURL("https://testService/api") Expect(err).To(BeNil()) Expect(resourceControllerService).ToNot(BeNil()) @@ -121,13 +119,12 @@ var _ = Describe(`ResourceControllerV2`, func() { Context(`Using external config, construct service client instances with error: Invalid Auth`, func() { // Map containing environment variables used in testing. var testEnvironment = map[string]string{ - "RESOURCE_CONTROLLER_URL": "https://resourcecontrollerv2/api", + "RESOURCE_CONTROLLER_URL": "https://resourcecontrollerv2/api", "RESOURCE_CONTROLLER_AUTH_TYPE": "someOtherAuth", } SetTestEnvironment(testEnvironment) - resourceControllerService, serviceErr := resourcecontrollerv2.NewResourceControllerV2UsingExternalConfig(&resourcecontrollerv2.ResourceControllerV2Options{ - }) + resourceControllerService, serviceErr := resourcecontrollerv2.NewResourceControllerV2UsingExternalConfig(&resourcecontrollerv2.ResourceControllerV2Options{}) It(`Instantiate service client with error`, func() { Expect(resourceControllerService).To(BeNil()) @@ -138,7 +135,7 @@ var _ = Describe(`ResourceControllerV2`, func() { Context(`Using external config, construct service client instances with error: Invalid URL`, func() { // Map containing environment variables used in testing. var testEnvironment = map[string]string{ - "RESOURCE_CONTROLLER_AUTH_TYPE": "NOAuth", + "RESOURCE_CONTROLLER_AUTH_TYPE": "NOAuth", } SetTestEnvironment(testEnvironment) @@ -462,14 +459,14 @@ var _ = Describe(`ResourceControllerV2`, func() { It(`Invoke GetNextStart successfully`, func() { responseObject := new(resourcecontrollerv2.ResourceInstancesList) responseObject.NextURL = core.StringPtr("ibm.com?start=abc-123") - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(Equal(core.StringPtr("abc-123"))) }) It(`Invoke GetNextStart without a "NextURL" property in the response`, func() { responseObject := new(resourcecontrollerv2.ResourceInstancesList) - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -477,7 +474,7 @@ var _ = Describe(`ResourceControllerV2`, func() { It(`Invoke GetNextStart without any query params in the "NextURL" URL`, func() { responseObject := new(resourcecontrollerv2.ResourceInstancesList) responseObject.NextURL = core.StringPtr("ibm.com") - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -515,17 +512,17 @@ var _ = Describe(`ResourceControllerV2`, func() { Expect(resourceControllerService).ToNot(BeNil()) listResourceInstancesOptionsModel := &resourcecontrollerv2.ListResourceInstancesOptions{ - GUID: core.StringPtr("testString"), - Name: core.StringPtr("testString"), + GUID: core.StringPtr("testString"), + Name: core.StringPtr("testString"), ResourceGroupID: core.StringPtr("testString"), - ResourceID: core.StringPtr("testString"), - ResourcePlanID: core.StringPtr("testString"), - Type: core.StringPtr("testString"), - SubType: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(10)), - State: core.StringPtr("active"), - UpdatedFrom: core.StringPtr("2021-01-01"), - UpdatedTo: core.StringPtr("2021-01-01"), + ResourceID: core.StringPtr("testString"), + ResourcePlanID: core.StringPtr("testString"), + Type: core.StringPtr("testString"), + SubType: core.StringPtr("testString"), + Limit: core.Int64Ptr(int64(10)), + State: core.StringPtr("active"), + UpdatedFrom: core.StringPtr("2021-01-01"), + UpdatedTo: core.StringPtr("2021-01-01"), } pager, err := resourceControllerService.NewResourceInstancesPager(listResourceInstancesOptionsModel) @@ -550,17 +547,17 @@ var _ = Describe(`ResourceControllerV2`, func() { Expect(resourceControllerService).ToNot(BeNil()) listResourceInstancesOptionsModel := &resourcecontrollerv2.ListResourceInstancesOptions{ - GUID: core.StringPtr("testString"), - Name: core.StringPtr("testString"), + GUID: core.StringPtr("testString"), + Name: core.StringPtr("testString"), ResourceGroupID: core.StringPtr("testString"), - ResourceID: core.StringPtr("testString"), - ResourcePlanID: core.StringPtr("testString"), - Type: core.StringPtr("testString"), - SubType: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(10)), - State: core.StringPtr("active"), - UpdatedFrom: core.StringPtr("2021-01-01"), - UpdatedTo: core.StringPtr("2021-01-01"), + ResourceID: core.StringPtr("testString"), + ResourcePlanID: core.StringPtr("testString"), + Type: core.StringPtr("testString"), + SubType: core.StringPtr("testString"), + Limit: core.Int64Ptr(int64(10)), + State: core.StringPtr("active"), + UpdatedFrom: core.StringPtr("2021-01-01"), + UpdatedTo: core.StringPtr("2021-01-01"), } pager, err := resourceControllerService.NewResourceInstancesPager(listResourceInstancesOptionsModel) @@ -1637,14 +1634,14 @@ var _ = Describe(`ResourceControllerV2`, func() { It(`Invoke GetNextStart successfully`, func() { responseObject := new(resourcecontrollerv2.ResourceAliasesList) responseObject.NextURL = core.StringPtr("ibm.com?start=abc-123") - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(Equal(core.StringPtr("abc-123"))) }) It(`Invoke GetNextStart without a "NextURL" property in the response`, func() { responseObject := new(resourcecontrollerv2.ResourceAliasesList) - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -1652,7 +1649,7 @@ var _ = Describe(`ResourceControllerV2`, func() { It(`Invoke GetNextStart without any query params in the "NextURL" URL`, func() { responseObject := new(resourcecontrollerv2.ResourceAliasesList) responseObject.NextURL = core.StringPtr("ibm.com") - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -1690,7 +1687,7 @@ var _ = Describe(`ResourceControllerV2`, func() { Expect(resourceControllerService).ToNot(BeNil()) listResourceAliasesForInstanceOptionsModel := &resourcecontrollerv2.ListResourceAliasesForInstanceOptions{ - ID: core.StringPtr("testString"), + ID: core.StringPtr("testString"), Limit: core.Int64Ptr(int64(10)), } @@ -1716,7 +1713,7 @@ var _ = Describe(`ResourceControllerV2`, func() { Expect(resourceControllerService).ToNot(BeNil()) listResourceAliasesForInstanceOptionsModel := &resourcecontrollerv2.ListResourceAliasesForInstanceOptions{ - ID: core.StringPtr("testString"), + ID: core.StringPtr("testString"), Limit: core.Int64Ptr(int64(10)), } @@ -1962,14 +1959,14 @@ var _ = Describe(`ResourceControllerV2`, func() { It(`Invoke GetNextStart successfully`, func() { responseObject := new(resourcecontrollerv2.ResourceKeysList) responseObject.NextURL = core.StringPtr("ibm.com?start=abc-123") - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(Equal(core.StringPtr("abc-123"))) }) It(`Invoke GetNextStart without a "NextURL" property in the response`, func() { responseObject := new(resourcecontrollerv2.ResourceKeysList) - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -1977,7 +1974,7 @@ var _ = Describe(`ResourceControllerV2`, func() { It(`Invoke GetNextStart without any query params in the "NextURL" URL`, func() { responseObject := new(resourcecontrollerv2.ResourceKeysList) responseObject.NextURL = core.StringPtr("ibm.com") - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -2015,7 +2012,7 @@ var _ = Describe(`ResourceControllerV2`, func() { Expect(resourceControllerService).ToNot(BeNil()) listResourceKeysForInstanceOptionsModel := &resourcecontrollerv2.ListResourceKeysForInstanceOptions{ - ID: core.StringPtr("testString"), + ID: core.StringPtr("testString"), Limit: core.Int64Ptr(int64(10)), } @@ -2041,7 +2038,7 @@ var _ = Describe(`ResourceControllerV2`, func() { Expect(resourceControllerService).ToNot(BeNil()) listResourceKeysForInstanceOptionsModel := &resourcecontrollerv2.ListResourceKeysForInstanceOptions{ - ID: core.StringPtr("testString"), + ID: core.StringPtr("testString"), Limit: core.Int64Ptr(int64(10)), } @@ -2959,14 +2956,14 @@ var _ = Describe(`ResourceControllerV2`, func() { It(`Invoke GetNextStart successfully`, func() { responseObject := new(resourcecontrollerv2.ResourceKeysList) responseObject.NextURL = core.StringPtr("ibm.com?start=abc-123") - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(Equal(core.StringPtr("abc-123"))) }) It(`Invoke GetNextStart without a "NextURL" property in the response`, func() { responseObject := new(resourcecontrollerv2.ResourceKeysList) - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -2974,7 +2971,7 @@ var _ = Describe(`ResourceControllerV2`, func() { It(`Invoke GetNextStart without any query params in the "NextURL" URL`, func() { responseObject := new(resourcecontrollerv2.ResourceKeysList) responseObject.NextURL = core.StringPtr("ibm.com") - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -3012,13 +3009,13 @@ var _ = Describe(`ResourceControllerV2`, func() { Expect(resourceControllerService).ToNot(BeNil()) listResourceKeysOptionsModel := &resourcecontrollerv2.ListResourceKeysOptions{ - GUID: core.StringPtr("testString"), - Name: core.StringPtr("testString"), + GUID: core.StringPtr("testString"), + Name: core.StringPtr("testString"), ResourceGroupID: core.StringPtr("testString"), - ResourceID: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(10)), - UpdatedFrom: core.StringPtr("2021-01-01"), - UpdatedTo: core.StringPtr("2021-01-01"), + ResourceID: core.StringPtr("testString"), + Limit: core.Int64Ptr(int64(10)), + UpdatedFrom: core.StringPtr("2021-01-01"), + UpdatedTo: core.StringPtr("2021-01-01"), } pager, err := resourceControllerService.NewResourceKeysPager(listResourceKeysOptionsModel) @@ -3043,13 +3040,13 @@ var _ = Describe(`ResourceControllerV2`, func() { Expect(resourceControllerService).ToNot(BeNil()) listResourceKeysOptionsModel := &resourcecontrollerv2.ListResourceKeysOptions{ - GUID: core.StringPtr("testString"), - Name: core.StringPtr("testString"), + GUID: core.StringPtr("testString"), + Name: core.StringPtr("testString"), ResourceGroupID: core.StringPtr("testString"), - ResourceID: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(10)), - UpdatedFrom: core.StringPtr("2021-01-01"), - UpdatedTo: core.StringPtr("2021-01-01"), + ResourceID: core.StringPtr("testString"), + Limit: core.Int64Ptr(int64(10)), + UpdatedFrom: core.StringPtr("2021-01-01"), + UpdatedTo: core.StringPtr("2021-01-01"), } pager, err := resourceControllerService.NewResourceKeysPager(listResourceKeysOptionsModel) @@ -4151,14 +4148,14 @@ var _ = Describe(`ResourceControllerV2`, func() { It(`Invoke GetNextStart successfully`, func() { responseObject := new(resourcecontrollerv2.ResourceBindingsList) responseObject.NextURL = core.StringPtr("ibm.com?start=abc-123") - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(Equal(core.StringPtr("abc-123"))) }) It(`Invoke GetNextStart without a "NextURL" property in the response`, func() { responseObject := new(resourcecontrollerv2.ResourceBindingsList) - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -4166,7 +4163,7 @@ var _ = Describe(`ResourceControllerV2`, func() { It(`Invoke GetNextStart without any query params in the "NextURL" URL`, func() { responseObject := new(resourcecontrollerv2.ResourceBindingsList) responseObject.NextURL = core.StringPtr("ibm.com") - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -4204,14 +4201,14 @@ var _ = Describe(`ResourceControllerV2`, func() { Expect(resourceControllerService).ToNot(BeNil()) listResourceBindingsOptionsModel := &resourcecontrollerv2.ListResourceBindingsOptions{ - GUID: core.StringPtr("testString"), - Name: core.StringPtr("testString"), + GUID: core.StringPtr("testString"), + Name: core.StringPtr("testString"), ResourceGroupID: core.StringPtr("testString"), - ResourceID: core.StringPtr("testString"), + ResourceID: core.StringPtr("testString"), RegionBindingID: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(10)), - UpdatedFrom: core.StringPtr("2021-01-01"), - UpdatedTo: core.StringPtr("2021-01-01"), + Limit: core.Int64Ptr(int64(10)), + UpdatedFrom: core.StringPtr("2021-01-01"), + UpdatedTo: core.StringPtr("2021-01-01"), } pager, err := resourceControllerService.NewResourceBindingsPager(listResourceBindingsOptionsModel) @@ -4236,14 +4233,14 @@ var _ = Describe(`ResourceControllerV2`, func() { Expect(resourceControllerService).ToNot(BeNil()) listResourceBindingsOptionsModel := &resourcecontrollerv2.ListResourceBindingsOptions{ - GUID: core.StringPtr("testString"), - Name: core.StringPtr("testString"), + GUID: core.StringPtr("testString"), + Name: core.StringPtr("testString"), ResourceGroupID: core.StringPtr("testString"), - ResourceID: core.StringPtr("testString"), + ResourceID: core.StringPtr("testString"), RegionBindingID: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(10)), - UpdatedFrom: core.StringPtr("2021-01-01"), - UpdatedTo: core.StringPtr("2021-01-01"), + Limit: core.Int64Ptr(int64(10)), + UpdatedFrom: core.StringPtr("2021-01-01"), + UpdatedTo: core.StringPtr("2021-01-01"), } pager, err := resourceControllerService.NewResourceBindingsPager(listResourceBindingsOptionsModel) @@ -5358,14 +5355,14 @@ var _ = Describe(`ResourceControllerV2`, func() { It(`Invoke GetNextStart successfully`, func() { responseObject := new(resourcecontrollerv2.ResourceAliasesList) responseObject.NextURL = core.StringPtr("ibm.com?start=abc-123") - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(Equal(core.StringPtr("abc-123"))) }) It(`Invoke GetNextStart without a "NextURL" property in the response`, func() { responseObject := new(resourcecontrollerv2.ResourceAliasesList) - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -5373,7 +5370,7 @@ var _ = Describe(`ResourceControllerV2`, func() { It(`Invoke GetNextStart without any query params in the "NextURL" URL`, func() { responseObject := new(resourcecontrollerv2.ResourceAliasesList) responseObject.NextURL = core.StringPtr("ibm.com") - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -5411,15 +5408,15 @@ var _ = Describe(`ResourceControllerV2`, func() { Expect(resourceControllerService).ToNot(BeNil()) listResourceAliasesOptionsModel := &resourcecontrollerv2.ListResourceAliasesOptions{ - GUID: core.StringPtr("testString"), - Name: core.StringPtr("testString"), + GUID: core.StringPtr("testString"), + Name: core.StringPtr("testString"), ResourceInstanceID: core.StringPtr("testString"), - RegionInstanceID: core.StringPtr("testString"), - ResourceID: core.StringPtr("testString"), - ResourceGroupID: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(10)), - UpdatedFrom: core.StringPtr("2021-01-01"), - UpdatedTo: core.StringPtr("2021-01-01"), + RegionInstanceID: core.StringPtr("testString"), + ResourceID: core.StringPtr("testString"), + ResourceGroupID: core.StringPtr("testString"), + Limit: core.Int64Ptr(int64(10)), + UpdatedFrom: core.StringPtr("2021-01-01"), + UpdatedTo: core.StringPtr("2021-01-01"), } pager, err := resourceControllerService.NewResourceAliasesPager(listResourceAliasesOptionsModel) @@ -5444,15 +5441,15 @@ var _ = Describe(`ResourceControllerV2`, func() { Expect(resourceControllerService).ToNot(BeNil()) listResourceAliasesOptionsModel := &resourcecontrollerv2.ListResourceAliasesOptions{ - GUID: core.StringPtr("testString"), - Name: core.StringPtr("testString"), + GUID: core.StringPtr("testString"), + Name: core.StringPtr("testString"), ResourceInstanceID: core.StringPtr("testString"), - RegionInstanceID: core.StringPtr("testString"), - ResourceID: core.StringPtr("testString"), - ResourceGroupID: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(10)), - UpdatedFrom: core.StringPtr("2021-01-01"), - UpdatedTo: core.StringPtr("2021-01-01"), + RegionInstanceID: core.StringPtr("testString"), + ResourceID: core.StringPtr("testString"), + ResourceGroupID: core.StringPtr("testString"), + Limit: core.Int64Ptr(int64(10)), + UpdatedFrom: core.StringPtr("2021-01-01"), + UpdatedTo: core.StringPtr("2021-01-01"), } pager, err := resourceControllerService.NewResourceAliasesPager(listResourceAliasesOptionsModel) @@ -6483,14 +6480,14 @@ var _ = Describe(`ResourceControllerV2`, func() { It(`Invoke GetNextStart successfully`, func() { responseObject := new(resourcecontrollerv2.ResourceBindingsList) responseObject.NextURL = core.StringPtr("ibm.com?start=abc-123") - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(Equal(core.StringPtr("abc-123"))) }) It(`Invoke GetNextStart without a "NextURL" property in the response`, func() { responseObject := new(resourcecontrollerv2.ResourceBindingsList) - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -6498,7 +6495,7 @@ var _ = Describe(`ResourceControllerV2`, func() { It(`Invoke GetNextStart without any query params in the "NextURL" URL`, func() { responseObject := new(resourcecontrollerv2.ResourceBindingsList) responseObject.NextURL = core.StringPtr("ibm.com") - + value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -6536,7 +6533,7 @@ var _ = Describe(`ResourceControllerV2`, func() { Expect(resourceControllerService).ToNot(BeNil()) listResourceBindingsForAliasOptionsModel := &resourcecontrollerv2.ListResourceBindingsForAliasOptions{ - ID: core.StringPtr("testString"), + ID: core.StringPtr("testString"), Limit: core.Int64Ptr(int64(10)), } @@ -6562,7 +6559,7 @@ var _ = Describe(`ResourceControllerV2`, func() { Expect(resourceControllerService).ToNot(BeNil()) listResourceBindingsForAliasOptionsModel := &resourcecontrollerv2.ListResourceBindingsForAliasOptions{ - ID: core.StringPtr("testString"), + ID: core.StringPtr("testString"), Limit: core.Int64Ptr(int64(10)), } @@ -6589,6 +6586,7 @@ var _ = Describe(`ResourceControllerV2`, func() { Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["account_id"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["resource_instance_id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["resource_group_id"]).To(Equal([]string{"testString"})) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) @@ -6606,6 +6604,7 @@ var _ = Describe(`ResourceControllerV2`, func() { listReclamationsOptionsModel := new(resourcecontrollerv2.ListReclamationsOptions) listReclamationsOptionsModel.AccountID = core.StringPtr("testString") listReclamationsOptionsModel.ResourceInstanceID = core.StringPtr("testString") + listReclamationsOptionsModel.ResourceGroupID = core.StringPtr("testString") listReclamationsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response result, response, operationErr := resourceControllerService.ListReclamations(listReclamationsOptionsModel) @@ -6638,6 +6637,7 @@ var _ = Describe(`ResourceControllerV2`, func() { Expect(req.URL.Query()["account_id"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["resource_instance_id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["resource_group_id"]).To(Equal([]string{"testString"})) // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) @@ -6660,6 +6660,7 @@ var _ = Describe(`ResourceControllerV2`, func() { listReclamationsOptionsModel := new(resourcecontrollerv2.ListReclamationsOptions) listReclamationsOptionsModel.AccountID = core.StringPtr("testString") listReclamationsOptionsModel.ResourceInstanceID = core.StringPtr("testString") + listReclamationsOptionsModel.ResourceGroupID = core.StringPtr("testString") listReclamationsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error @@ -6698,6 +6699,7 @@ var _ = Describe(`ResourceControllerV2`, func() { Expect(req.URL.Query()["account_id"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["resource_instance_id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["resource_group_id"]).To(Equal([]string{"testString"})) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) @@ -6722,6 +6724,7 @@ var _ = Describe(`ResourceControllerV2`, func() { listReclamationsOptionsModel := new(resourcecontrollerv2.ListReclamationsOptions) listReclamationsOptionsModel.AccountID = core.StringPtr("testString") listReclamationsOptionsModel.ResourceInstanceID = core.StringPtr("testString") + listReclamationsOptionsModel.ResourceGroupID = core.StringPtr("testString") listReclamationsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -6743,6 +6746,7 @@ var _ = Describe(`ResourceControllerV2`, func() { listReclamationsOptionsModel := new(resourcecontrollerv2.ListReclamationsOptions) listReclamationsOptionsModel.AccountID = core.StringPtr("testString") listReclamationsOptionsModel.ResourceInstanceID = core.StringPtr("testString") + listReclamationsOptionsModel.ResourceGroupID = core.StringPtr("testString") listReclamationsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := resourceControllerService.SetServiceURL("") @@ -6778,6 +6782,7 @@ var _ = Describe(`ResourceControllerV2`, func() { listReclamationsOptionsModel := new(resourcecontrollerv2.ListReclamationsOptions) listReclamationsOptionsModel.AccountID = core.StringPtr("testString") listReclamationsOptionsModel.ResourceInstanceID = core.StringPtr("testString") + listReclamationsOptionsModel.ResourceGroupID = core.StringPtr("testString") listReclamationsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation @@ -7272,10 +7277,12 @@ var _ = Describe(`ResourceControllerV2`, func() { listReclamationsOptionsModel := resourceControllerService.NewListReclamationsOptions() listReclamationsOptionsModel.SetAccountID("testString") listReclamationsOptionsModel.SetResourceInstanceID("testString") + listReclamationsOptionsModel.SetResourceGroupID("testString") listReclamationsOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(listReclamationsOptionsModel).ToNot(BeNil()) Expect(listReclamationsOptionsModel.AccountID).To(Equal(core.StringPtr("testString"))) Expect(listReclamationsOptionsModel.ResourceInstanceID).To(Equal(core.StringPtr("testString"))) + Expect(listReclamationsOptionsModel.ResourceGroupID).To(Equal(core.StringPtr("testString"))) Expect(listReclamationsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewListResourceAliasesForInstanceOptions successfully`, func() { From 39240c45c068025a64464b5668bc203cc7685671 Mon Sep 17 00:00:00 2001 From: "manu.k.m" Date: Mon, 4 Sep 2023 14:22:40 +0530 Subject: [PATCH 14/27] Temperory Change Signed-off-by: manu.k.m --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 0646fd7a..e8dc6cc3 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/IBM/platform-services-go-sdk +module github.com/manukm-ibm/platform-services-go-sdk go 1.19 From 48fc2620e6489ec88c8d255272f6942340f9e8f1 Mon Sep 17 00:00:00 2001 From: "manu.k.m" Date: Mon, 4 Sep 2023 14:23:58 +0530 Subject: [PATCH 15/27] feat(Usage Reports): Revert Temperory Change Signed-off-by: manu.k.m --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index e8dc6cc3..0646fd7a 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/manukm-ibm/platform-services-go-sdk +module github.com/IBM/platform-services-go-sdk go 1.19 From 578c8b8adffc9fc4c66df288c7a8ee098e1cc139 Mon Sep 17 00:00:00 2001 From: "manu.k.m" Date: Wed, 13 Sep 2023 21:10:48 +0530 Subject: [PATCH 16/27] feat(Usage Reports): add integration tests and examples for billing snapshot config service Signed-off-by: manu.k.m --- .../usage_reports_v4_examples_test.go | 137 +++++++++++++++++- .../usage_reports_v4_integration_test.go | 124 +++++++++++++++- 2 files changed, 259 insertions(+), 2 deletions(-) diff --git a/usagereportsv4/usage_reports_v4_examples_test.go b/usagereportsv4/usage_reports_v4_examples_test.go index ac42c504..b48a757a 100644 --- a/usagereportsv4/usage_reports_v4_examples_test.go +++ b/usagereportsv4/usage_reports_v4_examples_test.go @@ -2,7 +2,7 @@ // +build examples /** - * (C) Copyright IBM Corp. 2020. + * (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. @@ -23,6 +23,7 @@ import ( "encoding/json" "fmt" "os" + "strconv" "github.com/IBM/go-sdk-core/v5/core" "github.com/IBM/platform-services-go-sdk/usagereportsv4" @@ -60,6 +61,10 @@ var _ = Describe(`UsageReportsV4 Examples Tests`, func() { resourceGroupID string orgID string billingMonth string + cosBucket string + cosLocation string + dateFrom string + dateTo string ) var shouldSkipTest = func() { @@ -94,6 +99,18 @@ var _ = Describe(`UsageReportsV4 Examples Tests`, func() { billingMonth = config["BILLING_MONTH"] Expect(billingMonth).ToNot(BeEmpty()) + cosBucket = config["COS_BUCKET"] + Expect(cosBucket).ToNot(BeEmpty()) + + cosLocation = config["COS_LOCATION"] + Expect(cosLocation).ToNot(BeEmpty()) + + dateFrom = config["DATE_FROM"] + Expect(dateFrom).ToNot(BeEmpty()) + + dateTo = config["DATE_TO"] + Expect(dateTo).ToNot(BeEmpty()) + configLoaded = len(config) > 0 }) }) @@ -283,5 +300,123 @@ var _ = Describe(`UsageReportsV4 Examples Tests`, func() { Expect(response.StatusCode).To(Equal(200)) Expect(instancesUsage).ToNot(BeNil()) }) + It(`CreateReportsSnapshotConfig request example`, func() { + fmt.Println("\nCreateReportsSnapshotConfig() result:") + // begin-create_reports_snapshot_config + + createReportsSnapshotConfigOptions := usageReportsService.NewCreateReportsSnapshotConfigOptions( + accountID, + "daily", + cosBucket, + cosLocation, + ) + + snapshotConfig, response, err := usageReportsService.CreateReportsSnapshotConfig(createReportsSnapshotConfigOptions) + if err != nil { + panic(err) + } + b, _ := json.MarshalIndent(snapshotConfig, "", " ") + fmt.Println(string(b)) + + // end-create_reports_snapshot_config + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(201)) + Expect(snapshotConfig).ToNot(BeNil()) + }) + It(`GetReportsSnapshotConfig request example`, func() { + fmt.Println("\nGetReportsSnapshotConfig() result:") + // begin-get_reports_snapshot_config + + getReportsSnapshotConfigOptions := usageReportsService.NewGetReportsSnapshotConfigOptions( + accountID, + ) + + snapshotConfig, response, err := usageReportsService.GetReportsSnapshotConfig(getReportsSnapshotConfigOptions) + if err != nil { + panic(err) + } + b, _ := json.MarshalIndent(snapshotConfig, "", " ") + fmt.Println(string(b)) + + // end-get_reports_snapshot_config + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(snapshotConfig).ToNot(BeNil()) + }) + It(`UpdateReportsSnapshotConfig request example`, func() { + fmt.Println("\nUpdateReportsSnapshotConfig() result:") + // begin-update_reports_snapshot_config + + updateReportsSnapshotConfigOptions := usageReportsService.NewUpdateReportsSnapshotConfigOptions( + accountID, + ) + + snapshotConfig, response, err := usageReportsService.UpdateReportsSnapshotConfig(updateReportsSnapshotConfigOptions) + if err != nil { + panic(err) + } + b, _ := json.MarshalIndent(snapshotConfig, "", " ") + fmt.Println(string(b)) + + // end-update_reports_snapshot_config + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(snapshotConfig).ToNot(BeNil()) + }) + It(`GetReportsSnapshot request example`, func() { + fmt.Println("\nGetReportsSnapshot() result:") + // begin-get_reports_snapshot + + getReportsSnapshotOptions := usageReportsService.NewGetReportsSnapshotOptions( + accountID, + billingMonth, + ) + from, err := strconv.ParseInt(dateFrom, 10, 64) + if err != nil { + panic(err) + } + to, err := strconv.ParseInt(dateTo, 10, 64) + if err != nil { + panic(err) + } + getReportsSnapshotOptions.SetDateFrom(from) + getReportsSnapshotOptions.SetDateTo(to) + + snapshotList, response, err := usageReportsService.GetReportsSnapshot(getReportsSnapshotOptions) + if err != nil { + panic(err) + } + b, _ := json.MarshalIndent(snapshotList, "", " ") + fmt.Println(string(b)) + + // end-get_reports_snapshot + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(snapshotList).ToNot(BeNil()) + }) + It(`DeleteReportsSnapshotConfig request example`, func() { + // begin-delete_reports_snapshot_config + + deleteReportsSnapshotConfigOptions := usageReportsService.NewDeleteReportsSnapshotConfigOptions( + accountID, + ) + + response, err := usageReportsService.DeleteReportsSnapshotConfig(deleteReportsSnapshotConfigOptions) + if err != nil { + panic(err) + } + if response.StatusCode != 204 { + fmt.Printf("\nUnexpected response status code received from DeleteReportsSnapshotConfig(): %d\n", response.StatusCode) + } + + // end-delete_reports_snapshot_config + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(204)) + }) }) }) diff --git a/usagereportsv4/usage_reports_v4_integration_test.go b/usagereportsv4/usage_reports_v4_integration_test.go index 2f4eecdd..5f017d73 100644 --- a/usagereportsv4/usage_reports_v4_integration_test.go +++ b/usagereportsv4/usage_reports_v4_integration_test.go @@ -1,7 +1,8 @@ +//go:build integration // +build integration /** - * (C) Copyright IBM Corp. 2020. + * (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. @@ -22,6 +23,7 @@ import ( "fmt" "log" "os" + "strconv" "time" "github.com/IBM/go-sdk-core/v5/core" @@ -53,6 +55,10 @@ var _ = Describe(`UsageReportsV4 Integration Tests`, func() { resourceGroupID string orgID string billingMonth string + cosBucket string + cosLocation string + dateFrom string + dateTo string ) var shouldSkipTest = func() { @@ -90,6 +96,18 @@ var _ = Describe(`UsageReportsV4 Integration Tests`, func() { billingMonth = config["BILLING_MONTH"] Expect(billingMonth).ToNot(BeEmpty()) + cosBucket = config["COS_BUCKET"] + Expect(cosBucket).ToNot(BeEmpty()) + + cosLocation = config["COS_LOCATION"] + Expect(cosLocation).ToNot(BeEmpty()) + + dateFrom = config["DATE_FROM"] + Expect(dateFrom).ToNot(BeEmpty()) + + dateTo = config["DATE_TO"] + Expect(dateTo).ToNot(BeEmpty()) + shouldSkipTest = func() {} }) }) @@ -355,4 +373,108 @@ var _ = Describe(`UsageReportsV4 Integration Tests`, func() { Expect(results).ToNot(BeEmpty()) }) }) + + Describe(`CreateReportsSnapshotConfig - Setup the snapshot configuration`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`CreateReportsSnapshotConfig(createReportsSnapshotConfigOptions *CreateReportsSnapshotConfigOptions)`, func() { + fmt.Printf("TEST VALUES: %s", cosBucket) + fmt.Printf("TEST VALUES:%s", cosLocation) + createReportsSnapshotConfigOptions := &usagereportsv4.CreateReportsSnapshotConfigOptions{ + AccountID: &accountID, + Interval: core.StringPtr("daily"), + CosBucket: &cosBucket, + CosLocation: &cosLocation, + CosReportsFolder: core.StringPtr("IBMCloud-Billing-Reports"), + ReportTypes: []string{"account_summary", "enterprise_summary", "account_resource_instance_usage"}, + Versioning: core.StringPtr("new"), + } + + snapshotConfig, response, err := usageReportsService.CreateReportsSnapshotConfig(createReportsSnapshotConfigOptions) + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(201)) + Expect(snapshotConfig).ToNot(BeNil()) + }) + }) + + Describe(`GetReportsSnapshotConfig - Fetch the snapshot configuration`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`GetReportsSnapshotConfig(getReportsSnapshotConfigOptions *GetReportsSnapshotConfigOptions)`, func() { + getReportsSnapshotConfigOptions := &usagereportsv4.GetReportsSnapshotConfigOptions{ + AccountID: &accountID, + } + + snapshotConfig, response, err := usageReportsService.GetReportsSnapshotConfig(getReportsSnapshotConfigOptions) + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(snapshotConfig).ToNot(BeNil()) + }) + }) + + Describe(`UpdateReportsSnapshotConfig - Update the snapshot configuration`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`UpdateReportsSnapshotConfig(updateReportsSnapshotConfigOptions *UpdateReportsSnapshotConfigOptions)`, func() { + updateReportsSnapshotConfigOptions := &usagereportsv4.UpdateReportsSnapshotConfigOptions{ + AccountID: &accountID, + Interval: core.StringPtr("daily"), + CosBucket: &cosBucket, + CosLocation: &cosLocation, + CosReportsFolder: core.StringPtr("IBMCloud-Billing-Reports"), + ReportTypes: []string{"account_summary"}, + Versioning: core.StringPtr("new"), + } + + snapshotConfig, response, err := usageReportsService.UpdateReportsSnapshotConfig(updateReportsSnapshotConfigOptions) + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(snapshotConfig).ToNot(BeNil()) + }) + }) + + Describe(`GetReportsSnapshot - Fetch the current or past snapshots`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`GetReportsSnapshot(getReportsSnapshotOptions *GetReportsSnapshotOptions)`, func() { + getReportsSnapshotOptions := &usagereportsv4.GetReportsSnapshotOptions{ + AccountID: &accountID, + Month: &billingMonth, + } + from, err := strconv.ParseInt(dateFrom, 10, 64) + if err != nil { + panic(err) + } + to, err := strconv.ParseInt(dateTo, 10, 64) + if err != nil { + panic(err) + } + getReportsSnapshotOptions.SetDateFrom(from) + getReportsSnapshotOptions.SetDateTo(to) + + snapshotList, response, err := usageReportsService.GetReportsSnapshot(getReportsSnapshotOptions) + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(snapshotList).ToNot(BeNil()) + }) + }) + + Describe(`DeleteReportsSnapshotConfig - Delete the snapshot configuration`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`DeleteReportsSnapshotConfig(deleteReportsSnapshotConfigOptions *DeleteReportsSnapshotConfigOptions)`, func() { + deleteReportsSnapshotConfigOptions := &usagereportsv4.DeleteReportsSnapshotConfigOptions{ + AccountID: &accountID, + } + + response, err := usageReportsService.DeleteReportsSnapshotConfig(deleteReportsSnapshotConfigOptions) + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(204)) + }) + }) }) From dc5ac524502e36ba689ba80b40bd1427573599d1 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 1 Sep 2023 13:57:49 +0000 Subject: [PATCH 17/27] Update version 0.47.1 -> 0.48.0 [skip ci] Signed-off-by: manu.k.m --- .bumpversion.cfg | 2 +- README.md | 4 ++-- common/version.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 554cba83..eb2f244d 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.47.1 +current_version = 0.48.0 commit = True message = Update version {current_version} -> {new_version} [skip ci] diff --git a/README.md b/README.md index 64ffffa8..2201d7bb 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![CLA assistant](https://cla-assistant.io/readme/badge/IBM/platform-services-go-sdk)](https://cla-assistant.io/IBM/platform-services-go-sdk) -# IBM Cloud Platform Services Go SDK Version 0.47.1 +# IBM Cloud Platform Services Go SDK Version 0.48.0 Go client library to interact with various [IBM Cloud Platform Service APIs](https://cloud.ibm.com/docs?tab=api-docs&category=platform_services). @@ -86,7 +86,7 @@ Service Name | Package name * Go version 1.19 or above. ## Installation -The current version of this SDK: 0.47.1 +The current version of this SDK: 0.48.0 ### Go modules If your application uses Go modules for dependency management (recommended), just add an import for each service diff --git a/common/version.go b/common/version.go index 16bffd71..42fddced 100644 --- a/common/version.go +++ b/common/version.go @@ -17,4 +17,4 @@ package common // Version of the SDK -const Version = "0.47.1" +const Version = "0.48.0" From d1b6c613561ebdf869a7f3eb43786238943acb2a Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 1 Sep 2023 13:57:49 +0000 Subject: [PATCH 18/27] chore(release): 0.48.0 release notes [skip ci] # [0.48.0](https://github.com/IBM/platform-services-go-sdk/compare/v0.47.1...v0.48.0) (2023-09-01) ### Features * **Resource Controller:** support resource group filter for list reclamations ([#264](https://github.com/IBM/platform-services-go-sdk/issues/264)) ([6985653](https://github.com/IBM/platform-services-go-sdk/commit/6985653a853b73e06189b40547f38afffa6513c0)) Signed-off-by: manu.k.m --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04e9dddb..82588d05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [0.48.0](https://github.com/IBM/platform-services-go-sdk/compare/v0.47.1...v0.48.0) (2023-09-01) + + +### Features + +* **Resource Controller:** support resource group filter for list reclamations ([#264](https://github.com/IBM/platform-services-go-sdk/issues/264)) ([6985653](https://github.com/IBM/platform-services-go-sdk/commit/6985653a853b73e06189b40547f38afffa6513c0)) + ## [0.47.1](https://github.com/IBM/platform-services-go-sdk/compare/v0.47.0...v0.47.1) (2023-08-31) From bb000ff716338b4adc737b1710ce9c97ec369b95 Mon Sep 17 00:00:00 2001 From: hariarla <68221277+hariarla@users.noreply.github.com> Date: Tue, 5 Sep 2023 21:31:00 +0530 Subject: [PATCH 19/27] fix(IAM Access Groups): rRemove update action control from assertions (#276) Signed-off-by: HARI K ARLA Signed-off-by: manu.k.m --- iamaccessgroupsv2/iam_access_groups_v2.go | 163 +++++++------- .../iam_access_groups_v2_examples_test.go | 3 - .../iam_access_groups_v2_integration_test.go | 6 - .../iam_access_groups_v2_test.go | 211 +++++++----------- 4 files changed, 172 insertions(+), 211 deletions(-) diff --git a/iamaccessgroupsv2/iam_access_groups_v2.go b/iamaccessgroupsv2/iam_access_groups_v2.go index a33becb6..80265f53 100644 --- a/iamaccessgroupsv2/iam_access_groups_v2.go +++ b/iamaccessgroupsv2/iam_access_groups_v2.go @@ -15,7 +15,7 @@ */ /* - * IBM OpenAPI SDK Code Generator Version: 3.74.0-89f1dbab-20230630-160213 + * IBM OpenAPI SDK Code Generator Version: 3.78.0-67aec9b7-20230818-174940 */ // Package iamaccessgroupsv2 : Operations and models for the IamAccessGroupsV2 service @@ -554,7 +554,7 @@ func (iamAccessGroups *IamAccessGroupsV2) IsMemberOfAccessGroupWithContext(ctx c pathParamsMap := map[string]string{ "access_group_id": *isMemberOfAccessGroupOptions.AccessGroupID, - "iam_id": *isMemberOfAccessGroupOptions.IamID, + "iam_id": *isMemberOfAccessGroupOptions.IamID, } builder := core.NewRequestBuilder(core.HEAD) @@ -770,7 +770,7 @@ func (iamAccessGroups *IamAccessGroupsV2) RemoveMemberFromAccessGroupWithContext pathParamsMap := map[string]string{ "access_group_id": *removeMemberFromAccessGroupOptions.AccessGroupID, - "iam_id": *removeMemberFromAccessGroupOptions.IamID, + "iam_id": *removeMemberFromAccessGroupOptions.IamID, } builder := core.NewRequestBuilder(core.DELETE) @@ -1195,7 +1195,7 @@ func (iamAccessGroups *IamAccessGroupsV2) GetAccessGroupRuleWithContext(ctx cont pathParamsMap := map[string]string{ "access_group_id": *getAccessGroupRuleOptions.AccessGroupID, - "rule_id": *getAccessGroupRuleOptions.RuleID, + "rule_id": *getAccessGroupRuleOptions.RuleID, } builder := core.NewRequestBuilder(core.GET) @@ -1260,7 +1260,7 @@ func (iamAccessGroups *IamAccessGroupsV2) ReplaceAccessGroupRuleWithContext(ctx pathParamsMap := map[string]string{ "access_group_id": *replaceAccessGroupRuleOptions.AccessGroupID, - "rule_id": *replaceAccessGroupRuleOptions.RuleID, + "rule_id": *replaceAccessGroupRuleOptions.RuleID, } builder := core.NewRequestBuilder(core.PUT) @@ -1347,7 +1347,7 @@ func (iamAccessGroups *IamAccessGroupsV2) RemoveAccessGroupRuleWithContext(ctx c pathParamsMap := map[string]string{ "access_group_id": *removeAccessGroupRuleOptions.AccessGroupID, - "rule_id": *removeAccessGroupRuleOptions.RuleID, + "rule_id": *removeAccessGroupRuleOptions.RuleID, } builder := core.NewRequestBuilder(core.DELETE) @@ -2551,7 +2551,11 @@ func (iamAccessGroups *IamAccessGroupsV2) DeleteAssignmentWithContext(ctx contex // enterprise-managed access group in their account. type AccessActionControls struct { // Action control for adding access policies to an enterprise-managed access group in a child account. If an access - // group administrator in a child account adds a policy, they can always update or remove it. + // group administrator in a child account adds a policy, they can always update or remove it. Note that if conflicts + // arise between an update to this control in a new version and polices added to the access group by an administrator + // in a child account, you must resolve those conflicts in the child account. This prevents breaking access in the + // child account. For more information, see [Working with + // versions](https://test.cloud.ibm.com/docs/secure-enterprise?topic=secure-enterprise-working-with-versions#new-version-scenarios). Add *bool `json:"add,omitempty"` } @@ -2739,9 +2743,9 @@ type AddAccessGroupRuleOptions struct { func (*IamAccessGroupsV2) NewAddAccessGroupRuleOptions(accessGroupID string, expiration int64, realmName string, conditions []RuleConditions) *AddAccessGroupRuleOptions { return &AddAccessGroupRuleOptions{ AccessGroupID: core.StringPtr(accessGroupID), - Expiration: core.Int64Ptr(expiration), - RealmName: core.StringPtr(realmName), - Conditions: conditions, + Expiration: core.Int64Ptr(expiration), + RealmName: core.StringPtr(realmName), + Conditions: conditions, } } @@ -2800,7 +2804,7 @@ type AddGroupMembersRequestMembersItem struct { func (*IamAccessGroupsV2) NewAddGroupMembersRequestMembersItem(iamID string, typeVar string) (_model *AddGroupMembersRequestMembersItem, err error) { _model = &AddGroupMembersRequestMembersItem{ IamID: core.StringPtr(iamID), - Type: core.StringPtr(typeVar), + Type: core.StringPtr(typeVar), } err = core.ValidateStruct(_model, "required parameters") return @@ -2926,7 +2930,7 @@ type AddMemberToMultipleAccessGroupsOptions struct { func (*IamAccessGroupsV2) NewAddMemberToMultipleAccessGroupsOptions(accountID string, iamID string) *AddMemberToMultipleAccessGroupsOptions { return &AddMemberToMultipleAccessGroupsOptions{ AccountID: core.StringPtr(accountID), - IamID: core.StringPtr(iamID), + IamID: core.StringPtr(iamID), } } @@ -3107,14 +3111,16 @@ func UnmarshalAssertions(m map[string]json.RawMessage, result interface{}) (err // `update` action controls. type AssertionsActionControls struct { // Action control for adding dynamic rules to an enterprise-managed access group. If an access group administrator in a - // child account adds a dynamic rule, they can always update or remove it. + // child account adds a dynamic rule, they can always update or remove it. Note that if conflicts arise between an + // update to this control and rules added or updated by an administrator in the child account, you must resolve those + // conflicts in the child account. This prevents breaking access that the rules might grant in the child account. For + // more information, see [Working with versions]. Add *bool `json:"add,omitempty"` - // Action control for removing enterprise-managed dynamic rules in an enterprise-managed access group. + // Action control for removing enterprise-managed dynamic rules in an enterprise-managed access group. Note that if a + // rule is removed from an enterprise-managed access group by an administrator in a child account and and you reassign + // the template, the rule is reinstated. Remove *bool `json:"remove,omitempty"` - - // Action control for updating enterprise-managed dynamic rules in an enterprise-managed access group. - Update *bool `json:"update,omitempty"` } // UnmarshalAssertionsActionControls unmarshals an instance of AssertionsActionControls from the specified map of raw messages. @@ -3128,10 +3134,6 @@ func UnmarshalAssertionsActionControls(m map[string]json.RawMessage, result inte if err != nil { return } - err = core.UnmarshalPrimitive(m, "update", &obj.Update) - if err != nil { - return - } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) return } @@ -3296,7 +3298,7 @@ func (*IamAccessGroupsV2) NewCommitTemplateOptions(templateID string, versionNum return &CommitTemplateOptions{ TemplateID: core.StringPtr(templateID), VersionNum: core.StringPtr(versionNum), - IfMatch: core.StringPtr(ifMatch), + IfMatch: core.StringPtr(ifMatch), } } @@ -3388,7 +3390,7 @@ type CreateAccessGroupOptions struct { func (*IamAccessGroupsV2) NewCreateAccessGroupOptions(accountID string, name string) *CreateAccessGroupOptions { return &CreateAccessGroupOptions{ AccountID: core.StringPtr(accountID), - Name: core.StringPtr(name), + Name: core.StringPtr(name), } } @@ -3446,17 +3448,17 @@ type CreateAssignmentOptions struct { // Constants associated with the CreateAssignmentOptions.TargetType property. // The type of the entity to which the template should be assigned, e.g. 'Account', 'AccountGroup', etc. const ( - CreateAssignmentOptionsTargetTypeAccountConst = "Account" + CreateAssignmentOptionsTargetTypeAccountConst = "Account" CreateAssignmentOptionsTargetTypeAccountgroupConst = "AccountGroup" ) // NewCreateAssignmentOptions : Instantiate CreateAssignmentOptions func (*IamAccessGroupsV2) NewCreateAssignmentOptions(templateID string, templateVersion string, targetType string, target string) *CreateAssignmentOptions { return &CreateAssignmentOptions{ - TemplateID: core.StringPtr(templateID), + TemplateID: core.StringPtr(templateID), TemplateVersion: core.StringPtr(templateVersion), - TargetType: core.StringPtr(targetType), - Target: core.StringPtr(target), + TargetType: core.StringPtr(targetType), + Target: core.StringPtr(target), } } @@ -3524,7 +3526,7 @@ type CreateTemplateOptions struct { // NewCreateTemplateOptions : Instantiate CreateTemplateOptions func (*IamAccessGroupsV2) NewCreateTemplateOptions(name string, accountID string) *CreateTemplateOptions { return &CreateTemplateOptions{ - Name: core.StringPtr(name), + Name: core.StringPtr(name), AccountID: core.StringPtr(accountID), } } @@ -4034,7 +4036,7 @@ type GetAccessGroupRuleOptions struct { func (*IamAccessGroupsV2) NewGetAccessGroupRuleOptions(accessGroupID string, ruleID string) *GetAccessGroupRuleOptions { return &GetAccessGroupRuleOptions{ AccessGroupID: core.StringPtr(accessGroupID), - RuleID: core.StringPtr(ruleID), + RuleID: core.StringPtr(ruleID), } } @@ -4650,7 +4652,7 @@ type IsMemberOfAccessGroupOptions struct { func (*IamAccessGroupsV2) NewIsMemberOfAccessGroupOptions(accessGroupID string, iamID string) *IsMemberOfAccessGroupOptions { return &IsMemberOfAccessGroupOptions{ AccessGroupID: core.StringPtr(accessGroupID), - IamID: core.StringPtr(iamID), + IamID: core.StringPtr(iamID), } } @@ -4965,10 +4967,10 @@ type ListAssignmentsOptions struct { // Constants associated with the ListAssignmentsOptions.Status property. // Filter results by the assignment status. const ( - ListAssignmentsOptionsStatusAcceptedConst = "accepted" - ListAssignmentsOptionsStatusFailedConst = "failed" + ListAssignmentsOptionsStatusAcceptedConst = "accepted" + ListAssignmentsOptionsStatusFailedConst = "failed" ListAssignmentsOptionsStatusInProgressConst = "in_progress" - ListAssignmentsOptionsStatusSucceededConst = "succeeded" + ListAssignmentsOptionsStatusSucceededConst = "succeeded" ) // NewListAssignmentsOptions : Instantiate ListAssignmentsOptions @@ -5566,10 +5568,16 @@ func UnmarshalMembers(m map[string]json.RawMessage, result interface{}) (err err // enterprise-managed access group in their account. type MembersActionControls struct { // Action control for adding child account members to an enterprise-managed access group. If an access group - // administrator in a child account adds a member, they can always remove them. + // administrator in a child account adds a member, they can always remove them. Note that if conflicts arise between an + // update to this control in a new version and members added by an administrator in the child account, you must resolve + // those conflicts in the child account. This prevents breaking access in the child account. For more information, see + // [Working with versions] + // (https://test.cloud.ibm.com/docs/secure-enterprise?topic=secure-enterprise-working-with-versions#new-version-scenarios). Add *bool `json:"add,omitempty"` - // Action control for removing enterprise-managed members from an enterprise-managed access group. + // Action control for removing enterprise-managed members from an enterprise-managed access group. Note that if an + // enterprise member is removed from an enterprise-managed access group in a child account and you reassign the + // template, the membership is reinstated. Remove *bool `json:"remove,omitempty"` } @@ -5633,7 +5641,7 @@ type RemoveAccessGroupRuleOptions struct { func (*IamAccessGroupsV2) NewRemoveAccessGroupRuleOptions(accessGroupID string, ruleID string) *RemoveAccessGroupRuleOptions { return &RemoveAccessGroupRuleOptions{ AccessGroupID: core.StringPtr(accessGroupID), - RuleID: core.StringPtr(ruleID), + RuleID: core.StringPtr(ruleID), } } @@ -5682,7 +5690,7 @@ type RemoveMemberFromAccessGroupOptions struct { func (*IamAccessGroupsV2) NewRemoveMemberFromAccessGroupOptions(accessGroupID string, iamID string) *RemoveMemberFromAccessGroupOptions { return &RemoveMemberFromAccessGroupOptions{ AccessGroupID: core.StringPtr(accessGroupID), - IamID: core.StringPtr(iamID), + IamID: core.StringPtr(iamID), } } @@ -5733,7 +5741,7 @@ type RemoveMemberFromAllAccessGroupsOptions struct { func (*IamAccessGroupsV2) NewRemoveMemberFromAllAccessGroupsOptions(accountID string, iamID string) *RemoveMemberFromAllAccessGroupsOptions { return &RemoveMemberFromAllAccessGroupsOptions{ AccountID: core.StringPtr(accountID), - IamID: core.StringPtr(iamID), + IamID: core.StringPtr(iamID), } } @@ -5846,11 +5854,11 @@ type ReplaceAccessGroupRuleOptions struct { func (*IamAccessGroupsV2) NewReplaceAccessGroupRuleOptions(accessGroupID string, ruleID string, ifMatch string, expiration int64, realmName string, conditions []RuleConditions) *ReplaceAccessGroupRuleOptions { return &ReplaceAccessGroupRuleOptions{ AccessGroupID: core.StringPtr(accessGroupID), - RuleID: core.StringPtr(ruleID), - IfMatch: core.StringPtr(ifMatch), - Expiration: core.Int64Ptr(expiration), - RealmName: core.StringPtr(realmName), - Conditions: conditions, + RuleID: core.StringPtr(ruleID), + IfMatch: core.StringPtr(ifMatch), + Expiration: core.Int64Ptr(expiration), + RealmName: core.StringPtr(realmName), + Conditions: conditions, } } @@ -6032,9 +6040,6 @@ func UnmarshalRule(m map[string]json.RawMessage, result interface{}) (err error) type RuleActionControls struct { // Action control for removing this enterprise-managed dynamic rule. Remove *bool `json:"remove,omitempty"` - - // Action control for updating this enterprise-managed dynamic rule. - Update *bool `json:"update,omitempty"` } // UnmarshalRuleActionControls unmarshals an instance of RuleActionControls from the specified map of raw messages. @@ -6044,10 +6049,6 @@ func UnmarshalRuleActionControls(m map[string]json.RawMessage, result interface{ if err != nil { return } - err = core.UnmarshalPrimitive(m, "update", &obj.Update) - if err != nil { - return - } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) return } @@ -6067,20 +6068,20 @@ type RuleConditions struct { // Constants associated with the RuleConditions.Operator property. // The operation to perform on the claim. const ( - RuleConditionsOperatorContainsConst = "CONTAINS" - RuleConditionsOperatorEqualsConst = "EQUALS" - RuleConditionsOperatorEqualsIgnoreCaseConst = "EQUALS_IGNORE_CASE" - RuleConditionsOperatorInConst = "IN" - RuleConditionsOperatorNotEqualsConst = "NOT_EQUALS" + RuleConditionsOperatorContainsConst = "CONTAINS" + RuleConditionsOperatorEqualsConst = "EQUALS" + RuleConditionsOperatorEqualsIgnoreCaseConst = "EQUALS_IGNORE_CASE" + RuleConditionsOperatorInConst = "IN" + RuleConditionsOperatorNotEqualsConst = "NOT_EQUALS" RuleConditionsOperatorNotEqualsIgnoreCaseConst = "NOT_EQUALS_IGNORE_CASE" ) // NewRuleConditions : Instantiate RuleConditions (Generic Model Constructor) func (*IamAccessGroupsV2) NewRuleConditions(claim string, operator string, value string) (_model *RuleConditions, err error) { _model = &RuleConditions{ - Claim: core.StringPtr(claim), + Claim: core.StringPtr(claim), Operator: core.StringPtr(operator), - Value: core.StringPtr(value), + Value: core.StringPtr(value), } err = core.ValidateStruct(_model, "required parameters") return @@ -6167,7 +6168,7 @@ type TemplateAssignmentResponse struct { // Constants associated with the TemplateAssignmentResponse.TargetType property. // The type of the entity that the assignment applies to. const ( - TemplateAssignmentResponseTargetTypeAccountConst = "Account" + TemplateAssignmentResponseTargetTypeAccountConst = "Account" TemplateAssignmentResponseTargetTypeAccountgroupConst = "AccountGroup" ) @@ -6182,10 +6183,10 @@ const ( // Constants associated with the TemplateAssignmentResponse.Status property. // The status of the assignment (e.g. 'accepted', 'in_progress', 'succeeded', 'failed', 'superseded'). const ( - TemplateAssignmentResponseStatusAcceptedConst = "accepted" - TemplateAssignmentResponseStatusFailedConst = "failed" + TemplateAssignmentResponseStatusAcceptedConst = "accepted" + TemplateAssignmentResponseStatusFailedConst = "failed" TemplateAssignmentResponseStatusInProgressConst = "in_progress" - TemplateAssignmentResponseStatusSucceededConst = "succeeded" + TemplateAssignmentResponseStatusSucceededConst = "succeeded" TemplateAssignmentResponseStatusSupersededConst = "superseded" ) @@ -6589,7 +6590,7 @@ type UpdateAccessGroupOptions struct { func (*IamAccessGroupsV2) NewUpdateAccessGroupOptions(accessGroupID string, ifMatch string) *UpdateAccessGroupOptions { return &UpdateAccessGroupOptions{ AccessGroupID: core.StringPtr(accessGroupID), - IfMatch: core.StringPtr(ifMatch), + IfMatch: core.StringPtr(ifMatch), } } @@ -6700,8 +6701,8 @@ type UpdateAssignmentOptions struct { // NewUpdateAssignmentOptions : Instantiate UpdateAssignmentOptions func (*IamAccessGroupsV2) NewUpdateAssignmentOptions(assignmentID string, ifMatch string, templateVersion string) *UpdateAssignmentOptions { return &UpdateAssignmentOptions{ - AssignmentID: core.StringPtr(assignmentID), - IfMatch: core.StringPtr(ifMatch), + AssignmentID: core.StringPtr(assignmentID), + IfMatch: core.StringPtr(ifMatch), TemplateVersion: core.StringPtr(templateVersion), } } @@ -6766,7 +6767,7 @@ func (*IamAccessGroupsV2) NewUpdateTemplateVersionOptions(templateID string, ver return &UpdateTemplateVersionOptions{ TemplateID: core.StringPtr(templateID), VersionNum: core.StringPtr(versionNum), - IfMatch: core.StringPtr(ifMatch), + IfMatch: core.StringPtr(ifMatch), } } @@ -6824,11 +6825,13 @@ func (options *UpdateTemplateVersionOptions) SetHeaders(param map[string]string) return options } +// // AccessGroupsPager can be used to simplify the use of the "ListAccessGroups" method. +// type AccessGroupsPager struct { - hasNext bool - options *ListAccessGroupsOptions - client *IamAccessGroupsV2 + hasNext bool + options *ListAccessGroupsOptions + client *IamAccessGroupsV2 pageContext struct { next *int64 } @@ -6909,11 +6912,13 @@ func (pager *AccessGroupsPager) GetAll() (allItems []Group, err error) { return pager.GetAllWithContext(context.Background()) } +// // AccessGroupMembersPager can be used to simplify the use of the "ListAccessGroupMembers" method. +// type AccessGroupMembersPager struct { - hasNext bool - options *ListAccessGroupMembersOptions - client *IamAccessGroupsV2 + hasNext bool + options *ListAccessGroupMembersOptions + client *IamAccessGroupsV2 pageContext struct { next *int64 } @@ -6994,11 +6999,13 @@ func (pager *AccessGroupMembersPager) GetAll() (allItems []ListGroupMembersRespo return pager.GetAllWithContext(context.Background()) } +// // TemplatesPager can be used to simplify the use of the "ListTemplates" method. +// type TemplatesPager struct { - hasNext bool - options *ListTemplatesOptions - client *IamAccessGroupsV2 + hasNext bool + options *ListTemplatesOptions + client *IamAccessGroupsV2 pageContext struct { next *int64 } @@ -7079,11 +7086,13 @@ func (pager *TemplatesPager) GetAll() (allItems []GroupTemplate, err error) { return pager.GetAllWithContext(context.Background()) } +// // TemplateVersionsPager can be used to simplify the use of the "ListTemplateVersions" method. +// type TemplateVersionsPager struct { - hasNext bool - options *ListTemplateVersionsOptions - client *IamAccessGroupsV2 + hasNext bool + options *ListTemplateVersionsOptions + client *IamAccessGroupsV2 pageContext struct { next *int64 } diff --git a/iamaccessgroupsv2/iam_access_groups_v2_examples_test.go b/iamaccessgroupsv2/iam_access_groups_v2_examples_test.go index 02de183f..d29c25e9 100644 --- a/iamaccessgroupsv2/iam_access_groups_v2_examples_test.go +++ b/iamaccessgroupsv2/iam_access_groups_v2_examples_test.go @@ -642,7 +642,6 @@ var _ = Describe(`IamAccessGroupsV2 Examples Tests`, func() { rulesActionControlsModel := &iamaccessgroupsv2.RuleActionControls{ Remove: core.BoolPtr(false), - Update: core.BoolPtr(false), } ruleInputModel := &iamaccessgroupsv2.AssertionsRule{ @@ -656,7 +655,6 @@ var _ = Describe(`IamAccessGroupsV2 Examples Tests`, func() { assertionsActionControlsModel := &iamaccessgroupsv2.AssertionsActionControls{ Add: core.BoolPtr(false), Remove: core.BoolPtr(true), - Update: core.BoolPtr(true), } assertionsInputModel := &iamaccessgroupsv2.Assertions{ @@ -885,7 +883,6 @@ var _ = Describe(`IamAccessGroupsV2 Examples Tests`, func() { rulesActionControlsModel := &iamaccessgroupsv2.RuleActionControls{ Remove: core.BoolPtr(false), - Update: core.BoolPtr(false), } ruleInputModel := &iamaccessgroupsv2.AssertionsRule{ diff --git a/iamaccessgroupsv2/iam_access_groups_v2_integration_test.go b/iamaccessgroupsv2/iam_access_groups_v2_integration_test.go index e39400f3..ab44c861 100644 --- a/iamaccessgroupsv2/iam_access_groups_v2_integration_test.go +++ b/iamaccessgroupsv2/iam_access_groups_v2_integration_test.go @@ -517,7 +517,6 @@ var _ = Describe("IAM Access Groups - Integration Tests", func() { rulesActionControlsModel := &iamaccessgroupsv2.RuleActionControls{ Remove: core.BoolPtr(false), - Update: core.BoolPtr(false), } ruleInputModel := &iamaccessgroupsv2.AssertionsRule{ @@ -531,7 +530,6 @@ var _ = Describe("IAM Access Groups - Integration Tests", func() { assertionsActionControlsModel := &iamaccessgroupsv2.AssertionsActionControls{ Add: core.BoolPtr(false), Remove: core.BoolPtr(true), - Update: core.BoolPtr(true), } assertionsInputModel := &iamaccessgroupsv2.Assertions{ @@ -668,7 +666,6 @@ var _ = Describe("IAM Access Groups - Integration Tests", func() { rulesActionControlsModel := &iamaccessgroupsv2.RuleActionControls{ Remove: core.BoolPtr(true), - Update: core.BoolPtr(true), } ruleInputModel := &iamaccessgroupsv2.AssertionsRule{ @@ -682,7 +679,6 @@ var _ = Describe("IAM Access Groups - Integration Tests", func() { assertionsActionControlsModel := &iamaccessgroupsv2.AssertionsActionControls{ Add: core.BoolPtr(false), Remove: core.BoolPtr(true), - Update: core.BoolPtr(true), } assertionsInputModel := &iamaccessgroupsv2.Assertions{ @@ -834,7 +830,6 @@ var _ = Describe("IAM Access Groups - Integration Tests", func() { rulesActionControlsModel := &iamaccessgroupsv2.RuleActionControls{ Remove: core.BoolPtr(false), - Update: core.BoolPtr(false), } ruleInputModel := &iamaccessgroupsv2.AssertionsRule{ @@ -848,7 +843,6 @@ var _ = Describe("IAM Access Groups - Integration Tests", func() { assertionsActionControlsModel := &iamaccessgroupsv2.AssertionsActionControls{ Add: core.BoolPtr(false), Remove: core.BoolPtr(true), - Update: core.BoolPtr(true), } assertionsInputModel := &iamaccessgroupsv2.Assertions{ diff --git a/iamaccessgroupsv2/iam_access_groups_v2_test.go b/iamaccessgroupsv2/iam_access_groups_v2_test.go index 310a8479..963a2bc5 100644 --- a/iamaccessgroupsv2/iam_access_groups_v2_test.go +++ b/iamaccessgroupsv2/iam_access_groups_v2_test.go @@ -66,13 +66,14 @@ var _ = Describe(`IamAccessGroupsV2`, func() { Context(`Using external config, construct service client instances`, func() { // Map containing environment variables used in testing. var testEnvironment = map[string]string{ - "IAM_ACCESS_GROUPS_URL": "https://iamaccessgroupsv2/api", + "IAM_ACCESS_GROUPS_URL": "https://iamaccessgroupsv2/api", "IAM_ACCESS_GROUPS_AUTH_TYPE": "noauth", } It(`Create service client using external config successfully`, func() { SetTestEnvironment(testEnvironment) - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{}) + iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{ + }) Expect(iamAccessGroupsService).ToNot(BeNil()) Expect(serviceErr).To(BeNil()) ClearTestEnvironment(testEnvironment) @@ -101,7 +102,8 @@ var _ = Describe(`IamAccessGroupsV2`, func() { }) It(`Create service client using external config and set url programatically successfully`, func() { SetTestEnvironment(testEnvironment) - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{}) + iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{ + }) err := iamAccessGroupsService.SetServiceURL("https://testService/api") Expect(err).To(BeNil()) Expect(iamAccessGroupsService).ToNot(BeNil()) @@ -119,12 +121,13 @@ var _ = Describe(`IamAccessGroupsV2`, func() { Context(`Using external config, construct service client instances with error: Invalid Auth`, func() { // Map containing environment variables used in testing. var testEnvironment = map[string]string{ - "IAM_ACCESS_GROUPS_URL": "https://iamaccessgroupsv2/api", + "IAM_ACCESS_GROUPS_URL": "https://iamaccessgroupsv2/api", "IAM_ACCESS_GROUPS_AUTH_TYPE": "someOtherAuth", } SetTestEnvironment(testEnvironment) - iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{}) + iamAccessGroupsService, serviceErr := iamaccessgroupsv2.NewIamAccessGroupsV2UsingExternalConfig(&iamaccessgroupsv2.IamAccessGroupsV2Options{ + }) It(`Instantiate service client with error`, func() { Expect(iamAccessGroupsService).To(BeNil()) @@ -135,7 +138,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { Context(`Using external config, construct service client instances with error: Invalid URL`, func() { // Map containing environment variables used in testing. var testEnvironment = map[string]string{ - "IAM_ACCESS_GROUPS_AUTH_TYPE": "NOAuth", + "IAM_ACCESS_GROUPS_AUTH_TYPE": "NOAuth", } SetTestEnvironment(testEnvironment) @@ -723,14 +726,14 @@ var _ = Describe(`IamAccessGroupsV2`, func() { nextObject := new(iamaccessgroupsv2.HrefStruct) nextObject.Href = core.StringPtr("ibm.com?offset=135") responseObject.Next = nextObject - + value, err := responseObject.GetNextOffset() Expect(err).To(BeNil()) Expect(value).To(Equal(core.Int64Ptr(int64(135)))) }) It(`Invoke GetNextOffset without a "Next" property in the response`, func() { responseObject := new(iamaccessgroupsv2.GroupsList) - + value, err := responseObject.GetNextOffset() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -740,7 +743,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { nextObject := new(iamaccessgroupsv2.HrefStruct) nextObject.Href = core.StringPtr("ibm.com") responseObject.Next = nextObject - + value, err := responseObject.GetNextOffset() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -750,7 +753,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { nextObject := new(iamaccessgroupsv2.HrefStruct) nextObject.Href = core.StringPtr("ibm.com?offset=tiger") responseObject.Next = nextObject - + value, err := responseObject.GetNextOffset() Expect(err).NotTo(BeNil()) Expect(value).To(BeNil()) @@ -788,14 +791,14 @@ var _ = Describe(`IamAccessGroupsV2`, func() { Expect(iamAccessGroupsService).ToNot(BeNil()) listAccessGroupsOptionsModel := &iamaccessgroupsv2.ListAccessGroupsOptions{ - AccountID: core.StringPtr("testString"), - TransactionID: core.StringPtr("testString"), - IamID: core.StringPtr("testString"), - Search: core.StringPtr("testString"), - MembershipType: core.StringPtr("static"), - Limit: core.Int64Ptr(int64(10)), - Sort: core.StringPtr("name"), - ShowFederated: core.BoolPtr(false), + AccountID: core.StringPtr("testString"), + TransactionID: core.StringPtr("testString"), + IamID: core.StringPtr("testString"), + Search: core.StringPtr("testString"), + MembershipType: core.StringPtr("static"), + Limit: core.Int64Ptr(int64(10)), + Sort: core.StringPtr("name"), + ShowFederated: core.BoolPtr(false), HidePublicAccess: core.BoolPtr(false), } @@ -821,14 +824,14 @@ var _ = Describe(`IamAccessGroupsV2`, func() { Expect(iamAccessGroupsService).ToNot(BeNil()) listAccessGroupsOptionsModel := &iamaccessgroupsv2.ListAccessGroupsOptions{ - AccountID: core.StringPtr("testString"), - TransactionID: core.StringPtr("testString"), - IamID: core.StringPtr("testString"), - Search: core.StringPtr("testString"), - MembershipType: core.StringPtr("static"), - Limit: core.Int64Ptr(int64(10)), - Sort: core.StringPtr("name"), - ShowFederated: core.BoolPtr(false), + AccountID: core.StringPtr("testString"), + TransactionID: core.StringPtr("testString"), + IamID: core.StringPtr("testString"), + Search: core.StringPtr("testString"), + MembershipType: core.StringPtr("static"), + Limit: core.Int64Ptr(int64(10)), + Sort: core.StringPtr("name"), + ShowFederated: core.BoolPtr(false), HidePublicAccess: core.BoolPtr(false), } @@ -2060,14 +2063,14 @@ var _ = Describe(`IamAccessGroupsV2`, func() { nextObject := new(iamaccessgroupsv2.HrefStruct) nextObject.Href = core.StringPtr("ibm.com?offset=135") responseObject.Next = nextObject - + value, err := responseObject.GetNextOffset() Expect(err).To(BeNil()) Expect(value).To(Equal(core.Int64Ptr(int64(135)))) }) It(`Invoke GetNextOffset without a "Next" property in the response`, func() { responseObject := new(iamaccessgroupsv2.GroupMembersList) - + value, err := responseObject.GetNextOffset() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -2077,7 +2080,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { nextObject := new(iamaccessgroupsv2.HrefStruct) nextObject.Href = core.StringPtr("ibm.com") responseObject.Next = nextObject - + value, err := responseObject.GetNextOffset() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -2087,7 +2090,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { nextObject := new(iamaccessgroupsv2.HrefStruct) nextObject.Href = core.StringPtr("ibm.com?offset=tiger") responseObject.Next = nextObject - + value, err := responseObject.GetNextOffset() Expect(err).NotTo(BeNil()) Expect(value).To(BeNil()) @@ -2125,13 +2128,13 @@ var _ = Describe(`IamAccessGroupsV2`, func() { Expect(iamAccessGroupsService).ToNot(BeNil()) listAccessGroupMembersOptionsModel := &iamaccessgroupsv2.ListAccessGroupMembersOptions{ - AccessGroupID: core.StringPtr("testString"), - TransactionID: core.StringPtr("testString"), + AccessGroupID: core.StringPtr("testString"), + TransactionID: core.StringPtr("testString"), MembershipType: core.StringPtr("static"), - Limit: core.Int64Ptr(int64(10)), - Type: core.StringPtr("testString"), - Verbose: core.BoolPtr(false), - Sort: core.StringPtr("testString"), + Limit: core.Int64Ptr(int64(10)), + Type: core.StringPtr("testString"), + Verbose: core.BoolPtr(false), + Sort: core.StringPtr("testString"), } pager, err := iamAccessGroupsService.NewAccessGroupMembersPager(listAccessGroupMembersOptionsModel) @@ -2156,13 +2159,13 @@ var _ = Describe(`IamAccessGroupsV2`, func() { Expect(iamAccessGroupsService).ToNot(BeNil()) listAccessGroupMembersOptionsModel := &iamaccessgroupsv2.ListAccessGroupMembersOptions{ - AccessGroupID: core.StringPtr("testString"), - TransactionID: core.StringPtr("testString"), + AccessGroupID: core.StringPtr("testString"), + TransactionID: core.StringPtr("testString"), MembershipType: core.StringPtr("static"), - Limit: core.Int64Ptr(int64(10)), - Type: core.StringPtr("testString"), - Verbose: core.BoolPtr(false), - Sort: core.StringPtr("testString"), + Limit: core.Int64Ptr(int64(10)), + Type: core.StringPtr("testString"), + Verbose: core.BoolPtr(false), + Sort: core.StringPtr("testString"), } pager, err := iamAccessGroupsService.NewAccessGroupMembersPager(listAccessGroupMembersOptionsModel) @@ -4699,7 +4702,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Construct an instance of the RuleActionControls model ruleActionControlsModel := new(iamaccessgroupsv2.RuleActionControls) ruleActionControlsModel.Remove = core.BoolPtr(false) - ruleActionControlsModel.Update = core.BoolPtr(false) // Construct an instance of the AssertionsRule model assertionsRuleModel := new(iamaccessgroupsv2.AssertionsRule) @@ -4713,7 +4715,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { assertionsActionControlsModel := new(iamaccessgroupsv2.AssertionsActionControls) assertionsActionControlsModel.Add = core.BoolPtr(false) assertionsActionControlsModel.Remove = core.BoolPtr(true) - assertionsActionControlsModel.Update = core.BoolPtr(true) // Construct an instance of the Assertions model assertionsModel := new(iamaccessgroupsv2.Assertions) @@ -4803,7 +4804,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"id": "ID", "name": "Name", "description": "Description", "account_id": "AccountID", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "name": "Name", "description": "Description", "account_id": "AccountID", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true}}], "action_controls": {"add": false, "remove": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) })) }) It(`Invoke CreateTemplate successfully with retries`, func() { @@ -4835,7 +4836,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Construct an instance of the RuleActionControls model ruleActionControlsModel := new(iamaccessgroupsv2.RuleActionControls) ruleActionControlsModel.Remove = core.BoolPtr(false) - ruleActionControlsModel.Update = core.BoolPtr(false) // Construct an instance of the AssertionsRule model assertionsRuleModel := new(iamaccessgroupsv2.AssertionsRule) @@ -4849,7 +4849,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { assertionsActionControlsModel := new(iamaccessgroupsv2.AssertionsActionControls) assertionsActionControlsModel.Add = core.BoolPtr(false) assertionsActionControlsModel.Remove = core.BoolPtr(true) - assertionsActionControlsModel.Update = core.BoolPtr(true) // Construct an instance of the Assertions model assertionsModel := new(iamaccessgroupsv2.Assertions) @@ -4942,7 +4941,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"id": "ID", "name": "Name", "description": "Description", "account_id": "AccountID", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "name": "Name", "description": "Description", "account_id": "AccountID", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true}}], "action_controls": {"add": false, "remove": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) })) }) It(`Invoke CreateTemplate successfully`, func() { @@ -4979,7 +4978,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Construct an instance of the RuleActionControls model ruleActionControlsModel := new(iamaccessgroupsv2.RuleActionControls) ruleActionControlsModel.Remove = core.BoolPtr(false) - ruleActionControlsModel.Update = core.BoolPtr(false) // Construct an instance of the AssertionsRule model assertionsRuleModel := new(iamaccessgroupsv2.AssertionsRule) @@ -4993,7 +4991,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { assertionsActionControlsModel := new(iamaccessgroupsv2.AssertionsActionControls) assertionsActionControlsModel.Add = core.BoolPtr(false) assertionsActionControlsModel.Remove = core.BoolPtr(true) - assertionsActionControlsModel.Update = core.BoolPtr(true) // Construct an instance of the Assertions model assertionsModel := new(iamaccessgroupsv2.Assertions) @@ -5066,7 +5063,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Construct an instance of the RuleActionControls model ruleActionControlsModel := new(iamaccessgroupsv2.RuleActionControls) ruleActionControlsModel.Remove = core.BoolPtr(false) - ruleActionControlsModel.Update = core.BoolPtr(false) // Construct an instance of the AssertionsRule model assertionsRuleModel := new(iamaccessgroupsv2.AssertionsRule) @@ -5080,7 +5076,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { assertionsActionControlsModel := new(iamaccessgroupsv2.AssertionsActionControls) assertionsActionControlsModel.Add = core.BoolPtr(false) assertionsActionControlsModel.Remove = core.BoolPtr(true) - assertionsActionControlsModel.Update = core.BoolPtr(true) // Construct an instance of the Assertions model assertionsModel := new(iamaccessgroupsv2.Assertions) @@ -5174,7 +5169,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Construct an instance of the RuleActionControls model ruleActionControlsModel := new(iamaccessgroupsv2.RuleActionControls) ruleActionControlsModel.Remove = core.BoolPtr(false) - ruleActionControlsModel.Update = core.BoolPtr(false) // Construct an instance of the AssertionsRule model assertionsRuleModel := new(iamaccessgroupsv2.AssertionsRule) @@ -5188,7 +5182,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { assertionsActionControlsModel := new(iamaccessgroupsv2.AssertionsActionControls) assertionsActionControlsModel.Add = core.BoolPtr(false) assertionsActionControlsModel.Remove = core.BoolPtr(true) - assertionsActionControlsModel.Update = core.BoolPtr(true) // Construct an instance of the Assertions model assertionsModel := new(iamaccessgroupsv2.Assertions) @@ -5317,7 +5310,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"limit": 5, "offset": 6, "total_count": 10, "first": {"href": "Href"}, "previous": {"href": "Href"}, "next": {"href": "Href"}, "last": {"href": "Href"}, "group_templates": [{"id": "ID", "name": "Name", "description": "Description", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}]}`) + fmt.Fprintf(res, "%s", `{"limit": 5, "offset": 6, "total_count": 10, "first": {"href": "Href"}, "previous": {"href": "Href"}, "next": {"href": "Href"}, "last": {"href": "Href"}, "group_templates": [{"id": "ID", "name": "Name", "description": "Description", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true}}], "action_controls": {"add": false, "remove": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}]}`) })) }) It(`Invoke ListTemplates successfully with retries`, func() { @@ -5381,7 +5374,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"limit": 5, "offset": 6, "total_count": 10, "first": {"href": "Href"}, "previous": {"href": "Href"}, "next": {"href": "Href"}, "last": {"href": "Href"}, "group_templates": [{"id": "ID", "name": "Name", "description": "Description", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}]}`) + fmt.Fprintf(res, "%s", `{"limit": 5, "offset": 6, "total_count": 10, "first": {"href": "Href"}, "previous": {"href": "Href"}, "next": {"href": "Href"}, "last": {"href": "Href"}, "group_templates": [{"id": "ID", "name": "Name", "description": "Description", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true}}], "action_controls": {"add": false, "remove": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}]}`) })) }) It(`Invoke ListTemplates successfully`, func() { @@ -5494,14 +5487,14 @@ var _ = Describe(`IamAccessGroupsV2`, func() { nextObject := new(iamaccessgroupsv2.HrefStruct) nextObject.Href = core.StringPtr("ibm.com?offset=135") responseObject.Next = nextObject - + value, err := responseObject.GetNextOffset() Expect(err).To(BeNil()) Expect(value).To(Equal(core.Int64Ptr(int64(135)))) }) It(`Invoke GetNextOffset without a "Next" property in the response`, func() { responseObject := new(iamaccessgroupsv2.ListTemplatesResponse) - + value, err := responseObject.GetNextOffset() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -5511,7 +5504,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { nextObject := new(iamaccessgroupsv2.HrefStruct) nextObject.Href = core.StringPtr("ibm.com") responseObject.Next = nextObject - + value, err := responseObject.GetNextOffset() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -5521,7 +5514,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { nextObject := new(iamaccessgroupsv2.HrefStruct) nextObject.Href = core.StringPtr("ibm.com?offset=tiger") responseObject.Next = nextObject - + value, err := responseObject.GetNextOffset() Expect(err).NotTo(BeNil()) Expect(value).To(BeNil()) @@ -5542,9 +5535,9 @@ var _ = Describe(`IamAccessGroupsV2`, func() { res.WriteHeader(200) requestNumber++ if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"group_templates":[{"id":"ID","name":"Name","description":"Description","version":"Version","committed":false,"group":{"name":"Name","description":"Description","members":{"users":["Users"],"services":["Services"],"action_controls":{"add":false,"remove":true}},"assertions":{"rules":[{"name":"Name","expiration":10,"realm_name":"RealmName","conditions":[{"claim":"Claim","operator":"Operator","value":"Value"}],"action_controls":{"remove":true,"update":true}}],"action_controls":{"add":false,"remove":true,"update":true}},"action_controls":{"access":{"add":false}}},"policy_template_references":[{"id":"ID","version":"Version"}],"href":"Href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"CreatedByID","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"LastModifiedByID"}],"next":{"href":"https://myhost.com/somePath?offset=1"},"total_count":2,"limit":1}`) + fmt.Fprintf(res, "%s", `{"group_templates":[{"id":"ID","name":"Name","description":"Description","version":"Version","committed":false,"group":{"name":"Name","description":"Description","members":{"users":["Users"],"services":["Services"],"action_controls":{"add":false,"remove":true}},"assertions":{"rules":[{"name":"Name","expiration":10,"realm_name":"RealmName","conditions":[{"claim":"Claim","operator":"Operator","value":"Value"}],"action_controls":{"remove":true}}],"action_controls":{"add":false,"remove":true}},"action_controls":{"access":{"add":false}}},"policy_template_references":[{"id":"ID","version":"Version"}],"href":"Href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"CreatedByID","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"LastModifiedByID"}],"next":{"href":"https://myhost.com/somePath?offset=1"},"total_count":2,"limit":1}`) } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"group_templates":[{"id":"ID","name":"Name","description":"Description","version":"Version","committed":false,"group":{"name":"Name","description":"Description","members":{"users":["Users"],"services":["Services"],"action_controls":{"add":false,"remove":true}},"assertions":{"rules":[{"name":"Name","expiration":10,"realm_name":"RealmName","conditions":[{"claim":"Claim","operator":"Operator","value":"Value"}],"action_controls":{"remove":true,"update":true}}],"action_controls":{"add":false,"remove":true,"update":true}},"action_controls":{"access":{"add":false}}},"policy_template_references":[{"id":"ID","version":"Version"}],"href":"Href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"CreatedByID","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"LastModifiedByID"}],"total_count":2,"limit":1}`) + fmt.Fprintf(res, "%s", `{"group_templates":[{"id":"ID","name":"Name","description":"Description","version":"Version","committed":false,"group":{"name":"Name","description":"Description","members":{"users":["Users"],"services":["Services"],"action_controls":{"add":false,"remove":true}},"assertions":{"rules":[{"name":"Name","expiration":10,"realm_name":"RealmName","conditions":[{"claim":"Claim","operator":"Operator","value":"Value"}],"action_controls":{"remove":true}}],"action_controls":{"add":false,"remove":true}},"action_controls":{"access":{"add":false}}},"policy_template_references":[{"id":"ID","version":"Version"}],"href":"Href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"CreatedByID","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"LastModifiedByID"}],"total_count":2,"limit":1}`) } else { res.WriteHeader(400) } @@ -5559,10 +5552,10 @@ var _ = Describe(`IamAccessGroupsV2`, func() { Expect(iamAccessGroupsService).ToNot(BeNil()) listTemplatesOptionsModel := &iamaccessgroupsv2.ListTemplatesOptions{ - AccountID: core.StringPtr("accountID-123"), + AccountID: core.StringPtr("accountID-123"), TransactionID: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(50)), - Verbose: core.BoolPtr(true), + Limit: core.Int64Ptr(int64(50)), + Verbose: core.BoolPtr(true), } pager, err := iamAccessGroupsService.NewTemplatesPager(listTemplatesOptionsModel) @@ -5587,10 +5580,10 @@ var _ = Describe(`IamAccessGroupsV2`, func() { Expect(iamAccessGroupsService).ToNot(BeNil()) listTemplatesOptionsModel := &iamaccessgroupsv2.ListTemplatesOptions{ - AccountID: core.StringPtr("accountID-123"), + AccountID: core.StringPtr("accountID-123"), TransactionID: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(50)), - Verbose: core.BoolPtr(true), + Limit: core.Int64Ptr(int64(50)), + Verbose: core.BoolPtr(true), } pager, err := iamAccessGroupsService.NewTemplatesPager(listTemplatesOptionsModel) @@ -5648,8 +5641,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Construct an instance of the RuleActionControls model ruleActionControlsModel := new(iamaccessgroupsv2.RuleActionControls) - ruleActionControlsModel.Remove = core.BoolPtr(true) - ruleActionControlsModel.Update = core.BoolPtr(true) + ruleActionControlsModel.Remove = core.BoolPtr(false) // Construct an instance of the AssertionsRule model assertionsRuleModel := new(iamaccessgroupsv2.AssertionsRule) @@ -5663,7 +5655,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { assertionsActionControlsModel := new(iamaccessgroupsv2.AssertionsActionControls) assertionsActionControlsModel.Add = core.BoolPtr(false) assertionsActionControlsModel.Remove = core.BoolPtr(true) - assertionsActionControlsModel.Update = core.BoolPtr(true) // Construct an instance of the Assertions model assertionsModel := new(iamaccessgroupsv2.Assertions) @@ -5753,7 +5744,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"id": "ID", "name": "Name", "description": "Description", "account_id": "AccountID", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "name": "Name", "description": "Description", "account_id": "AccountID", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true}}], "action_controls": {"add": false, "remove": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) })) }) It(`Invoke CreateTemplateVersion successfully with retries`, func() { @@ -5784,8 +5775,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Construct an instance of the RuleActionControls model ruleActionControlsModel := new(iamaccessgroupsv2.RuleActionControls) - ruleActionControlsModel.Remove = core.BoolPtr(true) - ruleActionControlsModel.Update = core.BoolPtr(true) + ruleActionControlsModel.Remove = core.BoolPtr(false) // Construct an instance of the AssertionsRule model assertionsRuleModel := new(iamaccessgroupsv2.AssertionsRule) @@ -5799,7 +5789,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { assertionsActionControlsModel := new(iamaccessgroupsv2.AssertionsActionControls) assertionsActionControlsModel.Add = core.BoolPtr(false) assertionsActionControlsModel.Remove = core.BoolPtr(true) - assertionsActionControlsModel.Update = core.BoolPtr(true) // Construct an instance of the Assertions model assertionsModel := new(iamaccessgroupsv2.Assertions) @@ -5892,7 +5881,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"id": "ID", "name": "Name", "description": "Description", "account_id": "AccountID", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "name": "Name", "description": "Description", "account_id": "AccountID", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true}}], "action_controls": {"add": false, "remove": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) })) }) It(`Invoke CreateTemplateVersion successfully`, func() { @@ -5928,8 +5917,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Construct an instance of the RuleActionControls model ruleActionControlsModel := new(iamaccessgroupsv2.RuleActionControls) - ruleActionControlsModel.Remove = core.BoolPtr(true) - ruleActionControlsModel.Update = core.BoolPtr(true) + ruleActionControlsModel.Remove = core.BoolPtr(false) // Construct an instance of the AssertionsRule model assertionsRuleModel := new(iamaccessgroupsv2.AssertionsRule) @@ -5943,7 +5931,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { assertionsActionControlsModel := new(iamaccessgroupsv2.AssertionsActionControls) assertionsActionControlsModel.Add = core.BoolPtr(false) assertionsActionControlsModel.Remove = core.BoolPtr(true) - assertionsActionControlsModel.Update = core.BoolPtr(true) // Construct an instance of the Assertions model assertionsModel := new(iamaccessgroupsv2.Assertions) @@ -6015,8 +6002,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Construct an instance of the RuleActionControls model ruleActionControlsModel := new(iamaccessgroupsv2.RuleActionControls) - ruleActionControlsModel.Remove = core.BoolPtr(true) - ruleActionControlsModel.Update = core.BoolPtr(true) + ruleActionControlsModel.Remove = core.BoolPtr(false) // Construct an instance of the AssertionsRule model assertionsRuleModel := new(iamaccessgroupsv2.AssertionsRule) @@ -6030,7 +6016,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { assertionsActionControlsModel := new(iamaccessgroupsv2.AssertionsActionControls) assertionsActionControlsModel.Add = core.BoolPtr(false) assertionsActionControlsModel.Remove = core.BoolPtr(true) - assertionsActionControlsModel.Update = core.BoolPtr(true) // Construct an instance of the Assertions model assertionsModel := new(iamaccessgroupsv2.Assertions) @@ -6123,8 +6108,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Construct an instance of the RuleActionControls model ruleActionControlsModel := new(iamaccessgroupsv2.RuleActionControls) - ruleActionControlsModel.Remove = core.BoolPtr(true) - ruleActionControlsModel.Update = core.BoolPtr(true) + ruleActionControlsModel.Remove = core.BoolPtr(false) // Construct an instance of the AssertionsRule model assertionsRuleModel := new(iamaccessgroupsv2.AssertionsRule) @@ -6138,7 +6122,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { assertionsActionControlsModel := new(iamaccessgroupsv2.AssertionsActionControls) assertionsActionControlsModel.Add = core.BoolPtr(false) assertionsActionControlsModel.Remove = core.BoolPtr(true) - assertionsActionControlsModel.Update = core.BoolPtr(true) // Construct an instance of the Assertions model assertionsModel := new(iamaccessgroupsv2.Assertions) @@ -6257,7 +6240,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"limit": 5, "offset": 6, "total_count": 10, "first": {"href": "Href"}, "previous": {"href": "Href"}, "next": {"href": "Href"}, "last": {"href": "Href"}, "group_template_versions": [{"name": "Name", "description": "Description", "account_id": "AccountID", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}]}`) + fmt.Fprintf(res, "%s", `{"limit": 5, "offset": 6, "total_count": 10, "first": {"href": "Href"}, "previous": {"href": "Href"}, "next": {"href": "Href"}, "last": {"href": "Href"}, "group_template_versions": [{"name": "Name", "description": "Description", "account_id": "AccountID", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true}}], "action_controls": {"add": false, "remove": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}]}`) })) }) It(`Invoke ListTemplateVersions successfully with retries`, func() { @@ -6315,7 +6298,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"limit": 5, "offset": 6, "total_count": 10, "first": {"href": "Href"}, "previous": {"href": "Href"}, "next": {"href": "Href"}, "last": {"href": "Href"}, "group_template_versions": [{"name": "Name", "description": "Description", "account_id": "AccountID", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}]}`) + fmt.Fprintf(res, "%s", `{"limit": 5, "offset": 6, "total_count": 10, "first": {"href": "Href"}, "previous": {"href": "Href"}, "next": {"href": "Href"}, "last": {"href": "Href"}, "group_template_versions": [{"name": "Name", "description": "Description", "account_id": "AccountID", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true}}], "action_controls": {"add": false, "remove": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "CreatedAt", "created_by_id": "CreatedByID", "last_modified_at": "LastModifiedAt", "last_modified_by_id": "LastModifiedByID"}]}`) })) }) It(`Invoke ListTemplateVersions successfully`, func() { @@ -6422,14 +6405,14 @@ var _ = Describe(`IamAccessGroupsV2`, func() { nextObject := new(iamaccessgroupsv2.HrefStruct) nextObject.Href = core.StringPtr("ibm.com?offset=135") responseObject.Next = nextObject - + value, err := responseObject.GetNextOffset() Expect(err).To(BeNil()) Expect(value).To(Equal(core.Int64Ptr(int64(135)))) }) It(`Invoke GetNextOffset without a "Next" property in the response`, func() { responseObject := new(iamaccessgroupsv2.ListTemplateVersionsResponse) - + value, err := responseObject.GetNextOffset() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -6439,7 +6422,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { nextObject := new(iamaccessgroupsv2.HrefStruct) nextObject.Href = core.StringPtr("ibm.com") responseObject.Next = nextObject - + value, err := responseObject.GetNextOffset() Expect(err).To(BeNil()) Expect(value).To(BeNil()) @@ -6449,7 +6432,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { nextObject := new(iamaccessgroupsv2.HrefStruct) nextObject.Href = core.StringPtr("ibm.com?offset=tiger") responseObject.Next = nextObject - + value, err := responseObject.GetNextOffset() Expect(err).NotTo(BeNil()) Expect(value).To(BeNil()) @@ -6470,9 +6453,9 @@ var _ = Describe(`IamAccessGroupsV2`, func() { res.WriteHeader(200) requestNumber++ if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?offset=1"},"total_count":2,"group_template_versions":[{"name":"Name","description":"Description","account_id":"AccountID","version":"Version","committed":false,"group":{"name":"Name","description":"Description","members":{"users":["Users"],"services":["Services"],"action_controls":{"add":false,"remove":true}},"assertions":{"rules":[{"name":"Name","expiration":10,"realm_name":"RealmName","conditions":[{"claim":"Claim","operator":"Operator","value":"Value"}],"action_controls":{"remove":true,"update":true}}],"action_controls":{"add":false,"remove":true,"update":true}},"action_controls":{"access":{"add":false}}},"policy_template_references":[{"id":"ID","version":"Version"}],"href":"Href","created_at":"CreatedAt","created_by_id":"CreatedByID","last_modified_at":"LastModifiedAt","last_modified_by_id":"LastModifiedByID"}],"limit":1}`) + fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?offset=1"},"total_count":2,"group_template_versions":[{"name":"Name","description":"Description","account_id":"AccountID","version":"Version","committed":false,"group":{"name":"Name","description":"Description","members":{"users":["Users"],"services":["Services"],"action_controls":{"add":false,"remove":true}},"assertions":{"rules":[{"name":"Name","expiration":10,"realm_name":"RealmName","conditions":[{"claim":"Claim","operator":"Operator","value":"Value"}],"action_controls":{"remove":true}}],"action_controls":{"add":false,"remove":true}},"action_controls":{"access":{"add":false}}},"policy_template_references":[{"id":"ID","version":"Version"}],"href":"Href","created_at":"CreatedAt","created_by_id":"CreatedByID","last_modified_at":"LastModifiedAt","last_modified_by_id":"LastModifiedByID"}],"limit":1}`) } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"total_count":2,"group_template_versions":[{"name":"Name","description":"Description","account_id":"AccountID","version":"Version","committed":false,"group":{"name":"Name","description":"Description","members":{"users":["Users"],"services":["Services"],"action_controls":{"add":false,"remove":true}},"assertions":{"rules":[{"name":"Name","expiration":10,"realm_name":"RealmName","conditions":[{"claim":"Claim","operator":"Operator","value":"Value"}],"action_controls":{"remove":true,"update":true}}],"action_controls":{"add":false,"remove":true,"update":true}},"action_controls":{"access":{"add":false}}},"policy_template_references":[{"id":"ID","version":"Version"}],"href":"Href","created_at":"CreatedAt","created_by_id":"CreatedByID","last_modified_at":"LastModifiedAt","last_modified_by_id":"LastModifiedByID"}],"limit":1}`) + fmt.Fprintf(res, "%s", `{"total_count":2,"group_template_versions":[{"name":"Name","description":"Description","account_id":"AccountID","version":"Version","committed":false,"group":{"name":"Name","description":"Description","members":{"users":["Users"],"services":["Services"],"action_controls":{"add":false,"remove":true}},"assertions":{"rules":[{"name":"Name","expiration":10,"realm_name":"RealmName","conditions":[{"claim":"Claim","operator":"Operator","value":"Value"}],"action_controls":{"remove":true}}],"action_controls":{"add":false,"remove":true}},"action_controls":{"access":{"add":false}}},"policy_template_references":[{"id":"ID","version":"Version"}],"href":"Href","created_at":"CreatedAt","created_by_id":"CreatedByID","last_modified_at":"LastModifiedAt","last_modified_by_id":"LastModifiedByID"}],"limit":1}`) } else { res.WriteHeader(400) } @@ -6488,7 +6471,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { listTemplateVersionsOptionsModel := &iamaccessgroupsv2.ListTemplateVersionsOptions{ TemplateID: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(100)), + Limit: core.Int64Ptr(int64(100)), } pager, err := iamAccessGroupsService.NewTemplateVersionsPager(listTemplateVersionsOptionsModel) @@ -6514,7 +6497,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { listTemplateVersionsOptionsModel := &iamaccessgroupsv2.ListTemplateVersionsOptions{ TemplateID: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(100)), + Limit: core.Int64Ptr(int64(100)), } pager, err := iamAccessGroupsService.NewTemplateVersionsPager(listTemplateVersionsOptionsModel) @@ -6599,7 +6582,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "name": "Name", "description": "Description", "account_id": "AccountID", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "name": "Name", "description": "Description", "account_id": "AccountID", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true}}], "action_controls": {"add": false, "remove": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) })) }) It(`Invoke GetTemplateVersion successfully with retries`, func() { @@ -6659,7 +6642,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "name": "Name", "description": "Description", "account_id": "AccountID", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "name": "Name", "description": "Description", "account_id": "AccountID", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true}}], "action_controls": {"add": false, "remove": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) })) }) It(`Invoke GetTemplateVersion successfully`, func() { @@ -6811,7 +6794,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Construct an instance of the RuleActionControls model ruleActionControlsModel := new(iamaccessgroupsv2.RuleActionControls) ruleActionControlsModel.Remove = core.BoolPtr(false) - ruleActionControlsModel.Update = core.BoolPtr(false) // Construct an instance of the AssertionsRule model assertionsRuleModel := new(iamaccessgroupsv2.AssertionsRule) @@ -6825,7 +6807,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { assertionsActionControlsModel := new(iamaccessgroupsv2.AssertionsActionControls) assertionsActionControlsModel.Add = core.BoolPtr(false) assertionsActionControlsModel.Remove = core.BoolPtr(true) - assertionsActionControlsModel.Update = core.BoolPtr(true) // Construct an instance of the Assertions model assertionsModel := new(iamaccessgroupsv2.Assertions) @@ -6919,7 +6900,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"id": "ID", "name": "Name", "description": "Description", "account_id": "AccountID", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "name": "Name", "description": "Description", "account_id": "AccountID", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true}}], "action_controls": {"add": false, "remove": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) })) }) It(`Invoke UpdateTemplateVersion successfully with retries`, func() { @@ -6951,7 +6932,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Construct an instance of the RuleActionControls model ruleActionControlsModel := new(iamaccessgroupsv2.RuleActionControls) ruleActionControlsModel.Remove = core.BoolPtr(false) - ruleActionControlsModel.Update = core.BoolPtr(false) // Construct an instance of the AssertionsRule model assertionsRuleModel := new(iamaccessgroupsv2.AssertionsRule) @@ -6965,7 +6945,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { assertionsActionControlsModel := new(iamaccessgroupsv2.AssertionsActionControls) assertionsActionControlsModel.Add = core.BoolPtr(false) assertionsActionControlsModel.Remove = core.BoolPtr(true) - assertionsActionControlsModel.Update = core.BoolPtr(true) // Construct an instance of the Assertions model assertionsModel := new(iamaccessgroupsv2.Assertions) @@ -7062,7 +7041,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"id": "ID", "name": "Name", "description": "Description", "account_id": "AccountID", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "name": "Name", "description": "Description", "account_id": "AccountID", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true}}], "action_controls": {"add": false, "remove": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) })) }) It(`Invoke UpdateTemplateVersion successfully`, func() { @@ -7099,7 +7078,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Construct an instance of the RuleActionControls model ruleActionControlsModel := new(iamaccessgroupsv2.RuleActionControls) ruleActionControlsModel.Remove = core.BoolPtr(false) - ruleActionControlsModel.Update = core.BoolPtr(false) // Construct an instance of the AssertionsRule model assertionsRuleModel := new(iamaccessgroupsv2.AssertionsRule) @@ -7113,7 +7091,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { assertionsActionControlsModel := new(iamaccessgroupsv2.AssertionsActionControls) assertionsActionControlsModel.Add = core.BoolPtr(false) assertionsActionControlsModel.Remove = core.BoolPtr(true) - assertionsActionControlsModel.Update = core.BoolPtr(true) // Construct an instance of the Assertions model assertionsModel := new(iamaccessgroupsv2.Assertions) @@ -7188,7 +7165,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Construct an instance of the RuleActionControls model ruleActionControlsModel := new(iamaccessgroupsv2.RuleActionControls) ruleActionControlsModel.Remove = core.BoolPtr(false) - ruleActionControlsModel.Update = core.BoolPtr(false) // Construct an instance of the AssertionsRule model assertionsRuleModel := new(iamaccessgroupsv2.AssertionsRule) @@ -7202,7 +7178,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { assertionsActionControlsModel := new(iamaccessgroupsv2.AssertionsActionControls) assertionsActionControlsModel.Add = core.BoolPtr(false) assertionsActionControlsModel.Remove = core.BoolPtr(true) - assertionsActionControlsModel.Update = core.BoolPtr(true) // Construct an instance of the Assertions model assertionsModel := new(iamaccessgroupsv2.Assertions) @@ -7298,7 +7273,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Construct an instance of the RuleActionControls model ruleActionControlsModel := new(iamaccessgroupsv2.RuleActionControls) ruleActionControlsModel.Remove = core.BoolPtr(false) - ruleActionControlsModel.Update = core.BoolPtr(false) // Construct an instance of the AssertionsRule model assertionsRuleModel := new(iamaccessgroupsv2.AssertionsRule) @@ -7312,7 +7286,6 @@ var _ = Describe(`IamAccessGroupsV2`, func() { assertionsActionControlsModel := new(iamaccessgroupsv2.AssertionsActionControls) assertionsActionControlsModel.Add = core.BoolPtr(false) assertionsActionControlsModel.Remove = core.BoolPtr(true) - assertionsActionControlsModel.Update = core.BoolPtr(true) // Construct an instance of the Assertions model assertionsModel := new(iamaccessgroupsv2.Assertions) @@ -7587,7 +7560,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "name": "Name", "description": "Description", "account_id": "AccountID", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "name": "Name", "description": "Description", "account_id": "AccountID", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true}}], "action_controls": {"add": false, "remove": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) })) }) It(`Invoke GetLatestTemplateVersion successfully with retries`, func() { @@ -7646,7 +7619,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "name": "Name", "description": "Description", "account_id": "AccountID", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "name": "Name", "description": "Description", "account_id": "AccountID", "version": "Version", "committed": false, "group": {"name": "Name", "description": "Description", "members": {"users": ["Users"], "services": ["Services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "Name", "expiration": 10, "realm_name": "RealmName", "conditions": [{"claim": "Claim", "operator": "Operator", "value": "Value"}], "action_controls": {"remove": true}}], "action_controls": {"add": false, "remove": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "ID", "version": "Version"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) })) }) It(`Invoke GetLatestTemplateVersion successfully`, func() { @@ -9109,9 +9082,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { ruleActionControlsModel := new(iamaccessgroupsv2.RuleActionControls) Expect(ruleActionControlsModel).ToNot(BeNil()) ruleActionControlsModel.Remove = core.BoolPtr(false) - ruleActionControlsModel.Update = core.BoolPtr(false) Expect(ruleActionControlsModel.Remove).To(Equal(core.BoolPtr(false))) - Expect(ruleActionControlsModel.Update).To(Equal(core.BoolPtr(false))) // Construct an instance of the AssertionsRule model assertionsRuleModel := new(iamaccessgroupsv2.AssertionsRule) @@ -9132,10 +9103,8 @@ var _ = Describe(`IamAccessGroupsV2`, func() { Expect(assertionsActionControlsModel).ToNot(BeNil()) assertionsActionControlsModel.Add = core.BoolPtr(false) assertionsActionControlsModel.Remove = core.BoolPtr(true) - assertionsActionControlsModel.Update = core.BoolPtr(true) Expect(assertionsActionControlsModel.Add).To(Equal(core.BoolPtr(false))) Expect(assertionsActionControlsModel.Remove).To(Equal(core.BoolPtr(true))) - Expect(assertionsActionControlsModel.Update).To(Equal(core.BoolPtr(true))) // Construct an instance of the Assertions model assertionsModel := new(iamaccessgroupsv2.Assertions) @@ -9231,10 +9200,8 @@ var _ = Describe(`IamAccessGroupsV2`, func() { // Construct an instance of the RuleActionControls model ruleActionControlsModel := new(iamaccessgroupsv2.RuleActionControls) Expect(ruleActionControlsModel).ToNot(BeNil()) - ruleActionControlsModel.Remove = core.BoolPtr(true) - ruleActionControlsModel.Update = core.BoolPtr(true) - Expect(ruleActionControlsModel.Remove).To(Equal(core.BoolPtr(true))) - Expect(ruleActionControlsModel.Update).To(Equal(core.BoolPtr(true))) + ruleActionControlsModel.Remove = core.BoolPtr(false) + Expect(ruleActionControlsModel.Remove).To(Equal(core.BoolPtr(false))) // Construct an instance of the AssertionsRule model assertionsRuleModel := new(iamaccessgroupsv2.AssertionsRule) @@ -9255,10 +9222,8 @@ var _ = Describe(`IamAccessGroupsV2`, func() { Expect(assertionsActionControlsModel).ToNot(BeNil()) assertionsActionControlsModel.Add = core.BoolPtr(false) assertionsActionControlsModel.Remove = core.BoolPtr(true) - assertionsActionControlsModel.Update = core.BoolPtr(true) Expect(assertionsActionControlsModel.Add).To(Equal(core.BoolPtr(false))) Expect(assertionsActionControlsModel.Remove).To(Equal(core.BoolPtr(true))) - Expect(assertionsActionControlsModel.Update).To(Equal(core.BoolPtr(true))) // Construct an instance of the Assertions model assertionsModel := new(iamaccessgroupsv2.Assertions) @@ -9783,9 +9748,7 @@ var _ = Describe(`IamAccessGroupsV2`, func() { ruleActionControlsModel := new(iamaccessgroupsv2.RuleActionControls) Expect(ruleActionControlsModel).ToNot(BeNil()) ruleActionControlsModel.Remove = core.BoolPtr(false) - ruleActionControlsModel.Update = core.BoolPtr(false) Expect(ruleActionControlsModel.Remove).To(Equal(core.BoolPtr(false))) - Expect(ruleActionControlsModel.Update).To(Equal(core.BoolPtr(false))) // Construct an instance of the AssertionsRule model assertionsRuleModel := new(iamaccessgroupsv2.AssertionsRule) @@ -9806,10 +9769,8 @@ var _ = Describe(`IamAccessGroupsV2`, func() { Expect(assertionsActionControlsModel).ToNot(BeNil()) assertionsActionControlsModel.Add = core.BoolPtr(false) assertionsActionControlsModel.Remove = core.BoolPtr(true) - assertionsActionControlsModel.Update = core.BoolPtr(true) Expect(assertionsActionControlsModel.Add).To(Equal(core.BoolPtr(false))) Expect(assertionsActionControlsModel.Remove).To(Equal(core.BoolPtr(true))) - Expect(assertionsActionControlsModel.Update).To(Equal(core.BoolPtr(true))) // Construct an instance of the Assertions model assertionsModel := new(iamaccessgroupsv2.Assertions) From 9c60d7d16dd661dc684641e2f5316daf84d21989 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 5 Sep 2023 16:06:00 +0000 Subject: [PATCH 20/27] Update version 0.48.0 -> 0.48.1 [skip ci] Signed-off-by: manu.k.m --- .bumpversion.cfg | 2 +- README.md | 4 ++-- common/version.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index eb2f244d..692a2fe9 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.48.0 +current_version = 0.48.1 commit = True message = Update version {current_version} -> {new_version} [skip ci] diff --git a/README.md b/README.md index 2201d7bb..f3fd20b9 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![CLA assistant](https://cla-assistant.io/readme/badge/IBM/platform-services-go-sdk)](https://cla-assistant.io/IBM/platform-services-go-sdk) -# IBM Cloud Platform Services Go SDK Version 0.48.0 +# IBM Cloud Platform Services Go SDK Version 0.48.1 Go client library to interact with various [IBM Cloud Platform Service APIs](https://cloud.ibm.com/docs?tab=api-docs&category=platform_services). @@ -86,7 +86,7 @@ Service Name | Package name * Go version 1.19 or above. ## Installation -The current version of this SDK: 0.48.0 +The current version of this SDK: 0.48.1 ### Go modules If your application uses Go modules for dependency management (recommended), just add an import for each service diff --git a/common/version.go b/common/version.go index 42fddced..9c000560 100644 --- a/common/version.go +++ b/common/version.go @@ -17,4 +17,4 @@ package common // Version of the SDK -const Version = "0.48.0" +const Version = "0.48.1" From 49d0ae52ef815a5fe05855a9c636272de7a9ab09 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 5 Sep 2023 16:06:00 +0000 Subject: [PATCH 21/27] chore(release): 0.48.1 release notes [skip ci] ## [0.48.1](https://github.com/IBM/platform-services-go-sdk/compare/v0.48.0...v0.48.1) (2023-09-05) ### Bug Fixes * **IAM Access Groups:** rRemove update action control from assertions ([#276](https://github.com/IBM/platform-services-go-sdk/issues/276)) ([75ec5ee](https://github.com/IBM/platform-services-go-sdk/commit/75ec5ee4d6924c7a785c1349e05cfd5060fc94ae)) Signed-off-by: manu.k.m --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82588d05..05b735db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [0.48.1](https://github.com/IBM/platform-services-go-sdk/compare/v0.48.0...v0.48.1) (2023-09-05) + + +### Bug Fixes + +* **IAM Access Groups:** rRemove update action control from assertions ([#276](https://github.com/IBM/platform-services-go-sdk/issues/276)) ([75ec5ee](https://github.com/IBM/platform-services-go-sdk/commit/75ec5ee4d6924c7a785c1349e05cfd5060fc94ae)) + # [0.48.0](https://github.com/IBM/platform-services-go-sdk/compare/v0.47.1...v0.48.0) (2023-09-01) From 6176e09d9ba6b9621e5ea00b0f8aa1bf236346cb Mon Sep 17 00:00:00 2001 From: Dylan Yu Date: Wed, 13 Sep 2023 09:27:51 -0500 Subject: [PATCH 22/27] feat(Context-Based Restrictions): add service group support to operations (#277) Signed-off-by: Dylan Signed-off-by: manu.k.m --- .../context_based_restrictions_v1.go | 86 ++++++++++++++----- ...ext_based_restrictions_v1_examples_test.go | 7 +- ..._based_restrictions_v1_integration_test.go | 46 ++++++++-- ...ontext_based_restrictions_v1_suite_test.go | 2 +- .../context_based_restrictions_v1_test.go | 48 +++++++---- 5 files changed, 139 insertions(+), 50 deletions(-) diff --git a/contextbasedrestrictionsv1/context_based_restrictions_v1.go b/contextbasedrestrictionsv1/context_based_restrictions_v1.go index 1faaf6d0..1702a5e0 100644 --- a/contextbasedrestrictionsv1/context_based_restrictions_v1.go +++ b/contextbasedrestrictionsv1/context_based_restrictions_v1.go @@ -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. @@ -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 @@ -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 @@ -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 { @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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. @@ -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 @@ -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 @@ -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. @@ -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 @@ -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. @@ -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 @@ -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. @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/contextbasedrestrictionsv1/context_based_restrictions_v1_examples_test.go b/contextbasedrestrictionsv1/context_based_restrictions_v1_examples_test.go index 008bb026..4711f8ed 100644 --- a/contextbasedrestrictionsv1/context_based_restrictions_v1_examples_test.go +++ b/contextbasedrestrictionsv1/context_based_restrictions_v1_examples_test.go @@ -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. @@ -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 { diff --git a/contextbasedrestrictionsv1/context_based_restrictions_v1_integration_test.go b/contextbasedrestrictionsv1/context_based_restrictions_v1_integration_test.go index c6d1dae7..8b1de1a2 100644 --- a/contextbasedrestrictionsv1/context_based_restrictions_v1_integration_test.go +++ b/contextbasedrestrictionsv1/context_based_restrictions_v1_integration_test.go @@ -1,8 +1,7 @@ -//go:build integration // +build integration /** - * (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. @@ -688,11 +687,11 @@ var _ = Describe(`ContextBasedRestrictionsV1 Integration Tests`, func() { Expect(response.StatusCode).To(Equal(201)) Expect(rule).ToNot(BeNil()) - //list rule with service_group_id + //list rule with service_group_id listRulesOptions := &contextbasedrestrictionsv1.ListRulesOptions{ - AccountID: core.StringPtr(testAccountID), + AccountID: core.StringPtr(testAccountID), ServiceGroupID: core.StringPtr("IAM"), - TransactionID: getTransactionID(), + TransactionID: getTransactionID(), } ruleList, response, err := contextBasedRestrictionsService.ListRules(listRulesOptions) @@ -702,7 +701,7 @@ var _ = Describe(`ContextBasedRestrictionsV1 Integration Tests`, func() { Expect(*ruleList.Count).To(Equal(int64(1))) Expect(*ruleList.Rules[0].ID).To(Equal(*rule.ID)) - // cleanup + // cleanup deleteRuleOptions := &contextbasedrestrictionsv1.DeleteRuleOptions{ RuleID: rule.ID, TransactionID: getTransactionID(), @@ -1046,7 +1045,7 @@ var _ = Describe(`ContextBasedRestrictionsV1 Integration Tests`, func() { }) }) - Describe(`ListAvailableServiceOperations - List available service operations`, func() { + Describe(`ListAvailableServiceOperations - List available service operations with Service Name`, func() { BeforeEach(func() { shouldSkipTest() }) @@ -1062,6 +1061,39 @@ var _ = Describe(`ContextBasedRestrictionsV1 Integration Tests`, func() { Expect(operationsList).ToNot(BeNil()) }) }) + Describe(`ListAvailableServiceOperations - List available service operations with Service Group ID`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`ListAvailableServiceOperations(listAvailableServiceOperationsOptions *ListAvailableServiceOperationsOptions)`, func() { + listAvailableServiceOperationsOptions := &contextbasedrestrictionsv1.ListAvailableServiceOperationsOptions{ + ServiceGroupID: core.StringPtr("IAM"), + TransactionID: getTransactionID(), + } + + operationsList, response, err := contextBasedRestrictionsService.ListAvailableServiceOperations(listAvailableServiceOperationsOptions) + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(operationsList).ToNot(BeNil()) + }) + }) + Describe(`ListAvailableServiceOperations - List available service operations with Composite Parent`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`ListAvailableServiceOperations(listAvailableServiceOperationsOptions *ListAvailableServiceOperationsOptions)`, func() { + listAvailableServiceOperationsOptions := &contextbasedrestrictionsv1.ListAvailableServiceOperationsOptions{ + ServiceName: core.StringPtr("iam-access-management"), + ResourceType: core.StringPtr("customRole"), + TransactionID: getTransactionID(), + } + + operationsList, response, err := contextBasedRestrictionsService.ListAvailableServiceOperations(listAvailableServiceOperationsOptions) + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(operationsList).ToNot(BeNil()) + }) + }) // // Cleanup the created zones and rules diff --git a/contextbasedrestrictionsv1/context_based_restrictions_v1_suite_test.go b/contextbasedrestrictionsv1/context_based_restrictions_v1_suite_test.go index b38fac49..a78c70f7 100644 --- a/contextbasedrestrictionsv1/context_based_restrictions_v1_suite_test.go +++ b/contextbasedrestrictionsv1/context_based_restrictions_v1_suite_test.go @@ -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. diff --git a/contextbasedrestrictionsv1/context_based_restrictions_v1_test.go b/contextbasedrestrictionsv1/context_based_restrictions_v1_test.go index bcc71db1..6bf64c21 100644 --- a/contextbasedrestrictionsv1/context_based_restrictions_v1_test.go +++ b/contextbasedrestrictionsv1/context_based_restrictions_v1_test.go @@ -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. @@ -3381,6 +3381,8 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { Expect(req.Header["Transaction-Id"]).ToNot(BeNil()) Expect(req.Header["Transaction-Id"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) Expect(req.URL.Query()["service_name"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["service_group_id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["resource_type"]).To(Equal([]string{"testString"})) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) @@ -3396,9 +3398,11 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Construct an instance of the ListAvailableServiceOperationsOptions model listAvailableServiceOperationsOptionsModel := new(contextbasedrestrictionsv1.ListAvailableServiceOperationsOptions) - listAvailableServiceOperationsOptionsModel.ServiceName = core.StringPtr("testString") listAvailableServiceOperationsOptionsModel.XCorrelationID = core.StringPtr("testString") listAvailableServiceOperationsOptionsModel.TransactionID = core.StringPtr("testString") + listAvailableServiceOperationsOptionsModel.ServiceName = core.StringPtr("testString") + listAvailableServiceOperationsOptionsModel.ServiceGroupID = core.StringPtr("testString") + listAvailableServiceOperationsOptionsModel.ResourceType = core.StringPtr("testString") listAvailableServiceOperationsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response result, response, operationErr := contextBasedRestrictionsService.ListAvailableServiceOperations(listAvailableServiceOperationsOptionsModel) @@ -3434,6 +3438,8 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { Expect(req.Header["Transaction-Id"]).ToNot(BeNil()) Expect(req.Header["Transaction-Id"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) Expect(req.URL.Query()["service_name"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["service_group_id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["resource_type"]).To(Equal([]string{"testString"})) // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) @@ -3454,9 +3460,11 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Construct an instance of the ListAvailableServiceOperationsOptions model listAvailableServiceOperationsOptionsModel := new(contextbasedrestrictionsv1.ListAvailableServiceOperationsOptions) - listAvailableServiceOperationsOptionsModel.ServiceName = core.StringPtr("testString") listAvailableServiceOperationsOptionsModel.XCorrelationID = core.StringPtr("testString") listAvailableServiceOperationsOptionsModel.TransactionID = core.StringPtr("testString") + listAvailableServiceOperationsOptionsModel.ServiceName = core.StringPtr("testString") + listAvailableServiceOperationsOptionsModel.ServiceGroupID = core.StringPtr("testString") + listAvailableServiceOperationsOptionsModel.ResourceType = core.StringPtr("testString") listAvailableServiceOperationsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error @@ -3498,6 +3506,8 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { Expect(req.Header["Transaction-Id"]).ToNot(BeNil()) Expect(req.Header["Transaction-Id"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) Expect(req.URL.Query()["service_name"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["service_group_id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["resource_type"]).To(Equal([]string{"testString"})) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) @@ -3520,9 +3530,11 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Construct an instance of the ListAvailableServiceOperationsOptions model listAvailableServiceOperationsOptionsModel := new(contextbasedrestrictionsv1.ListAvailableServiceOperationsOptions) - listAvailableServiceOperationsOptionsModel.ServiceName = core.StringPtr("testString") listAvailableServiceOperationsOptionsModel.XCorrelationID = core.StringPtr("testString") listAvailableServiceOperationsOptionsModel.TransactionID = core.StringPtr("testString") + listAvailableServiceOperationsOptionsModel.ServiceName = core.StringPtr("testString") + listAvailableServiceOperationsOptionsModel.ServiceGroupID = core.StringPtr("testString") + listAvailableServiceOperationsOptionsModel.ResourceType = core.StringPtr("testString") listAvailableServiceOperationsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -3532,7 +3544,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { Expect(result).ToNot(BeNil()) }) - It(`Invoke ListAvailableServiceOperations with error: Operation validation and request error`, func() { + It(`Invoke ListAvailableServiceOperations with error: Operation request error`, func() { contextBasedRestrictionsService, serviceErr := contextbasedrestrictionsv1.NewContextBasedRestrictionsV1(&contextbasedrestrictionsv1.ContextBasedRestrictionsV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -3542,9 +3554,11 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Construct an instance of the ListAvailableServiceOperationsOptions model listAvailableServiceOperationsOptionsModel := new(contextbasedrestrictionsv1.ListAvailableServiceOperationsOptions) - listAvailableServiceOperationsOptionsModel.ServiceName = core.StringPtr("testString") listAvailableServiceOperationsOptionsModel.XCorrelationID = core.StringPtr("testString") listAvailableServiceOperationsOptionsModel.TransactionID = core.StringPtr("testString") + listAvailableServiceOperationsOptionsModel.ServiceName = core.StringPtr("testString") + listAvailableServiceOperationsOptionsModel.ServiceGroupID = core.StringPtr("testString") + listAvailableServiceOperationsOptionsModel.ResourceType = core.StringPtr("testString") listAvailableServiceOperationsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := contextBasedRestrictionsService.SetServiceURL("") @@ -3554,13 +3568,6 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the ListAvailableServiceOperationsOptions model with no property values - listAvailableServiceOperationsOptionsModelNew := new(contextbasedrestrictionsv1.ListAvailableServiceOperationsOptions) - // Invoke operation with invalid model (negative test) - result, response, operationErr = contextBasedRestrictionsService.ListAvailableServiceOperations(listAvailableServiceOperationsOptionsModelNew) - Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() @@ -3585,9 +3592,11 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Construct an instance of the ListAvailableServiceOperationsOptions model listAvailableServiceOperationsOptionsModel := new(contextbasedrestrictionsv1.ListAvailableServiceOperationsOptions) - listAvailableServiceOperationsOptionsModel.ServiceName = core.StringPtr("testString") listAvailableServiceOperationsOptionsModel.XCorrelationID = core.StringPtr("testString") listAvailableServiceOperationsOptionsModel.TransactionID = core.StringPtr("testString") + listAvailableServiceOperationsOptionsModel.ServiceName = core.StringPtr("testString") + listAvailableServiceOperationsOptionsModel.ServiceGroupID = core.StringPtr("testString") + listAvailableServiceOperationsOptionsModel.ResourceType = core.StringPtr("testString") listAvailableServiceOperationsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation @@ -3785,16 +3794,19 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { }) It(`Invoke NewListAvailableServiceOperationsOptions successfully`, func() { // Construct an instance of the ListAvailableServiceOperationsOptions model - serviceName := "testString" - listAvailableServiceOperationsOptionsModel := contextBasedRestrictionsService.NewListAvailableServiceOperationsOptions(serviceName) - listAvailableServiceOperationsOptionsModel.SetServiceName("testString") + listAvailableServiceOperationsOptionsModel := contextBasedRestrictionsService.NewListAvailableServiceOperationsOptions() listAvailableServiceOperationsOptionsModel.SetXCorrelationID("testString") listAvailableServiceOperationsOptionsModel.SetTransactionID("testString") + listAvailableServiceOperationsOptionsModel.SetServiceName("testString") + listAvailableServiceOperationsOptionsModel.SetServiceGroupID("testString") + listAvailableServiceOperationsOptionsModel.SetResourceType("testString") listAvailableServiceOperationsOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(listAvailableServiceOperationsOptionsModel).ToNot(BeNil()) - Expect(listAvailableServiceOperationsOptionsModel.ServiceName).To(Equal(core.StringPtr("testString"))) Expect(listAvailableServiceOperationsOptionsModel.XCorrelationID).To(Equal(core.StringPtr("testString"))) Expect(listAvailableServiceOperationsOptionsModel.TransactionID).To(Equal(core.StringPtr("testString"))) + Expect(listAvailableServiceOperationsOptionsModel.ServiceName).To(Equal(core.StringPtr("testString"))) + Expect(listAvailableServiceOperationsOptionsModel.ServiceGroupID).To(Equal(core.StringPtr("testString"))) + Expect(listAvailableServiceOperationsOptionsModel.ResourceType).To(Equal(core.StringPtr("testString"))) Expect(listAvailableServiceOperationsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewListAvailableServicerefTargetsOptions successfully`, func() { From d2632f3ab576b16f1206933dd0c2184995e782c4 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 13 Sep 2023 14:33:01 +0000 Subject: [PATCH 23/27] Update version 0.48.1 -> 0.49.0 [skip ci] Signed-off-by: manu.k.m --- .bumpversion.cfg | 2 +- README.md | 4 ++-- common/version.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 692a2fe9..6ad8e7b6 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.48.1 +current_version = 0.49.0 commit = True message = Update version {current_version} -> {new_version} [skip ci] diff --git a/README.md b/README.md index f3fd20b9..49cb767c 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![CLA assistant](https://cla-assistant.io/readme/badge/IBM/platform-services-go-sdk)](https://cla-assistant.io/IBM/platform-services-go-sdk) -# IBM Cloud Platform Services Go SDK Version 0.48.1 +# IBM Cloud Platform Services Go SDK Version 0.49.0 Go client library to interact with various [IBM Cloud Platform Service APIs](https://cloud.ibm.com/docs?tab=api-docs&category=platform_services). @@ -86,7 +86,7 @@ Service Name | Package name * Go version 1.19 or above. ## Installation -The current version of this SDK: 0.48.1 +The current version of this SDK: 0.49.0 ### Go modules If your application uses Go modules for dependency management (recommended), just add an import for each service diff --git a/common/version.go b/common/version.go index 9c000560..d7266a1c 100644 --- a/common/version.go +++ b/common/version.go @@ -17,4 +17,4 @@ package common // Version of the SDK -const Version = "0.48.1" +const Version = "0.49.0" From 37704aeeeccf5317b7f1582cbba0a25c24752fc9 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 13 Sep 2023 14:33:02 +0000 Subject: [PATCH 24/27] chore(release): 0.49.0 release notes [skip ci] # [0.49.0](https://github.com/IBM/platform-services-go-sdk/compare/v0.48.1...v0.49.0) (2023-09-13) ### Features * **Context-Based Restrictions:** add service group support to operations ([#277](https://github.com/IBM/platform-services-go-sdk/issues/277)) ([8ecdfa5](https://github.com/IBM/platform-services-go-sdk/commit/8ecdfa520c0254fbc366b80680b4bc7eab8565d5)) Signed-off-by: manu.k.m --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05b735db..19fa6b42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [0.49.0](https://github.com/IBM/platform-services-go-sdk/compare/v0.48.1...v0.49.0) (2023-09-13) + + +### Features + +* **Context-Based Restrictions:** add service group support to operations ([#277](https://github.com/IBM/platform-services-go-sdk/issues/277)) ([8ecdfa5](https://github.com/IBM/platform-services-go-sdk/commit/8ecdfa520c0254fbc366b80680b4bc7eab8565d5)) + ## [0.48.1](https://github.com/IBM/platform-services-go-sdk/compare/v0.48.0...v0.48.1) (2023-09-05) From fad29524f5239f67e91b77a0365e3184aa1727e3 Mon Sep 17 00:00:00 2001 From: "manu.k.m" Date: Wed, 13 Sep 2023 21:27:11 +0530 Subject: [PATCH 25/27] feat(Usage Reports): add required config properties for examples run Signed-off-by: manu.k.m --- usagereportsv4/usage_reports_v4_examples_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/usagereportsv4/usage_reports_v4_examples_test.go b/usagereportsv4/usage_reports_v4_examples_test.go index b48a757a..4ccdbfd9 100644 --- a/usagereportsv4/usage_reports_v4_examples_test.go +++ b/usagereportsv4/usage_reports_v4_examples_test.go @@ -43,6 +43,10 @@ import ( // USAGE_REPORTS_RESOURCE_GROUP_ID= // USAGE_REPORTS_ORG_ID= // USAGE_REPORTS_BILLING_MONTH= +// USAGE_REPORTS_COS_BUCKET= +// USAGE_REPORTS_COS_LOCATION= +// USAGE_REPORTS_DATE_FROM= +// USAGE_REPORTS_DATE_TO= // // These configuration properties can be exported as environment variables, or stored // in a configuration file and then: From 65607f5cd32b287534931c00e5526b6207a5f807 Mon Sep 17 00:00:00 2001 From: "manu.k.m" Date: Wed, 13 Sep 2023 23:34:15 +0530 Subject: [PATCH 26/27] feat(Usage Reports): revert copyright year change Signed-off-by: manu.k.m --- usagereportsv4/usage_reports_v4_examples_test.go | 2 +- usagereportsv4/usage_reports_v4_integration_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/usagereportsv4/usage_reports_v4_examples_test.go b/usagereportsv4/usage_reports_v4_examples_test.go index 4ccdbfd9..aebd1ef3 100644 --- a/usagereportsv4/usage_reports_v4_examples_test.go +++ b/usagereportsv4/usage_reports_v4_examples_test.go @@ -2,7 +2,7 @@ // +build examples /** - * (C) Copyright IBM Corp. 2023. + * (C) Copyright IBM Corp. 2020. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/usagereportsv4/usage_reports_v4_integration_test.go b/usagereportsv4/usage_reports_v4_integration_test.go index 5f017d73..1f50541e 100644 --- a/usagereportsv4/usage_reports_v4_integration_test.go +++ b/usagereportsv4/usage_reports_v4_integration_test.go @@ -2,7 +2,7 @@ // +build integration /** - * (C) Copyright IBM Corp. 2023. + * (C) Copyright IBM Corp. 2020. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 3a012a9728ecd3b276fae66da41f455bcf9d9e1b Mon Sep 17 00:00:00 2001 From: "manu.k.m" Date: Thu, 14 Sep 2023 07:37:45 +0530 Subject: [PATCH 27/27] feat(Usage Reports): minor changes to usage reports Signed-off-by: manu.k.m --- usagereportsv4/usage_reports_v4_integration_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/usagereportsv4/usage_reports_v4_integration_test.go b/usagereportsv4/usage_reports_v4_integration_test.go index 1f50541e..f06ac1cc 100644 --- a/usagereportsv4/usage_reports_v4_integration_test.go +++ b/usagereportsv4/usage_reports_v4_integration_test.go @@ -379,8 +379,6 @@ var _ = Describe(`UsageReportsV4 Integration Tests`, func() { shouldSkipTest() }) It(`CreateReportsSnapshotConfig(createReportsSnapshotConfigOptions *CreateReportsSnapshotConfigOptions)`, func() { - fmt.Printf("TEST VALUES: %s", cosBucket) - fmt.Printf("TEST VALUES:%s", cosLocation) createReportsSnapshotConfigOptions := &usagereportsv4.CreateReportsSnapshotConfigOptions{ AccountID: &accountID, Interval: core.StringPtr("daily"),