From 239d353c9f17660f5caf32872c220726739643d8 Mon Sep 17 00:00:00 2001 From: Matthew Brandyberry Date: Tue, 9 Jul 2024 17:18:46 -0500 Subject: [PATCH] fix(Context-Based Restrictions): address ID support (for use by terraform only) (#344) Signed-off-by: Matthew Brandyberry --- .../context_based_restrictions_v1.go | 394 ++++++++++++++++-- ..._based_restrictions_v1_integration_test.go | 2 +- .../context_based_restrictions_v1_test.go | 47 ++- 3 files changed, 404 insertions(+), 39 deletions(-) diff --git a/contextbasedrestrictionsv1/context_based_restrictions_v1.go b/contextbasedrestrictionsv1/context_based_restrictions_v1.go index 146a14fb..fe7f045c 100644 --- a/contextbasedrestrictionsv1/context_based_restrictions_v1.go +++ b/contextbasedrestrictionsv1/context_based_restrictions_v1.go @@ -15,7 +15,7 @@ */ /* - * IBM OpenAPI SDK Code Generator Version: 3.86.0-bc6f14b3-20240221-193958 + * IBM OpenAPI SDK Code Generator Version: 3.92.1-44330004-20240620-143510 */ // Package contextbasedrestrictionsv1 : Operations and models for the ContextBasedRestrictionsV1 service @@ -66,22 +66,26 @@ func NewContextBasedRestrictionsV1UsingExternalConfig(options *ContextBasedRestr if options.Authenticator == nil { options.Authenticator, err = core.GetAuthenticatorFromEnvironment(options.ServiceName) if err != nil { + err = core.SDKErrorf(err, "", "env-auth-error", common.GetComponentInfo()) return } } contextBasedRestrictions, err = NewContextBasedRestrictionsV1(options) + err = core.RepurposeSDKProblem(err, "new-client-error") if err != nil { return } err = contextBasedRestrictions.Service.ConfigureService(options.ServiceName) if err != nil { + err = core.SDKErrorf(err, "", "client-config-error", common.GetComponentInfo()) return } if options.URL != "" { err = contextBasedRestrictions.Service.SetServiceURL(options.URL) + err = core.RepurposeSDKProblem(err, "url-set-error") } return } @@ -95,12 +99,14 @@ func NewContextBasedRestrictionsV1(options *ContextBasedRestrictionsV1Options) ( 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 } } @@ -114,7 +120,7 @@ func NewContextBasedRestrictionsV1(options *ContextBasedRestrictionsV1Options) ( // 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 "contextBasedRestrictions" suitable for processing requests. @@ -129,7 +135,11 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) Clone() *ContextBase // SetServiceURL sets the service URL func (contextBasedRestrictions *ContextBasedRestrictionsV1) SetServiceURL(url string) error { - return contextBasedRestrictions.Service.SetServiceURL(url) + err := contextBasedRestrictions.Service.SetServiceURL(url) + if err != nil { + err = core.SDKErrorf(err, "", "url-set-error", common.GetComponentInfo()) + } + return err } // GetServiceURL returns the service URL @@ -166,13 +176,16 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) DisableRetries() { // CreateZone : Create a network zone // This operation creates a network zone for the specified account. func (contextBasedRestrictions *ContextBasedRestrictionsV1) CreateZone(createZoneOptions *CreateZoneOptions) (result *Zone, response *core.DetailedResponse, err error) { - return contextBasedRestrictions.CreateZoneWithContext(context.Background(), createZoneOptions) + result, response, err = contextBasedRestrictions.CreateZoneWithContext(context.Background(), createZoneOptions) + err = core.RepurposeSDKProblem(err, "") + return } // CreateZoneWithContext is an alternate form of the CreateZone method which supports a Context parameter func (contextBasedRestrictions *ContextBasedRestrictionsV1) CreateZoneWithContext(ctx context.Context, createZoneOptions *CreateZoneOptions) (result *Zone, response *core.DetailedResponse, err error) { err = core.ValidateStruct(createZoneOptions, "createZoneOptions") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } @@ -181,6 +194,7 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) CreateZoneWithContex builder.EnableGzipCompression = contextBasedRestrictions.GetEnableGzipCompression() _, err = builder.ResolveRequestURL(contextBasedRestrictions.Service.Options.URL, `/v1/zones`, nil) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } @@ -219,22 +233,27 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) CreateZoneWithContex } _, 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 = contextBasedRestrictions.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "create_zone", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalZone) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -246,17 +265,21 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) CreateZoneWithContex // ListZones : List network zones // This operation lists network zones in the specified account. func (contextBasedRestrictions *ContextBasedRestrictionsV1) ListZones(listZonesOptions *ListZonesOptions) (result *ZoneList, response *core.DetailedResponse, err error) { - return contextBasedRestrictions.ListZonesWithContext(context.Background(), listZonesOptions) + result, response, err = contextBasedRestrictions.ListZonesWithContext(context.Background(), listZonesOptions) + err = core.RepurposeSDKProblem(err, "") + return } // ListZonesWithContext is an alternate form of the ListZones method which supports a Context parameter func (contextBasedRestrictions *ContextBasedRestrictionsV1) ListZonesWithContext(ctx context.Context, listZonesOptions *ListZonesOptions) (result *ZoneList, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(listZonesOptions, "listZonesOptions cannot be nil") if err != nil { + err = core.SDKErrorf(err, "", "unexpected-nil-param", common.GetComponentInfo()) return } err = core.ValidateStruct(listZonesOptions, "listZonesOptions") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } @@ -265,6 +288,7 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) ListZonesWithContext builder.EnableGzipCompression = contextBasedRestrictions.GetEnableGzipCompression() _, err = builder.ResolveRequestURL(contextBasedRestrictions.Service.Options.URL, `/v1/zones`, nil) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } @@ -294,17 +318,21 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) ListZonesWithContext request, err := builder.Build() if err != nil { + err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo()) return } var rawResponse map[string]json.RawMessage response, err = contextBasedRestrictions.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "list_zones", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalZoneList) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -316,17 +344,21 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) ListZonesWithContext // GetZone : Get a network zone // This operation retrieves the network zone identified by the specified zone ID. func (contextBasedRestrictions *ContextBasedRestrictionsV1) GetZone(getZoneOptions *GetZoneOptions) (result *Zone, response *core.DetailedResponse, err error) { - return contextBasedRestrictions.GetZoneWithContext(context.Background(), getZoneOptions) + result, response, err = contextBasedRestrictions.GetZoneWithContext(context.Background(), getZoneOptions) + err = core.RepurposeSDKProblem(err, "") + return } // GetZoneWithContext is an alternate form of the GetZone method which supports a Context parameter func (contextBasedRestrictions *ContextBasedRestrictionsV1) GetZoneWithContext(ctx context.Context, getZoneOptions *GetZoneOptions) (result *Zone, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(getZoneOptions, "getZoneOptions cannot be nil") if err != nil { + err = core.SDKErrorf(err, "", "unexpected-nil-param", common.GetComponentInfo()) return } err = core.ValidateStruct(getZoneOptions, "getZoneOptions") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } @@ -339,6 +371,7 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) GetZoneWithContext(c builder.EnableGzipCompression = contextBasedRestrictions.GetEnableGzipCompression() _, err = builder.ResolveRequestURL(contextBasedRestrictions.Service.Options.URL, `/v1/zones/{zone_id}`, pathParamsMap) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } @@ -360,17 +393,21 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) GetZoneWithContext(c request, err := builder.Build() if err != nil { + err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo()) return } var rawResponse map[string]json.RawMessage response, err = contextBasedRestrictions.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "get_zone", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalZone) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -383,17 +420,21 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) GetZoneWithContext(c // This operation replaces the network zone identified by the specified zone ID. Partial updates are not supported. The // entire network zone object must be replaced. func (contextBasedRestrictions *ContextBasedRestrictionsV1) ReplaceZone(replaceZoneOptions *ReplaceZoneOptions) (result *Zone, response *core.DetailedResponse, err error) { - return contextBasedRestrictions.ReplaceZoneWithContext(context.Background(), replaceZoneOptions) + result, response, err = contextBasedRestrictions.ReplaceZoneWithContext(context.Background(), replaceZoneOptions) + err = core.RepurposeSDKProblem(err, "") + return } // ReplaceZoneWithContext is an alternate form of the ReplaceZone method which supports a Context parameter func (contextBasedRestrictions *ContextBasedRestrictionsV1) ReplaceZoneWithContext(ctx context.Context, replaceZoneOptions *ReplaceZoneOptions) (result *Zone, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(replaceZoneOptions, "replaceZoneOptions cannot be nil") if err != nil { + err = core.SDKErrorf(err, "", "unexpected-nil-param", common.GetComponentInfo()) return } err = core.ValidateStruct(replaceZoneOptions, "replaceZoneOptions") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } @@ -406,6 +447,7 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) ReplaceZoneWithConte builder.EnableGzipCompression = contextBasedRestrictions.GetEnableGzipCompression() _, err = builder.ResolveRequestURL(contextBasedRestrictions.Service.Options.URL, `/v1/zones/{zone_id}`, pathParamsMap) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } @@ -447,22 +489,27 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) ReplaceZoneWithConte } _, 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 = contextBasedRestrictions.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "replace_zone", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalZone) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -474,17 +521,21 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) ReplaceZoneWithConte // DeleteZone : Delete a network zone // This operation deletes the network zone identified by the specified zone ID. func (contextBasedRestrictions *ContextBasedRestrictionsV1) DeleteZone(deleteZoneOptions *DeleteZoneOptions) (response *core.DetailedResponse, err error) { - return contextBasedRestrictions.DeleteZoneWithContext(context.Background(), deleteZoneOptions) + response, err = contextBasedRestrictions.DeleteZoneWithContext(context.Background(), deleteZoneOptions) + err = core.RepurposeSDKProblem(err, "") + return } // DeleteZoneWithContext is an alternate form of the DeleteZone method which supports a Context parameter func (contextBasedRestrictions *ContextBasedRestrictionsV1) DeleteZoneWithContext(ctx context.Context, deleteZoneOptions *DeleteZoneOptions) (response *core.DetailedResponse, err error) { err = core.ValidateNotNil(deleteZoneOptions, "deleteZoneOptions cannot be nil") if err != nil { + err = core.SDKErrorf(err, "", "unexpected-nil-param", common.GetComponentInfo()) return } err = core.ValidateStruct(deleteZoneOptions, "deleteZoneOptions") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } @@ -497,6 +548,7 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) DeleteZoneWithContex builder.EnableGzipCompression = contextBasedRestrictions.GetEnableGzipCompression() _, err = builder.ResolveRequestURL(contextBasedRestrictions.Service.Options.URL, `/v1/zones/{zone_id}`, pathParamsMap) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } @@ -517,10 +569,16 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) DeleteZoneWithContex request, err := builder.Build() if err != nil { + err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo()) return } response, err = contextBasedRestrictions.Service.Request(request, nil) + if err != nil { + core.EnrichHTTPProblem(err, "delete_zone", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) + return + } return } @@ -528,13 +586,16 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) DeleteZoneWithContex // ListAvailableServicerefTargets : List available service reference targets // This operation lists all available service reference targets. func (contextBasedRestrictions *ContextBasedRestrictionsV1) ListAvailableServicerefTargets(listAvailableServicerefTargetsOptions *ListAvailableServicerefTargetsOptions) (result *ServiceRefTargetList, response *core.DetailedResponse, err error) { - return contextBasedRestrictions.ListAvailableServicerefTargetsWithContext(context.Background(), listAvailableServicerefTargetsOptions) + result, response, err = contextBasedRestrictions.ListAvailableServicerefTargetsWithContext(context.Background(), listAvailableServicerefTargetsOptions) + err = core.RepurposeSDKProblem(err, "") + return } // ListAvailableServicerefTargetsWithContext is an alternate form of the ListAvailableServicerefTargets method which supports a Context parameter func (contextBasedRestrictions *ContextBasedRestrictionsV1) ListAvailableServicerefTargetsWithContext(ctx context.Context, listAvailableServicerefTargetsOptions *ListAvailableServicerefTargetsOptions) (result *ServiceRefTargetList, response *core.DetailedResponse, err error) { err = core.ValidateStruct(listAvailableServicerefTargetsOptions, "listAvailableServicerefTargetsOptions") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } @@ -543,6 +604,7 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) ListAvailableService builder.EnableGzipCompression = contextBasedRestrictions.GetEnableGzipCompression() _, err = builder.ResolveRequestURL(contextBasedRestrictions.Service.Options.URL, `/v1/zones/serviceref_targets`, nil) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } @@ -568,17 +630,21 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) ListAvailableService request, err := builder.Build() if err != nil { + err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo()) return } var rawResponse map[string]json.RawMessage response, err = contextBasedRestrictions.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "list_available_serviceref_targets", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalServiceRefTargetList) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -590,17 +656,21 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) ListAvailableService // GetServicerefTarget : Get service reference target for a specified service name // This operation gets the service reference target for a specified service name. func (contextBasedRestrictions *ContextBasedRestrictionsV1) GetServicerefTarget(getServicerefTargetOptions *GetServicerefTargetOptions) (result *ServiceRefTarget, response *core.DetailedResponse, err error) { - return contextBasedRestrictions.GetServicerefTargetWithContext(context.Background(), getServicerefTargetOptions) + result, response, err = contextBasedRestrictions.GetServicerefTargetWithContext(context.Background(), getServicerefTargetOptions) + err = core.RepurposeSDKProblem(err, "") + return } // GetServicerefTargetWithContext is an alternate form of the GetServicerefTarget method which supports a Context parameter func (contextBasedRestrictions *ContextBasedRestrictionsV1) GetServicerefTargetWithContext(ctx context.Context, getServicerefTargetOptions *GetServicerefTargetOptions) (result *ServiceRefTarget, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(getServicerefTargetOptions, "getServicerefTargetOptions cannot be nil") if err != nil { + err = core.SDKErrorf(err, "", "unexpected-nil-param", common.GetComponentInfo()) return } err = core.ValidateStruct(getServicerefTargetOptions, "getServicerefTargetOptions") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } @@ -613,6 +683,7 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) GetServicerefTargetW builder.EnableGzipCompression = contextBasedRestrictions.GetEnableGzipCompression() _, err = builder.ResolveRequestURL(contextBasedRestrictions.Service.Options.URL, `/v1/zones/serviceref_targets/{service_name}`, pathParamsMap) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } @@ -634,17 +705,21 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) GetServicerefTargetW request, err := builder.Build() if err != nil { + err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo()) return } var rawResponse map[string]json.RawMessage response, err = contextBasedRestrictions.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "get_serviceref_target", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalServiceRefTarget) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -656,13 +731,16 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) GetServicerefTargetW // CreateRule : Create a rule // This operation creates a rule for the specified account. func (contextBasedRestrictions *ContextBasedRestrictionsV1) CreateRule(createRuleOptions *CreateRuleOptions) (result *Rule, response *core.DetailedResponse, err error) { - return contextBasedRestrictions.CreateRuleWithContext(context.Background(), createRuleOptions) + result, response, err = contextBasedRestrictions.CreateRuleWithContext(context.Background(), createRuleOptions) + err = core.RepurposeSDKProblem(err, "") + return } // CreateRuleWithContext is an alternate form of the CreateRule method which supports a Context parameter func (contextBasedRestrictions *ContextBasedRestrictionsV1) CreateRuleWithContext(ctx context.Context, createRuleOptions *CreateRuleOptions) (result *Rule, response *core.DetailedResponse, err error) { err = core.ValidateStruct(createRuleOptions, "createRuleOptions") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } @@ -671,6 +749,7 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) CreateRuleWithContex builder.EnableGzipCompression = contextBasedRestrictions.GetEnableGzipCompression() _, err = builder.ResolveRequestURL(contextBasedRestrictions.Service.Options.URL, `/v1/rules`, nil) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } @@ -709,22 +788,27 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) CreateRuleWithContex } _, 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 = contextBasedRestrictions.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "create_rule", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalRule) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -736,17 +820,21 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) CreateRuleWithContex // ListRules : List rules // This operation lists rules in the specified account. func (contextBasedRestrictions *ContextBasedRestrictionsV1) ListRules(listRulesOptions *ListRulesOptions) (result *RuleList, response *core.DetailedResponse, err error) { - return contextBasedRestrictions.ListRulesWithContext(context.Background(), listRulesOptions) + result, response, err = contextBasedRestrictions.ListRulesWithContext(context.Background(), listRulesOptions) + err = core.RepurposeSDKProblem(err, "") + return } // ListRulesWithContext is an alternate form of the ListRules method which supports a Context parameter func (contextBasedRestrictions *ContextBasedRestrictionsV1) ListRulesWithContext(ctx context.Context, listRulesOptions *ListRulesOptions) (result *RuleList, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(listRulesOptions, "listRulesOptions cannot be nil") if err != nil { + err = core.SDKErrorf(err, "", "unexpected-nil-param", common.GetComponentInfo()) return } err = core.ValidateStruct(listRulesOptions, "listRulesOptions") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } @@ -755,6 +843,7 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) ListRulesWithContext builder.EnableGzipCompression = contextBasedRestrictions.GetEnableGzipCompression() _, err = builder.ResolveRequestURL(contextBasedRestrictions.Service.Options.URL, `/v1/rules`, nil) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } @@ -808,17 +897,21 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) ListRulesWithContext request, err := builder.Build() if err != nil { + err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo()) return } var rawResponse map[string]json.RawMessage response, err = contextBasedRestrictions.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "list_rules", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalRuleList) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -830,17 +923,21 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) ListRulesWithContext // GetRule : Get a rule // This operation retrieves the rule identified by the specified rule ID. func (contextBasedRestrictions *ContextBasedRestrictionsV1) GetRule(getRuleOptions *GetRuleOptions) (result *Rule, response *core.DetailedResponse, err error) { - return contextBasedRestrictions.GetRuleWithContext(context.Background(), getRuleOptions) + result, response, err = contextBasedRestrictions.GetRuleWithContext(context.Background(), getRuleOptions) + err = core.RepurposeSDKProblem(err, "") + return } // GetRuleWithContext is an alternate form of the GetRule method which supports a Context parameter func (contextBasedRestrictions *ContextBasedRestrictionsV1) GetRuleWithContext(ctx context.Context, getRuleOptions *GetRuleOptions) (result *Rule, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(getRuleOptions, "getRuleOptions cannot be nil") if err != nil { + err = core.SDKErrorf(err, "", "unexpected-nil-param", common.GetComponentInfo()) return } err = core.ValidateStruct(getRuleOptions, "getRuleOptions") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } @@ -853,6 +950,7 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) GetRuleWithContext(c builder.EnableGzipCompression = contextBasedRestrictions.GetEnableGzipCompression() _, err = builder.ResolveRequestURL(contextBasedRestrictions.Service.Options.URL, `/v1/rules/{rule_id}`, pathParamsMap) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } @@ -874,17 +972,21 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) GetRuleWithContext(c request, err := builder.Build() if err != nil { + err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo()) return } var rawResponse map[string]json.RawMessage response, err = contextBasedRestrictions.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "get_rule", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalRule) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -897,17 +999,21 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) GetRuleWithContext(c // This operation replaces the rule identified by the specified rule ID. Partial updates are not supported. The entire // rule object must be replaced. func (contextBasedRestrictions *ContextBasedRestrictionsV1) ReplaceRule(replaceRuleOptions *ReplaceRuleOptions) (result *Rule, response *core.DetailedResponse, err error) { - return contextBasedRestrictions.ReplaceRuleWithContext(context.Background(), replaceRuleOptions) + result, response, err = contextBasedRestrictions.ReplaceRuleWithContext(context.Background(), replaceRuleOptions) + err = core.RepurposeSDKProblem(err, "") + return } // ReplaceRuleWithContext is an alternate form of the ReplaceRule method which supports a Context parameter func (contextBasedRestrictions *ContextBasedRestrictionsV1) ReplaceRuleWithContext(ctx context.Context, replaceRuleOptions *ReplaceRuleOptions) (result *Rule, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(replaceRuleOptions, "replaceRuleOptions cannot be nil") if err != nil { + err = core.SDKErrorf(err, "", "unexpected-nil-param", common.GetComponentInfo()) return } err = core.ValidateStruct(replaceRuleOptions, "replaceRuleOptions") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } @@ -920,6 +1026,7 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) ReplaceRuleWithConte builder.EnableGzipCompression = contextBasedRestrictions.GetEnableGzipCompression() _, err = builder.ResolveRequestURL(contextBasedRestrictions.Service.Options.URL, `/v1/rules/{rule_id}`, pathParamsMap) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } @@ -961,22 +1068,27 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) ReplaceRuleWithConte } _, 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 = contextBasedRestrictions.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "replace_rule", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalRule) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -988,17 +1100,21 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) ReplaceRuleWithConte // DeleteRule : Delete a rule // This operation deletes the rule identified by the specified rule ID. func (contextBasedRestrictions *ContextBasedRestrictionsV1) DeleteRule(deleteRuleOptions *DeleteRuleOptions) (response *core.DetailedResponse, err error) { - return contextBasedRestrictions.DeleteRuleWithContext(context.Background(), deleteRuleOptions) + response, err = contextBasedRestrictions.DeleteRuleWithContext(context.Background(), deleteRuleOptions) + err = core.RepurposeSDKProblem(err, "") + return } // DeleteRuleWithContext is an alternate form of the DeleteRule method which supports a Context parameter func (contextBasedRestrictions *ContextBasedRestrictionsV1) DeleteRuleWithContext(ctx context.Context, deleteRuleOptions *DeleteRuleOptions) (response *core.DetailedResponse, err error) { err = core.ValidateNotNil(deleteRuleOptions, "deleteRuleOptions cannot be nil") if err != nil { + err = core.SDKErrorf(err, "", "unexpected-nil-param", common.GetComponentInfo()) return } err = core.ValidateStruct(deleteRuleOptions, "deleteRuleOptions") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } @@ -1011,6 +1127,7 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) DeleteRuleWithContex builder.EnableGzipCompression = contextBasedRestrictions.GetEnableGzipCompression() _, err = builder.ResolveRequestURL(contextBasedRestrictions.Service.Options.URL, `/v1/rules/{rule_id}`, pathParamsMap) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } @@ -1031,10 +1148,16 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) DeleteRuleWithContex request, err := builder.Build() if err != nil { + err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo()) return } response, err = contextBasedRestrictions.Service.Request(request, nil) + if err != nil { + core.EnrichHTTPProblem(err, "delete_rule", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) + return + } return } @@ -1042,17 +1165,21 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) DeleteRuleWithContex // GetAccountSettings : Get account settings // This operation retrieves the settings for the specified account ID. func (contextBasedRestrictions *ContextBasedRestrictionsV1) GetAccountSettings(getAccountSettingsOptions *GetAccountSettingsOptions) (result *AccountSettings, response *core.DetailedResponse, err error) { - return contextBasedRestrictions.GetAccountSettingsWithContext(context.Background(), getAccountSettingsOptions) + result, response, err = contextBasedRestrictions.GetAccountSettingsWithContext(context.Background(), getAccountSettingsOptions) + err = core.RepurposeSDKProblem(err, "") + return } // GetAccountSettingsWithContext is an alternate form of the GetAccountSettings method which supports a Context parameter func (contextBasedRestrictions *ContextBasedRestrictionsV1) GetAccountSettingsWithContext(ctx context.Context, getAccountSettingsOptions *GetAccountSettingsOptions) (result *AccountSettings, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(getAccountSettingsOptions, "getAccountSettingsOptions cannot be nil") if err != nil { + err = core.SDKErrorf(err, "", "unexpected-nil-param", common.GetComponentInfo()) return } err = core.ValidateStruct(getAccountSettingsOptions, "getAccountSettingsOptions") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } @@ -1065,6 +1192,7 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) GetAccountSettingsWi builder.EnableGzipCompression = contextBasedRestrictions.GetEnableGzipCompression() _, err = builder.ResolveRequestURL(contextBasedRestrictions.Service.Options.URL, `/v1/account_settings/{account_id}`, pathParamsMap) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } @@ -1086,17 +1214,21 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) GetAccountSettingsWi request, err := builder.Build() if err != nil { + err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo()) return } var rawResponse map[string]json.RawMessage response, err = contextBasedRestrictions.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "get_account_settings", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalAccountSettings) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -1108,13 +1240,16 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) GetAccountSettingsWi // ListAvailableServiceOperations : List available service operations // This operation lists all available service operations. func (contextBasedRestrictions *ContextBasedRestrictionsV1) ListAvailableServiceOperations(listAvailableServiceOperationsOptions *ListAvailableServiceOperationsOptions) (result *OperationsList, response *core.DetailedResponse, err error) { - return contextBasedRestrictions.ListAvailableServiceOperationsWithContext(context.Background(), listAvailableServiceOperationsOptions) + result, response, err = contextBasedRestrictions.ListAvailableServiceOperationsWithContext(context.Background(), listAvailableServiceOperationsOptions) + err = core.RepurposeSDKProblem(err, "") + return } // ListAvailableServiceOperationsWithContext is an alternate form of the ListAvailableServiceOperations method which supports a Context parameter func (contextBasedRestrictions *ContextBasedRestrictionsV1) ListAvailableServiceOperationsWithContext(ctx context.Context, listAvailableServiceOperationsOptions *ListAvailableServiceOperationsOptions) (result *OperationsList, response *core.DetailedResponse, err error) { err = core.ValidateStruct(listAvailableServiceOperationsOptions, "listAvailableServiceOperationsOptions") if err != nil { + err = core.SDKErrorf(err, "", "struct-validation-error", common.GetComponentInfo()) return } @@ -1123,6 +1258,7 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) ListAvailableService builder.EnableGzipCompression = contextBasedRestrictions.GetEnableGzipCompression() _, err = builder.ResolveRequestURL(contextBasedRestrictions.Service.Options.URL, `/v1/operations`, nil) if err != nil { + err = core.SDKErrorf(err, "", "url-resolve-error", common.GetComponentInfo()) return } @@ -1154,17 +1290,21 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) ListAvailableService request, err := builder.Build() if err != nil { + err = core.SDKErrorf(err, "", "build-error", common.GetComponentInfo()) return } var rawResponse map[string]json.RawMessage response, err = contextBasedRestrictions.Service.Request(request, &rawResponse) if err != nil { + core.EnrichHTTPProblem(err, "list_available_service_operations", getServiceComponentInfo()) + err = core.SDKErrorf(err, "", "http-request-err", common.GetComponentInfo()) return } if rawResponse != nil { err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalOperationsList) if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-resp-error", common.GetComponentInfo()) return } response.Result = result @@ -1172,6 +1312,9 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) ListAvailableService return } +func getServiceComponentInfo() *core.ProblemComponent { + return core.NewProblemComponent(DefaultServiceName, "1.0.1") +} // APIType : Service API Type details. type APIType struct { @@ -1199,26 +1342,32 @@ func UnmarshalAPIType(m map[string]json.RawMessage, result interface{}) (err err obj := new(APIType) err = core.UnmarshalPrimitive(m, "api_type_id", &obj.APITypeID) if err != nil { + err = core.SDKErrorf(err, "", "api_type_id-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "display_name", &obj.DisplayName) if err != nil { + err = core.SDKErrorf(err, "", "display_name-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "description", &obj.Description) if err != nil { + err = core.SDKErrorf(err, "", "description-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "type", &obj.Type) if err != nil { + err = core.SDKErrorf(err, "", "type-error", common.GetComponentInfo()) return } err = core.UnmarshalModel(m, "actions", &obj.Actions, UnmarshalAction) if err != nil { + err = core.SDKErrorf(err, "", "actions-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "enforcement_modes", &obj.EnforcementModes) if err != nil { + err = core.SDKErrorf(err, "", "enforcement_modes-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -1240,7 +1389,7 @@ type AccountSettings struct { ZoneCountLimit *int64 `json:"zone_count_limit" validate:"required"` // the max number of rules with tags allowed for the account. - TagsRuleCountLimit *int64 `json:"tags_rule_count_limit,omitempty"` + TagsRuleCountLimit *int64 `json:"tags_rule_count_limit" validate:"required"` // the current number of rules used by the account. CurrentRuleCount *int64 `json:"current_rule_count" validate:"required"` @@ -1249,22 +1398,22 @@ type AccountSettings struct { CurrentZoneCount *int64 `json:"current_zone_count" validate:"required"` // the current number of rules with tags used by the account. - CurrentTagsRuleCount *int64 `json:"current_tags_rule_count,omitempty"` + CurrentTagsRuleCount *int64 `json:"current_tags_rule_count" validate:"required"` // The href link to the resource. Href *string `json:"href" validate:"required"` // The time the resource was created. - CreatedAt *strfmt.DateTime `json:"created_at" validate:"required"` + CreatedAt *strfmt.DateTime `json:"created_at,omitempty"` // IAM ID of the user or service which created the resource. - CreatedByID *string `json:"created_by_id" validate:"required"` + CreatedByID *string `json:"created_by_id,omitempty"` // The last time the resource was modified. - LastModifiedAt *strfmt.DateTime `json:"last_modified_at" validate:"required"` + LastModifiedAt *strfmt.DateTime `json:"last_modified_at,omitempty"` // IAM ID of the user or service which modified the resource. - LastModifiedByID *string `json:"last_modified_by_id" validate:"required"` + LastModifiedByID *string `json:"last_modified_by_id,omitempty"` } // UnmarshalAccountSettings unmarshals an instance of AccountSettings from the specified map of raw messages. @@ -1272,54 +1421,67 @@ func UnmarshalAccountSettings(m map[string]json.RawMessage, result interface{}) obj := new(AccountSettings) err = core.UnmarshalPrimitive(m, "id", &obj.ID) if err != nil { + err = core.SDKErrorf(err, "", "id-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) if err != nil { + err = core.SDKErrorf(err, "", "crn-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "rule_count_limit", &obj.RuleCountLimit) if err != nil { + err = core.SDKErrorf(err, "", "rule_count_limit-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "zone_count_limit", &obj.ZoneCountLimit) if err != nil { + err = core.SDKErrorf(err, "", "zone_count_limit-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "tags_rule_count_limit", &obj.TagsRuleCountLimit) if err != nil { + err = core.SDKErrorf(err, "", "tags_rule_count_limit-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "current_rule_count", &obj.CurrentRuleCount) if err != nil { + err = core.SDKErrorf(err, "", "current_rule_count-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "current_zone_count", &obj.CurrentZoneCount) if err != nil { + err = core.SDKErrorf(err, "", "current_zone_count-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "current_tags_rule_count", &obj.CurrentTagsRuleCount) if err != nil { + err = core.SDKErrorf(err, "", "current_tags_rule_count-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "href", &obj.Href) if err != nil { + err = core.SDKErrorf(err, "", "href-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) if err != nil { + err = core.SDKErrorf(err, "", "created_at-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "created_by_id", &obj.CreatedByID) if err != nil { + err = core.SDKErrorf(err, "", "created_by_id-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "last_modified_at", &obj.LastModifiedAt) if err != nil { + err = core.SDKErrorf(err, "", "last_modified_at-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "last_modified_by_id", &obj.LastModifiedByID) if err != nil { + err = core.SDKErrorf(err, "", "last_modified_by_id-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -1340,10 +1502,12 @@ func UnmarshalAction(m map[string]json.RawMessage, result interface{}) (err erro obj := new(Action) err = core.UnmarshalPrimitive(m, "action_id", &obj.ActionID) if err != nil { + err = core.SDKErrorf(err, "", "action_id-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "description", &obj.Description) if err != nil { + err = core.SDKErrorf(err, "", "description-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -1364,6 +1528,9 @@ type Address struct { // The IP address. Value *string `json:"value,omitempty"` + // The address id (for use by terraform only). + ID *string `json:"id,omitempty"` + // A service reference value. Ref *ServiceRefValue `json:"ref,omitempty"` } @@ -1392,25 +1559,42 @@ func UnmarshalAddress(m map[string]json.RawMessage, result interface{}) (err err var discValue string err = core.UnmarshalPrimitive(m, "type", &discValue) if err != nil { - err = fmt.Errorf("error unmarshalling discriminator property 'type': %s", err.Error()) + errMsg := fmt.Sprintf("error unmarshalling discriminator property 'type': %s", err.Error()) + err = core.SDKErrorf(err, errMsg, "discriminator-unmarshal-error", common.GetComponentInfo()) return } if discValue == "" { - err = fmt.Errorf("required discriminator property 'type' not found in JSON object") + err = core.SDKErrorf(err, "required discriminator property 'type' not found in JSON object", "missing-discriminator", common.GetComponentInfo()) return } if discValue == "ipAddress" { err = core.UnmarshalModel(m, "", result, UnmarshalAddressIPAddress) + if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-AddressIPAddress-error", common.GetComponentInfo()) + } } else if discValue == "ipRange" { err = core.UnmarshalModel(m, "", result, UnmarshalAddressIPAddressRange) + if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-AddressIPAddressRange-error", common.GetComponentInfo()) + } } else if discValue == "subnet" { err = core.UnmarshalModel(m, "", result, UnmarshalAddressSubnet) + if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-AddressSubnet-error", common.GetComponentInfo()) + } } else if discValue == "vpc" { err = core.UnmarshalModel(m, "", result, UnmarshalAddressVPC) + if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-AddressVPC-error", common.GetComponentInfo()) + } } else if discValue == "serviceRef" { err = core.UnmarshalModel(m, "", result, UnmarshalAddressServiceRef) + if err != nil { + err = core.SDKErrorf(err, "", "unmarshal-AddressServiceRef-error", common.GetComponentInfo()) + } } else { - err = fmt.Errorf("unrecognized value for discriminator property 'type': %s", discValue) + errMsg := fmt.Sprintf("unrecognized value for discriminator property 'type': %s", discValue) + err = core.SDKErrorf(err, errMsg, "invalid-discriminator", common.GetComponentInfo()) } return } @@ -2273,6 +2457,9 @@ func (*ContextBasedRestrictionsV1) NewNewRuleOperations(apiTypes []NewRuleOperat APITypes: apiTypes, } err = core.ValidateStruct(_model, "required parameters") + if err != nil { + err = core.SDKErrorf(err, "", "model-missing-required", common.GetComponentInfo()) + } return } @@ -2281,6 +2468,7 @@ func UnmarshalNewRuleOperations(m map[string]json.RawMessage, result interface{} obj := new(NewRuleOperations) err = core.UnmarshalModel(m, "api_types", &obj.APITypes, UnmarshalNewRuleOperationsAPITypesItem) if err != nil { + err = core.SDKErrorf(err, "", "api_types-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -2298,6 +2486,9 @@ func (*ContextBasedRestrictionsV1) NewNewRuleOperationsAPITypesItem(apiTypeID st APITypeID: core.StringPtr(apiTypeID), } err = core.ValidateStruct(_model, "required parameters") + if err != nil { + err = core.SDKErrorf(err, "", "model-missing-required", common.GetComponentInfo()) + } return } @@ -2306,6 +2497,7 @@ func UnmarshalNewRuleOperationsAPITypesItem(m map[string]json.RawMessage, result obj := new(NewRuleOperationsAPITypesItem) err = core.UnmarshalPrimitive(m, "api_type_id", &obj.APITypeID) if err != nil { + err = core.SDKErrorf(err, "", "api_type_id-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -2323,6 +2515,7 @@ func UnmarshalOperationsList(m map[string]json.RawMessage, result interface{}) ( obj := new(OperationsList) err = core.UnmarshalModel(m, "api_types", &obj.APITypes, UnmarshalAPIType) if err != nil { + err = core.SDKErrorf(err, "", "api_types-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -2575,6 +2768,9 @@ func (*ContextBasedRestrictionsV1) NewResource(attributes []ResourceAttribute) ( Attributes: attributes, } err = core.ValidateStruct(_model, "required parameters") + if err != nil { + err = core.SDKErrorf(err, "", "model-missing-required", common.GetComponentInfo()) + } return } @@ -2583,10 +2779,12 @@ func UnmarshalResource(m map[string]json.RawMessage, result interface{}) (err er obj := new(Resource) err = core.UnmarshalModel(m, "attributes", &obj.Attributes, UnmarshalResourceAttribute) if err != nil { + err = core.SDKErrorf(err, "", "attributes-error", common.GetComponentInfo()) return } err = core.UnmarshalModel(m, "tags", &obj.Tags, UnmarshalResourceTagAttribute) if err != nil { + err = core.SDKErrorf(err, "", "tags-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -2612,6 +2810,9 @@ func (*ContextBasedRestrictionsV1) NewResourceAttribute(name string, value strin Value: core.StringPtr(value), } err = core.ValidateStruct(_model, "required parameters") + if err != nil { + err = core.SDKErrorf(err, "", "model-missing-required", common.GetComponentInfo()) + } return } @@ -2620,14 +2821,17 @@ func UnmarshalResourceAttribute(m map[string]json.RawMessage, result interface{} obj := new(ResourceAttribute) err = core.UnmarshalPrimitive(m, "name", &obj.Name) if err != nil { + err = core.SDKErrorf(err, "", "name-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "value", &obj.Value) if err != nil { + err = core.SDKErrorf(err, "", "value-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "operator", &obj.Operator) if err != nil { + err = core.SDKErrorf(err, "", "operator-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -2653,6 +2857,9 @@ func (*ContextBasedRestrictionsV1) NewResourceTagAttribute(name string, value st Value: core.StringPtr(value), } err = core.ValidateStruct(_model, "required parameters") + if err != nil { + err = core.SDKErrorf(err, "", "model-missing-required", common.GetComponentInfo()) + } return } @@ -2661,14 +2868,17 @@ func UnmarshalResourceTagAttribute(m map[string]json.RawMessage, result interfac obj := new(ResourceTagAttribute) err = core.UnmarshalPrimitive(m, "name", &obj.Name) if err != nil { + err = core.SDKErrorf(err, "", "name-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "value", &obj.Value) if err != nil { + err = core.SDKErrorf(err, "", "value-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "operator", &obj.Operator) if err != nil { + err = core.SDKErrorf(err, "", "operator-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -2733,50 +2943,62 @@ func UnmarshalRule(m map[string]json.RawMessage, result interface{}) (err error) obj := new(Rule) err = core.UnmarshalPrimitive(m, "id", &obj.ID) if err != nil { + err = core.SDKErrorf(err, "", "id-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) if err != nil { + err = core.SDKErrorf(err, "", "crn-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "description", &obj.Description) if err != nil { + err = core.SDKErrorf(err, "", "description-error", common.GetComponentInfo()) return } err = core.UnmarshalModel(m, "contexts", &obj.Contexts, UnmarshalRuleContext) if err != nil { + err = core.SDKErrorf(err, "", "contexts-error", common.GetComponentInfo()) return } err = core.UnmarshalModel(m, "resources", &obj.Resources, UnmarshalResource) if err != nil { + err = core.SDKErrorf(err, "", "resources-error", common.GetComponentInfo()) return } err = core.UnmarshalModel(m, "operations", &obj.Operations, UnmarshalNewRuleOperations) if err != nil { + err = core.SDKErrorf(err, "", "operations-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "enforcement_mode", &obj.EnforcementMode) if err != nil { + err = core.SDKErrorf(err, "", "enforcement_mode-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "href", &obj.Href) if err != nil { + err = core.SDKErrorf(err, "", "href-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) if err != nil { + err = core.SDKErrorf(err, "", "created_at-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "created_by_id", &obj.CreatedByID) if err != nil { + err = core.SDKErrorf(err, "", "created_by_id-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "last_modified_at", &obj.LastModifiedAt) if err != nil { + err = core.SDKErrorf(err, "", "last_modified_at-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "last_modified_by_id", &obj.LastModifiedByID) if err != nil { + err = core.SDKErrorf(err, "", "last_modified_by_id-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -2795,6 +3017,9 @@ func (*ContextBasedRestrictionsV1) NewRuleContext(attributes []RuleContextAttrib Attributes: attributes, } err = core.ValidateStruct(_model, "required parameters") + if err != nil { + err = core.SDKErrorf(err, "", "model-missing-required", common.GetComponentInfo()) + } return } @@ -2803,6 +3028,7 @@ func UnmarshalRuleContext(m map[string]json.RawMessage, result interface{}) (err obj := new(RuleContext) err = core.UnmarshalModel(m, "attributes", &obj.Attributes, UnmarshalRuleContextAttribute) if err != nil { + err = core.SDKErrorf(err, "", "attributes-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -2825,6 +3051,9 @@ func (*ContextBasedRestrictionsV1) NewRuleContextAttribute(name string, value st Value: core.StringPtr(value), } err = core.ValidateStruct(_model, "required parameters") + if err != nil { + err = core.SDKErrorf(err, "", "model-missing-required", common.GetComponentInfo()) + } return } @@ -2833,10 +3062,12 @@ func UnmarshalRuleContextAttribute(m map[string]json.RawMessage, result interfac obj := new(RuleContextAttribute) err = core.UnmarshalPrimitive(m, "name", &obj.Name) if err != nil { + err = core.SDKErrorf(err, "", "name-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "value", &obj.Value) if err != nil { + err = core.SDKErrorf(err, "", "value-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -2857,10 +3088,12 @@ func UnmarshalRuleList(m map[string]json.RawMessage, result interface{}) (err er obj := new(RuleList) err = core.UnmarshalPrimitive(m, "count", &obj.Count) if err != nil { + err = core.SDKErrorf(err, "", "count-error", common.GetComponentInfo()) return } err = core.UnmarshalModel(m, "rules", &obj.Rules, UnmarshalRule) if err != nil { + err = core.SDKErrorf(err, "", "rules-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -2884,14 +3117,17 @@ func UnmarshalServiceRefTarget(m map[string]json.RawMessage, result interface{}) obj := new(ServiceRefTarget) err = core.UnmarshalPrimitive(m, "service_name", &obj.ServiceName) if err != nil { + err = core.SDKErrorf(err, "", "service_name-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "service_type", &obj.ServiceType) if err != nil { + err = core.SDKErrorf(err, "", "service_type-error", common.GetComponentInfo()) return } err = core.UnmarshalModel(m, "locations", &obj.Locations, UnmarshalServiceRefTargetLocationsItem) if err != nil { + err = core.SDKErrorf(err, "", "locations-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -2912,10 +3148,12 @@ func UnmarshalServiceRefTargetList(m map[string]json.RawMessage, result interfac obj := new(ServiceRefTargetList) err = core.UnmarshalPrimitive(m, "count", &obj.Count) if err != nil { + err = core.SDKErrorf(err, "", "count-error", common.GetComponentInfo()) return } err = core.UnmarshalModel(m, "targets", &obj.Targets, UnmarshalServiceRefTarget) if err != nil { + err = core.SDKErrorf(err, "", "targets-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -2939,14 +3177,17 @@ func UnmarshalServiceRefTargetLocationsItem(m map[string]json.RawMessage, result obj := new(ServiceRefTargetLocationsItem) err = core.UnmarshalPrimitive(m, "display_name", &obj.DisplayName) if err != nil { + err = core.SDKErrorf(err, "", "display_name-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "kind", &obj.Kind) if err != nil { + err = core.SDKErrorf(err, "", "kind-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "name", &obj.Name) if err != nil { + err = core.SDKErrorf(err, "", "name-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -2977,6 +3218,9 @@ func (*ContextBasedRestrictionsV1) NewServiceRefValue(accountID string) (_model AccountID: core.StringPtr(accountID), } err = core.ValidateStruct(_model, "required parameters") + if err != nil { + err = core.SDKErrorf(err, "", "model-missing-required", common.GetComponentInfo()) + } return } @@ -2985,22 +3229,27 @@ func UnmarshalServiceRefValue(m map[string]json.RawMessage, result interface{}) obj := new(ServiceRefValue) err = core.UnmarshalPrimitive(m, "account_id", &obj.AccountID) if err != nil { + err = core.SDKErrorf(err, "", "account_id-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "service_type", &obj.ServiceType) if err != nil { + err = core.SDKErrorf(err, "", "service_type-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "service_name", &obj.ServiceName) if err != nil { + err = core.SDKErrorf(err, "", "service_name-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "service_instance", &obj.ServiceInstance) if err != nil { + err = core.SDKErrorf(err, "", "service_instance-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "location", &obj.Location) if err != nil { + err = core.SDKErrorf(err, "", "location-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -3058,58 +3307,72 @@ func UnmarshalZone(m map[string]json.RawMessage, result interface{}) (err error) obj := new(Zone) err = core.UnmarshalPrimitive(m, "id", &obj.ID) if err != nil { + err = core.SDKErrorf(err, "", "id-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) if err != nil { + err = core.SDKErrorf(err, "", "crn-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "address_count", &obj.AddressCount) if err != nil { + err = core.SDKErrorf(err, "", "address_count-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "excluded_count", &obj.ExcludedCount) if err != nil { + err = core.SDKErrorf(err, "", "excluded_count-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "name", &obj.Name) if err != nil { + err = core.SDKErrorf(err, "", "name-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "account_id", &obj.AccountID) if err != nil { + err = core.SDKErrorf(err, "", "account_id-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "description", &obj.Description) if err != nil { + err = core.SDKErrorf(err, "", "description-error", common.GetComponentInfo()) return } err = core.UnmarshalModel(m, "addresses", &obj.Addresses, UnmarshalAddress) if err != nil { + err = core.SDKErrorf(err, "", "addresses-error", common.GetComponentInfo()) return } err = core.UnmarshalModel(m, "excluded", &obj.Excluded, UnmarshalAddress) if err != nil { + err = core.SDKErrorf(err, "", "excluded-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "href", &obj.Href) if err != nil { + err = core.SDKErrorf(err, "", "href-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) if err != nil { + err = core.SDKErrorf(err, "", "created_at-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "created_by_id", &obj.CreatedByID) if err != nil { + err = core.SDKErrorf(err, "", "created_by_id-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "last_modified_at", &obj.LastModifiedAt) if err != nil { + err = core.SDKErrorf(err, "", "last_modified_at-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "last_modified_by_id", &obj.LastModifiedByID) if err != nil { + err = core.SDKErrorf(err, "", "last_modified_by_id-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -3130,10 +3393,12 @@ func UnmarshalZoneList(m map[string]json.RawMessage, result interface{}) (err er obj := new(ZoneList) err = core.UnmarshalPrimitive(m, "count", &obj.Count) if err != nil { + err = core.SDKErrorf(err, "", "count-error", common.GetComponentInfo()) return } err = core.UnmarshalModel(m, "zones", &obj.Zones, UnmarshalZoneSummary) if err != nil { + err = core.SDKErrorf(err, "", "zones-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -3184,50 +3449,62 @@ func UnmarshalZoneSummary(m map[string]json.RawMessage, result interface{}) (err obj := new(ZoneSummary) err = core.UnmarshalPrimitive(m, "id", &obj.ID) if err != nil { + err = core.SDKErrorf(err, "", "id-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) if err != nil { + err = core.SDKErrorf(err, "", "crn-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "name", &obj.Name) if err != nil { + err = core.SDKErrorf(err, "", "name-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "description", &obj.Description) if err != nil { + err = core.SDKErrorf(err, "", "description-error", common.GetComponentInfo()) return } err = core.UnmarshalModel(m, "addresses_preview", &obj.AddressesPreview, UnmarshalAddress) if err != nil { + err = core.SDKErrorf(err, "", "addresses_preview-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "address_count", &obj.AddressCount) if err != nil { + err = core.SDKErrorf(err, "", "address_count-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "excluded_count", &obj.ExcludedCount) if err != nil { + err = core.SDKErrorf(err, "", "excluded_count-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "href", &obj.Href) if err != nil { + err = core.SDKErrorf(err, "", "href-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) if err != nil { + err = core.SDKErrorf(err, "", "created_at-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "created_by_id", &obj.CreatedByID) if err != nil { + err = core.SDKErrorf(err, "", "created_by_id-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "last_modified_at", &obj.LastModifiedAt) if err != nil { + err = core.SDKErrorf(err, "", "last_modified_at-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "last_modified_by_id", &obj.LastModifiedByID) if err != nil { + err = core.SDKErrorf(err, "", "last_modified_by_id-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -3242,6 +3519,9 @@ type AddressIPAddress struct { // The IP address. Value *string `json:"value" validate:"required"` + + // The address id (for use by terraform only). + ID *string `json:"id,omitempty"` } // Constants associated with the AddressIPAddress.Type property. @@ -3257,6 +3537,9 @@ func (*ContextBasedRestrictionsV1) NewAddressIPAddress(typeVar string, value str Value: core.StringPtr(value), } err = core.ValidateStruct(_model, "required parameters") + if err != nil { + err = core.SDKErrorf(err, "", "model-missing-required", common.GetComponentInfo()) + } return } @@ -3269,10 +3552,17 @@ func UnmarshalAddressIPAddress(m map[string]json.RawMessage, result interface{}) obj := new(AddressIPAddress) err = core.UnmarshalPrimitive(m, "type", &obj.Type) if err != nil { + err = core.SDKErrorf(err, "", "type-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "value", &obj.Value) if err != nil { + err = core.SDKErrorf(err, "", "value-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + err = core.SDKErrorf(err, "", "id-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -3287,6 +3577,9 @@ type AddressIPAddressRange struct { // The ip range in - format. Value *string `json:"value" validate:"required"` + + // The address id (for use by terraform only). + ID *string `json:"id,omitempty"` } // Constants associated with the AddressIPAddressRange.Type property. @@ -3302,6 +3595,9 @@ func (*ContextBasedRestrictionsV1) NewAddressIPAddressRange(typeVar string, valu Value: core.StringPtr(value), } err = core.ValidateStruct(_model, "required parameters") + if err != nil { + err = core.SDKErrorf(err, "", "model-missing-required", common.GetComponentInfo()) + } return } @@ -3314,10 +3610,17 @@ func UnmarshalAddressIPAddressRange(m map[string]json.RawMessage, result interfa obj := new(AddressIPAddressRange) err = core.UnmarshalPrimitive(m, "type", &obj.Type) if err != nil { + err = core.SDKErrorf(err, "", "type-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "value", &obj.Value) if err != nil { + err = core.SDKErrorf(err, "", "value-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + err = core.SDKErrorf(err, "", "id-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -3332,6 +3635,9 @@ type AddressServiceRef struct { // A service reference value. Ref *ServiceRefValue `json:"ref" validate:"required"` + + // The address id (for use by terraform only). + ID *string `json:"id,omitempty"` } // Constants associated with the AddressServiceRef.Type property. @@ -3347,6 +3653,9 @@ func (*ContextBasedRestrictionsV1) NewAddressServiceRef(typeVar string, ref *Ser Ref: ref, } err = core.ValidateStruct(_model, "required parameters") + if err != nil { + err = core.SDKErrorf(err, "", "model-missing-required", common.GetComponentInfo()) + } return } @@ -3359,10 +3668,17 @@ func UnmarshalAddressServiceRef(m map[string]json.RawMessage, result interface{} obj := new(AddressServiceRef) err = core.UnmarshalPrimitive(m, "type", &obj.Type) if err != nil { + err = core.SDKErrorf(err, "", "type-error", common.GetComponentInfo()) return } err = core.UnmarshalModel(m, "ref", &obj.Ref, UnmarshalServiceRefValue) if err != nil { + err = core.SDKErrorf(err, "", "ref-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + err = core.SDKErrorf(err, "", "id-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -3377,6 +3693,9 @@ type AddressSubnet struct { // The subnet in CIDR format. Value *string `json:"value" validate:"required"` + + // The address id (for use by terraform only). + ID *string `json:"id,omitempty"` } // Constants associated with the AddressSubnet.Type property. @@ -3392,6 +3711,9 @@ func (*ContextBasedRestrictionsV1) NewAddressSubnet(typeVar string, value string Value: core.StringPtr(value), } err = core.ValidateStruct(_model, "required parameters") + if err != nil { + err = core.SDKErrorf(err, "", "model-missing-required", common.GetComponentInfo()) + } return } @@ -3404,10 +3726,17 @@ func UnmarshalAddressSubnet(m map[string]json.RawMessage, result interface{}) (e obj := new(AddressSubnet) err = core.UnmarshalPrimitive(m, "type", &obj.Type) if err != nil { + err = core.SDKErrorf(err, "", "type-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "value", &obj.Value) if err != nil { + err = core.SDKErrorf(err, "", "value-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + err = core.SDKErrorf(err, "", "id-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) @@ -3422,6 +3751,9 @@ type AddressVPC struct { // The VPC CRN. Value *string `json:"value" validate:"required"` + + // The address id (for use by terraform only). + ID *string `json:"id,omitempty"` } // Constants associated with the AddressVPC.Type property. @@ -3437,6 +3769,9 @@ func (*ContextBasedRestrictionsV1) NewAddressVPC(typeVar string, value string) ( Value: core.StringPtr(value), } err = core.ValidateStruct(_model, "required parameters") + if err != nil { + err = core.SDKErrorf(err, "", "model-missing-required", common.GetComponentInfo()) + } return } @@ -3449,10 +3784,17 @@ func UnmarshalAddressVPC(m map[string]json.RawMessage, result interface{}) (err obj := new(AddressVPC) err = core.UnmarshalPrimitive(m, "type", &obj.Type) if err != nil { + err = core.SDKErrorf(err, "", "type-error", common.GetComponentInfo()) return } err = core.UnmarshalPrimitive(m, "value", &obj.Value) if err != nil { + err = core.SDKErrorf(err, "", "value-error", common.GetComponentInfo()) + return + } + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + err = core.SDKErrorf(err, "", "id-error", common.GetComponentInfo()) return } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) diff --git a/contextbasedrestrictionsv1/context_based_restrictions_v1_integration_test.go b/contextbasedrestrictionsv1/context_based_restrictions_v1_integration_test.go index 0aade69b..ff4b73e1 100644 --- a/contextbasedrestrictionsv1/context_based_restrictions_v1_integration_test.go +++ b/contextbasedrestrictionsv1/context_based_restrictions_v1_integration_test.go @@ -135,7 +135,7 @@ var _ = Describe(`ContextBasedRestrictionsV1 Integration Tests`, func() { Ref: &contextbasedrestrictionsv1.ServiceRefValue{ AccountID: core.StringPtr(testAccountID), ServiceName: core.StringPtr("containers-kubernetes"), - Location: core.StringPtr("us-south"), + Location: core.StringPtr("dal"), }, } diff --git a/contextbasedrestrictionsv1/context_based_restrictions_v1_test.go b/contextbasedrestrictionsv1/context_based_restrictions_v1_test.go index e9f69a38..d84340d5 100644 --- a/contextbasedrestrictionsv1/context_based_restrictions_v1_test.go +++ b/contextbasedrestrictionsv1/context_based_restrictions_v1_test.go @@ -19,6 +19,7 @@ package contextbasedrestrictionsv1_test import ( "bytes" "context" + "encoding/base64" "encoding/json" "fmt" "io" @@ -192,6 +193,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { addressModel := new(contextbasedrestrictionsv1.AddressIPAddress) addressModel.Type = core.StringPtr("ipAddress") addressModel.Value = core.StringPtr("169.23.56.234") + addressModel.ID = core.StringPtr("testString") // Construct an instance of the CreateZoneOptions model createZoneOptionsModel := new(contextbasedrestrictionsv1.CreateZoneOptions) @@ -258,7 +260,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"id": "ID", "crn": "CRN", "address_count": 12, "excluded_count": 13, "name": "Name", "account_id": "AccountID", "description": "Description", "addresses": [{"type": "ipAddress", "value": "Value"}], "excluded": [{"type": "ipAddress", "value": "Value"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "crn": "CRN", "address_count": 12, "excluded_count": 13, "name": "Name", "account_id": "AccountID", "description": "Description", "addresses": [{"type": "ipAddress", "value": "Value", "id": "ID"}], "excluded": [{"type": "ipAddress", "value": "Value", "id": "ID"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) })) }) It(`Invoke CreateZone successfully with retries`, func() { @@ -274,6 +276,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { addressModel := new(contextbasedrestrictionsv1.AddressIPAddress) addressModel.Type = core.StringPtr("ipAddress") addressModel.Value = core.StringPtr("169.23.56.234") + addressModel.ID = core.StringPtr("testString") // Construct an instance of the CreateZoneOptions model createZoneOptionsModel := new(contextbasedrestrictionsv1.CreateZoneOptions) @@ -343,7 +346,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"id": "ID", "crn": "CRN", "address_count": 12, "excluded_count": 13, "name": "Name", "account_id": "AccountID", "description": "Description", "addresses": [{"type": "ipAddress", "value": "Value"}], "excluded": [{"type": "ipAddress", "value": "Value"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "crn": "CRN", "address_count": 12, "excluded_count": 13, "name": "Name", "account_id": "AccountID", "description": "Description", "addresses": [{"type": "ipAddress", "value": "Value", "id": "ID"}], "excluded": [{"type": "ipAddress", "value": "Value", "id": "ID"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) })) }) It(`Invoke CreateZone successfully`, func() { @@ -364,6 +367,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { addressModel := new(contextbasedrestrictionsv1.AddressIPAddress) addressModel.Type = core.StringPtr("ipAddress") addressModel.Value = core.StringPtr("169.23.56.234") + addressModel.ID = core.StringPtr("testString") // Construct an instance of the CreateZoneOptions model createZoneOptionsModel := new(contextbasedrestrictionsv1.CreateZoneOptions) @@ -395,6 +399,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { addressModel := new(contextbasedrestrictionsv1.AddressIPAddress) addressModel.Type = core.StringPtr("ipAddress") addressModel.Value = core.StringPtr("169.23.56.234") + addressModel.ID = core.StringPtr("testString") // Construct an instance of the CreateZoneOptions model createZoneOptionsModel := new(contextbasedrestrictionsv1.CreateZoneOptions) @@ -440,6 +445,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { addressModel := new(contextbasedrestrictionsv1.AddressIPAddress) addressModel.Type = core.StringPtr("ipAddress") addressModel.Value = core.StringPtr("169.23.56.234") + addressModel.ID = core.StringPtr("testString") // Construct an instance of the CreateZoneOptions model createZoneOptionsModel := new(contextbasedrestrictionsv1.CreateZoneOptions) @@ -545,7 +551,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"count": 5, "zones": [{"id": "ID", "crn": "CRN", "name": "Name", "description": "Description", "addresses_preview": [{"type": "ipAddress", "value": "Value"}], "address_count": 12, "excluded_count": 13, "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}]}`) + fmt.Fprintf(res, "%s", `{"count": 5, "zones": [{"id": "ID", "crn": "CRN", "name": "Name", "description": "Description", "addresses_preview": [{"type": "ipAddress", "value": "Value", "id": "ID"}], "address_count": 12, "excluded_count": 13, "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}]}`) })) }) It(`Invoke ListZones successfully with retries`, func() { @@ -610,7 +616,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"count": 5, "zones": [{"id": "ID", "crn": "CRN", "name": "Name", "description": "Description", "addresses_preview": [{"type": "ipAddress", "value": "Value"}], "address_count": 12, "excluded_count": 13, "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}]}`) + fmt.Fprintf(res, "%s", `{"count": 5, "zones": [{"id": "ID", "crn": "CRN", "name": "Name", "description": "Description", "addresses_preview": [{"type": "ipAddress", "value": "Value", "id": "ID"}], "address_count": 12, "excluded_count": 13, "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}]}`) })) }) It(`Invoke ListZones successfully`, func() { @@ -790,7 +796,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "crn": "CRN", "address_count": 12, "excluded_count": 13, "name": "Name", "account_id": "AccountID", "description": "Description", "addresses": [{"type": "ipAddress", "value": "Value"}], "excluded": [{"type": "ipAddress", "value": "Value"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "crn": "CRN", "address_count": 12, "excluded_count": 13, "name": "Name", "account_id": "AccountID", "description": "Description", "addresses": [{"type": "ipAddress", "value": "Value", "id": "ID"}], "excluded": [{"type": "ipAddress", "value": "Value", "id": "ID"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) })) }) It(`Invoke GetZone successfully with retries`, func() { @@ -850,7 +856,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "crn": "CRN", "address_count": 12, "excluded_count": 13, "name": "Name", "account_id": "AccountID", "description": "Description", "addresses": [{"type": "ipAddress", "value": "Value"}], "excluded": [{"type": "ipAddress", "value": "Value"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "crn": "CRN", "address_count": 12, "excluded_count": 13, "name": "Name", "account_id": "AccountID", "description": "Description", "addresses": [{"type": "ipAddress", "value": "Value", "id": "ID"}], "excluded": [{"type": "ipAddress", "value": "Value", "id": "ID"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) })) }) It(`Invoke GetZone successfully`, func() { @@ -985,6 +991,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { addressModel := new(contextbasedrestrictionsv1.AddressIPAddress) addressModel.Type = core.StringPtr("ipAddress") addressModel.Value = core.StringPtr("169.23.56.234") + addressModel.ID = core.StringPtr("testString") // Construct an instance of the ReplaceZoneOptions model replaceZoneOptionsModel := new(contextbasedrestrictionsv1.ReplaceZoneOptions) @@ -1055,7 +1062,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "crn": "CRN", "address_count": 12, "excluded_count": 13, "name": "Name", "account_id": "AccountID", "description": "Description", "addresses": [{"type": "ipAddress", "value": "Value"}], "excluded": [{"type": "ipAddress", "value": "Value"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "crn": "CRN", "address_count": 12, "excluded_count": 13, "name": "Name", "account_id": "AccountID", "description": "Description", "addresses": [{"type": "ipAddress", "value": "Value", "id": "ID"}], "excluded": [{"type": "ipAddress", "value": "Value", "id": "ID"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) })) }) It(`Invoke ReplaceZone successfully with retries`, func() { @@ -1071,6 +1078,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { addressModel := new(contextbasedrestrictionsv1.AddressIPAddress) addressModel.Type = core.StringPtr("ipAddress") addressModel.Value = core.StringPtr("169.23.56.234") + addressModel.ID = core.StringPtr("testString") // Construct an instance of the ReplaceZoneOptions model replaceZoneOptionsModel := new(contextbasedrestrictionsv1.ReplaceZoneOptions) @@ -1144,7 +1152,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"id": "ID", "crn": "CRN", "address_count": 12, "excluded_count": 13, "name": "Name", "account_id": "AccountID", "description": "Description", "addresses": [{"type": "ipAddress", "value": "Value"}], "excluded": [{"type": "ipAddress", "value": "Value"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) + fmt.Fprintf(res, "%s", `{"id": "ID", "crn": "CRN", "address_count": 12, "excluded_count": 13, "name": "Name", "account_id": "AccountID", "description": "Description", "addresses": [{"type": "ipAddress", "value": "Value", "id": "ID"}], "excluded": [{"type": "ipAddress", "value": "Value", "id": "ID"}], "href": "Href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "CreatedByID", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "LastModifiedByID"}`) })) }) It(`Invoke ReplaceZone successfully`, func() { @@ -1165,6 +1173,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { addressModel := new(contextbasedrestrictionsv1.AddressIPAddress) addressModel.Type = core.StringPtr("ipAddress") addressModel.Value = core.StringPtr("169.23.56.234") + addressModel.ID = core.StringPtr("testString") // Construct an instance of the ReplaceZoneOptions model replaceZoneOptionsModel := new(contextbasedrestrictionsv1.ReplaceZoneOptions) @@ -1198,6 +1207,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { addressModel := new(contextbasedrestrictionsv1.AddressIPAddress) addressModel.Type = core.StringPtr("ipAddress") addressModel.Value = core.StringPtr("169.23.56.234") + addressModel.ID = core.StringPtr("testString") // Construct an instance of the ReplaceZoneOptions model replaceZoneOptionsModel := new(contextbasedrestrictionsv1.ReplaceZoneOptions) @@ -1252,6 +1262,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { addressModel := new(contextbasedrestrictionsv1.AddressIPAddress) addressModel.Type = core.StringPtr("ipAddress") addressModel.Value = core.StringPtr("169.23.56.234") + addressModel.ID = core.StringPtr("testString") // Construct an instance of the ReplaceZoneOptions model replaceZoneOptionsModel := new(contextbasedrestrictionsv1.ReplaceZoneOptions) @@ -3934,8 +3945,10 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { Expect(addressModel).ToNot(BeNil()) addressModel.Type = core.StringPtr("ipAddress") addressModel.Value = core.StringPtr("169.23.56.234") + addressModel.ID = core.StringPtr("testString") Expect(addressModel.Type).To(Equal(core.StringPtr("ipAddress"))) Expect(addressModel.Value).To(Equal(core.StringPtr("169.23.56.234"))) + Expect(addressModel.ID).To(Equal(core.StringPtr("testString"))) // Construct an instance of the CreateZoneOptions model createZoneOptionsModel := contextBasedRestrictionsService.NewCreateZoneOptions() @@ -4222,8 +4235,10 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { Expect(addressModel).ToNot(BeNil()) addressModel.Type = core.StringPtr("ipAddress") addressModel.Value = core.StringPtr("169.23.56.234") + addressModel.ID = core.StringPtr("testString") Expect(addressModel.Type).To(Equal(core.StringPtr("ipAddress"))) Expect(addressModel.Value).To(Equal(core.StringPtr("169.23.56.234"))) + Expect(addressModel.ID).To(Equal(core.StringPtr("testString"))) // Construct an instance of the ReplaceZoneOptions model zoneID := "testString" @@ -4332,6 +4347,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { model := new(contextbasedrestrictionsv1.Address) model.Type = core.StringPtr("ipAddress") model.Value = core.StringPtr("testString") + model.ID = core.StringPtr("testString") model.Ref = nil b, err := json.Marshal(model) @@ -4505,6 +4521,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { model := new(contextbasedrestrictionsv1.AddressIPAddress) model.Type = core.StringPtr("ipAddress") model.Value = core.StringPtr("testString") + model.ID = core.StringPtr("testString") b, err := json.Marshal(model) Expect(err).To(BeNil()) @@ -4524,6 +4541,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { model := new(contextbasedrestrictionsv1.AddressIPAddressRange) model.Type = core.StringPtr("ipRange") model.Value = core.StringPtr("testString") + model.ID = core.StringPtr("testString") b, err := json.Marshal(model) Expect(err).To(BeNil()) @@ -4543,6 +4561,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { model := new(contextbasedrestrictionsv1.AddressServiceRef) model.Type = core.StringPtr("serviceRef") model.Ref = nil + model.ID = core.StringPtr("testString") b, err := json.Marshal(model) Expect(err).To(BeNil()) @@ -4562,6 +4581,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { model := new(contextbasedrestrictionsv1.AddressSubnet) model.Type = core.StringPtr("subnet") model.Value = core.StringPtr("testString") + model.ID = core.StringPtr("testString") b, err := json.Marshal(model) Expect(err).To(BeNil()) @@ -4581,6 +4601,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { model := new(contextbasedrestrictionsv1.AddressVPC) model.Type = core.StringPtr("vpc") model.Value = core.StringPtr("testString") + model.ID = core.StringPtr("testString") b, err := json.Marshal(model) Expect(err).To(BeNil()) @@ -4596,10 +4617,9 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { Expect(result).To(Equal(model)) }) }) - Describe(`Utility function tests`, func() { It(`Invoke CreateMockByteArray() successfully`, func() { - mockByteArray := CreateMockByteArray("This is a test") + mockByteArray := CreateMockByteArray("VGhpcyBpcyBhIHRlc3Qgb2YgdGhlIGVtZXJnZW5jeSBicm9hZGNhc3Qgc3lzdGVt") Expect(mockByteArray).ToNot(BeNil()) }) It(`Invoke CreateMockUUID() successfully`, func() { @@ -4625,8 +4645,11 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Utility functions used by the generated test code // -func CreateMockByteArray(mockData string) *[]byte { - ba := []byte(mockData) +func CreateMockByteArray(encodedString string) *[]byte { + ba, err := base64.StdEncoding.DecodeString(encodedString) + if err != nil { + panic(err) + } return &ba }