Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Global Search & Tagging): re-gen services with latest API definition #315

Merged
merged 4 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 41 additions & 26 deletions globalsearchv2/global_search_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

/*
* IBM OpenAPI SDK Code Generator Version: 3.86.0-bc6f14b3-20240221-193958
* IBM OpenAPI SDK Code Generator Version: 3.87.0-91c7c775-20240320-213027
*/

// Package globalsearchv2 : Operations and models for the GlobalSearchV2 service
Expand All @@ -37,10 +37,10 @@ import (
// GlobalSearchV2 : Search for resources with the global and shared resource properties repository that is integrated in
// the IBM Cloud platform. The search repository stores and searches cloud resources attributes, which categorize or
// classify resources. A resource is a physical or logical component that can be created or reserved for an application
// or service instance. They are owned by resource providers, such as Cloud Foundry, IBM Kubernetes Service, or resource
// controller in IBM Cloud. Resources are uniquely identified by a Cloud Resource Name (CRN) or by an IMS ID. The
// properties of a resource include tags and system properties. Both properties are defined in an IBM Cloud billing
// account, and span across many regions.
// or service instance. They are owned by resource providers, such as IBM Kubernetes Service, or resource controller in
// IBM Cloud. Resources are uniquely identified by a Cloud Resource Name (CRN) or by an IMS ID. The properties of a
// resource include tags and system properties. Both properties are defined in an IBM Cloud billing account, and span
// across many regions.
//
// API Version: 2.0.1
type GlobalSearchV2 struct {
Expand Down Expand Up @@ -69,22 +69,26 @@ func NewGlobalSearchV2UsingExternalConfig(options *GlobalSearchV2Options) (globa
if options.Authenticator == nil {
options.Authenticator, err = core.GetAuthenticatorFromEnvironment(options.ServiceName)
if err != nil {
err = core.SDKErrorf(err, "", "env-auth-error", common.GetComponentInfo())
return
}
}

globalSearch, err = NewGlobalSearchV2(options)
err = core.RepurposeSDKProblem(err, "new-client-error")
if err != nil {
return
}

err = globalSearch.Service.ConfigureService(options.ServiceName)
if err != nil {
err = core.SDKErrorf(err, "", "client-config-error", common.GetComponentInfo())
return
}

if options.URL != "" {
err = globalSearch.Service.SetServiceURL(options.URL)
err = core.RepurposeSDKProblem(err, "url-set-error")
}
return
}
Expand All @@ -98,12 +102,14 @@ func NewGlobalSearchV2(options *GlobalSearchV2Options) (service *GlobalSearchV2,

baseService, err := core.NewBaseService(serviceOptions)
if err != nil {
err = core.SDKErrorf(err, "", "new-base-error", common.GetComponentInfo())
return
}

if options.URL != "" {
err = baseService.SetServiceURL(options.URL)
if err != nil {
err = core.SDKErrorf(err, "", "set-url-error", common.GetComponentInfo())
return
}
}
Expand All @@ -117,7 +123,7 @@ func NewGlobalSearchV2(options *GlobalSearchV2Options) (service *GlobalSearchV2,

// 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")
return "", core.SDKErrorf(nil, "service does not support regional URLs", "no-regional-support", common.GetComponentInfo())
}

// Clone makes a copy of "globalSearch" suitable for processing requests.
Expand All @@ -132,7 +138,11 @@ func (globalSearch *GlobalSearchV2) Clone() *GlobalSearchV2 {

// SetServiceURL sets the service URL
func (globalSearch *GlobalSearchV2) SetServiceURL(url string) error {
return globalSearch.Service.SetServiceURL(url)
err := globalSearch.Service.SetServiceURL(url)
if err != nil {
err = core.SDKErrorf(err, "", "url-set-error", common.GetComponentInfo())
}
return err
}

// GetServiceURL returns the service URL
Expand Down Expand Up @@ -167,8 +177,8 @@ func (globalSearch *GlobalSearchV2) DisableRetries() {
}

// Search : Find instances of resources (v3)
// Find Cloud Foundry resources, IAM-enabled resources, or storage and network resources that run on classic
// infrastructure in a specific account ID. You can apply query strings if necessary.
// Find IAM-enabled resources or storage and network resources that run on classic infrastructure in a specific account
// ID. You can apply query strings if necessary.
//
// To filter results, you can insert a string by using the Lucene syntax and the query string is parsed into a series of
// terms and operators. A term can be a single word or a phrase, in which case the search is performed for all the
Expand All @@ -184,17 +194,21 @@ func (globalSearch *GlobalSearchV2) DisableRetries() {
// `family`, `type`, and `account_id`. You can specify the subset of the fields you want in your request using the
// `fields` request body attribute. Set `"fields": ["*"]` to discover the set of fields which are available to request.
func (globalSearch *GlobalSearchV2) Search(searchOptions *SearchOptions) (result *ScanResult, response *core.DetailedResponse, err error) {
return globalSearch.SearchWithContext(context.Background(), searchOptions)
result, response, err = globalSearch.SearchWithContext(context.Background(), searchOptions)
err = core.RepurposeSDKProblem(err, "")
return
}

// 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 {
err = core.SDKErrorf(err, "", "unexpected-nil-param", common.GetComponentInfo())
return
}
err = core.ValidateStruct(searchOptions, "searchOptions")
if err != nil {
err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo())
return
}

Expand All @@ -203,6 +217,7 @@ func (globalSearch *GlobalSearchV2) SearchWithContext(ctx context.Context, searc
builder.EnableGzipCompression = globalSearch.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(globalSearch.Service.Options.URL, `/v3/resources/search`, nil)
if err != nil {
err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo())
return
}

Expand All @@ -222,9 +237,6 @@ func (globalSearch *GlobalSearchV2) SearchWithContext(ctx context.Context, searc
if searchOptions.XCorrelationID != nil {
builder.AddHeader("x-correlation-id", fmt.Sprint(*searchOptions.XCorrelationID))
}
if searchOptions.TransactionID != nil {
builder.AddHeader("transaction-id", fmt.Sprint(*searchOptions.TransactionID))
}

if searchOptions.AccountID != nil {
builder.AddQuery("account_id", fmt.Sprint(*searchOptions.AccountID))
Expand Down Expand Up @@ -266,29 +278,37 @@ func (globalSearch *GlobalSearchV2) SearchWithContext(ctx context.Context, searc
}
_, err = builder.SetBodyContentJSON(body)
if err != nil {
err = core.SDKErrorf(err, "", "set-json-body-error", common.GetComponentInfo())
return
}

request, err := builder.Build()
if err != nil {
err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo())
return
}

var rawResponse map[string]json.RawMessage
response, err = globalSearch.Service.Request(request, &rawResponse)
if err != nil {
core.EnrichHTTPProblem(err, "search", getServiceComponentInfo())
err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo())
return
}
if rawResponse != nil {
err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalScanResult)
if err != nil {
err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo())
return
}
response.Result = result
}

return
}
func getServiceComponentInfo() *core.ProblemComponent {
return core.NewProblemComponent(DefaultServiceName, "2.0.1")
}

