diff --git a/resourcemanagerv2/resource_manager_v2.go b/resourcemanagerv2/resource_manager_v2.go index 06ac2228..fa4a3132 100644 --- a/resourcemanagerv2/resource_manager_v2.go +++ b/resourcemanagerv2/resource_manager_v2.go @@ -15,7 +15,7 @@ */ /* - * IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-8d569e8f-20201030-111043 + * IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-d753183b-20201209-163011 */ @@ -109,6 +109,21 @@ func NewResourceManagerV2(options *ResourceManagerV2Options) (service *ResourceM return } +// GetServiceURLForRegion returns the service URL to be used for the specified region +func GetServiceURLForRegion(region string) (string, error) { + return "", fmt.Errorf("service does not support regional URLs") +} + +// Clone makes a copy of "resourceManager" suitable for processing requests. +func (resourceManager *ResourceManagerV2) Clone() *ResourceManagerV2 { + if core.IsNil(resourceManager) { + return nil + } + clone := *resourceManager + clone.Service = resourceManager.Service.Clone() + return &clone +} + // SetServiceURL sets the service URL func (resourceManager *ResourceManagerV2) SetServiceURL(url string) error { return resourceManager.Service.SetServiceURL(url) @@ -849,7 +864,7 @@ type ResCreateResourceGroup struct { // The full CRN (cloud resource name) associated with the resource group. For more on this format, see [Cloud Resource // Names](https://cloud.ibm.com/docs/resources?topic=resources-crn). - Crn *string `json:"crn,omitempty"` + CRN *string `json:"crn,omitempty"` } @@ -860,7 +875,7 @@ func UnmarshalResCreateResourceGroup(m map[string]json.RawMessage, result interf if err != nil { return } - err = core.UnmarshalPrimitive(m, "crn", &obj.Crn) + err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) if err != nil { return } @@ -875,7 +890,7 @@ type ResourceGroup struct { // The full CRN (cloud resource name) associated with the resource group. For more on this format, see [Cloud Resource // Names](https://cloud.ibm.com/docs/resources?topic=resources-crn). - Crn *string `json:"crn,omitempty"` + CRN *string `json:"crn,omitempty"` // An alpha-numeric value identifying the account ID. AccountID *string `json:"account_id,omitempty"` @@ -919,7 +934,7 @@ func UnmarshalResourceGroup(m map[string]json.RawMessage, result interface{}) (e if err != nil { return } - err = core.UnmarshalPrimitive(m, "crn", &obj.Crn) + err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) if err != nil { return } @@ -999,7 +1014,7 @@ type ResourceQuota struct { // The full CRN (cloud resource name) associated with the quota. For more on this format, see // https://cloud.ibm.com/docs/resources?topic=resources-crn#crn. - Crn *string `json:"crn,omitempty"` + CRN *string `json:"crn,omitempty"` // The limit number of this resource. Limit *float64 `json:"limit,omitempty"` @@ -1017,7 +1032,7 @@ func UnmarshalResourceQuota(m map[string]json.RawMessage, result interface{}) (e if err != nil { return } - err = core.UnmarshalPrimitive(m, "crn", &obj.Crn) + err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) if err != nil { return } diff --git a/resourcemanagerv2/resource_manager_v2_integration_test.go b/resourcemanagerv2/resource_manager_v2_integration_test.go index 58d14349..d207a3bc 100644 --- a/resourcemanagerv2/resource_manager_v2_integration_test.go +++ b/resourcemanagerv2/resource_manager_v2_integration_test.go @@ -113,7 +113,7 @@ var _ = Describe("Resource Manager - Integration Tests", func() { Expect(result.Resources[0]).NotTo(BeNil()) Expect(result.Resources[0].ID).NotTo(BeNil()) Expect(result.Resources[0].Name).NotTo(BeNil()) - Expect(result.Resources[0].Crn).NotTo(BeNil()) + Expect(result.Resources[0].CRN).NotTo(BeNil()) Expect(result.Resources[0].AccountID).NotTo(BeNil()) Expect(result.Resources[0].QuotaID).NotTo(BeNil()) Expect(result.Resources[0].QuotaURL).NotTo(BeNil()) diff --git a/resourcemanagerv2/resource_manager_v2_test.go b/resourcemanagerv2/resource_manager_v2_test.go index ec2a9503..7cfb39e4 100644 --- a/resourcemanagerv2/resource_manager_v2_test.go +++ b/resourcemanagerv2/resource_manager_v2_test.go @@ -77,6 +77,12 @@ var _ = Describe(`ResourceManagerV2`, func() { Expect(resourceManagerService).ToNot(BeNil()) Expect(serviceErr).To(BeNil()) ClearTestEnvironment(testEnvironment) + + clone := resourceManagerService.Clone() + Expect(clone).ToNot(BeNil()) + Expect(clone.Service != resourceManagerService.Service).To(BeTrue()) + Expect(clone.GetServiceURL()).To(Equal(resourceManagerService.GetServiceURL())) + Expect(clone.Service.Options.Authenticator).To(Equal(resourceManagerService.Service.Options.Authenticator)) }) It(`Create service client using external config and set url from constructor successfully`, func() { SetTestEnvironment(testEnvironment) @@ -87,6 +93,12 @@ var _ = Describe(`ResourceManagerV2`, func() { Expect(serviceErr).To(BeNil()) Expect(resourceManagerService.Service.GetServiceURL()).To(Equal("https://testService/api")) ClearTestEnvironment(testEnvironment) + + clone := resourceManagerService.Clone() + Expect(clone).ToNot(BeNil()) + Expect(clone.Service != resourceManagerService.Service).To(BeTrue()) + Expect(clone.GetServiceURL()).To(Equal(resourceManagerService.GetServiceURL())) + Expect(clone.Service.Options.Authenticator).To(Equal(resourceManagerService.Service.Options.Authenticator)) }) It(`Create service client using external config and set url programatically successfully`, func() { SetTestEnvironment(testEnvironment) @@ -98,6 +110,12 @@ var _ = Describe(`ResourceManagerV2`, func() { Expect(serviceErr).To(BeNil()) Expect(resourceManagerService.Service.GetServiceURL()).To(Equal("https://testService/api")) ClearTestEnvironment(testEnvironment) + + clone := resourceManagerService.Clone() + Expect(clone).ToNot(BeNil()) + Expect(clone.Service != resourceManagerService.Service).To(BeTrue()) + Expect(clone.GetServiceURL()).To(Equal(resourceManagerService.GetServiceURL())) + Expect(clone.Service.Options.Authenticator).To(Equal(resourceManagerService.Service.Options.Authenticator)) }) }) Context(`Using external config, construct service client instances with error: Invalid Auth`, func() { @@ -135,6 +153,16 @@ var _ = Describe(`ResourceManagerV2`, func() { }) }) }) + Describe(`Regional endpoint tests`, func() { + It(`GetServiceURLForRegion(region string)`, func() { + var url string + var err error + url, err = resourcemanagerv2.GetServiceURLForRegion("INVALID_REGION") + Expect(url).To(BeEmpty()) + Expect(err).ToNot(BeNil()) + fmt.Fprintf(GinkgoWriter, "Expected error: %s\n", err.Error()) + }) + }) Describe(`ListResourceGroups(listResourceGroupsOptions *ListResourceGroupsOptions) - Operation response error`, func() { listResourceGroupsPath := "/resource_groups" Context(`Using mock server endpoint`, func() { @@ -209,7 +237,7 @@ var _ = Describe(`ResourceManagerV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"resources": [{"id": "ID", "crn": "Crn", "account_id": "AccountID", "name": "Name", "state": "State", "default": false, "quota_id": "QuotaID", "quota_url": "QuotaURL", "payment_methods_url": "PaymentMethodsURL", "resource_linkages": [{"anyKey": "anyValue"}], "teams_url": "TeamsURL", "created_at": "2019-01-01T12:00:00", "updated_at": "2019-01-01T12:00:00"}]}`) + fmt.Fprintf(res, "%s", `{"resources": [{"id": "ID", "crn": "CRN", "account_id": "AccountID", "name": "Name", "state": "State", "default": false, "quota_id": "QuotaID", "quota_url": "QuotaURL", "payment_methods_url": "PaymentMethodsURL", "resource_linkages": [{"anyKey": "anyValue"}], "teams_url": "TeamsURL", "created_at": "2019-01-01T12:00:00", "updated_at": "2019-01-01T12:00:00"}]}`) })) }) It(`Invoke ListResourceGroups successfully`, func() { @@ -373,7 +401,7 @@ var _ = Describe(`ResourceManagerV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"id": "ID", "crn": "Crn"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "crn": "CRN"}`) })) }) It(`Invoke CreateResourceGroup successfully`, func() { @@ -520,7 +548,7 @@ var _ = Describe(`ResourceManagerV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "crn": "Crn", "account_id": "AccountID", "name": "Name", "state": "State", "default": false, "quota_id": "QuotaID", "quota_url": "QuotaURL", "payment_methods_url": "PaymentMethodsURL", "resource_linkages": [{"anyKey": "anyValue"}], "teams_url": "TeamsURL", "created_at": "2019-01-01T12:00:00", "updated_at": "2019-01-01T12:00:00"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "crn": "CRN", "account_id": "AccountID", "name": "Name", "state": "State", "default": false, "quota_id": "QuotaID", "quota_url": "QuotaURL", "payment_methods_url": "PaymentMethodsURL", "resource_linkages": [{"anyKey": "anyValue"}], "teams_url": "TeamsURL", "created_at": "2019-01-01T12:00:00", "updated_at": "2019-01-01T12:00:00"}`) })) }) It(`Invoke GetResourceGroup successfully`, func() { @@ -690,7 +718,7 @@ var _ = Describe(`ResourceManagerV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "crn": "Crn", "account_id": "AccountID", "name": "Name", "state": "State", "default": false, "quota_id": "QuotaID", "quota_url": "QuotaURL", "payment_methods_url": "PaymentMethodsURL", "resource_linkages": [{"anyKey": "anyValue"}], "teams_url": "TeamsURL", "created_at": "2019-01-01T12:00:00", "updated_at": "2019-01-01T12:00:00"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "crn": "CRN", "account_id": "AccountID", "name": "Name", "state": "State", "default": false, "quota_id": "QuotaID", "quota_url": "QuotaURL", "payment_methods_url": "PaymentMethodsURL", "resource_linkages": [{"anyKey": "anyValue"}], "teams_url": "TeamsURL", "created_at": "2019-01-01T12:00:00", "updated_at": "2019-01-01T12:00:00"}`) })) }) It(`Invoke UpdateResourceGroup successfully`, func() { @@ -899,6 +927,12 @@ var _ = Describe(`ResourceManagerV2`, func() { Expect(resourceManagerService).ToNot(BeNil()) Expect(serviceErr).To(BeNil()) ClearTestEnvironment(testEnvironment) + + clone := resourceManagerService.Clone() + Expect(clone).ToNot(BeNil()) + Expect(clone.Service != resourceManagerService.Service).To(BeTrue()) + Expect(clone.GetServiceURL()).To(Equal(resourceManagerService.GetServiceURL())) + Expect(clone.Service.Options.Authenticator).To(Equal(resourceManagerService.Service.Options.Authenticator)) }) It(`Create service client using external config and set url from constructor successfully`, func() { SetTestEnvironment(testEnvironment) @@ -909,6 +943,12 @@ var _ = Describe(`ResourceManagerV2`, func() { Expect(serviceErr).To(BeNil()) Expect(resourceManagerService.Service.GetServiceURL()).To(Equal("https://testService/api")) ClearTestEnvironment(testEnvironment) + + clone := resourceManagerService.Clone() + Expect(clone).ToNot(BeNil()) + Expect(clone.Service != resourceManagerService.Service).To(BeTrue()) + Expect(clone.GetServiceURL()).To(Equal(resourceManagerService.GetServiceURL())) + Expect(clone.Service.Options.Authenticator).To(Equal(resourceManagerService.Service.Options.Authenticator)) }) It(`Create service client using external config and set url programatically successfully`, func() { SetTestEnvironment(testEnvironment) @@ -920,6 +960,12 @@ var _ = Describe(`ResourceManagerV2`, func() { Expect(serviceErr).To(BeNil()) Expect(resourceManagerService.Service.GetServiceURL()).To(Equal("https://testService/api")) ClearTestEnvironment(testEnvironment) + + clone := resourceManagerService.Clone() + Expect(clone).ToNot(BeNil()) + Expect(clone.Service != resourceManagerService.Service).To(BeTrue()) + Expect(clone.GetServiceURL()).To(Equal(resourceManagerService.GetServiceURL())) + Expect(clone.Service.Options.Authenticator).To(Equal(resourceManagerService.Service.Options.Authenticator)) }) }) Context(`Using external config, construct service client instances with error: Invalid Auth`, func() { @@ -957,6 +1003,16 @@ var _ = Describe(`ResourceManagerV2`, func() { }) }) }) + Describe(`Regional endpoint tests`, func() { + It(`GetServiceURLForRegion(region string)`, func() { + var url string + var err error + url, err = resourcemanagerv2.GetServiceURLForRegion("INVALID_REGION") + Expect(url).To(BeEmpty()) + Expect(err).ToNot(BeNil()) + fmt.Fprintf(GinkgoWriter, "Expected error: %s\n", err.Error()) + }) + }) Describe(`ListQuotaDefinitions(listQuotaDefinitionsOptions *ListQuotaDefinitionsOptions) - Operation response error`, func() { listQuotaDefinitionsPath := "/quota_definitions" Context(`Using mock server endpoint`, func() { @@ -1021,7 +1077,7 @@ var _ = Describe(`ResourceManagerV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"resources": [{"id": "ID", "name": "Name", "type": "Type", "number_of_apps": 12, "number_of_service_instances": 24, "default_number_of_instances_per_lite_plan": 35, "instances_per_app": 15, "instance_memory": "InstanceMemory", "total_app_memory": "TotalAppMemory", "vsi_limit": 8, "resource_quotas": [{"_id": "ID", "resource_id": "ResourceID", "crn": "Crn", "limit": 5}], "created_at": "2019-01-01T12:00:00", "updated_at": "2019-01-01T12:00:00"}]}`) + fmt.Fprintf(res, "%s", `{"resources": [{"id": "ID", "name": "Name", "type": "Type", "number_of_apps": 12, "number_of_service_instances": 24, "default_number_of_instances_per_lite_plan": 35, "instances_per_app": 15, "instance_memory": "InstanceMemory", "total_app_memory": "TotalAppMemory", "vsi_limit": 8, "resource_quotas": [{"_id": "ID", "resource_id": "ResourceID", "crn": "CRN", "limit": 5}], "created_at": "2019-01-01T12:00:00", "updated_at": "2019-01-01T12:00:00"}]}`) })) }) It(`Invoke ListQuotaDefinitions successfully`, func() { @@ -1164,7 +1220,7 @@ var _ = Describe(`ResourceManagerV2`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "name": "Name", "type": "Type", "number_of_apps": 12, "number_of_service_instances": 24, "default_number_of_instances_per_lite_plan": 35, "instances_per_app": 15, "instance_memory": "InstanceMemory", "total_app_memory": "TotalAppMemory", "vsi_limit": 8, "resource_quotas": [{"_id": "ID", "resource_id": "ResourceID", "crn": "Crn", "limit": 5}], "created_at": "2019-01-01T12:00:00", "updated_at": "2019-01-01T12:00:00"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "name": "Name", "type": "Type", "number_of_apps": 12, "number_of_service_instances": 24, "default_number_of_instances_per_lite_plan": 35, "instances_per_app": 15, "instance_memory": "InstanceMemory", "total_app_memory": "TotalAppMemory", "vsi_limit": 8, "resource_quotas": [{"_id": "ID", "resource_id": "ResourceID", "crn": "CRN", "limit": 5}], "created_at": "2019-01-01T12:00:00", "updated_at": "2019-01-01T12:00:00"}`) })) }) It(`Invoke GetQuotaDefinition successfully`, func() {