Skip to content

Commit

Permalink
fix(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 11, 2020
1 parent ebeaea8 commit 548ddbd
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
17 changes: 16 additions & 1 deletion usagereportsv4/usage_reports_v4.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-d753183b-20201209-163011
*/


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

// SetServiceURL sets the service URL
func (usageReports *UsageReportsV4) SetServiceURL(url string) error {
return usageReports.Service.SetServiceURL(url)
Expand Down
28 changes: 28 additions & 0 deletions usagereportsv4/usage_reports_v4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ var _ = Describe(`UsageReportsV4`, func() {
Expect(usageReportsService).ToNot(BeNil())
Expect(serviceErr).To(BeNil())
ClearTestEnvironment(testEnvironment)

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

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

clone := usageReportsService.Clone()
Expect(clone).ToNot(BeNil())
Expect(clone.Service != usageReportsService.Service).To(BeTrue())
Expect(clone.GetServiceURL()).To(Equal(usageReportsService.GetServiceURL()))
Expect(clone.Service.Options.Authenticator).To(Equal(usageReportsService.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(`UsageReportsV4`, func() {
})
})
})
Describe(`Regional endpoint tests`, func() {
It(`GetServiceURLForRegion(region string)`, func() {
var url string
var err error
url, err = usagereportsv4.GetServiceURLForRegion("INVALID_REGION")
Expect(url).To(BeEmpty())
Expect(err).ToNot(BeNil())
fmt.Fprintf(GinkgoWriter, "Expected error: %s\n", err.Error())
})
})
Describe(`GetAccountSummary(getAccountSummaryOptions *GetAccountSummaryOptions) - Operation response error`, func() {
getAccountSummaryPath := "/v4/accounts/testString/summary/testString"
Context(`Using mock server endpoint`, func() {
Expand Down

0 comments on commit 548ddbd

Please sign in to comment.