Skip to content

Commit

Permalink
fix: regen services with latest SDK generator
Browse files Browse the repository at this point in the history
  • Loading branch information
padamstx committed Oct 30, 2020
1 parent 67a5a91 commit 5f02911
Show file tree
Hide file tree
Showing 30 changed files with 19,724 additions and 5,619 deletions.
122 changes: 112 additions & 10 deletions casemanagementv1/case_management_v1.go

Large diffs are not rendered by default.

536 changes: 530 additions & 6 deletions casemanagementv1/case_management_v1_test.go

Large diffs are not rendered by default.

9,474 changes: 6,130 additions & 3,344 deletions catalogmanagementv1/catalog_management_v1.go

Large diffs are not rendered by default.

8,575 changes: 6,369 additions & 2,206 deletions catalogmanagementv1/catalog_management_v1_test.go

Large diffs are not rendered by default.

106 changes: 105 additions & 1 deletion configurationgovernancev1/configuration_governance_v1.go

Large diffs are not rendered by default.

401 changes: 401 additions & 0 deletions configurationgovernancev1/configuration_governance_v1_test.go

Large diffs are not rendered by default.

127 changes: 126 additions & 1 deletion enterprisemanagementv1/enterprise_management_v1.go

Large diffs are not rendered by default.

505 changes: 505 additions & 0 deletions enterprisemanagementv1/enterprise_management_v1_test.go

Large diffs are not rendered by default.

141 changes: 140 additions & 1 deletion globalcatalogv1/global_catalog_v1.go

Large diffs are not rendered by default.

498 changes: 498 additions & 0 deletions globalcatalogv1/global_catalog_v1_test.go

Large diffs are not rendered by default.

50 changes: 49 additions & 1 deletion globalsearchv2/global_search_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@
*/

/*
* IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-ef5e13c2-20200915-144510
* IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-8d569e8f-20201030-111043
*/


// Package globalsearchv2 : Operations and models for the GlobalSearchV2 service
package globalsearchv2

import (
"context"
"encoding/json"
"fmt"
"github.com/IBM/go-sdk-core/v4/core"
common "github.com/IBM/platform-services-go-sdk/common"
"net/http"
"reflect"
"strings"
"time"
)

// GlobalSearchV2 : Search for resources with the global and shared resource properties repository integrated in the IBM
Expand Down Expand Up @@ -117,6 +120,37 @@ func (globalSearch *GlobalSearchV2) SetServiceURL(url string) error {
return globalSearch.Service.SetServiceURL(url)
}

// GetServiceURL returns the service URL
func (globalSearch *GlobalSearchV2) GetServiceURL() string {
return globalSearch.Service.GetServiceURL()
}

// SetDefaultHeaders sets HTTP headers to be sent in every request
func (globalSearch *GlobalSearchV2) SetDefaultHeaders(headers http.Header) {
globalSearch.Service.SetDefaultHeaders(headers)
}

// SetEnableGzipCompression sets the service's EnableGzipCompression field
func (globalSearch *GlobalSearchV2) SetEnableGzipCompression(enableGzip bool) {
globalSearch.Service.SetEnableGzipCompression(enableGzip)
}

// GetEnableGzipCompression returns the service's EnableGzipCompression field
func (globalSearch *GlobalSearchV2) GetEnableGzipCompression() bool {
return globalSearch.Service.GetEnableGzipCompression()
}

// EnableRetries enables automatic retries for requests invoked for this service instance.
// If either parameter is specified as 0, then a default value is used instead.
func (globalSearch *GlobalSearchV2) EnableRetries(maxRetries int, maxRetryInterval time.Duration) {
globalSearch.Service.EnableRetries(maxRetries, maxRetryInterval)
}

// DisableRetries disables automatic retries for requests invoked for this service instance.
func (globalSearch *GlobalSearchV2) DisableRetries() {
globalSearch.Service.DisableRetries()
}

