From 10dc3c5c25f214180252831fc75f8d515652784b Mon Sep 17 00:00:00 2001 From: arjunchauhanibm <157371067+arjunchauhanibm@users.noreply.github.com> Date: Sat, 13 Jul 2024 02:19:56 +0530 Subject: [PATCH] feat(CIS): origin post quantum encryption and max HTTP version (#201) * feat(CIS): origin post quantum encryption and max HTTP version Signed-off-by: Arjun Chauhan * change pqe patch request to put Signed-off-by: Arjun Chauhan --------- Signed-off-by: Arjun Chauhan --- zonessettingsv1/zones_settings_v1.go | 516 +++++++++- .../zones_settings_v1_integration_test.go | 46 +- .../zones_settings_v1_suite_test.go | 2 +- zonessettingsv1/zones_settings_v1_test.go | 964 +++++++++++++++++- 4 files changed, 1523 insertions(+), 5 deletions(-) diff --git a/zonessettingsv1/zones_settings_v1.go b/zonessettingsv1/zones_settings_v1.go index 48bb6e6..95682b2 100644 --- a/zonessettingsv1/zones_settings_v1.go +++ b/zonessettingsv1/zones_settings_v1.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2022. + * (C) Copyright IBM Corp. 2024. * * 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: 99-SNAPSHOT-df265cd0-20221201-141156 + * IBM OpenAPI SDK Code Generator Version: 3.84.0-a4533f12-20240103-170852 */ // Package zonessettingsv1 : Operations and models for the ZonesSettingsV1 service @@ -4271,6 +4271,254 @@ func (zonesSettings *ZonesSettingsV1) UpdateCiphersWithContext(ctx context.Conte return } +// GetOriginMaxHttpVersion : Get origin max http version setting +// Get origin max http version setting for a zone. +func (zonesSettings *ZonesSettingsV1) GetOriginMaxHttpVersion(getOriginMaxHttpVersionOptions *GetOriginMaxHttpVersionOptions) (result *OriginMaxHttpVersionResp, response *core.DetailedResponse, err error) { + return zonesSettings.GetOriginMaxHttpVersionWithContext(context.Background(), getOriginMaxHttpVersionOptions) +} + +// GetOriginMaxHttpVersionWithContext is an alternate form of the GetOriginMaxHttpVersion method which supports a Context parameter +func (zonesSettings *ZonesSettingsV1) GetOriginMaxHttpVersionWithContext(ctx context.Context, getOriginMaxHttpVersionOptions *GetOriginMaxHttpVersionOptions) (result *OriginMaxHttpVersionResp, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(getOriginMaxHttpVersionOptions, "getOriginMaxHttpVersionOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "crn": *zonesSettings.Crn, + "zone_identifier": *zonesSettings.ZoneIdentifier, + } + + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = zonesSettings.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(zonesSettings.Service.Options.URL, `/v1/{crn}/zones/{zone_identifier}/settings/origin_max_http_version`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range getOriginMaxHttpVersionOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("zones_settings", "V1", "GetOriginMaxHttpVersion") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + + request, err := builder.Build() + if err != nil { + return + } + + var rawResponse map[string]json.RawMessage + response, err = zonesSettings.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalOriginMaxHttpVersionResp) + if err != nil { + return + } + response.Result = result + } + + return +} + +// UpdateOriginMaxHttpVersion : Update origin max http version setting +// Update origin max http version setting for a zone. +func (zonesSettings *ZonesSettingsV1) UpdateOriginMaxHttpVersion(updateOriginMaxHttpVersionOptions *UpdateOriginMaxHttpVersionOptions) (result *OriginMaxHttpVersionResp, response *core.DetailedResponse, err error) { + return zonesSettings.UpdateOriginMaxHttpVersionWithContext(context.Background(), updateOriginMaxHttpVersionOptions) +} + +// UpdateOriginMaxHttpVersionWithContext is an alternate form of the UpdateOriginMaxHttpVersion method which supports a Context parameter +func (zonesSettings *ZonesSettingsV1) UpdateOriginMaxHttpVersionWithContext(ctx context.Context, updateOriginMaxHttpVersionOptions *UpdateOriginMaxHttpVersionOptions) (result *OriginMaxHttpVersionResp, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(updateOriginMaxHttpVersionOptions, "updateOriginMaxHttpVersionOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "crn": *zonesSettings.Crn, + "zone_identifier": *zonesSettings.ZoneIdentifier, + } + + builder := core.NewRequestBuilder(core.PATCH) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = zonesSettings.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(zonesSettings.Service.Options.URL, `/v1/{crn}/zones/{zone_identifier}/settings/origin_max_http_version`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range updateOriginMaxHttpVersionOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("zones_settings", "V1", "UpdateOriginMaxHttpVersion") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") + + body := make(map[string]interface{}) + if updateOriginMaxHttpVersionOptions.Value != nil { + body["value"] = updateOriginMaxHttpVersionOptions.Value + } + _, err = builder.SetBodyContentJSON(body) + if err != nil { + return + } + + request, err := builder.Build() + if err != nil { + return + } + + var rawResponse map[string]json.RawMessage + response, err = zonesSettings.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalOriginMaxHttpVersionResp) + if err != nil { + return + } + response.Result = result + } + + return +} + +// GetOriginPostQuantumEncryption : Get origin post quantum encryption setting +// Get origin post quantum encryption setting for a zone. +func (zonesSettings *ZonesSettingsV1) GetOriginPostQuantumEncryption(getOriginPostQuantumEncryptionOptions *GetOriginPostQuantumEncryptionOptions) (result *OriginPostQuantumEncryptionResp, response *core.DetailedResponse, err error) { + return zonesSettings.GetOriginPostQuantumEncryptionWithContext(context.Background(), getOriginPostQuantumEncryptionOptions) +} + +// GetOriginPostQuantumEncryptionWithContext is an alternate form of the GetOriginPostQuantumEncryption method which supports a Context parameter +func (zonesSettings *ZonesSettingsV1) GetOriginPostQuantumEncryptionWithContext(ctx context.Context, getOriginPostQuantumEncryptionOptions *GetOriginPostQuantumEncryptionOptions) (result *OriginPostQuantumEncryptionResp, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(getOriginPostQuantumEncryptionOptions, "getOriginPostQuantumEncryptionOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "crn": *zonesSettings.Crn, + "zone_identifier": *zonesSettings.ZoneIdentifier, + } + + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = zonesSettings.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(zonesSettings.Service.Options.URL, `/v1/{crn}/zones/{zone_identifier}/cache/origin_post_quantum_encryption`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range getOriginPostQuantumEncryptionOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("zones_settings", "V1", "GetOriginPostQuantumEncryption") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + + request, err := builder.Build() + if err != nil { + return + } + + var rawResponse map[string]json.RawMessage + response, err = zonesSettings.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalOriginPostQuantumEncryptionResp) + if err != nil { + return + } + response.Result = result + } + + return +} + +// UpdateOriginPostQuantumEncryption : Update origin post quantum encryption setting +// Update origin post quantum encryption setting for a zone. +func (zonesSettings *ZonesSettingsV1) UpdateOriginPostQuantumEncryption(updateOriginPostQuantumEncryptionOptions *UpdateOriginPostQuantumEncryptionOptions) (result *OriginPostQuantumEncryptionResp, response *core.DetailedResponse, err error) { + return zonesSettings.UpdateOriginPostQuantumEncryptionWithContext(context.Background(), updateOriginPostQuantumEncryptionOptions) +} + +// UpdateOriginPostQuantumEncryptionWithContext is an alternate form of the UpdateOriginPostQuantumEncryption method which supports a Context parameter +func (zonesSettings *ZonesSettingsV1) UpdateOriginPostQuantumEncryptionWithContext(ctx context.Context, updateOriginPostQuantumEncryptionOptions *UpdateOriginPostQuantumEncryptionOptions) (result *OriginPostQuantumEncryptionResp, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(updateOriginPostQuantumEncryptionOptions, "updateOriginPostQuantumEncryptionOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "crn": *zonesSettings.Crn, + "zone_identifier": *zonesSettings.ZoneIdentifier, + } + + builder := core.NewRequestBuilder(core.PUT) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = zonesSettings.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(zonesSettings.Service.Options.URL, `/v1/{crn}/zones/{zone_identifier}/cache/origin_post_quantum_encryption`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range updateOriginPostQuantumEncryptionOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("zones_settings", "V1", "UpdateOriginPostQuantumEncryption") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") + + body := make(map[string]interface{}) + if updateOriginPostQuantumEncryptionOptions.Value != nil { + body["value"] = updateOriginPostQuantumEncryptionOptions.Value + } + _, err = builder.SetBodyContentJSON(body) + if err != nil { + return + } + + request, err := builder.Build() + if err != nil { + return + } + + var rawResponse map[string]json.RawMessage + response, err = zonesSettings.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalOriginPostQuantumEncryptionResp) + if err != nil { + return + } + response.Result = result + } + + return +} + // AlwaysUseHttpsRespResult : Container for response information. type AlwaysUseHttpsRespResult struct { // ID. @@ -4859,6 +5107,42 @@ func (options *GetOpportunisticOnionOptions) SetHeaders(param map[string]string) return options } +// GetOriginMaxHttpVersionOptions : The GetOriginMaxHttpVersion options. +type GetOriginMaxHttpVersionOptions struct { + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetOriginMaxHttpVersionOptions : Instantiate GetOriginMaxHttpVersionOptions +func (*ZonesSettingsV1) NewGetOriginMaxHttpVersionOptions() *GetOriginMaxHttpVersionOptions { + return &GetOriginMaxHttpVersionOptions{} +} + +// SetHeaders : Allow user to set Headers +func (options *GetOriginMaxHttpVersionOptions) SetHeaders(param map[string]string) *GetOriginMaxHttpVersionOptions { + options.Headers = param + return options +} + +// GetOriginPostQuantumEncryptionOptions : The GetOriginPostQuantumEncryption options. +type GetOriginPostQuantumEncryptionOptions struct { + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetOriginPostQuantumEncryptionOptions : Instantiate GetOriginPostQuantumEncryptionOptions +func (*ZonesSettingsV1) NewGetOriginPostQuantumEncryptionOptions() *GetOriginPostQuantumEncryptionOptions { + return &GetOriginPostQuantumEncryptionOptions{} +} + +// SetHeaders : Allow user to set Headers +func (options *GetOriginPostQuantumEncryptionOptions) SetHeaders(param map[string]string) *GetOriginPostQuantumEncryptionOptions { + options.Headers = param + return options +} + // GetPrefetchPreloadOptions : The GetPrefetchPreload options. type GetPrefetchPreloadOptions struct { @@ -5801,6 +6085,90 @@ func UnmarshalOriginErrorPagePassThruRespResult(m map[string]json.RawMessage, re return } +// OriginMaxHttpVersionRespResult : Container for response information. +type OriginMaxHttpVersionRespResult struct { + // ID. + ID *string `json:"id" validate:"required"` + + // Value. + Value *string `json:"value" validate:"required"` + + // Editable. + Editable *bool `json:"editable" validate:"required"` + + // Modified date. + ModifiedOn *strfmt.DateTime `json:"modified_on" validate:"required"` +} + +// UnmarshalOriginMaxHttpVersionRespResult unmarshals an instance of OriginMaxHttpVersionRespResult from the specified map of raw messages. +func UnmarshalOriginMaxHttpVersionRespResult(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(OriginMaxHttpVersionRespResult) + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "value", &obj.Value) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "editable", &obj.Editable) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "modified_on", &obj.ModifiedOn) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// OriginPostQuantumEncryptionRespResult : Container for response information. +type OriginPostQuantumEncryptionRespResult struct { + // ID. + ID *string `json:"id" validate:"required"` + + // Value. + Value *string `json:"value" validate:"required"` + + // Editable. + Editable *bool `json:"editable" validate:"required"` + + // Modified date. + ModifiedOn *strfmt.DateTime `json:"modified_on" validate:"required"` +} + +// Constants associated with the OriginPostQuantumEncryptionRespResult.Value property. +// Value. +const ( + OriginPostQuantumEncryptionRespResult_Value_Off = "off" + OriginPostQuantumEncryptionRespResult_Value_Preferred = "preferred" + OriginPostQuantumEncryptionRespResult_Value_Supported = "supported" +) + +// UnmarshalOriginPostQuantumEncryptionRespResult unmarshals an instance of OriginPostQuantumEncryptionRespResult from the specified map of raw messages. +func UnmarshalOriginPostQuantumEncryptionRespResult(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(OriginPostQuantumEncryptionRespResult) + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "value", &obj.Value) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "editable", &obj.Editable) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "modified_on", &obj.ModifiedOn) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + // PrefetchPreloadRespResult : Container for response information. type PrefetchPreloadRespResult struct { // ID. @@ -6937,6 +7305,74 @@ func (options *UpdateOpportunisticOnionOptions) SetHeaders(param map[string]stri return options } +// UpdateOriginMaxHttpVersionOptions : The UpdateOriginMaxHttpVersion options. +type UpdateOriginMaxHttpVersionOptions struct { + // Value. + Value *string `json:"value,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewUpdateOriginMaxHttpVersionOptions : Instantiate UpdateOriginMaxHttpVersionOptions +func (*ZonesSettingsV1) NewUpdateOriginMaxHttpVersionOptions() *UpdateOriginMaxHttpVersionOptions { + return &UpdateOriginMaxHttpVersionOptions{} +} + +// SetValue : Allow user to set Value +func (_options *UpdateOriginMaxHttpVersionOptions) SetValue(value string) *UpdateOriginMaxHttpVersionOptions { + _options.Value = core.StringPtr(value) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *UpdateOriginMaxHttpVersionOptions) SetHeaders(param map[string]string) *UpdateOriginMaxHttpVersionOptions { + options.Headers = param + return options +} + +// UpdateOriginPostQuantumEncryptionOptions : The UpdateOriginPostQuantumEncryption options. +type UpdateOriginPostQuantumEncryptionOptions struct { + // Instructs CIS to use Post-Quantum (PQ) key agreement algorithms when connecting to your origin. + // - `preferred`: Instructs CIS to opportunistically send a Post-Quantum keyshare in the first message to the origin + // for fastest connections when the origin supports and prefers PQ. + // - `supported`: The PQ algorithms are advertised but used only when requested by the origin. + // - `off`: The PQ algorithms are not advertised. + Value *string `json:"value,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// Constants associated with the UpdateOriginPostQuantumEncryptionOptions.Value property. +// Instructs CIS to use Post-Quantum (PQ) key agreement algorithms when connecting to your origin. +// - `preferred`: Instructs CIS to opportunistically send a Post-Quantum keyshare in the first message to the origin for +// fastest connections when the origin supports and prefers PQ. +// - `supported`: The PQ algorithms are advertised but used only when requested by the origin. +// - `off`: The PQ algorithms are not advertised. +const ( + UpdateOriginPostQuantumEncryptionOptions_Value_Off = "off" + UpdateOriginPostQuantumEncryptionOptions_Value_Preferred = "preferred" + UpdateOriginPostQuantumEncryptionOptions_Value_Supported = "supported" +) + +// NewUpdateOriginPostQuantumEncryptionOptions : Instantiate UpdateOriginPostQuantumEncryptionOptions +func (*ZonesSettingsV1) NewUpdateOriginPostQuantumEncryptionOptions() *UpdateOriginPostQuantumEncryptionOptions { + return &UpdateOriginPostQuantumEncryptionOptions{} +} + +// SetValue : Allow user to set Value +func (_options *UpdateOriginPostQuantumEncryptionOptions) SetValue(value string) *UpdateOriginPostQuantumEncryptionOptions { + _options.Value = core.StringPtr(value) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *UpdateOriginPostQuantumEncryptionOptions) SetHeaders(param map[string]string) *UpdateOriginPostQuantumEncryptionOptions { + options.Headers = param + return options +} + // UpdatePrefetchPreloadOptions : The UpdatePrefetchPreload options. type UpdatePrefetchPreloadOptions struct { // Value. @@ -8326,6 +8762,82 @@ func UnmarshalOriginErrorPagePassThruResp(m map[string]json.RawMessage, result i return } +// OriginMaxHttpVersionResp : Origin max http version response. +type OriginMaxHttpVersionResp struct { + // Container for response information. + Result *OriginMaxHttpVersionRespResult `json:"result" validate:"required"` + + // Was the get successful. + Success *bool `json:"success" validate:"required"` + + // Array of errors encountered. + Errors [][]string `json:"errors" validate:"required"` + + // Array of messages returned. + Messages [][]string `json:"messages" validate:"required"` +} + +// UnmarshalOriginMaxHttpVersionResp unmarshals an instance of OriginMaxHttpVersionResp from the specified map of raw messages. +func UnmarshalOriginMaxHttpVersionResp(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(OriginMaxHttpVersionResp) + err = core.UnmarshalModel(m, "result", &obj.Result, UnmarshalOriginMaxHttpVersionRespResult) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "success", &obj.Success) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "errors", &obj.Errors) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "messages", &obj.Messages) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// OriginPostQuantumEncryptionResp : Origin post quantum encryption response. +type OriginPostQuantumEncryptionResp struct { + // Container for response information. + Result *OriginPostQuantumEncryptionRespResult `json:"result" validate:"required"` + + // Was the get successful. + Success *bool `json:"success" validate:"required"` + + // Array of errors encountered. + Errors [][]string `json:"errors" validate:"required"` + + // Array of messages returned. + Messages [][]string `json:"messages" validate:"required"` +} + +// UnmarshalOriginPostQuantumEncryptionResp unmarshals an instance of OriginPostQuantumEncryptionResp from the specified map of raw messages. +func UnmarshalOriginPostQuantumEncryptionResp(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(OriginPostQuantumEncryptionResp) + err = core.UnmarshalModel(m, "result", &obj.Result, UnmarshalOriginPostQuantumEncryptionRespResult) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "success", &obj.Success) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "errors", &obj.Errors) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "messages", &obj.Messages) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + // PrefetchPreloadResp : Prefetch & Preload Response. type PrefetchPreloadResp struct { // Container for response information. diff --git a/zonessettingsv1/zones_settings_v1_integration_test.go b/zonessettingsv1/zones_settings_v1_integration_test.go index b9c2162..d68ed81 100644 --- a/zonessettingsv1/zones_settings_v1_integration_test.go +++ b/zonessettingsv1/zones_settings_v1_integration_test.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2024. */ package zonessettingsv1_test @@ -693,6 +693,50 @@ var _ = Describe(`zone_settings_v1_test`, func() { Expect(*updateResult.Success).Should(BeTrue()) } }) + It("origin max http version setting test", func() { + shouldSkipTest() + getOpt := service.NewGetOriginMaxHttpVersionOptions() + getResult, getResp, getErr := service.GetOriginMaxHttpVersion(getOpt) + Expect(getErr).To(BeNil()) + Expect(getResp).ToNot(BeNil()) + Expect(getResult).ToNot(BeNil()) + Expect(*getResult.Success).Should(BeTrue()) + + values := []string{"1", "2"} + + updateOpt := service.NewUpdateOriginMaxHttpVersionOptions() + for _, value := range values { + updateOpt.SetValue(value) + updateResult, updateResp, updateErr := service.UpdateOriginMaxHttpVersion(updateOpt) + Expect(updateErr).To(BeNil()) + Expect(updateResp).ToNot(BeNil()) + Expect(updateResult).ToNot(BeNil()) + Expect(*updateResult.Success).Should(BeTrue()) + } + }) + It("origin post-quantum enrcryption setting test", func() { + shouldSkipTest() + getOpt := service.NewGetOriginPostQuantumEncryptionOptions() + getResult, getResp, getErr := service.GetOriginPostQuantumEncryption(getOpt) + Expect(getErr).To(BeNil()) + Expect(getResp).ToNot(BeNil()) + Expect(getResult).ToNot(BeNil()) + Expect(*getResult.Success).Should(BeTrue()) + + values := []string{OriginPostQuantumEncryptionRespResult_Value_Preferred, + OriginPostQuantumEncryptionRespResult_Value_Supported, + OriginPostQuantumEncryptionRespResult_Value_Off} + + updateOpt := service.NewUpdateOriginPostQuantumEncryptionOptions() + for _, value := range values { + updateOpt.SetValue(value) + updateResult, updateResp, updateErr := service.UpdateOriginPostQuantumEncryption(updateOpt) + Expect(updateErr).To(BeNil()) + Expect(updateResp).ToNot(BeNil()) + Expect(updateResult).ToNot(BeNil()) + Expect(*updateResult.Success).Should(BeTrue()) + } + }) }) }) }) diff --git a/zonessettingsv1/zones_settings_v1_suite_test.go b/zonessettingsv1/zones_settings_v1_suite_test.go index 5cb6b74..b3ee38d 100644 --- a/zonessettingsv1/zones_settings_v1_suite_test.go +++ b/zonessettingsv1/zones_settings_v1_suite_test.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2022. + * (C) Copyright IBM Corp. 2024. * * 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/zonessettingsv1/zones_settings_v1_test.go b/zonessettingsv1/zones_settings_v1_test.go index 572c50d..c6266b3 100644 --- a/zonessettingsv1/zones_settings_v1_test.go +++ b/zonessettingsv1/zones_settings_v1_test.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2022. + * (C) Copyright IBM Corp. 2024. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15653,6 +15653,936 @@ var _ = Describe(`ZonesSettingsV1`, func() { }) }) }) + Describe(`GetOriginMaxHttpVersion(getOriginMaxHttpVersionOptions *GetOriginMaxHttpVersionOptions) - Operation response error`, func() { + crn := "testString" + zoneIdentifier := "testString" + getOriginMaxHttpVersionPath := "/v1/testString/zones/testString/settings/origin_max_http_version" + Context(`Using mock server endpoint with invalid JSON response`, 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(getOriginMaxHttpVersionPath)) + Expect(req.Method).To(Equal("GET")) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke GetOriginMaxHttpVersion with error: Operation response processing error`, func() { + zonesSettingsService, serviceErr := zonessettingsv1.NewZonesSettingsV1(&zonessettingsv1.ZonesSettingsV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Crn: core.StringPtr(crn), + ZoneIdentifier: core.StringPtr(zoneIdentifier), + }) + Expect(serviceErr).To(BeNil()) + Expect(zonesSettingsService).ToNot(BeNil()) + + // Construct an instance of the GetOriginMaxHttpVersionOptions model + getOriginMaxHttpVersionOptionsModel := new(zonessettingsv1.GetOriginMaxHttpVersionOptions) + getOriginMaxHttpVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := zonesSettingsService.GetOriginMaxHttpVersion(getOriginMaxHttpVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + zonesSettingsService.EnableRetries(0, 0) + result, response, operationErr = zonesSettingsService.GetOriginMaxHttpVersion(getOriginMaxHttpVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetOriginMaxHttpVersion(getOriginMaxHttpVersionOptions *GetOriginMaxHttpVersionOptions)`, func() { + crn := "testString" + zoneIdentifier := "testString" + getOriginMaxHttpVersionPath := "/v1/testString/zones/testString/settings/origin_max_http_version" + Context(`Using mock server endpoint with timeout`, 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(getOriginMaxHttpVersionPath)) + Expect(req.Method).To(Equal("GET")) + + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"result": {"id": "origin_max_http_version", "value": "1", "editable": true, "modified_on": "2023-09-14T09:49:19.524Z"}, "success": true, "errors": [["Errors"]], "messages": [["Messages"]]}`) + })) + }) + It(`Invoke GetOriginMaxHttpVersion successfully with retries`, func() { + zonesSettingsService, serviceErr := zonessettingsv1.NewZonesSettingsV1(&zonessettingsv1.ZonesSettingsV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Crn: core.StringPtr(crn), + ZoneIdentifier: core.StringPtr(zoneIdentifier), + }) + Expect(serviceErr).To(BeNil()) + Expect(zonesSettingsService).ToNot(BeNil()) + zonesSettingsService.EnableRetries(0, 0) + + // Construct an instance of the GetOriginMaxHttpVersionOptions model + getOriginMaxHttpVersionOptionsModel := new(zonessettingsv1.GetOriginMaxHttpVersionOptions) + getOriginMaxHttpVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := zonesSettingsService.GetOriginMaxHttpVersionWithContext(ctx, getOriginMaxHttpVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + zonesSettingsService.DisableRetries() + result, response, operationErr := zonesSettingsService.GetOriginMaxHttpVersion(getOriginMaxHttpVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = zonesSettingsService.GetOriginMaxHttpVersionWithContext(ctx, getOriginMaxHttpVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + 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(getOriginMaxHttpVersionPath)) + Expect(req.Method).To(Equal("GET")) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"result": {"id": "origin_max_http_version", "value": "1", "editable": true, "modified_on": "2023-09-14T09:49:19.524Z"}, "success": true, "errors": [["Errors"]], "messages": [["Messages"]]}`) + })) + }) + It(`Invoke GetOriginMaxHttpVersion successfully`, func() { + zonesSettingsService, serviceErr := zonessettingsv1.NewZonesSettingsV1(&zonessettingsv1.ZonesSettingsV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Crn: core.StringPtr(crn), + ZoneIdentifier: core.StringPtr(zoneIdentifier), + }) + Expect(serviceErr).To(BeNil()) + Expect(zonesSettingsService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := zonesSettingsService.GetOriginMaxHttpVersion(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the GetOriginMaxHttpVersionOptions model + getOriginMaxHttpVersionOptionsModel := new(zonessettingsv1.GetOriginMaxHttpVersionOptions) + getOriginMaxHttpVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = zonesSettingsService.GetOriginMaxHttpVersion(getOriginMaxHttpVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke GetOriginMaxHttpVersion with error: Operation request error`, func() { + zonesSettingsService, serviceErr := zonessettingsv1.NewZonesSettingsV1(&zonessettingsv1.ZonesSettingsV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Crn: core.StringPtr(crn), + ZoneIdentifier: core.StringPtr(zoneIdentifier), + }) + Expect(serviceErr).To(BeNil()) + Expect(zonesSettingsService).ToNot(BeNil()) + + // Construct an instance of the GetOriginMaxHttpVersionOptions model + getOriginMaxHttpVersionOptionsModel := new(zonessettingsv1.GetOriginMaxHttpVersionOptions) + getOriginMaxHttpVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := zonesSettingsService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := zonesSettingsService.GetOriginMaxHttpVersion(getOriginMaxHttpVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke GetOriginMaxHttpVersion successfully`, func() { + zonesSettingsService, serviceErr := zonessettingsv1.NewZonesSettingsV1(&zonessettingsv1.ZonesSettingsV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Crn: core.StringPtr(crn), + ZoneIdentifier: core.StringPtr(zoneIdentifier), + }) + Expect(serviceErr).To(BeNil()) + Expect(zonesSettingsService).ToNot(BeNil()) + + // Construct an instance of the GetOriginMaxHttpVersionOptions model + getOriginMaxHttpVersionOptionsModel := new(zonessettingsv1.GetOriginMaxHttpVersionOptions) + getOriginMaxHttpVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := zonesSettingsService.GetOriginMaxHttpVersion(getOriginMaxHttpVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`UpdateOriginMaxHttpVersion(updateOriginMaxHttpVersionOptions *UpdateOriginMaxHttpVersionOptions) - Operation response error`, func() { + crn := "testString" + zoneIdentifier := "testString" + updateOriginMaxHttpVersionPath := "/v1/testString/zones/testString/settings/origin_max_http_version" + Context(`Using mock server endpoint with invalid JSON response`, 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(updateOriginMaxHttpVersionPath)) + Expect(req.Method).To(Equal("PATCH")) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke UpdateOriginMaxHttpVersion with error: Operation response processing error`, func() { + zonesSettingsService, serviceErr := zonessettingsv1.NewZonesSettingsV1(&zonessettingsv1.ZonesSettingsV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Crn: core.StringPtr(crn), + ZoneIdentifier: core.StringPtr(zoneIdentifier), + }) + Expect(serviceErr).To(BeNil()) + Expect(zonesSettingsService).ToNot(BeNil()) + + // Construct an instance of the UpdateOriginMaxHttpVersionOptions model + updateOriginMaxHttpVersionOptionsModel := new(zonessettingsv1.UpdateOriginMaxHttpVersionOptions) + updateOriginMaxHttpVersionOptionsModel.Value = core.StringPtr("1") + updateOriginMaxHttpVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := zonesSettingsService.UpdateOriginMaxHttpVersion(updateOriginMaxHttpVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + zonesSettingsService.EnableRetries(0, 0) + result, response, operationErr = zonesSettingsService.UpdateOriginMaxHttpVersion(updateOriginMaxHttpVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`UpdateOriginMaxHttpVersion(updateOriginMaxHttpVersionOptions *UpdateOriginMaxHttpVersionOptions)`, func() { + crn := "testString" + zoneIdentifier := "testString" + updateOriginMaxHttpVersionPath := "/v1/testString/zones/testString/settings/origin_max_http_version" + Context(`Using mock server endpoint with timeout`, 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(updateOriginMaxHttpVersionPath)) + Expect(req.Method).To(Equal("PATCH")) + + // 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()) + + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"result": {"id": "origin_max_http_version", "value": "1", "editable": true, "modified_on": "2023-09-14T09:49:19.524Z"}, "success": true, "errors": [["Errors"]], "messages": [["Messages"]]}`) + })) + }) + It(`Invoke UpdateOriginMaxHttpVersion successfully with retries`, func() { + zonesSettingsService, serviceErr := zonessettingsv1.NewZonesSettingsV1(&zonessettingsv1.ZonesSettingsV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Crn: core.StringPtr(crn), + ZoneIdentifier: core.StringPtr(zoneIdentifier), + }) + Expect(serviceErr).To(BeNil()) + Expect(zonesSettingsService).ToNot(BeNil()) + zonesSettingsService.EnableRetries(0, 0) + + // Construct an instance of the UpdateOriginMaxHttpVersionOptions model + updateOriginMaxHttpVersionOptionsModel := new(zonessettingsv1.UpdateOriginMaxHttpVersionOptions) + updateOriginMaxHttpVersionOptionsModel.Value = core.StringPtr("1") + updateOriginMaxHttpVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := zonesSettingsService.UpdateOriginMaxHttpVersionWithContext(ctx, updateOriginMaxHttpVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + zonesSettingsService.DisableRetries() + result, response, operationErr := zonesSettingsService.UpdateOriginMaxHttpVersion(updateOriginMaxHttpVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = zonesSettingsService.UpdateOriginMaxHttpVersionWithContext(ctx, updateOriginMaxHttpVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + 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(updateOriginMaxHttpVersionPath)) + Expect(req.Method).To(Equal("PATCH")) + + // 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()) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"result": {"id": "origin_max_http_version", "value": "1", "editable": true, "modified_on": "2023-09-14T09:49:19.524Z"}, "success": true, "errors": [["Errors"]], "messages": [["Messages"]]}`) + })) + }) + It(`Invoke UpdateOriginMaxHttpVersion successfully`, func() { + zonesSettingsService, serviceErr := zonessettingsv1.NewZonesSettingsV1(&zonessettingsv1.ZonesSettingsV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Crn: core.StringPtr(crn), + ZoneIdentifier: core.StringPtr(zoneIdentifier), + }) + Expect(serviceErr).To(BeNil()) + Expect(zonesSettingsService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := zonesSettingsService.UpdateOriginMaxHttpVersion(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the UpdateOriginMaxHttpVersionOptions model + updateOriginMaxHttpVersionOptionsModel := new(zonessettingsv1.UpdateOriginMaxHttpVersionOptions) + updateOriginMaxHttpVersionOptionsModel.Value = core.StringPtr("1") + updateOriginMaxHttpVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = zonesSettingsService.UpdateOriginMaxHttpVersion(updateOriginMaxHttpVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke UpdateOriginMaxHttpVersion with error: Operation request error`, func() { + zonesSettingsService, serviceErr := zonessettingsv1.NewZonesSettingsV1(&zonessettingsv1.ZonesSettingsV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Crn: core.StringPtr(crn), + ZoneIdentifier: core.StringPtr(zoneIdentifier), + }) + Expect(serviceErr).To(BeNil()) + Expect(zonesSettingsService).ToNot(BeNil()) + + // Construct an instance of the UpdateOriginMaxHttpVersionOptions model + updateOriginMaxHttpVersionOptionsModel := new(zonessettingsv1.UpdateOriginMaxHttpVersionOptions) + updateOriginMaxHttpVersionOptionsModel.Value = core.StringPtr("1") + updateOriginMaxHttpVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := zonesSettingsService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := zonesSettingsService.UpdateOriginMaxHttpVersion(updateOriginMaxHttpVersionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke UpdateOriginMaxHttpVersion successfully`, func() { + zonesSettingsService, serviceErr := zonessettingsv1.NewZonesSettingsV1(&zonessettingsv1.ZonesSettingsV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Crn: core.StringPtr(crn), + ZoneIdentifier: core.StringPtr(zoneIdentifier), + }) + Expect(serviceErr).To(BeNil()) + Expect(zonesSettingsService).ToNot(BeNil()) + + // Construct an instance of the UpdateOriginMaxHttpVersionOptions model + updateOriginMaxHttpVersionOptionsModel := new(zonessettingsv1.UpdateOriginMaxHttpVersionOptions) + updateOriginMaxHttpVersionOptionsModel.Value = core.StringPtr("1") + updateOriginMaxHttpVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := zonesSettingsService.UpdateOriginMaxHttpVersion(updateOriginMaxHttpVersionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetOriginPostQuantumEncryption(getOriginPostQuantumEncryptionOptions *GetOriginPostQuantumEncryptionOptions) - Operation response error`, func() { + crn := "testString" + zoneIdentifier := "testString" + getOriginPostQuantumEncryptionPath := "/v1/testString/zones/testString/cache/origin_post_quantum_encryption" + Context(`Using mock server endpoint with invalid JSON response`, 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(getOriginPostQuantumEncryptionPath)) + Expect(req.Method).To(Equal("GET")) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke GetOriginPostQuantumEncryption with error: Operation response processing error`, func() { + zonesSettingsService, serviceErr := zonessettingsv1.NewZonesSettingsV1(&zonessettingsv1.ZonesSettingsV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Crn: core.StringPtr(crn), + ZoneIdentifier: core.StringPtr(zoneIdentifier), + }) + Expect(serviceErr).To(BeNil()) + Expect(zonesSettingsService).ToNot(BeNil()) + + // Construct an instance of the GetOriginPostQuantumEncryptionOptions model + getOriginPostQuantumEncryptionOptionsModel := new(zonessettingsv1.GetOriginPostQuantumEncryptionOptions) + getOriginPostQuantumEncryptionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := zonesSettingsService.GetOriginPostQuantumEncryption(getOriginPostQuantumEncryptionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + zonesSettingsService.EnableRetries(0, 0) + result, response, operationErr = zonesSettingsService.GetOriginPostQuantumEncryption(getOriginPostQuantumEncryptionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetOriginPostQuantumEncryption(getOriginPostQuantumEncryptionOptions *GetOriginPostQuantumEncryptionOptions)`, func() { + crn := "testString" + zoneIdentifier := "testString" + getOriginPostQuantumEncryptionPath := "/v1/testString/zones/testString/cache/origin_post_quantum_encryption" + Context(`Using mock server endpoint with timeout`, 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(getOriginPostQuantumEncryptionPath)) + Expect(req.Method).To(Equal("GET")) + + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"result": {"id": "origin_pqe", "value": "off", "editable": true, "modified_on": "2023-09-14T09:49:19.524Z"}, "success": true, "errors": [["Errors"]], "messages": [["Messages"]]}`) + })) + }) + It(`Invoke GetOriginPostQuantumEncryption successfully with retries`, func() { + zonesSettingsService, serviceErr := zonessettingsv1.NewZonesSettingsV1(&zonessettingsv1.ZonesSettingsV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Crn: core.StringPtr(crn), + ZoneIdentifier: core.StringPtr(zoneIdentifier), + }) + Expect(serviceErr).To(BeNil()) + Expect(zonesSettingsService).ToNot(BeNil()) + zonesSettingsService.EnableRetries(0, 0) + + // Construct an instance of the GetOriginPostQuantumEncryptionOptions model + getOriginPostQuantumEncryptionOptionsModel := new(zonessettingsv1.GetOriginPostQuantumEncryptionOptions) + getOriginPostQuantumEncryptionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := zonesSettingsService.GetOriginPostQuantumEncryptionWithContext(ctx, getOriginPostQuantumEncryptionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + zonesSettingsService.DisableRetries() + result, response, operationErr := zonesSettingsService.GetOriginPostQuantumEncryption(getOriginPostQuantumEncryptionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = zonesSettingsService.GetOriginPostQuantumEncryptionWithContext(ctx, getOriginPostQuantumEncryptionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + 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(getOriginPostQuantumEncryptionPath)) + Expect(req.Method).To(Equal("GET")) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"result": {"id": "origin_pqe", "value": "off", "editable": true, "modified_on": "2023-09-14T09:49:19.524Z"}, "success": true, "errors": [["Errors"]], "messages": [["Messages"]]}`) + })) + }) + It(`Invoke GetOriginPostQuantumEncryption successfully`, func() { + zonesSettingsService, serviceErr := zonessettingsv1.NewZonesSettingsV1(&zonessettingsv1.ZonesSettingsV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Crn: core.StringPtr(crn), + ZoneIdentifier: core.StringPtr(zoneIdentifier), + }) + Expect(serviceErr).To(BeNil()) + Expect(zonesSettingsService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := zonesSettingsService.GetOriginPostQuantumEncryption(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the GetOriginPostQuantumEncryptionOptions model + getOriginPostQuantumEncryptionOptionsModel := new(zonessettingsv1.GetOriginPostQuantumEncryptionOptions) + getOriginPostQuantumEncryptionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = zonesSettingsService.GetOriginPostQuantumEncryption(getOriginPostQuantumEncryptionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke GetOriginPostQuantumEncryption with error: Operation request error`, func() { + zonesSettingsService, serviceErr := zonessettingsv1.NewZonesSettingsV1(&zonessettingsv1.ZonesSettingsV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Crn: core.StringPtr(crn), + ZoneIdentifier: core.StringPtr(zoneIdentifier), + }) + Expect(serviceErr).To(BeNil()) + Expect(zonesSettingsService).ToNot(BeNil()) + + // Construct an instance of the GetOriginPostQuantumEncryptionOptions model + getOriginPostQuantumEncryptionOptionsModel := new(zonessettingsv1.GetOriginPostQuantumEncryptionOptions) + getOriginPostQuantumEncryptionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := zonesSettingsService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := zonesSettingsService.GetOriginPostQuantumEncryption(getOriginPostQuantumEncryptionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke GetOriginPostQuantumEncryption successfully`, func() { + zonesSettingsService, serviceErr := zonessettingsv1.NewZonesSettingsV1(&zonessettingsv1.ZonesSettingsV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Crn: core.StringPtr(crn), + ZoneIdentifier: core.StringPtr(zoneIdentifier), + }) + Expect(serviceErr).To(BeNil()) + Expect(zonesSettingsService).ToNot(BeNil()) + + // Construct an instance of the GetOriginPostQuantumEncryptionOptions model + getOriginPostQuantumEncryptionOptionsModel := new(zonessettingsv1.GetOriginPostQuantumEncryptionOptions) + getOriginPostQuantumEncryptionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := zonesSettingsService.GetOriginPostQuantumEncryption(getOriginPostQuantumEncryptionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`UpdateOriginPostQuantumEncryption(updateOriginPostQuantumEncryptionOptions *UpdateOriginPostQuantumEncryptionOptions) - Operation response error`, func() { + crn := "testString" + zoneIdentifier := "testString" + updateOriginPostQuantumEncryptionPath := "/v1/testString/zones/testString/cache/origin_post_quantum_encryption" + Context(`Using mock server endpoint with invalid JSON response`, 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(updateOriginPostQuantumEncryptionPath)) + Expect(req.Method).To(Equal("PUT")) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke UpdateOriginPostQuantumEncryption with error: Operation response processing error`, func() { + zonesSettingsService, serviceErr := zonessettingsv1.NewZonesSettingsV1(&zonessettingsv1.ZonesSettingsV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Crn: core.StringPtr(crn), + ZoneIdentifier: core.StringPtr(zoneIdentifier), + }) + Expect(serviceErr).To(BeNil()) + Expect(zonesSettingsService).ToNot(BeNil()) + + // Construct an instance of the UpdateOriginPostQuantumEncryptionOptions model + updateOriginPostQuantumEncryptionOptionsModel := new(zonessettingsv1.UpdateOriginPostQuantumEncryptionOptions) + updateOriginPostQuantumEncryptionOptionsModel.Value = core.StringPtr("preferred") + updateOriginPostQuantumEncryptionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := zonesSettingsService.UpdateOriginPostQuantumEncryption(updateOriginPostQuantumEncryptionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + zonesSettingsService.EnableRetries(0, 0) + result, response, operationErr = zonesSettingsService.UpdateOriginPostQuantumEncryption(updateOriginPostQuantumEncryptionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`UpdateOriginPostQuantumEncryption(updateOriginPostQuantumEncryptionOptions *UpdateOriginPostQuantumEncryptionOptions)`, func() { + crn := "testString" + zoneIdentifier := "testString" + updateOriginPostQuantumEncryptionPath := "/v1/testString/zones/testString/cache/origin_post_quantum_encryption" + Context(`Using mock server endpoint with timeout`, 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(updateOriginPostQuantumEncryptionPath)) + 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()) + + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"result": {"id": "origin_pqe", "value": "off", "editable": true, "modified_on": "2023-09-14T09:49:19.524Z"}, "success": true, "errors": [["Errors"]], "messages": [["Messages"]]}`) + })) + }) + It(`Invoke UpdateOriginPostQuantumEncryption successfully with retries`, func() { + zonesSettingsService, serviceErr := zonessettingsv1.NewZonesSettingsV1(&zonessettingsv1.ZonesSettingsV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Crn: core.StringPtr(crn), + ZoneIdentifier: core.StringPtr(zoneIdentifier), + }) + Expect(serviceErr).To(BeNil()) + Expect(zonesSettingsService).ToNot(BeNil()) + zonesSettingsService.EnableRetries(0, 0) + + // Construct an instance of the UpdateOriginPostQuantumEncryptionOptions model + updateOriginPostQuantumEncryptionOptionsModel := new(zonessettingsv1.UpdateOriginPostQuantumEncryptionOptions) + updateOriginPostQuantumEncryptionOptionsModel.Value = core.StringPtr("preferred") + updateOriginPostQuantumEncryptionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := zonesSettingsService.UpdateOriginPostQuantumEncryptionWithContext(ctx, updateOriginPostQuantumEncryptionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + zonesSettingsService.DisableRetries() + result, response, operationErr := zonesSettingsService.UpdateOriginPostQuantumEncryption(updateOriginPostQuantumEncryptionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = zonesSettingsService.UpdateOriginPostQuantumEncryptionWithContext(ctx, updateOriginPostQuantumEncryptionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + 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(updateOriginPostQuantumEncryptionPath)) + 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()) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"result": {"id": "origin_pqe", "value": "off", "editable": true, "modified_on": "2023-09-14T09:49:19.524Z"}, "success": true, "errors": [["Errors"]], "messages": [["Messages"]]}`) + })) + }) + It(`Invoke UpdateOriginPostQuantumEncryption successfully`, func() { + zonesSettingsService, serviceErr := zonessettingsv1.NewZonesSettingsV1(&zonessettingsv1.ZonesSettingsV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Crn: core.StringPtr(crn), + ZoneIdentifier: core.StringPtr(zoneIdentifier), + }) + Expect(serviceErr).To(BeNil()) + Expect(zonesSettingsService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := zonesSettingsService.UpdateOriginPostQuantumEncryption(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the UpdateOriginPostQuantumEncryptionOptions model + updateOriginPostQuantumEncryptionOptionsModel := new(zonessettingsv1.UpdateOriginPostQuantumEncryptionOptions) + updateOriginPostQuantumEncryptionOptionsModel.Value = core.StringPtr("preferred") + updateOriginPostQuantumEncryptionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = zonesSettingsService.UpdateOriginPostQuantumEncryption(updateOriginPostQuantumEncryptionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke UpdateOriginPostQuantumEncryption with error: Operation request error`, func() { + zonesSettingsService, serviceErr := zonessettingsv1.NewZonesSettingsV1(&zonessettingsv1.ZonesSettingsV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Crn: core.StringPtr(crn), + ZoneIdentifier: core.StringPtr(zoneIdentifier), + }) + Expect(serviceErr).To(BeNil()) + Expect(zonesSettingsService).ToNot(BeNil()) + + // Construct an instance of the UpdateOriginPostQuantumEncryptionOptions model + updateOriginPostQuantumEncryptionOptionsModel := new(zonessettingsv1.UpdateOriginPostQuantumEncryptionOptions) + updateOriginPostQuantumEncryptionOptionsModel.Value = core.StringPtr("preferred") + updateOriginPostQuantumEncryptionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := zonesSettingsService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := zonesSettingsService.UpdateOriginPostQuantumEncryption(updateOriginPostQuantumEncryptionOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke UpdateOriginPostQuantumEncryption successfully`, func() { + zonesSettingsService, serviceErr := zonessettingsv1.NewZonesSettingsV1(&zonessettingsv1.ZonesSettingsV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Crn: core.StringPtr(crn), + ZoneIdentifier: core.StringPtr(zoneIdentifier), + }) + Expect(serviceErr).To(BeNil()) + Expect(zonesSettingsService).ToNot(BeNil()) + + // Construct an instance of the UpdateOriginPostQuantumEncryptionOptions model + updateOriginPostQuantumEncryptionOptionsModel := new(zonessettingsv1.UpdateOriginPostQuantumEncryptionOptions) + updateOriginPostQuantumEncryptionOptionsModel.Value = core.StringPtr("preferred") + updateOriginPostQuantumEncryptionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := zonesSettingsService.UpdateOriginPostQuantumEncryption(updateOriginPostQuantumEncryptionOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) Describe(`Model constructor tests`, func() { Context(`Using a service client instance`, func() { crn := "testString" @@ -15803,6 +16733,20 @@ var _ = Describe(`ZonesSettingsV1`, func() { Expect(getOpportunisticOnionOptionsModel).ToNot(BeNil()) Expect(getOpportunisticOnionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewGetOriginMaxHttpVersionOptions successfully`, func() { + // Construct an instance of the GetOriginMaxHttpVersionOptions model + getOriginMaxHttpVersionOptionsModel := zonesSettingsService.NewGetOriginMaxHttpVersionOptions() + getOriginMaxHttpVersionOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(getOriginMaxHttpVersionOptionsModel).ToNot(BeNil()) + Expect(getOriginMaxHttpVersionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewGetOriginPostQuantumEncryptionOptions successfully`, func() { + // Construct an instance of the GetOriginPostQuantumEncryptionOptions model + getOriginPostQuantumEncryptionOptionsModel := zonesSettingsService.NewGetOriginPostQuantumEncryptionOptions() + getOriginPostQuantumEncryptionOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(getOriginPostQuantumEncryptionOptionsModel).ToNot(BeNil()) + Expect(getOriginPostQuantumEncryptionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewGetPrefetchPreloadOptions successfully`, func() { // Construct an instance of the GetPrefetchPreloadOptions model getPrefetchPreloadOptionsModel := zonesSettingsService.NewGetPrefetchPreloadOptions() @@ -16125,6 +17069,24 @@ var _ = Describe(`ZonesSettingsV1`, func() { Expect(updateOpportunisticOnionOptionsModel.Value).To(Equal(core.StringPtr("off"))) Expect(updateOpportunisticOnionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewUpdateOriginMaxHttpVersionOptions successfully`, func() { + // Construct an instance of the UpdateOriginMaxHttpVersionOptions model + updateOriginMaxHttpVersionOptionsModel := zonesSettingsService.NewUpdateOriginMaxHttpVersionOptions() + updateOriginMaxHttpVersionOptionsModel.SetValue("1") + updateOriginMaxHttpVersionOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(updateOriginMaxHttpVersionOptionsModel).ToNot(BeNil()) + Expect(updateOriginMaxHttpVersionOptionsModel.Value).To(Equal(core.StringPtr("1"))) + Expect(updateOriginMaxHttpVersionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewUpdateOriginPostQuantumEncryptionOptions successfully`, func() { + // Construct an instance of the UpdateOriginPostQuantumEncryptionOptions model + updateOriginPostQuantumEncryptionOptionsModel := zonesSettingsService.NewUpdateOriginPostQuantumEncryptionOptions() + updateOriginPostQuantumEncryptionOptionsModel.SetValue("preferred") + updateOriginPostQuantumEncryptionOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(updateOriginPostQuantumEncryptionOptionsModel).ToNot(BeNil()) + Expect(updateOriginPostQuantumEncryptionOptionsModel.Value).To(Equal(core.StringPtr("preferred"))) + Expect(updateOriginPostQuantumEncryptionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewUpdatePrefetchPreloadOptions successfully`, func() { // Construct an instance of the UpdatePrefetchPreloadOptions model updatePrefetchPreloadOptionsModel := zonesSettingsService.NewUpdatePrefetchPreloadOptions()