From e03cca8675f2074662ac7689d6a2a5d2a70ec241 Mon Sep 17 00:00:00 2001 From: sreee9 Date: Wed, 20 Sep 2023 14:34:04 +0530 Subject: [PATCH] update sdk with set schema and schema version state changes Signed-off-by: sreee9 --- examples/schema/main.go | 61 +++- pkg/schemaregistryv1/schemaregistry_v1.go | 320 +++++++++++++++--- .../schemaregistry_v1_suite_test.go | 2 +- .../schemaregistry_v1_test.go | 245 +++++++++++++- 4 files changed, 567 insertions(+), 61 deletions(-) diff --git a/examples/schema/main.go b/examples/schema/main.go index bd9ecc6..b9cd6ee 100644 --- a/examples/schema/main.go +++ b/examples/schema/main.go @@ -71,6 +71,9 @@ func main() { os.Exit(1) } + // Set Schema state to DISABLED to be able to delete Schema + setSchemaState(esClient, "DISABLED") + // Try to delete Schema before creating deleteSchema(esClient) @@ -106,14 +109,14 @@ func main() { // Create Version err = createVersion(esClient) if err != nil { - log.Printf("error occurred while creating version") + log.Printf("error occurred while creating version: %q", err) } log.Printf("creating version successful") // Get Version err = getVersion(esClient) if err != nil { - log.Printf("error occurred while getting version 2") + log.Printf("error occurred while getting version 2: %q", err) } log.Printf("getting version successful") @@ -125,6 +128,13 @@ func main() { } log.Printf("listing versions successful") + // Set Schema Version state to DISABLED to be able to delete Schema Version + err = setSchemaVersionState(esClient, "DISABLED", 2) + if err != nil { + log.Printf("error occurred while updating the schema to DISABLED state: %q", err) + os.Exit(1) + } + // Delete Version if err = deleteVersion(esClient); err != nil { log.Printf("error occurred while deleting the version: %q", err) @@ -174,6 +184,13 @@ func main() { } log.Printf("deleting schema rule successful") + // Set Schema state to DISABLED to be able to delete Schema + err = setSchemaState(esClient, "DISABLED") + if err != nil { + log.Printf("error occurred while updating the schema to DISABLED state: %q", err) + os.Exit(1) + } + // Delete Schema if err = deleteSchema(esClient); err != nil { log.Printf("error occurred while deleting the schema: %q", err) @@ -221,6 +238,46 @@ func createSchema(esClient *schemaregistryv1.SchemaregistryV1) error { return nil } // func.end +func setSchemaState(esClient *schemaregistryv1.SchemaregistryV1, state string) error { + // Construct an instance of the setSchemaStateOptions + setSchemaStateOptions := esClient.NewSetSchemaStateOptions("schema-id") + setSchemaStateOptions.SetID("schema-id") + setSchemaStateOptions.SetState(state) + + // Set the schema state + response, operationErr := esClient.SetSchemaState(setSchemaStateOptions) + if operationErr != nil { + return fmt.Errorf("error updating schema state to %s : %s", state, operationErr.Error()) + } + + // Check the result + if response.StatusCode != http.StatusNoContent { + operationErr = fmt.Errorf("updating schema state to %s failed with response: %v", state, response) + return operationErr + } + return nil +} // func.end + +func setSchemaVersionState(esClient *schemaregistryv1.SchemaregistryV1, state string, version int64) error { + // Construct an instance of the setSchemaStateOptions + setSchemaVersionStateOptions := esClient.NewSetSchemaVersionStateOptions("schema-id", version) + setSchemaVersionStateOptions.SetID("schema-id") + setSchemaVersionStateOptions.SetState(state) + + // Set the schema state + response, operationErr := esClient.SetSchemaVersionState(setSchemaVersionStateOptions) + if operationErr != nil { + return fmt.Errorf("error updating schema state to %s : %s", state, operationErr.Error()) + } + + // Check the result + if response.StatusCode != http.StatusNoContent { + operationErr = fmt.Errorf("updating schema state to %s failed with response: %v", state, response) + return operationErr + } + return nil +} // func.end + func getLatestSchema(esClient *schemaregistryv1.SchemaregistryV1) error { // Construct an instance of the GetLatestSchemaOptions model getLatestSchemaOptions := esClient.NewGetLatestSchemaOptions("schema-id") diff --git a/pkg/schemaregistryv1/schemaregistry_v1.go b/pkg/schemaregistryv1/schemaregistry_v1.go index aec8bcb..0dd7eb1 100644 --- a/pkg/schemaregistryv1/schemaregistry_v1.go +++ b/pkg/schemaregistryv1/schemaregistry_v1.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2021. + * (C) Copyright IBM Corp. 2023. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ /* - * IBM OpenAPI SDK Code Generator Version: 3.37.1-66e80f2e-20210813-202232 + * IBM OpenAPI SDK Code Generator Version: 3.78.0-67aec9b7-20230818-174940 */ // Package schemaregistryv1 : Operations and models for the SchemaregistryV1 service @@ -35,7 +35,7 @@ import ( // SchemaregistryV1 : IBM Event Streams schema registry management // -// Version: 1.0.0 +// API Version: 1.0.0 type SchemaregistryV1 struct { Service *core.BaseService } @@ -383,7 +383,7 @@ func (schemaregistry *SchemaregistryV1) GetSchemaRuleWithContext(ctx context.Con } pathParamsMap := map[string]string{ - "id": *getSchemaRuleOptions.ID, + "id": *getSchemaRuleOptions.ID, "rule": *getSchemaRuleOptions.Rule, } @@ -445,7 +445,7 @@ func (schemaregistry *SchemaregistryV1) UpdateSchemaRuleWithContext(ctx context. } pathParamsMap := map[string]string{ - "id": *updateSchemaRuleOptions.ID, + "id": *updateSchemaRuleOptions.ID, "rule": *updateSchemaRuleOptions.Rule, } @@ -520,7 +520,7 @@ func (schemaregistry *SchemaregistryV1) DeleteSchemaRuleWithContext(ctx context. } pathParamsMap := map[string]string{ - "id": *deleteSchemaRuleOptions.ID, + "id": *deleteSchemaRuleOptions.ID, "rule": *deleteSchemaRuleOptions.Rule, } @@ -551,6 +551,123 @@ func (schemaregistry *SchemaregistryV1) DeleteSchemaRuleWithContext(ctx context. return } +// SetSchemaState : Set schema state +// Sets schema state. +func (schemaregistry *SchemaregistryV1) SetSchemaState(setSchemaStateOptions *SetSchemaStateOptions) (response *core.DetailedResponse, err error) { + return schemaregistry.SetSchemaStateWithContext(context.Background(), setSchemaStateOptions) +} + +// SetSchemaStateWithContext is an alternate form of the SetSchemaState method which supports a Context parameter +func (schemaregistry *SchemaregistryV1) SetSchemaStateWithContext(ctx context.Context, setSchemaStateOptions *SetSchemaStateOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(setSchemaStateOptions, "setSchemaStateOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(setSchemaStateOptions, "setSchemaStateOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "id": *setSchemaStateOptions.ID, + } + + builder := core.NewRequestBuilder(core.PUT) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = schemaregistry.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(schemaregistry.Service.Options.URL, `/artifacts/{id}/state`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range setSchemaStateOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("schemaregistry", "V1", "SetSchemaState") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Content-Type", "application/json") + + body := make(map[string]interface{}) + if setSchemaStateOptions.State != nil { + body["state"] = setSchemaStateOptions.State + } + _, err = builder.SetBodyContentJSON(body) + if err != nil { + return + } + + request, err := builder.Build() + if err != nil { + return + } + + response, err = schemaregistry.Service.Request(request, nil) + + return +} + +// SetSchemaVersionState : Set schema version state +// Sets schema version state. +func (schemaregistry *SchemaregistryV1) SetSchemaVersionState(setSchemaVersionStateOptions *SetSchemaVersionStateOptions) (response *core.DetailedResponse, err error) { + return schemaregistry.SetSchemaVersionStateWithContext(context.Background(), setSchemaVersionStateOptions) +} + +// SetSchemaVersionStateWithContext is an alternate form of the SetSchemaVersionState method which supports a Context parameter +func (schemaregistry *SchemaregistryV1) SetSchemaVersionStateWithContext(ctx context.Context, setSchemaVersionStateOptions *SetSchemaVersionStateOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(setSchemaVersionStateOptions, "setSchemaVersionStateOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(setSchemaVersionStateOptions, "setSchemaVersionStateOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "id": *setSchemaVersionStateOptions.ID, + "version": fmt.Sprint(*setSchemaVersionStateOptions.Version), + } + + builder := core.NewRequestBuilder(core.PUT) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = schemaregistry.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(schemaregistry.Service.Options.URL, `/artifacts/{id}/versions/{version}/state`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range setSchemaVersionStateOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("schemaregistry", "V1", "SetSchemaVersionState") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Content-Type", "application/json") + + body := make(map[string]interface{}) + if setSchemaVersionStateOptions.State != nil { + body["state"] = setSchemaVersionStateOptions.State + } + _, err = builder.SetBodyContentJSON(body) + if err != nil { + return + } + + request, err := builder.Build() + if err != nil { + return + } + + response, err = schemaregistry.Service.Request(request, nil) + + return +} + // ListVersions : List the versions of a schema // Returns an array containing the version numbers of all of the versions of the specified schema. func (schemaregistry *SchemaregistryV1) ListVersions(listVersionsOptions *ListVersionsOptions) (result []int64, response *core.DetailedResponse, err error) { @@ -590,6 +707,10 @@ func (schemaregistry *SchemaregistryV1) ListVersionsWithContext(ctx context.Cont } builder.AddHeader("Accept", "application/json") + if listVersionsOptions.Jsonformat != nil { + builder.AddQuery("jsonformat", fmt.Sprint(*listVersionsOptions.Jsonformat)) + } + request, err := builder.Build() if err != nil { return @@ -688,7 +809,7 @@ func (schemaregistry *SchemaregistryV1) GetVersionWithContext(ctx context.Contex } pathParamsMap := map[string]string{ - "id": *getVersionOptions.ID, + "id": *getVersionOptions.ID, "version": fmt.Sprint(*getVersionOptions.Version), } @@ -738,7 +859,7 @@ func (schemaregistry *SchemaregistryV1) DeleteVersionWithContext(ctx context.Con } pathParamsMap := map[string]string{ - "id": *deleteVersionOptions.ID, + "id": *deleteVersionOptions.ID, "version": fmt.Sprint(*deleteVersionOptions.Version), } @@ -800,6 +921,10 @@ func (schemaregistry *SchemaregistryV1) ListSchemasWithContext(ctx context.Conte } builder.AddHeader("Accept", "application/json") + if listSchemasOptions.Jsonformat != nil { + builder.AddQuery("jsonformat", fmt.Sprint(*listSchemasOptions.Jsonformat)) + } + request, err := builder.Build() if err != nil { return @@ -1104,20 +1229,20 @@ const ( // Constants associated with the CreateSchemaRuleOptions.Config property. // The configuration value for the rule. Which values are valid depends on the value of this object's `type` property. const ( - CreateSchemaRuleOptionsConfigBackwardConst = "BACKWARD" + CreateSchemaRuleOptionsConfigBackwardConst = "BACKWARD" CreateSchemaRuleOptionsConfigBackwardTransitiveConst = "BACKWARD_TRANSITIVE" - CreateSchemaRuleOptionsConfigForwardConst = "FORWARD" - CreateSchemaRuleOptionsConfigForwardTransitiveConst = "FORWARD_TRANSITIVE" - CreateSchemaRuleOptionsConfigFullConst = "FULL" - CreateSchemaRuleOptionsConfigFullTransitiveConst = "FULL_TRANSITIVE" - CreateSchemaRuleOptionsConfigNoneConst = "NONE" + CreateSchemaRuleOptionsConfigForwardConst = "FORWARD" + CreateSchemaRuleOptionsConfigForwardTransitiveConst = "FORWARD_TRANSITIVE" + CreateSchemaRuleOptionsConfigFullConst = "FULL" + CreateSchemaRuleOptionsConfigFullTransitiveConst = "FULL_TRANSITIVE" + CreateSchemaRuleOptionsConfigNoneConst = "NONE" ) // NewCreateSchemaRuleOptions : Instantiate CreateSchemaRuleOptions func (*SchemaregistryV1) NewCreateSchemaRuleOptions(id string, typeVar string, config string) *CreateSchemaRuleOptions { return &CreateSchemaRuleOptions{ - ID: core.StringPtr(id), - Type: core.StringPtr(typeVar), + ID: core.StringPtr(id), + Type: core.StringPtr(typeVar), Config: core.StringPtr(config), } } @@ -1232,7 +1357,7 @@ const ( // NewDeleteSchemaRuleOptions : Instantiate DeleteSchemaRuleOptions func (*SchemaregistryV1) NewDeleteSchemaRuleOptions(id string, rule string) *DeleteSchemaRuleOptions { return &DeleteSchemaRuleOptions{ - ID: core.StringPtr(id), + ID: core.StringPtr(id), Rule: core.StringPtr(rule), } } @@ -1270,7 +1395,7 @@ type DeleteVersionOptions struct { // NewDeleteVersionOptions : Instantiate DeleteVersionOptions func (*SchemaregistryV1) NewDeleteVersionOptions(id string, version int64) *DeleteVersionOptions { return &DeleteVersionOptions{ - ID: core.StringPtr(id), + ID: core.StringPtr(id), Version: core.Int64Ptr(version), } } @@ -1376,7 +1501,7 @@ const ( // NewGetSchemaRuleOptions : Instantiate GetSchemaRuleOptions func (*SchemaregistryV1) NewGetSchemaRuleOptions(id string, rule string) *GetSchemaRuleOptions { return &GetSchemaRuleOptions{ - ID: core.StringPtr(id), + ID: core.StringPtr(id), Rule: core.StringPtr(rule), } } @@ -1414,7 +1539,7 @@ type GetVersionOptions struct { // NewGetVersionOptions : Instantiate GetVersionOptions func (*SchemaregistryV1) NewGetVersionOptions(id string, version int64) *GetVersionOptions { return &GetVersionOptions{ - ID: core.StringPtr(id), + ID: core.StringPtr(id), Version: core.Int64Ptr(version), } } @@ -1439,6 +1564,8 @@ func (options *GetVersionOptions) SetHeaders(param map[string]string) *GetVersio // ListSchemasOptions : The ListSchemas options. type ListSchemasOptions struct { + // format of the response to be returned, allowed values are 'string' and 'object'. + Jsonformat *string `json:"jsonformat,omitempty"` // Allows users to set headers on API requests Headers map[string]string @@ -1449,6 +1576,12 @@ func (*SchemaregistryV1) NewListSchemasOptions() *ListSchemasOptions { return &ListSchemasOptions{} } +// SetJsonformat : Allow user to set Jsonformat +func (_options *ListSchemasOptions) SetJsonformat(jsonformat string) *ListSchemasOptions { + _options.Jsonformat = core.StringPtr(jsonformat) + return _options +} + // SetHeaders : Allow user to set Headers func (options *ListSchemasOptions) SetHeaders(param map[string]string) *ListSchemasOptions { options.Headers = param @@ -1460,6 +1593,9 @@ type ListVersionsOptions struct { // The schema ID for which the list of versions will be returned. ID *string `json:"-" validate:"required,ne="` + // format of the response to be returned, allowed values are 'number' and 'object'. + Jsonformat *string `json:"jsonformat,omitempty"` + // Allows users to set headers on API requests Headers map[string]string } @@ -1477,12 +1613,103 @@ func (_options *ListVersionsOptions) SetID(id string) *ListVersionsOptions { return _options } +// SetJsonformat : Allow user to set Jsonformat +func (_options *ListVersionsOptions) SetJsonformat(jsonformat string) *ListVersionsOptions { + _options.Jsonformat = core.StringPtr(jsonformat) + return _options +} + // SetHeaders : Allow user to set Headers func (options *ListVersionsOptions) SetHeaders(param map[string]string) *ListVersionsOptions { options.Headers = param return options } +// SetSchemaStateOptions : The SetSchemaState options. +type SetSchemaStateOptions struct { + // The ID of a schema. + ID *string `json:"id" validate:"required,ne="` + + // The state of the schema or schema version. + State *string `json:"state,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewSetSchemaStateOptions : Instantiate SetSchemaStateOptions +func (*SchemaregistryV1) NewSetSchemaStateOptions(id string) *SetSchemaStateOptions { + return &SetSchemaStateOptions{ + ID: core.StringPtr(id), + } +} + +// SetID : Allow user to set ID +func (_options *SetSchemaStateOptions) SetID(id string) *SetSchemaStateOptions { + _options.ID = core.StringPtr(id) + return _options +} + +// SetType : Allow user to set Type +func (_options *SetSchemaStateOptions) SetState(stateVar string) *SetSchemaStateOptions { + _options.State = core.StringPtr(stateVar) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *SetSchemaStateOptions) SetHeaders(param map[string]string) *SetSchemaStateOptions { + options.Headers = param + return options +} + +// SetSchemaVersionStateOptions : The SetSchemaVersionState options. +type SetSchemaVersionStateOptions struct { + // The ID of a schema. + ID *string `json:"id" validate:"required,ne="` + + // The version number that identifies the particular schema version to return. + Version *int64 `json:"version" validate:"required"` + + // The state of the schema or schema version. + State *string `json:"state,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + + +// NewSetSchemaVersionStateOptions : Instantiate SetSchemaVersionStateOptions +func (*SchemaregistryV1) NewSetSchemaVersionStateOptions(id string, version int64) *SetSchemaVersionStateOptions { + return &SetSchemaVersionStateOptions{ + ID: core.StringPtr(id), + Version: core.Int64Ptr(version), + } +} + +// SetID : Allow user to set ID +func (_options *SetSchemaVersionStateOptions) SetID(id string) *SetSchemaVersionStateOptions { + _options.ID = core.StringPtr(id) + return _options +} + +// SetVersion : Allow user to set Version +func (_options *SetSchemaVersionStateOptions) SetVersion(version int64) *SetSchemaVersionStateOptions { + _options.Version = core.Int64Ptr(version) + return _options +} + +// SetType : Allow user to set Type +func (_options *SetSchemaVersionStateOptions) SetState(stateVar string) *SetSchemaVersionStateOptions { + _options.State = core.StringPtr(stateVar) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *SetSchemaVersionStateOptions) SetHeaders(param map[string]string) *SetSchemaVersionStateOptions { + options.Headers = param + return options +} + // UpdateGlobalRuleOptions : The UpdateGlobalRule options. type UpdateGlobalRuleOptions struct { // The type of the global rule to update. Currently only `COMPATIBILITY` is supported. @@ -1513,20 +1740,20 @@ const ( // Constants associated with the UpdateGlobalRuleOptions.Config property. // The configuration value for the rule. Which values are valid depends on the value of this object's `type` property. const ( - UpdateGlobalRuleOptionsConfigBackwardConst = "BACKWARD" + UpdateGlobalRuleOptionsConfigBackwardConst = "BACKWARD" UpdateGlobalRuleOptionsConfigBackwardTransitiveConst = "BACKWARD_TRANSITIVE" - UpdateGlobalRuleOptionsConfigForwardConst = "FORWARD" - UpdateGlobalRuleOptionsConfigForwardTransitiveConst = "FORWARD_TRANSITIVE" - UpdateGlobalRuleOptionsConfigFullConst = "FULL" - UpdateGlobalRuleOptionsConfigFullTransitiveConst = "FULL_TRANSITIVE" - UpdateGlobalRuleOptionsConfigNoneConst = "NONE" + UpdateGlobalRuleOptionsConfigForwardConst = "FORWARD" + UpdateGlobalRuleOptionsConfigForwardTransitiveConst = "FORWARD_TRANSITIVE" + UpdateGlobalRuleOptionsConfigFullConst = "FULL" + UpdateGlobalRuleOptionsConfigFullTransitiveConst = "FULL_TRANSITIVE" + UpdateGlobalRuleOptionsConfigNoneConst = "NONE" ) // NewUpdateGlobalRuleOptions : Instantiate UpdateGlobalRuleOptions func (*SchemaregistryV1) NewUpdateGlobalRuleOptions(rule string, typeVar string, config string) *UpdateGlobalRuleOptions { return &UpdateGlobalRuleOptions{ - Rule: core.StringPtr(rule), - Type: core.StringPtr(typeVar), + Rule: core.StringPtr(rule), + Type: core.StringPtr(typeVar), Config: core.StringPtr(config), } } @@ -1625,21 +1852,21 @@ const ( // Constants associated with the UpdateSchemaRuleOptions.Config property. // The configuration value for the rule. Which values are valid depends on the value of this object's `type` property. const ( - UpdateSchemaRuleOptionsConfigBackwardConst = "BACKWARD" + UpdateSchemaRuleOptionsConfigBackwardConst = "BACKWARD" UpdateSchemaRuleOptionsConfigBackwardTransitiveConst = "BACKWARD_TRANSITIVE" - UpdateSchemaRuleOptionsConfigForwardConst = "FORWARD" - UpdateSchemaRuleOptionsConfigForwardTransitiveConst = "FORWARD_TRANSITIVE" - UpdateSchemaRuleOptionsConfigFullConst = "FULL" - UpdateSchemaRuleOptionsConfigFullTransitiveConst = "FULL_TRANSITIVE" - UpdateSchemaRuleOptionsConfigNoneConst = "NONE" + UpdateSchemaRuleOptionsConfigForwardConst = "FORWARD" + UpdateSchemaRuleOptionsConfigForwardTransitiveConst = "FORWARD_TRANSITIVE" + UpdateSchemaRuleOptionsConfigFullConst = "FULL" + UpdateSchemaRuleOptionsConfigFullTransitiveConst = "FULL_TRANSITIVE" + UpdateSchemaRuleOptionsConfigNoneConst = "NONE" ) // NewUpdateSchemaRuleOptions : Instantiate UpdateSchemaRuleOptions func (*SchemaregistryV1) NewUpdateSchemaRuleOptions(id string, rule string, typeVar string, config string) *UpdateSchemaRuleOptions { return &UpdateSchemaRuleOptions{ - ID: core.StringPtr(id), - Rule: core.StringPtr(rule), - Type: core.StringPtr(typeVar), + ID: core.StringPtr(id), + Rule: core.StringPtr(rule), + Type: core.StringPtr(typeVar), Config: core.StringPtr(config), } } @@ -1674,6 +1901,11 @@ func (options *UpdateSchemaRuleOptions) SetHeaders(param map[string]string) *Upd return options } +// AllowedStates : Valid values for the `state` property to set schema state. +type AllowedStates struct { +} + + // CompatibilityRuleConfig : Valid values for the `config` property of a compatibility rule. type CompatibilityRuleConfig struct { } @@ -1734,19 +1966,19 @@ const ( // Constants associated with the Rule.Config property. // The configuration value for the rule. Which values are valid depends on the value of this object's `type` property. const ( - RuleConfigBackwardConst = "BACKWARD" + RuleConfigBackwardConst = "BACKWARD" RuleConfigBackwardTransitiveConst = "BACKWARD_TRANSITIVE" - RuleConfigForwardConst = "FORWARD" - RuleConfigForwardTransitiveConst = "FORWARD_TRANSITIVE" - RuleConfigFullConst = "FULL" - RuleConfigFullTransitiveConst = "FULL_TRANSITIVE" - RuleConfigNoneConst = "NONE" + RuleConfigForwardConst = "FORWARD" + RuleConfigForwardTransitiveConst = "FORWARD_TRANSITIVE" + RuleConfigFullConst = "FULL" + RuleConfigFullTransitiveConst = "FULL_TRANSITIVE" + RuleConfigNoneConst = "NONE" ) // NewRule : Instantiate Rule (Generic Model Constructor) func (*SchemaregistryV1) NewRule(typeVar string, config string) (_model *Rule, err error) { _model = &Rule{ - Type: core.StringPtr(typeVar), + Type: core.StringPtr(typeVar), Config: core.StringPtr(config), } err = core.ValidateStruct(_model, "required parameters") diff --git a/pkg/schemaregistryv1/schemaregistry_v1_suite_test.go b/pkg/schemaregistryv1/schemaregistry_v1_suite_test.go index d088b65..7122bd0 100644 --- a/pkg/schemaregistryv1/schemaregistry_v1_suite_test.go +++ b/pkg/schemaregistryv1/schemaregistry_v1_suite_test.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2021. + * (C) Copyright IBM Corp. 2023. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/pkg/schemaregistryv1/schemaregistry_v1_test.go b/pkg/schemaregistryv1/schemaregistry_v1_test.go index c76703a..77deb49 100644 --- a/pkg/schemaregistryv1/schemaregistry_v1_test.go +++ b/pkg/schemaregistryv1/schemaregistry_v1_test.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2021. + * (C) Copyright IBM Corp. 2023. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,7 +67,7 @@ var _ = Describe(`SchemaregistryV1`, func() { Context(`Using external config, construct service client instances`, func() { // Map containing environment variables used in testing. var testEnvironment = map[string]string{ - "SCHEMAREGISTRY_URL": "https://schemaregistryv1/api", + "SCHEMAREGISTRY_URL": "https://schemaregistryv1/api", "SCHEMAREGISTRY_AUTH_TYPE": "noauth", } @@ -120,7 +120,7 @@ var _ = Describe(`SchemaregistryV1`, func() { Context(`Using external config, construct service client instances with error: Invalid Auth`, func() { // Map containing environment variables used in testing. var testEnvironment = map[string]string{ - "SCHEMAREGISTRY_URL": "https://schemaregistryv1/api", + "SCHEMAREGISTRY_URL": "https://schemaregistryv1/api", "SCHEMAREGISTRY_AUTH_TYPE": "someOtherAuth", } @@ -136,7 +136,7 @@ var _ = Describe(`SchemaregistryV1`, func() { Context(`Using external config, construct service client instances with error: Invalid URL`, func() { // Map containing environment variables used in testing. var testEnvironment = map[string]string{ - "SCHEMAREGISTRY_AUTH_TYPE": "NOAuth", + "SCHEMAREGISTRY_AUTH_TYPE": "NOAuth", } SetTestEnvironment(testEnvironment) @@ -173,7 +173,7 @@ var _ = Describe(`SchemaregistryV1`, func() { Expect(req.Method).To(Equal("GET")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) + fmt.Fprint(res, `} this is not valid json {`) })) }) It(`Invoke GetGlobalRule with error: Operation response processing error`, func() { @@ -385,7 +385,7 @@ var _ = Describe(`SchemaregistryV1`, func() { Expect(req.Method).To(Equal("PUT")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) + fmt.Fprint(res, `} this is not valid json {`) })) }) It(`Invoke UpdateGlobalRule with error: Operation response processing error`, func() { @@ -639,7 +639,7 @@ var _ = Describe(`SchemaregistryV1`, func() { Expect(req.Method).To(Equal("POST")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) + fmt.Fprint(res, `} this is not valid json {`) })) }) It(`Invoke CreateSchemaRule with error: Operation response processing error`, func() { @@ -893,7 +893,7 @@ var _ = Describe(`SchemaregistryV1`, func() { Expect(req.Method).To(Equal("GET")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) + fmt.Fprint(res, `} this is not valid json {`) })) }) It(`Invoke GetSchemaRule with error: Operation response processing error`, func() { @@ -1110,7 +1110,7 @@ var _ = Describe(`SchemaregistryV1`, func() { Expect(req.Method).To(Equal("PUT")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) + fmt.Fprint(res, `} this is not valid json {`) })) }) It(`Invoke UpdateSchemaRule with error: Operation response processing error`, func() { @@ -1427,6 +1427,180 @@ var _ = Describe(`SchemaregistryV1`, func() { }) }) }) + Describe(`SetSchemaState(setSchemaStateOptions *SetSchemaStateOptions)`, func() { + setSchemaStatePath := "/artifacts/testString/state" + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(setSchemaStatePath)) + Expect(req.Method).To(Equal("PUT")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + res.WriteHeader(204) + })) + }) + It(`Invoke SetSchemaState successfully`, func() { + schemaregistryService, serviceErr := schemaregistryv1.NewSchemaregistryV1(&schemaregistryv1.SchemaregistryV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(schemaregistryService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + response, operationErr := schemaregistryService.SetSchemaState(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + + // Construct an instance of the SetSchemaStateOptions model + setSchemaStateOptionsModel := new(schemaregistryv1.SetSchemaStateOptions) + setSchemaStateOptionsModel.ID = core.StringPtr("testString") + setSchemaStateOptionsModel.State = core.StringPtr("ENABLED") + setSchemaStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + response, operationErr = schemaregistryService.SetSchemaState(setSchemaStateOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + }) + It(`Invoke SetSchemaState with error: Operation validation and request error`, func() { + schemaregistryService, serviceErr := schemaregistryv1.NewSchemaregistryV1(&schemaregistryv1.SchemaregistryV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(schemaregistryService).ToNot(BeNil()) + + // Construct an instance of the SetSchemaStateOptions model + setSchemaStateOptionsModel := new(schemaregistryv1.SetSchemaStateOptions) + setSchemaStateOptionsModel.ID = core.StringPtr("testString") + setSchemaStateOptionsModel.State = core.StringPtr("ENABLED") + setSchemaStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := schemaregistryService.SetServiceURL("") + Expect(err).To(BeNil()) + response, operationErr := schemaregistryService.SetSchemaState(setSchemaStateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the SetSchemaStateOptions model with no property values + setSchemaStateOptionsModelNew := new(schemaregistryv1.SetSchemaStateOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = schemaregistryService.SetSchemaState(setSchemaStateOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`SetSchemaVersionState(setSchemaVersionStateOptions *SetSchemaVersionStateOptions)`, func() { + setSchemaVersionStatePath := "/artifacts/testString/versions/38/state" + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(setSchemaVersionStatePath)) + Expect(req.Method).To(Equal("PUT")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + res.WriteHeader(204) + })) + }) + It(`Invoke SetSchemaVersionState successfully`, func() { + schemaregistryService, serviceErr := schemaregistryv1.NewSchemaregistryV1(&schemaregistryv1.SchemaregistryV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(schemaregistryService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + response, operationErr := schemaregistryService.SetSchemaVersionState(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + + // Construct an instance of the SetSchemaVersionStateOptions model + setSchemaVersionStateOptionsModel := new(schemaregistryv1.SetSchemaVersionStateOptions) + setSchemaVersionStateOptionsModel.ID = core.StringPtr("testString") + setSchemaVersionStateOptionsModel.Version = core.Int64Ptr(int64(38)) + setSchemaVersionStateOptionsModel.State = core.StringPtr("ENABLED") + setSchemaVersionStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + response, operationErr = schemaregistryService.SetSchemaVersionState(setSchemaVersionStateOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + }) + It(`Invoke SetSchemaVersionState with error: Operation validation and request error`, func() { + schemaregistryService, serviceErr := schemaregistryv1.NewSchemaregistryV1(&schemaregistryv1.SchemaregistryV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(schemaregistryService).ToNot(BeNil()) + + // Construct an instance of the SetSchemaVersionStateOptions model + setSchemaVersionStateOptionsModel := new(schemaregistryv1.SetSchemaVersionStateOptions) + setSchemaVersionStateOptionsModel.ID = core.StringPtr("testString") + setSchemaVersionStateOptionsModel.Version = core.Int64Ptr(int64(38)) + setSchemaVersionStateOptionsModel.State = core.StringPtr("ENABLED") + setSchemaVersionStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := schemaregistryService.SetServiceURL("") + Expect(err).To(BeNil()) + response, operationErr := schemaregistryService.SetSchemaVersionState(setSchemaVersionStateOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the SetSchemaVersionStateOptions model with no property values + setSchemaVersionStateOptionsModelNew := new(schemaregistryv1.SetSchemaVersionStateOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = schemaregistryService.SetSchemaVersionState(setSchemaVersionStateOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) Describe(`ListVersions(listVersionsOptions *ListVersionsOptions)`, func() { listVersionsPath := "/artifacts/testString/versions" Context(`Using mock server endpoint with timeout`, func() { @@ -1438,6 +1612,7 @@ var _ = Describe(`SchemaregistryV1`, func() { Expect(req.URL.EscapedPath()).To(Equal(listVersionsPath)) Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["jsonformat"]).To(Equal([]string{"testString"})) // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) @@ -1459,6 +1634,7 @@ var _ = Describe(`SchemaregistryV1`, func() { // Construct an instance of the ListVersionsOptions model listVersionsOptionsModel := new(schemaregistryv1.ListVersionsOptions) listVersionsOptionsModel.ID = core.StringPtr("testString") + listVersionsOptionsModel.Jsonformat = core.StringPtr("testString") listVersionsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error @@ -1495,6 +1671,7 @@ var _ = Describe(`SchemaregistryV1`, func() { Expect(req.URL.EscapedPath()).To(Equal(listVersionsPath)) Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["jsonformat"]).To(Equal([]string{"testString"})) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) @@ -1518,6 +1695,7 @@ var _ = Describe(`SchemaregistryV1`, func() { // Construct an instance of the ListVersionsOptions model listVersionsOptionsModel := new(schemaregistryv1.ListVersionsOptions) listVersionsOptionsModel.ID = core.StringPtr("testString") + listVersionsOptionsModel.Jsonformat = core.StringPtr("testString") listVersionsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -1538,6 +1716,7 @@ var _ = Describe(`SchemaregistryV1`, func() { // Construct an instance of the ListVersionsOptions model listVersionsOptionsModel := new(schemaregistryv1.ListVersionsOptions) listVersionsOptionsModel.ID = core.StringPtr("testString") + listVersionsOptionsModel.Jsonformat = core.StringPtr("testString") listVersionsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := schemaregistryService.SetServiceURL("") @@ -1579,6 +1758,7 @@ var _ = Describe(`SchemaregistryV1`, func() { // Construct an instance of the ListVersionsOptions model listVersionsOptionsModel := new(schemaregistryv1.ListVersionsOptions) listVersionsOptionsModel.ID = core.StringPtr("testString") + listVersionsOptionsModel.Jsonformat = core.StringPtr("testString") listVersionsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation @@ -1606,7 +1786,7 @@ var _ = Describe(`SchemaregistryV1`, func() { Expect(req.Method).To(Equal("POST")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) + fmt.Fprint(res, `} this is not valid json {`) })) }) It(`Invoke CreateVersion with error: Operation response processing error`, func() { @@ -1855,7 +2035,7 @@ var _ = Describe(`SchemaregistryV1`, func() { Expect(req.Method).To(Equal("GET")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) + fmt.Fprint(res, `} this is not valid json {`) })) }) It(`Invoke GetVersion with error: Operation response processing error`, func() { @@ -2141,6 +2321,7 @@ var _ = Describe(`SchemaregistryV1`, func() { Expect(req.URL.EscapedPath()).To(Equal(listSchemasPath)) Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["jsonformat"]).To(Equal([]string{"testString"})) // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) @@ -2161,6 +2342,7 @@ var _ = Describe(`SchemaregistryV1`, func() { // Construct an instance of the ListSchemasOptions model listSchemasOptionsModel := new(schemaregistryv1.ListSchemasOptions) + listSchemasOptionsModel.Jsonformat = core.StringPtr("testString") listSchemasOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error @@ -2197,6 +2379,7 @@ var _ = Describe(`SchemaregistryV1`, func() { Expect(req.URL.EscapedPath()).To(Equal(listSchemasPath)) Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["jsonformat"]).To(Equal([]string{"testString"})) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) @@ -2219,6 +2402,7 @@ var _ = Describe(`SchemaregistryV1`, func() { // Construct an instance of the ListSchemasOptions model listSchemasOptionsModel := new(schemaregistryv1.ListSchemasOptions) + listSchemasOptionsModel.Jsonformat = core.StringPtr("testString") listSchemasOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -2238,6 +2422,7 @@ var _ = Describe(`SchemaregistryV1`, func() { // Construct an instance of the ListSchemasOptions model listSchemasOptionsModel := new(schemaregistryv1.ListSchemasOptions) + listSchemasOptionsModel.Jsonformat = core.StringPtr("testString") listSchemasOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := schemaregistryService.SetServiceURL("") @@ -2271,6 +2456,7 @@ var _ = Describe(`SchemaregistryV1`, func() { // Construct an instance of the ListSchemasOptions model listSchemasOptionsModel := new(schemaregistryv1.ListSchemasOptions) + listSchemasOptionsModel.Jsonformat = core.StringPtr("testString") listSchemasOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation @@ -2300,7 +2486,7 @@ var _ = Describe(`SchemaregistryV1`, func() { Expect(req.Header["X-Registry-Artifactid"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) + fmt.Fprint(res, `} this is not valid json {`) })) }) It(`Invoke CreateSchema with error: Operation response processing error`, func() { @@ -2546,7 +2732,7 @@ var _ = Describe(`SchemaregistryV1`, func() { Expect(req.Method).To(Equal("GET")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) + fmt.Fprint(res, `} this is not valid json {`) })) }) It(`Invoke GetLatestSchema with error: Operation response processing error`, func() { @@ -2826,7 +3012,7 @@ var _ = Describe(`SchemaregistryV1`, func() { Expect(req.Method).To(Equal("PUT")) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, `} this is not valid json {`) + fmt.Fprint(res, `} this is not valid json {`) })) }) It(`Invoke UpdateSchema with error: Operation response processing error`, func() { @@ -3193,8 +3379,10 @@ var _ = Describe(`SchemaregistryV1`, func() { It(`Invoke NewListSchemasOptions successfully`, func() { // Construct an instance of the ListSchemasOptions model listSchemasOptionsModel := schemaregistryService.NewListSchemasOptions() + listSchemasOptionsModel.SetJsonformat("testString") listSchemasOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(listSchemasOptionsModel).ToNot(BeNil()) + Expect(listSchemasOptionsModel.Jsonformat).To(Equal(core.StringPtr("testString"))) Expect(listSchemasOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewListVersionsOptions successfully`, func() { @@ -3202,11 +3390,40 @@ var _ = Describe(`SchemaregistryV1`, func() { id := "testString" listVersionsOptionsModel := schemaregistryService.NewListVersionsOptions(id) listVersionsOptionsModel.SetID("testString") + listVersionsOptionsModel.SetJsonformat("testString") listVersionsOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(listVersionsOptionsModel).ToNot(BeNil()) Expect(listVersionsOptionsModel.ID).To(Equal(core.StringPtr("testString"))) + Expect(listVersionsOptionsModel.Jsonformat).To(Equal(core.StringPtr("testString"))) Expect(listVersionsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewSetSchemaStateOptions successfully`, func() { + // Construct an instance of the SetSchemaStateOptions model + id := "testString" + setSchemaStateOptionsModel := schemaregistryService.NewSetSchemaStateOptions(id) + setSchemaStateOptionsModel.SetID("testString") + setSchemaStateOptionsModel.SetState("ENABLED") + setSchemaStateOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(setSchemaStateOptionsModel).ToNot(BeNil()) + Expect(setSchemaStateOptionsModel.ID).To(Equal(core.StringPtr("testString"))) + Expect(setSchemaStateOptionsModel.State).To(Equal(core.StringPtr("ENABLED"))) + Expect(setSchemaStateOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewSetSchemaVersionStateOptions successfully`, func() { + // Construct an instance of the SetSchemaVersionStateOptions model + id := "testString" + version := int64(38) + setSchemaVersionStateOptionsModel := schemaregistryService.NewSetSchemaVersionStateOptions(id, version) + setSchemaVersionStateOptionsModel.SetID("testString") + setSchemaVersionStateOptionsModel.SetVersion(int64(38)) + setSchemaVersionStateOptionsModel.SetState("ENABLED") + setSchemaVersionStateOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(setSchemaVersionStateOptionsModel).ToNot(BeNil()) + Expect(setSchemaVersionStateOptionsModel.ID).To(Equal(core.StringPtr("testString"))) + Expect(setSchemaVersionStateOptionsModel.Version).To(Equal(core.Int64Ptr(int64(38)))) + Expect(setSchemaVersionStateOptionsModel.State).To(Equal(core.StringPtr("ENABLED"))) + Expect(setSchemaVersionStateOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewUpdateGlobalRuleOptions successfully`, func() { // Construct an instance of the UpdateGlobalRuleOptions model rule := "COMPATIBILITY"