// Search : Find instances of resources
// 'Find cloud foundry resources, resource controlled enabled resources, or storage and network resources running on
// classic infrastructure in a specific account ID. You can apply query strings if necessary. To filter results, you can
Expand All @@ -130,6 +164,11 @@ func (globalSearch *GlobalSearchV2) SetServiceURL(url string) error {
// returned for every resources are: "crn", "name", "family", "type", "account_id". You can specify the subset of the
// fields you want in your request.''.
func (globalSearch *GlobalSearchV2) Search(searchOptions *SearchOptions) (result *ScanResult, response *core.DetailedResponse, err error) {
return globalSearch.SearchWithContext(context.Background(), searchOptions)
}

// SearchWithContext is an alternate form of the Search method which supports a Context parameter
func (globalSearch *GlobalSearchV2) SearchWithContext(ctx context.Context, searchOptions *SearchOptions) (result *ScanResult, response *core.DetailedResponse, err error) {
err = core.ValidateNotNil(searchOptions, "searchOptions cannot be nil")
if err != nil {
return
Expand All @@ -140,6 +179,8 @@ func (globalSearch *GlobalSearchV2) Search(searchOptions *SearchOptions) (result
}

builder := core.NewRequestBuilder(core.POST)
builder = builder.WithContext(ctx)
builder.EnableGzipCompression = globalSearch.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(globalSearch.Service.Options.URL, `/v3/resources/search`, nil)
if err != nil {
return
Expand Down Expand Up @@ -209,12 +250,19 @@ func (globalSearch *GlobalSearchV2) Search(searchOptions *SearchOptions) (result
// GetSupportedTypes : Get all supported resource types
// Retrieves a list of all the resource types supported by GhoST.
func (globalSearch *GlobalSearchV2) GetSupportedTypes(getSupportedTypesOptions *GetSupportedTypesOptions) (result *SupportedTypesList, response *core.DetailedResponse, err error) {
return globalSearch.GetSupportedTypesWithContext(context.Background(), getSupportedTypesOptions)
}

// GetSupportedTypesWithContext is an alternate form of the GetSupportedTypes method which supports a Context parameter
func (globalSearch *GlobalSearchV2) GetSupportedTypesWithContext(ctx context.Context, getSupportedTypesOptions *GetSupportedTypesOptions) (result *SupportedTypesList, response *core.DetailedResponse, err error) {
err = core.ValidateStruct(getSupportedTypesOptions, "getSupportedTypesOptions")
if err != nil {
return
}

builder := core.NewRequestBuilder(core.GET)
builder = builder.WithContext(ctx)
builder.EnableGzipCompression = globalSearch.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(globalSearch.Service.Options.URL, `/v2/resources/supported_types`, nil)
if err != nil {
return
Expand Down
97 changes: 97 additions & 0 deletions globalsearchv2/global_search_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package globalsearchv2_test

import (
"bytes"
"context"
"fmt"
"github.com/IBM/go-sdk-core/v4/core"
"github.com/IBM/platform-services-go-sdk/globalsearchv2"
Expand Down Expand Up @@ -181,6 +182,13 @@ var _ = Describe(`GlobalSearchV2`, func() {
Expect(operationErr).ToNot(BeNil())
Expect(response).ToNot(BeNil())
Expect(result).To(BeNil())

// Enable retries and test again
globalSearchService.EnableRetries(0, 0)
result, response, operationErr = globalSearchService.Search(searchOptionsModel)
Expect(operationErr).ToNot(BeNil())
Expect(response).ToNot(BeNil())
Expect(result).To(BeNil())
})
AfterEach(func() {
testServer.Close()
Expand All @@ -190,14 +198,33 @@ var _ = Describe(`GlobalSearchV2`, func() {

Describe(`Search(searchOptions *SearchOptions)`, func() {
searchPath := "/v3/resources/search"
var serverSleepTime time.Duration
Context(`Using mock server endpoint`, func() {
BeforeEach(func() {
serverSleepTime = 0
testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
defer GinkgoRecover()

// Verify the contents of the request
Expect(req.URL.EscapedPath()).To(Equal(searchPath))
Expect(req.Method).To(Equal("POST"))

// For gzip-disabled operation, verify Content-Encoding is not set.
Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())

// If there is a body, then make sure we can read it
bodyBuf := new(bytes.Buffer)
if req.Header.Get("Content-Encoding") == "gzip" {
body, err := core.NewGzipDecompressionReader(req.Body)
Expect(err).To(BeNil())
_, err = bodyBuf.ReadFrom(body)
Expect(err).To(BeNil())
} else {
_, err := bodyBuf.ReadFrom(req.Body)
Expect(err).To(BeNil())
}
fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())

Expect(req.Header["Transaction-Id"]).ToNot(BeNil())
Expect(req.Header["Transaction-Id"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
Expect(req.URL.Query()["account_id"]).To(Equal([]string{"testString"}))
Expand All @@ -206,6 +233,10 @@ var _ = Describe(`GlobalSearchV2`, func() {

Expect(req.URL.Query()["timeout"]).To(Equal([]string{fmt.Sprint(int64(0))}))

// Sleep a short time to support a timeout test
time.Sleep(serverSleepTime)

// Set mock response
res.Header().Set("Content-type", "application/json")
res.WriteHeader(200)
fmt.Fprintf(res, "%s", `{"search_cursor": "SearchCursor", "limit": 5, "items": [{"crn": "Crn"}]}`)
Expand All @@ -218,6 +249,7 @@ var _ = Describe(`GlobalSearchV2`, func() {
})
Expect(serviceErr).To(BeNil())
Expect(globalSearchService).ToNot(BeNil())
globalSearchService.EnableRetries(0, 0)

// Invoke operation with nil options model (negative test)
result, response, operationErr := globalSearchService.Search(nil)
Expand All @@ -242,6 +274,31 @@ var _ = Describe(`GlobalSearchV2`, func() {
Expect(operationErr).To(BeNil())
Expect(response).ToNot(BeNil())
Expect(result).ToNot(BeNil())

// Invoke operation with a Context to test a timeout error
ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
defer cancelFunc()
serverSleepTime = 100 * time.Millisecond
_, _, operationErr = globalSearchService.SearchWithContext(ctx, searchOptionsModel)
Expect(operationErr).ToNot(BeNil())
Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
serverSleepTime = time.Duration(0)

// Disable retries and test again
globalSearchService.DisableRetries()
result, response, operationErr = globalSearchService.Search(searchOptionsModel)
Expect(operationErr).To(BeNil())
Expect(response).ToNot(BeNil())
Expect(result).ToNot(BeNil())

// Re-test the timeout error with retries disabled
ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
defer cancelFunc2()
serverSleepTime = 100 * time.Millisecond
_, _, operationErr = globalSearchService.SearchWithContext(ctx, searchOptionsModel)
Expect(operationErr).ToNot(BeNil())
Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
serverSleepTime = time.Duration(0)
})
It(`Invoke Search with error: Operation request error`, func() {
globalSearchService, serviceErr := globalsearchv2.NewGlobalSearchV2(&globalsearchv2.GlobalSearchV2Options{
Expand Down Expand Up @@ -407,6 +464,13 @@ var _ = Describe(`GlobalSearchV2`, func() {
Expect(operationErr).ToNot(BeNil())
Expect(response).ToNot(BeNil())
Expect(result).To(BeNil())

// Enable retries and test again
globalSearchService.EnableRetries(0, 0)
result, response, operationErr = globalSearchService.GetSupportedTypes(getSupportedTypesOptionsModel)
Expect(operationErr).ToNot(BeNil())
Expect(response).ToNot(BeNil())
Expect(result).To(BeNil())
})
AfterEach(func() {
testServer.Close()
Expand All @@ -416,14 +480,21 @@ var _ = Describe(`GlobalSearchV2`, func() {

Describe(`GetSupportedTypes(getSupportedTypesOptions *GetSupportedTypesOptions)`, func() {
getSupportedTypesPath := "/v2/resources/supported_types"
var serverSleepTime time.Duration
Context(`Using mock server endpoint`, func() {
BeforeEach(func() {
serverSleepTime = 0
testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
defer GinkgoRecover()

// Verify the contents of the request
Expect(req.URL.EscapedPath()).To(Equal(getSupportedTypesPath))
Expect(req.Method).To(Equal("GET"))

// Sleep a short time to support a timeout test
time.Sleep(serverSleepTime)

// Set mock response
res.Header().Set("Content-type", "application/json")
res.WriteHeader(200)
fmt.Fprintf(res, "%s", `{"supported_types": ["SupportedTypes"]}`)
Expand All @@ -436,6 +507,7 @@ var _ = Describe(`GlobalSearchV2`, func() {
})
Expect(serviceErr).To(BeNil())
Expect(globalSearchService).ToNot(BeNil())
globalSearchService.EnableRetries(0, 0)

// Invoke operation with nil options model (negative test)
result, response, operationErr := globalSearchService.GetSupportedTypes(nil)
Expand All @@ -452,6 +524,31 @@ var _ = Describe(`GlobalSearchV2`, func() {
Expect(operationErr).To(BeNil())
Expect(response).ToNot(BeNil())
Expect(result).ToNot(BeNil())

// Invoke operation with a Context to test a timeout error
ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
defer cancelFunc()
serverSleepTime = 100 * time.Millisecond
_, _, operationErr = globalSearchService.GetSupportedTypesWithContext(ctx, getSupportedTypesOptionsModel)
Expect(operationErr).ToNot(BeNil())
Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
serverSleepTime = time.Duration(0)

// Disable retries and test again
globalSearchService.DisableRetries()
result, response, operationErr = globalSearchService.GetSupportedTypes(getSupportedTypesOptionsModel)
Expect(operationErr).To(BeNil())
Expect(response).ToNot(BeNil())
Expect(result).ToNot(BeNil())

// Re-test the timeout error with retries disabled
ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
defer cancelFunc2()
serverSleepTime = 100 * time.Millisecond
_, _, operationErr = globalSearchService.GetSupportedTypesWithContext(ctx, getSupportedTypesOptionsModel)
Expect(operationErr).ToNot(BeNil())
Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
serverSleepTime = time.Duration(0)
})
It(`Invoke GetSupportedTypes with error: Operation request error`, func() {
globalSearchService, serviceErr := globalsearchv2.NewGlobalSearchV2(&globalsearchv2.GlobalSearchV2Options{
Expand Down

0 comments on commit 5f02911

Please sign in to comment.