Skip to content

Commit

Permalink
fix(Enterprise Management): re-gen service with latest API
Browse files Browse the repository at this point in the history
  • Loading branch information
padamstx committed Dec 10, 2020
1 parent 20b712c commit 14639de
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 16 deletions.
33 changes: 24 additions & 9 deletions enterprisemanagementv1/enterprise_management_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

/*
* IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-8d569e8f-20201030-111043
* IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-629bbb97-20201207-171303
*/


Expand Down Expand Up @@ -110,6 +110,21 @@ func NewEnterpriseManagementV1(options *EnterpriseManagementV1Options) (service
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 "enterpriseManagement" suitable for processing requests.
func (enterpriseManagement *EnterpriseManagementV1) Clone() *EnterpriseManagementV1 {
if core.IsNil(enterpriseManagement) {
return nil
}
clone := *enterpriseManagement
clone.Service = enterpriseManagement.Service.Clone()
return &clone
}

// SetServiceURL sets the service URL
func (enterpriseManagement *EnterpriseManagementV1) SetServiceURL(url string) error {
return enterpriseManagement.Service.SetServiceURL(url)
Expand Down Expand Up @@ -482,8 +497,8 @@ func (enterpriseManagement *EnterpriseManagementV1) ImportAccountToEnterpriseWit
// CreateAccount : Create a new account in an enterprise
// Create a new account as a part of an existing enterprise. The API creates an account entity under the parent that is
// specified in the payload of the request. The request also takes in the name and the owner of this new account. The
// owner must have a valid IBMid that's registered with {{site.data.keyword.cloud_notm}}, but they don't need to be a
// user in the enterprise account.
// owner must have a valid IBMid that's registered with IBM Cloud, but they don't need to be a user in the enterprise
// account.
func (enterpriseManagement *EnterpriseManagementV1) CreateAccount(createAccountOptions *CreateAccountOptions) (result *CreateAccountResponse, response *core.DetailedResponse, err error) {
return enterpriseManagement.CreateAccountWithContext(context.Background(), createAccountOptions)
}
Expand Down Expand Up @@ -1021,7 +1036,7 @@ type Account struct {
ID *string `json:"id,omitempty"`

// The Cloud Resource Name (CRN) of the account.
Crn *string `json:"crn,omitempty"`
CRN *string `json:"crn,omitempty"`

// The CRN of the parent of the account.
Parent *string `json:"parent,omitempty"`
Expand Down Expand Up @@ -1078,7 +1093,7 @@ func UnmarshalAccount(m map[string]json.RawMessage, result interface{}) (err err
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "crn", &obj.Crn)
err = core.UnmarshalPrimitive(m, "crn", &obj.CRN)
if err != nil {
return
}
Expand Down Expand Up @@ -1151,7 +1166,7 @@ type AccountGroup struct {
ID *string `json:"id,omitempty"`

// The Cloud Resource Name (CRN) of the account group.
Crn *string `json:"crn,omitempty"`
CRN *string `json:"crn,omitempty"`

// The CRN of the parent of the account group.
Parent *string `json:"parent,omitempty"`
Expand Down Expand Up @@ -1202,7 +1217,7 @@ func UnmarshalAccountGroup(m map[string]json.RawMessage, result interface{}) (er
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "crn", &obj.Crn)
err = core.UnmarshalPrimitive(m, "crn", &obj.CRN)
if err != nil {
return
}
Expand Down Expand Up @@ -1487,7 +1502,7 @@ type Enterprise struct {
EnterpriseAccountID *string `json:"enterprise_account_id,omitempty"`

// The Cloud Resource Name (CRN) of the enterprise.
Crn *string `json:"crn,omitempty"`
CRN *string `json:"crn,omitempty"`

// The name of the enterprise.
Name *string `json:"name,omitempty"`
Expand Down Expand Up @@ -1533,7 +1548,7 @@ func UnmarshalEnterprise(m map[string]json.RawMessage, result interface{}) (err
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "crn", &obj.Crn)
err = core.UnmarshalPrimitive(m, "crn", &obj.CRN)
if err != nil {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ var _ = Describe("Enterprise Management - Integration Tests", func() {
Expect(err).To(BeNil())
Expect(detailedResponse.StatusCode).To(Equal(200))

crn = *result.Crn
crn = *result.CRN
})

It("Successfully Update Account group", func() {
Expand Down
96 changes: 90 additions & 6 deletions enterprisemanagementv1/enterprise_management_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ var _ = Describe(`EnterpriseManagementV1`, func() {
Expect(enterpriseManagementService).ToNot(BeNil())
Expect(serviceErr).To(BeNil())
ClearTestEnvironment(testEnvironment)

clone := enterpriseManagementService.Clone()
Expect(clone).ToNot(BeNil())
Expect(clone.Service != enterpriseManagementService.Service).To(BeTrue())
Expect(clone.GetServiceURL()).To(Equal(enterpriseManagementService.GetServiceURL()))
Expect(clone.Service.Options.Authenticator).To(Equal(enterpriseManagementService.Service.Options.Authenticator))
})
It(`Create service client using external config and set url from constructor successfully`, func() {
SetTestEnvironment(testEnvironment)
Expand All @@ -87,6 +93,12 @@ var _ = Describe(`EnterpriseManagementV1`, func() {
Expect(serviceErr).To(BeNil())
Expect(enterpriseManagementService.Service.GetServiceURL()).To(Equal("https://testService/api"))
ClearTestEnvironment(testEnvironment)

clone := enterpriseManagementService.Clone()
Expect(clone).ToNot(BeNil())
Expect(clone.Service != enterpriseManagementService.Service).To(BeTrue())
Expect(clone.GetServiceURL()).To(Equal(enterpriseManagementService.GetServiceURL()))
Expect(clone.Service.Options.Authenticator).To(Equal(enterpriseManagementService.Service.Options.Authenticator))
})
It(`Create service client using external config and set url programatically successfully`, func() {
SetTestEnvironment(testEnvironment)
Expand All @@ -98,6 +110,12 @@ var _ = Describe(`EnterpriseManagementV1`, func() {
Expect(serviceErr).To(BeNil())
Expect(enterpriseManagementService.Service.GetServiceURL()).To(Equal("https://testService/api"))
ClearTestEnvironment(testEnvironment)

clone := enterpriseManagementService.Clone()
Expect(clone).ToNot(BeNil())
Expect(clone.Service != enterpriseManagementService.Service).To(BeTrue())
Expect(clone.GetServiceURL()).To(Equal(enterpriseManagementService.GetServiceURL()))
Expect(clone.Service.Options.Authenticator).To(Equal(enterpriseManagementService.Service.Options.Authenticator))
})
})
Context(`Using external config, construct service client instances with error: Invalid Auth`, func() {
Expand Down Expand Up @@ -135,6 +153,16 @@ var _ = Describe(`EnterpriseManagementV1`, func() {
})
})
})
Describe(`Regional endpoint tests`, func() {
It(`GetServiceURLForRegion(region string)`, func() {
var url string
var err error
url, err = enterprisemanagementv1.GetServiceURLForRegion("INVALID_REGION")
Expect(url).To(BeEmpty())
Expect(err).ToNot(BeNil())
fmt.Fprintf(GinkgoWriter, "Expected error: %s\n", err.Error())
})
})
Describe(`CreateAccountGroup(createAccountGroupOptions *CreateAccountGroupOptions) - Operation response error`, func() {
createAccountGroupPath := "/account-groups"
Context(`Using mock server endpoint`, func() {
Expand Down Expand Up @@ -393,7 +421,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() {
// Set mock response
res.Header().Set("Content-type", "application/json")
res.WriteHeader(200)
fmt.Fprintf(res, "%s", `{"rows_count": 9, "next_url": "NextURL", "resources": [{"url": "URL", "id": "ID", "crn": "Crn", "parent": "Parent", "enterprise_account_id": "EnterpriseAccountID", "enterprise_id": "EnterpriseID", "enterprise_path": "EnterprisePath", "name": "Name", "state": "State", "primary_contact_iam_id": "PrimaryContactIamID", "primary_contact_email": "PrimaryContactEmail", "created_at": "2019-01-01T12:00:00", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00", "updated_by": "UpdatedBy"}]}`)
fmt.Fprintf(res, "%s", `{"rows_count": 9, "next_url": "NextURL", "resources": [{"url": "URL", "id": "ID", "crn": "CRN", "parent": "Parent", "enterprise_account_id": "EnterpriseAccountID", "enterprise_id": "EnterpriseID", "enterprise_path": "EnterprisePath", "name": "Name", "state": "State", "primary_contact_iam_id": "PrimaryContactIamID", "primary_contact_email": "PrimaryContactEmail", "created_at": "2019-01-01T12:00:00", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00", "updated_by": "UpdatedBy"}]}`)
}))
})
It(`Invoke ListAccountGroups successfully`, func() {
Expand Down Expand Up @@ -544,7 +572,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() {
// Set mock response
res.Header().Set("Content-type", "application/json")
res.WriteHeader(200)
fmt.Fprintf(res, "%s", `{"url": "URL", "id": "ID", "crn": "Crn", "parent": "Parent", "enterprise_account_id": "EnterpriseAccountID", "enterprise_id": "EnterpriseID", "enterprise_path": "EnterprisePath", "name": "Name", "state": "State", "primary_contact_iam_id": "PrimaryContactIamID", "primary_contact_email": "PrimaryContactEmail", "created_at": "2019-01-01T12:00:00", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00", "updated_by": "UpdatedBy"}`)
fmt.Fprintf(res, "%s", `{"url": "URL", "id": "ID", "crn": "CRN", "parent": "Parent", "enterprise_account_id": "EnterpriseAccountID", "enterprise_id": "EnterpriseID", "enterprise_path": "EnterprisePath", "name": "Name", "state": "State", "primary_contact_iam_id": "PrimaryContactIamID", "primary_contact_email": "PrimaryContactEmail", "created_at": "2019-01-01T12:00:00", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00", "updated_by": "UpdatedBy"}`)
}))
})
It(`Invoke GetAccountGroup successfully`, func() {
Expand Down Expand Up @@ -769,6 +797,12 @@ var _ = Describe(`EnterpriseManagementV1`, func() {
Expect(enterpriseManagementService).ToNot(BeNil())
Expect(serviceErr).To(BeNil())
ClearTestEnvironment(testEnvironment)

clone := enterpriseManagementService.Clone()
Expect(clone).ToNot(BeNil())
Expect(clone.Service != enterpriseManagementService.Service).To(BeTrue())
Expect(clone.GetServiceURL()).To(Equal(enterpriseManagementService.GetServiceURL()))
Expect(clone.Service.Options.Authenticator).To(Equal(enterpriseManagementService.Service.Options.Authenticator))
})
It(`Create service client using external config and set url from constructor successfully`, func() {
SetTestEnvironment(testEnvironment)
Expand All @@ -779,6 +813,12 @@ var _ = Describe(`EnterpriseManagementV1`, func() {
Expect(serviceErr).To(BeNil())
Expect(enterpriseManagementService.Service.GetServiceURL()).To(Equal("https://testService/api"))
ClearTestEnvironment(testEnvironment)

clone := enterpriseManagementService.Clone()
Expect(clone).ToNot(BeNil())
Expect(clone.Service != enterpriseManagementService.Service).To(BeTrue())
Expect(clone.GetServiceURL()).To(Equal(enterpriseManagementService.GetServiceURL()))
Expect(clone.Service.Options.Authenticator).To(Equal(enterpriseManagementService.Service.Options.Authenticator))
})
It(`Create service client using external config and set url programatically successfully`, func() {
SetTestEnvironment(testEnvironment)
Expand All @@ -790,6 +830,12 @@ var _ = Describe(`EnterpriseManagementV1`, func() {
Expect(serviceErr).To(BeNil())
Expect(enterpriseManagementService.Service.GetServiceURL()).To(Equal("https://testService/api"))
ClearTestEnvironment(testEnvironment)

clone := enterpriseManagementService.Clone()
Expect(clone).ToNot(BeNil())
Expect(clone.Service != enterpriseManagementService.Service).To(BeTrue())
Expect(clone.GetServiceURL()).To(Equal(enterpriseManagementService.GetServiceURL()))
Expect(clone.Service.Options.Authenticator).To(Equal(enterpriseManagementService.Service.Options.Authenticator))
})
})
Context(`Using external config, construct service client instances with error: Invalid Auth`, func() {
Expand Down Expand Up @@ -827,6 +873,16 @@ var _ = Describe(`EnterpriseManagementV1`, func() {
})
})
})
Describe(`Regional endpoint tests`, func() {
It(`GetServiceURLForRegion(region string)`, func() {
var url string
var err error
url, err = enterprisemanagementv1.GetServiceURLForRegion("INVALID_REGION")
Expect(url).To(BeEmpty())
Expect(err).ToNot(BeNil())
fmt.Fprintf(GinkgoWriter, "Expected error: %s\n", err.Error())
})
})

Describe(`ImportAccountToEnterprise(importAccountToEnterpriseOptions *ImportAccountToEnterpriseOptions)`, func() {
importAccountToEnterprisePath := "/enterprises/testString/import/accounts/testString"
Expand Down Expand Up @@ -1183,7 +1239,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() {
// Set mock response
res.Header().Set("Content-type", "application/json")
res.WriteHeader(200)
fmt.Fprintf(res, "%s", `{"rows_count": 9, "next_url": "NextURL", "resources": [{"url": "URL", "id": "ID", "crn": "Crn", "parent": "Parent", "enterprise_account_id": "EnterpriseAccountID", "enterprise_id": "EnterpriseID", "enterprise_path": "EnterprisePath", "name": "Name", "state": "State", "owner_iam_id": "OwnerIamID", "paid": true, "owner_email": "OwnerEmail", "is_enterprise_account": false, "created_at": "2019-01-01T12:00:00", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00", "updated_by": "UpdatedBy"}]}`)
fmt.Fprintf(res, "%s", `{"rows_count": 9, "next_url": "NextURL", "resources": [{"url": "URL", "id": "ID", "crn": "CRN", "parent": "Parent", "enterprise_account_id": "EnterpriseAccountID", "enterprise_id": "EnterpriseID", "enterprise_path": "EnterprisePath", "name": "Name", "state": "State", "owner_iam_id": "OwnerIamID", "paid": true, "owner_email": "OwnerEmail", "is_enterprise_account": false, "created_at": "2019-01-01T12:00:00", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00", "updated_by": "UpdatedBy"}]}`)
}))
})
It(`Invoke ListAccounts successfully`, func() {
Expand Down Expand Up @@ -1334,7 +1390,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() {
// Set mock response
res.Header().Set("Content-type", "application/json")
res.WriteHeader(200)
fmt.Fprintf(res, "%s", `{"url": "URL", "id": "ID", "crn": "Crn", "parent": "Parent", "enterprise_account_id": "EnterpriseAccountID", "enterprise_id": "EnterpriseID", "enterprise_path": "EnterprisePath", "name": "Name", "state": "State", "owner_iam_id": "OwnerIamID", "paid": true, "owner_email": "OwnerEmail", "is_enterprise_account": false, "created_at": "2019-01-01T12:00:00", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00", "updated_by": "UpdatedBy"}`)
fmt.Fprintf(res, "%s", `{"url": "URL", "id": "ID", "crn": "CRN", "parent": "Parent", "enterprise_account_id": "EnterpriseAccountID", "enterprise_id": "EnterpriseID", "enterprise_path": "EnterprisePath", "name": "Name", "state": "State", "owner_iam_id": "OwnerIamID", "paid": true, "owner_email": "OwnerEmail", "is_enterprise_account": false, "created_at": "2019-01-01T12:00:00", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00", "updated_by": "UpdatedBy"}`)
}))
})
It(`Invoke GetAccount successfully`, func() {
Expand Down Expand Up @@ -1557,6 +1613,12 @@ var _ = Describe(`EnterpriseManagementV1`, func() {
Expect(enterpriseManagementService).ToNot(BeNil())
Expect(serviceErr).To(BeNil())
ClearTestEnvironment(testEnvironment)

clone := enterpriseManagementService.Clone()
Expect(clone).ToNot(BeNil())
Expect(clone.Service != enterpriseManagementService.Service).To(BeTrue())
Expect(clone.GetServiceURL()).To(Equal(enterpriseManagementService.GetServiceURL()))
Expect(clone.Service.Options.Authenticator).To(Equal(enterpriseManagementService.Service.Options.Authenticator))
})
It(`Create service client using external config and set url from constructor successfully`, func() {
SetTestEnvironment(testEnvironment)
Expand All @@ -1567,6 +1629,12 @@ var _ = Describe(`EnterpriseManagementV1`, func() {
Expect(serviceErr).To(BeNil())
Expect(enterpriseManagementService.Service.GetServiceURL()).To(Equal("https://testService/api"))
ClearTestEnvironment(testEnvironment)

clone := enterpriseManagementService.Clone()
Expect(clone).ToNot(BeNil())
Expect(clone.Service != enterpriseManagementService.Service).To(BeTrue())
Expect(clone.GetServiceURL()).To(Equal(enterpriseManagementService.GetServiceURL()))
Expect(clone.Service.Options.Authenticator).To(Equal(enterpriseManagementService.Service.Options.Authenticator))
})
It(`Create service client using external config and set url programatically successfully`, func() {
SetTestEnvironment(testEnvironment)
Expand All @@ -1578,6 +1646,12 @@ var _ = Describe(`EnterpriseManagementV1`, func() {
Expect(serviceErr).To(BeNil())
Expect(enterpriseManagementService.Service.GetServiceURL()).To(Equal("https://testService/api"))
ClearTestEnvironment(testEnvironment)

clone := enterpriseManagementService.Clone()
Expect(clone).ToNot(BeNil())
Expect(clone.Service != enterpriseManagementService.Service).To(BeTrue())
Expect(clone.GetServiceURL()).To(Equal(enterpriseManagementService.GetServiceURL()))
Expect(clone.Service.Options.Authenticator).To(Equal(enterpriseManagementService.Service.Options.Authenticator))
})
})
Context(`Using external config, construct service client instances with error: Invalid Auth`, func() {
Expand Down Expand Up @@ -1615,6 +1689,16 @@ var _ = Describe(`EnterpriseManagementV1`, func() {
})
})
})
Describe(`Regional endpoint tests`, func() {
It(`GetServiceURLForRegion(region string)`, func() {
var url string
var err error
url, err = enterprisemanagementv1.GetServiceURLForRegion("INVALID_REGION")
Expect(url).To(BeEmpty())
Expect(err).ToNot(BeNil())
fmt.Fprintf(GinkgoWriter, "Expected error: %s\n", err.Error())
})
})
Describe(`CreateEnterprise(createEnterpriseOptions *CreateEnterpriseOptions) - Operation response error`, func() {
createEnterprisePath := "/enterprises"
Context(`Using mock server endpoint`, func() {
Expand Down Expand Up @@ -1876,7 +1960,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() {
// Set mock response
res.Header().Set("Content-type", "application/json")
res.WriteHeader(200)
fmt.Fprintf(res, "%s", `{"rows_count": 9, "next_url": "NextURL", "resources": [{"url": "URL", "id": "ID", "enterprise_account_id": "EnterpriseAccountID", "crn": "Crn", "name": "Name", "domain": "Domain", "state": "State", "primary_contact_iam_id": "PrimaryContactIamID", "primary_contact_email": "PrimaryContactEmail", "created_at": "2019-01-01T12:00:00", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00", "updated_by": "UpdatedBy"}]}`)
fmt.Fprintf(res, "%s", `{"rows_count": 9, "next_url": "NextURL", "resources": [{"url": "URL", "id": "ID", "enterprise_account_id": "EnterpriseAccountID", "crn": "CRN", "name": "Name", "domain": "Domain", "state": "State", "primary_contact_iam_id": "PrimaryContactIamID", "primary_contact_email": "PrimaryContactEmail", "created_at": "2019-01-01T12:00:00", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00", "updated_by": "UpdatedBy"}]}`)
}))
})
It(`Invoke ListEnterprises successfully`, func() {
Expand Down Expand Up @@ -2027,7 +2111,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() {
// Set mock response
res.Header().Set("Content-type", "application/json")
res.WriteHeader(200)
fmt.Fprintf(res, "%s", `{"url": "URL", "id": "ID", "enterprise_account_id": "EnterpriseAccountID", "crn": "Crn", "name": "Name", "domain": "Domain", "state": "State", "primary_contact_iam_id": "PrimaryContactIamID", "primary_contact_email": "PrimaryContactEmail", "created_at": "2019-01-01T12:00:00", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00", "updated_by": "UpdatedBy"}`)
fmt.Fprintf(res, "%s", `{"url": "URL", "id": "ID", "enterprise_account_id": "EnterpriseAccountID", "crn": "CRN", "name": "Name", "domain": "Domain", "state": "State", "primary_contact_iam_id": "PrimaryContactIamID", "primary_contact_email": "PrimaryContactEmail", "created_at": "2019-01-01T12:00:00", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00", "updated_by": "UpdatedBy"}`)
}))
})
It(`Invoke GetEnterprise successfully`, func() {
Expand Down

0 comments on commit 14639de

Please sign in to comment.