Skip to content

Commit

Permalink
fix(Enterprise Usage Reports): 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 14639de commit 8174e10
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 8 deletions.
31 changes: 23 additions & 8 deletions enterpriseusagereportsv1/enterprise_usage_reports_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-20201101-090040
* IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-629bbb97-20201207-171303
*/


Expand Down Expand Up @@ -108,6 +108,21 @@ func NewEnterpriseUsageReportsV1(options *EnterpriseUsageReportsV1Options) (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 "enterpriseUsageReports" suitable for processing requests.
func (enterpriseUsageReports *EnterpriseUsageReportsV1) Clone() *EnterpriseUsageReportsV1 {
if core.IsNil(enterpriseUsageReports) {
return nil
}
clone := *enterpriseUsageReports
clone.Service = enterpriseUsageReports.Service.Clone()
return &clone
}

// SetServiceURL sets the service URL
func (enterpriseUsageReports *EnterpriseUsageReportsV1) SetServiceURL(url string) error {
return enterpriseUsageReports.Service.SetServiceURL(url)
Expand Down Expand Up @@ -555,7 +570,7 @@ type ResourceUsageReport struct {
EntityType *string `json:"entity_type" validate:"required"`

// The Cloud Resource Name (CRN) of the entity towards which the resource usages were rolled up.
EntityCrn *string `json:"entity_crn" validate:"required"`
EntityCRN *string `json:"entity_crn" validate:"required"`

// A user-defined name for the entity, such as the enterprise name or account group name.
EntityName *string `json:"entity_name" validate:"required"`
Expand All @@ -564,7 +579,7 @@ type ResourceUsageReport struct {
BillingUnitID *string `json:"billing_unit_id" validate:"required"`

// The CRN of the billing unit.
BillingUnitCrn *string `json:"billing_unit_crn" validate:"required"`
BillingUnitCRN *string `json:"billing_unit_crn" validate:"required"`

// The name of the billing unit.
BillingUnitName *string `json:"billing_unit_name" validate:"required"`
Expand Down Expand Up @@ -597,9 +612,9 @@ type ResourceUsageReport struct {
// Constants associated with the ResourceUsageReport.EntityType property.
// The entity type.
const (
ResourceUsageReport_EntityType_Account = "account"
ResourceUsageReport_EntityType_AccountGroup = "account-group"
ResourceUsageReport_EntityType_Enterprise = "enterprise"
ResourceUsageReportEntityTypeAccountConst = "account"
ResourceUsageReportEntityTypeAccountGroupConst = "account-group"
ResourceUsageReportEntityTypeEnterpriseConst = "enterprise"
)


Expand All @@ -614,7 +629,7 @@ func UnmarshalResourceUsageReport(m map[string]json.RawMessage, result interface
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "entity_crn", &obj.EntityCrn)
err = core.UnmarshalPrimitive(m, "entity_crn", &obj.EntityCRN)
if err != nil {
return
}
Expand All @@ -626,7 +641,7 @@ func UnmarshalResourceUsageReport(m map[string]json.RawMessage, result interface
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "billing_unit_crn", &obj.BillingUnitCrn)
err = core.UnmarshalPrimitive(m, "billing_unit_crn", &obj.BillingUnitCRN)
if err != nil {
return
}
Expand Down
28 changes: 28 additions & 0 deletions enterpriseusagereportsv1/enterprise_usage_reports_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ var _ = Describe(`EnterpriseUsageReportsV1`, func() {
Expect(enterpriseUsageReportsService).ToNot(BeNil())
Expect(serviceErr).To(BeNil())
ClearTestEnvironment(testEnvironment)

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

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

clone := enterpriseUsageReportsService.Clone()
Expect(clone).ToNot(BeNil())
Expect(clone.Service != enterpriseUsageReportsService.Service).To(BeTrue())
Expect(clone.GetServiceURL()).To(Equal(enterpriseUsageReportsService.GetServiceURL()))
Expect(clone.Service.Options.Authenticator).To(Equal(enterpriseUsageReportsService.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(`EnterpriseUsageReportsV1`, func() {
})
})
})
Describe(`Regional endpoint tests`, func() {
It(`GetServiceURLForRegion(region string)`, func() {
var url string
var err error
url, err = enterpriseusagereportsv1.GetServiceURLForRegion("INVALID_REGION")
Expect(url).To(BeEmpty())
Expect(err).ToNot(BeNil())
fmt.Fprintf(GinkgoWriter, "Expected error: %s\n", err.Error())
})
})
Describe(`GetResourceUsageReport(getResourceUsageReportOptions *GetResourceUsageReportOptions) - Operation response error`, func() {
getResourceUsageReportPath := "/v1/resource-usage-reports"
Context(`Using mock server endpoint`, func() {
Expand Down

0 comments on commit 8174e10

Please sign in to comment.