Skip to content

Commit

Permalink
fix(Enterprise Billing Units): 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 c7b2866 commit 20b712c
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 17 deletions.
49 changes: 32 additions & 17 deletions enterprisebillingunitsv1/enterprise_billing_units_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-ef9b3113-20201118-074613
* IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-629bbb97-20201207-171303
*/


Expand Down Expand Up @@ -109,6 +109,21 @@ func NewEnterpriseBillingUnitsV1(options *EnterpriseBillingUnitsV1Options) (serv
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 "enterpriseBillingUnits" suitable for processing requests.
func (enterpriseBillingUnits *EnterpriseBillingUnitsV1) Clone() *EnterpriseBillingUnitsV1 {
if core.IsNil(enterpriseBillingUnits) {
return nil
}
clone := *enterpriseBillingUnits
clone.Service = enterpriseBillingUnits.Service.Clone()
return &clone
}

// SetServiceURL sets the service URL
func (enterpriseBillingUnits *EnterpriseBillingUnitsV1) SetServiceURL(url string) error {
return enterpriseBillingUnits.Service.SetServiceURL(url)
Expand Down Expand Up @@ -431,24 +446,24 @@ type BillingOption struct {
// Constants associated with the BillingOption.State property.
// The state of the billing option. The valid values include `ACTIVE, `SUSPENDED`, and `CANCELED`.
const (
BillingOption_State_Active = "ACTIVE"
BillingOption_State_Canceled = "CANCELED"
BillingOption_State_Suspended = "SUSPENDED"
BillingOptionStateActiveConst = "ACTIVE"
BillingOptionStateCanceledConst = "CANCELED"
BillingOptionStateSuspendedConst = "SUSPENDED"
)

// Constants associated with the BillingOption.Type property.
// The type of billing option. The valid values are `SUBSCRIPTION` and `OFFER`.
const (
BillingOption_Type_Offer = "OFFER"
BillingOption_Type_Subscription = "SUBSCRIPTION"
BillingOptionTypeOfferConst = "OFFER"
BillingOptionTypeSubscriptionConst = "SUBSCRIPTION"
)

// Constants associated with the BillingOption.Category property.
// The category of the billing option. The valid values are `PLATFORM`, `SERVICE`, and `SUPPORT`.
const (
BillingOption_Category_Platform = "PLATFORM"
BillingOption_Category_Service = "SERVICE"
BillingOption_Category_Support = "SUPPORT"
BillingOptionCategoryPlatformConst = "PLATFORM"
BillingOptionCategoryServiceConst = "SERVICE"
BillingOptionCategorySupportConst = "SUPPORT"
)


Expand Down Expand Up @@ -549,7 +564,7 @@ type BillingUnit struct {
ID *string `json:"id,omitempty"`

// The Cloud Resource Name (CRN) of the billing unit, scoped to the enterprise account ID.
Crn *string `json:"crn,omitempty"`
CRN *string `json:"crn,omitempty"`

// The name of the billing unit.
Name *string `json:"name,omitempty"`
Expand Down Expand Up @@ -578,7 +593,7 @@ func UnmarshalBillingUnit(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 Expand Up @@ -664,8 +679,8 @@ type CreditPool struct {
// Constants associated with the CreditPool.Type property.
// The type of credit, either `PLATFORM` or `SUPPORT`.
const (
CreditPool_Type_Platform = "PLATFORM"
CreditPool_Type_Support = "SUPPORT"
CreditPoolTypePlatformConst = "PLATFORM"
CreditPoolTypeSupportConst = "SUPPORT"
)


Expand Down Expand Up @@ -935,10 +950,10 @@ type TermCredits struct {
// The category of the credit pool. The valid values are `PLATFORM`, `OFFER`, or `SERVICE` for platform credit and
// `SUPPORT` for support credit.
const (
TermCredits_Category_Offer = "OFFER"
TermCredits_Category_Platform = "PLATFORM"
TermCredits_Category_Service = "SERVICE"
TermCredits_Category_Support = "SUPPORT"
TermCreditsCategoryOfferConst = "OFFER"
TermCreditsCategoryPlatformConst = "PLATFORM"
TermCreditsCategoryServiceConst = "SERVICE"
TermCreditsCategorySupportConst = "SUPPORT"
)


Expand Down
84 changes: 84 additions & 0 deletions enterprisebillingunitsv1/enterprise_billing_units_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ var _ = Describe(`EnterpriseBillingUnitsV1`, func() {
Expect(enterpriseBillingUnitsService).ToNot(BeNil())
Expect(serviceErr).To(BeNil())
ClearTestEnvironment(testEnvironment)

clone := enterpriseBillingUnitsService.Clone()
Expect(clone).ToNot(BeNil())
Expect(clone.Service != enterpriseBillingUnitsService.Service).To(BeTrue())
Expect(clone.GetServiceURL()).To(Equal(enterpriseBillingUnitsService.GetServiceURL()))
Expect(clone.Service.Options.Authenticator).To(Equal(enterpriseBillingUnitsService.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(`EnterpriseBillingUnitsV1`, func() {
Expect(serviceErr).To(BeNil())
Expect(enterpriseBillingUnitsService.Service.GetServiceURL()).To(Equal("https://testService/api"))
ClearTestEnvironment(testEnvironment)

clone := enterpriseBillingUnitsService.Clone()
Expect(clone).ToNot(BeNil())
Expect(clone.Service != enterpriseBillingUnitsService.Service).To(BeTrue())
Expect(clone.GetServiceURL()).To(Equal(enterpriseBillingUnitsService.GetServiceURL()))
Expect(clone.Service.Options.Authenticator).To(Equal(enterpriseBillingUnitsService.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(`EnterpriseBillingUnitsV1`, func() {
Expect(serviceErr).To(BeNil())
Expect(enterpriseBillingUnitsService.Service.GetServiceURL()).To(Equal("https://testService/api"))
ClearTestEnvironment(testEnvironment)

clone := enterpriseBillingUnitsService.Clone()
Expect(clone).ToNot(BeNil())
Expect(clone.Service != enterpriseBillingUnitsService.Service).To(BeTrue())
Expect(clone.GetServiceURL()).To(Equal(enterpriseBillingUnitsService.GetServiceURL()))
Expect(clone.Service.Options.Authenticator).To(Equal(enterpriseBillingUnitsService.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(`EnterpriseBillingUnitsV1`, func() {
})
})
})
Describe(`Regional endpoint tests`, func() {
It(`GetServiceURLForRegion(region string)`, func() {
var url string
var err error
url, err = enterprisebillingunitsv1.GetServiceURLForRegion("INVALID_REGION")
Expect(url).To(BeEmpty())
Expect(err).ToNot(BeNil())
fmt.Fprintf(GinkgoWriter, "Expected error: %s\n", err.Error())
})
})
Describe(`GetBillingUnit(getBillingUnitOptions *GetBillingUnitOptions) - Operation response error`, func() {
getBillingUnitPath := "/v1/billing-units/testString"
Context(`Using mock server endpoint`, func() {
Expand Down Expand Up @@ -492,6 +520,12 @@ var _ = Describe(`EnterpriseBillingUnitsV1`, func() {
Expect(enterpriseBillingUnitsService).ToNot(BeNil())
Expect(serviceErr).To(BeNil())
ClearTestEnvironment(testEnvironment)

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

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

clone := enterpriseBillingUnitsService.Clone()
Expect(clone).ToNot(BeNil())
Expect(clone.Service != enterpriseBillingUnitsService.Service).To(BeTrue())
Expect(clone.GetServiceURL()).To(Equal(enterpriseBillingUnitsService.GetServiceURL()))
Expect(clone.Service.Options.Authenticator).To(Equal(enterpriseBillingUnitsService.Service.Options.Authenticator))
})
})
Context(`Using external config, construct service client instances with error: Invalid Auth`, func() {
Expand Down Expand Up @@ -550,6 +596,16 @@ var _ = Describe(`EnterpriseBillingUnitsV1`, func() {
})
})
})
Describe(`Regional endpoint tests`, func() {
It(`GetServiceURLForRegion(region string)`, func() {
var url string
var err error
url, err = enterprisebillingunitsv1.GetServiceURLForRegion("INVALID_REGION")
Expect(url).To(BeEmpty())
Expect(err).ToNot(BeNil())
fmt.Fprintf(GinkgoWriter, "Expected error: %s\n", err.Error())
})
})
Describe(`ListBillingOptions(listBillingOptionsOptions *ListBillingOptionsOptions) - Operation response error`, func() {
listBillingOptionsPath := "/v1/billing-options"
Context(`Using mock server endpoint`, func() {
Expand Down Expand Up @@ -748,6 +804,12 @@ var _ = Describe(`EnterpriseBillingUnitsV1`, func() {
Expect(enterpriseBillingUnitsService).ToNot(BeNil())
Expect(serviceErr).To(BeNil())
ClearTestEnvironment(testEnvironment)

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

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

clone := enterpriseBillingUnitsService.Clone()
Expect(clone).ToNot(BeNil())
Expect(clone.Service != enterpriseBillingUnitsService.Service).To(BeTrue())
Expect(clone.GetServiceURL()).To(Equal(enterpriseBillingUnitsService.GetServiceURL()))
Expect(clone.Service.Options.Authenticator).To(Equal(enterpriseBillingUnitsService.Service.Options.Authenticator))
})
})
Context(`Using external config, construct service client instances with error: Invalid Auth`, func() {
Expand Down Expand Up @@ -806,6 +880,16 @@ var _ = Describe(`EnterpriseBillingUnitsV1`, func() {
})
})
})
Describe(`Regional endpoint tests`, func() {
It(`GetServiceURLForRegion(region string)`, func() {
var url string
var err error
url, err = enterprisebillingunitsv1.GetServiceURLForRegion("INVALID_REGION")
Expect(url).To(BeEmpty())
Expect(err).ToNot(BeNil())
fmt.Fprintf(GinkgoWriter, "Expected error: %s\n", err.Error())
})
})
Describe(`GetCreditPools(getCreditPoolsOptions *GetCreditPoolsOptions) - Operation response error`, func() {
getCreditPoolsPath := "/v1/credit-pools"
Context(`Using mock server endpoint`, func() {
Expand Down

0 comments on commit 20b712c

Please sign in to comment.