// ResultItem : A resource returned in a search result, which is identified by its `crn`. It contains other properties that depend on
// the resource type.
Expand Down Expand Up @@ -338,6 +358,9 @@ func (o *ResultItem) MarshalJSON() (buffer []byte, err error) {
m["crn"] = o.CRN
}
buffer, err = json.Marshal(m)
if err != nil {
err = core.SDKErrorf(err, "", "model-marshal", common.GetComponentInfo())
}
return
}

Expand All @@ -346,14 +369,15 @@ func UnmarshalResultItem(m map[string]json.RawMessage, result interface{}) (err
obj := new(ResultItem)
err = core.UnmarshalPrimitive(m, "crn", &obj.CRN)
if err != nil {
err = core.SDKErrorf(err, "", "crn-error", common.GetComponentInfo())
return
}
delete(m, "crn")
for k := range m {
var v interface{}
e := core.UnmarshalPrimitive(m, k, &v)
if e != nil {
err = e
err = core.SDKErrorf(e, "", "additional-properties-error", common.GetComponentInfo())
return
}
obj.SetProperty(k, v)
Expand Down Expand Up @@ -381,14 +405,17 @@ func UnmarshalScanResult(m map[string]json.RawMessage, result interface{}) (err
obj := new(ScanResult)
err = core.UnmarshalPrimitive(m, "search_cursor", &obj.SearchCursor)
if err != nil {
err = core.SDKErrorf(err, "", "search_cursor-error", common.GetComponentInfo())
return
}
err = core.UnmarshalPrimitive(m, "limit", &obj.Limit)
if err != nil {
err = core.SDKErrorf(err, "", "limit-error", common.GetComponentInfo())
return
}
err = core.UnmarshalModel(m, "items", &obj.Items, UnmarshalResultItem)
if err != nil {
err = core.SDKErrorf(err, "", "items-error", common.GetComponentInfo())
return
}
reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj))
Expand Down Expand Up @@ -424,11 +451,6 @@ type SearchOptions struct {
// (version 4) UUID.
XCorrelationID *string `json:"x-correlation-id,omitempty"`

// An alphanumeric string that can be used to trace a request across services. If not specified, it automatically
// generated with the prefix "gst-".
// Deprecated: this field is deprecated and may be removed in a future release.
TransactionID *string `json:"transaction-id,omitempty"`

// The account ID to filter resources.
AccountID *string `json:"account_id,omitempty"`

Expand Down Expand Up @@ -544,13 +566,6 @@ func (_options *SearchOptions) SetXCorrelationID(xCorrelationID string) *SearchO
return _options
}

// SetTransactionID : Allow user to set TransactionID
// Deprecated: this method is deprecated and may be removed in a future release.
func (_options *SearchOptions) SetTransactionID(transactionID string) *SearchOptions {
_options.TransactionID = core.StringPtr(transactionID)
return _options
}

// SetAccountID : Allow user to set AccountID
func (_options *SearchOptions) SetAccountID(accountID string) *SearchOptions {
_options.AccountID = core.StringPtr(accountID)
Expand Down
4 changes: 0 additions & 4 deletions globalsearchv2/global_search_v2_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/IBM/go-sdk-core/v5/core"
common "github.com/IBM/platform-services-go-sdk/common"
"github.com/IBM/platform-services-go-sdk/globalsearchv2"
"github.com/google/uuid"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
Expand All @@ -48,8 +47,6 @@ var _ = Describe(`GlobalSearchV2 Integration Tests`, func() {
globalSearchService *globalsearchv2.GlobalSearchV2
serviceURL string
config map[string]string

transactionID = uuid.New().String()
gstQuery = "GST-sdk*"
)

Expand Down Expand Up @@ -116,7 +113,6 @@ var _ = Describe(`GlobalSearchV2 Integration Tests`, func() {
Query: &gstQuery,
Fields: []string{"*"},
SearchCursor: searchCursor,
TransactionID: &transactionID,
Limit: &limit,
}

Expand Down
13 changes: 0 additions & 13 deletions globalsearchv2/global_search_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ var _ = Describe(`GlobalSearchV2`, func() {
Expect(req.Header["X-Request-Id"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
Expect(req.Header["X-Correlation-Id"]).ToNot(BeNil())
Expect(req.Header["X-Correlation-Id"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
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"}))
Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))}))
Expect(req.URL.Query()["timeout"]).To(Equal([]string{fmt.Sprint(int64(0))}))
Expand Down Expand Up @@ -207,7 +205,6 @@ var _ = Describe(`GlobalSearchV2`, func() {
searchOptionsModel.SearchCursor = core.StringPtr("testString")
searchOptionsModel.XRequestID = core.StringPtr("testString")
searchOptionsModel.XCorrelationID = core.StringPtr("testString")
searchOptionsModel.TransactionID = core.StringPtr("testString")
searchOptionsModel.AccountID = core.StringPtr("testString")
searchOptionsModel.Limit = core.Int64Ptr(int64(10))
searchOptionsModel.Timeout = core.Int64Ptr(int64(0))
Expand Down Expand Up @@ -267,8 +264,6 @@ var _ = Describe(`GlobalSearchV2`, func() {
Expect(req.Header["X-Request-Id"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
Expect(req.Header["X-Correlation-Id"]).ToNot(BeNil())
Expect(req.Header["X-Correlation-Id"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
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"}))
Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))}))
Expect(req.URL.Query()["timeout"]).To(Equal([]string{fmt.Sprint(int64(0))}))
Expand Down Expand Up @@ -302,7 +297,6 @@ var _ = Describe(`GlobalSearchV2`, func() {
searchOptionsModel.SearchCursor = core.StringPtr("testString")
searchOptionsModel.XRequestID = core.StringPtr("testString")
searchOptionsModel.XCorrelationID = core.StringPtr("testString")
searchOptionsModel.TransactionID = core.StringPtr("testString")
searchOptionsModel.AccountID = core.StringPtr("testString")
searchOptionsModel.Limit = core.Int64Ptr(int64(10))
searchOptionsModel.Timeout = core.Int64Ptr(int64(0))
Expand Down Expand Up @@ -368,8 +362,6 @@ var _ = Describe(`GlobalSearchV2`, func() {
Expect(req.Header["X-Request-Id"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
Expect(req.Header["X-Correlation-Id"]).ToNot(BeNil())
Expect(req.Header["X-Correlation-Id"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
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"}))
Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))}))
Expect(req.URL.Query()["timeout"]).To(Equal([]string{fmt.Sprint(int64(0))}))
Expand Down Expand Up @@ -405,7 +397,6 @@ var _ = Describe(`GlobalSearchV2`, func() {
searchOptionsModel.SearchCursor = core.StringPtr("testString")
searchOptionsModel.XRequestID = core.StringPtr("testString")
searchOptionsModel.XCorrelationID = core.StringPtr("testString")
searchOptionsModel.TransactionID = core.StringPtr("testString")
searchOptionsModel.AccountID = core.StringPtr("testString")
searchOptionsModel.Limit = core.Int64Ptr(int64(10))
searchOptionsModel.Timeout = core.Int64Ptr(int64(0))
Expand Down Expand Up @@ -439,7 +430,6 @@ var _ = Describe(`GlobalSearchV2`, func() {
searchOptionsModel.SearchCursor = core.StringPtr("testString")
searchOptionsModel.XRequestID = core.StringPtr("testString")
searchOptionsModel.XCorrelationID = core.StringPtr("testString")
searchOptionsModel.TransactionID = core.StringPtr("testString")
searchOptionsModel.AccountID = core.StringPtr("testString")
searchOptionsModel.Limit = core.Int64Ptr(int64(10))
searchOptionsModel.Timeout = core.Int64Ptr(int64(0))
Expand Down Expand Up @@ -487,7 +477,6 @@ var _ = Describe(`GlobalSearchV2`, func() {
searchOptionsModel.SearchCursor = core.StringPtr("testString")
searchOptionsModel.XRequestID = core.StringPtr("testString")
searchOptionsModel.XCorrelationID = core.StringPtr("testString")
searchOptionsModel.TransactionID = core.StringPtr("testString")
searchOptionsModel.AccountID = core.StringPtr("testString")
searchOptionsModel.Limit = core.Int64Ptr(int64(10))
searchOptionsModel.Timeout = core.Int64Ptr(int64(0))
Expand Down Expand Up @@ -526,7 +515,6 @@ var _ = Describe(`GlobalSearchV2`, func() {
searchOptionsModel.SetSearchCursor("testString")
searchOptionsModel.SetXRequestID("testString")
searchOptionsModel.SetXCorrelationID("testString")
searchOptionsModel.SetTransactionID("testString")
searchOptionsModel.SetAccountID("testString")
searchOptionsModel.SetLimit(int64(10))
searchOptionsModel.SetTimeout(int64(0))
Expand All @@ -543,7 +531,6 @@ var _ = Describe(`GlobalSearchV2`, func() {
Expect(searchOptionsModel.SearchCursor).To(Equal(core.StringPtr("testString")))
Expect(searchOptionsModel.XRequestID).To(Equal(core.StringPtr("testString")))
Expect(searchOptionsModel.XCorrelationID).To(Equal(core.StringPtr("testString")))
Expect(searchOptionsModel.TransactionID).To(Equal(core.StringPtr("testString")))
Expect(searchOptionsModel.AccountID).To(Equal(core.StringPtr("testString")))
Expect(searchOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(10))))
Expect(searchOptionsModel.Timeout).To(Equal(core.Int64Ptr(int64(0))))
Expand Down
Loading