diff --git a/services/cdn/model_config.go b/services/cdn/model_config.go index 410af618a..d820c2dc5 100644 --- a/services/cdn/model_config.go +++ b/services/cdn/model_config.go @@ -162,6 +162,26 @@ func setConfigGetOptimizerAttributeType(arg *ConfigGetOptimizerAttributeType, va *arg = &val } +/* + types and functions for redirects +*/ + +// isModel +type ConfigGetRedirectsAttributeType = *RedirectConfig +type ConfigGetRedirectsArgType = RedirectConfig +type ConfigGetRedirectsRetType = RedirectConfig + +func getConfigGetRedirectsAttributeTypeOk(arg ConfigGetRedirectsAttributeType) (ret ConfigGetRedirectsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setConfigGetRedirectsAttributeType(arg *ConfigGetRedirectsAttributeType, val ConfigGetRedirectsRetType) { + *arg = &val +} + /* types and functions for regions */ @@ -218,6 +238,7 @@ type Config struct { // Sets the monthly limit of bandwidth in bytes that the pullzone is allowed to use. MonthlyLimitBytes ConfigGetMonthlyLimitBytesAttributeType `json:"monthlyLimitBytes,omitempty"` Optimizer ConfigGetOptimizerAttributeType `json:"optimizer,omitempty"` + Redirects ConfigGetRedirectsAttributeType `json:"redirects,omitempty"` // REQUIRED Regions ConfigGetRegionsAttributeType `json:"regions" required:"true"` // REQUIRED @@ -413,6 +434,29 @@ func (o *Config) SetOptimizer(v ConfigGetOptimizerRetType) { setConfigGetOptimizerAttributeType(&o.Optimizer, v) } +// GetRedirects returns the Redirects field value if set, zero value otherwise. +func (o *Config) GetRedirects() (res ConfigGetRedirectsRetType) { + res, _ = o.GetRedirectsOk() + return +} + +// GetRedirectsOk returns a tuple with the Redirects field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Config) GetRedirectsOk() (ret ConfigGetRedirectsRetType, ok bool) { + return getConfigGetRedirectsAttributeTypeOk(o.Redirects) +} + +// HasRedirects returns a boolean if a field has been set. +func (o *Config) HasRedirects() bool { + _, ok := o.GetRedirectsOk() + return ok +} + +// SetRedirects gets a reference to the given RedirectConfig and assigns it to the Redirects field. +func (o *Config) SetRedirects(v ConfigGetRedirectsRetType) { + setConfigGetRedirectsAttributeType(&o.Redirects, v) +} + // GetRegions returns the Regions field value func (o *Config) GetRegions() (ret ConfigGetRegionsRetType) { ret, _ = o.GetRegionsOk() @@ -470,6 +514,9 @@ func (o Config) ToMap() (map[string]interface{}, error) { if val, ok := getConfigGetOptimizerAttributeTypeOk(o.Optimizer); ok { toSerialize["Optimizer"] = val } + if val, ok := getConfigGetRedirectsAttributeTypeOk(o.Redirects); ok { + toSerialize["Redirects"] = val + } if val, ok := getConfigGetRegionsAttributeTypeOk(o.Regions); ok { toSerialize["Regions"] = val } diff --git a/services/cdn/model_config_patch.go b/services/cdn/model_config_patch.go index 87559e76e..70a601f81 100644 --- a/services/cdn/model_config_patch.go +++ b/services/cdn/model_config_patch.go @@ -162,6 +162,26 @@ func setConfigPatchGetOptimizerAttributeType(arg *ConfigPatchGetOptimizerAttribu *arg = &val } +/* + types and functions for redirects +*/ + +// isModel +type ConfigPatchGetRedirectsAttributeType = *RedirectConfig +type ConfigPatchGetRedirectsArgType = RedirectConfig +type ConfigPatchGetRedirectsRetType = RedirectConfig + +func getConfigPatchGetRedirectsAttributeTypeOk(arg ConfigPatchGetRedirectsAttributeType) (ret ConfigPatchGetRedirectsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setConfigPatchGetRedirectsAttributeType(arg *ConfigPatchGetRedirectsAttributeType, val ConfigPatchGetRedirectsRetType) { + *arg = &val +} + /* types and functions for regions */ @@ -215,6 +235,7 @@ type ConfigPatch struct { // Sets the monthly limit of bandwidth in bytes that the pullzone is allowed to use. MonthlyLimitBytes ConfigPatchGetMonthlyLimitBytesAttributeType `json:"monthlyLimitBytes,omitempty"` Optimizer ConfigPatchGetOptimizerAttributeType `json:"optimizer,omitempty"` + Redirects ConfigPatchGetRedirectsAttributeType `json:"redirects,omitempty"` Regions ConfigPatchGetRegionsAttributeType `json:"regions,omitempty"` Waf ConfigPatchGetWafAttributeType `json:"waf,omitempty"` } @@ -430,6 +451,29 @@ func (o *ConfigPatch) SetOptimizer(v ConfigPatchGetOptimizerRetType) { setConfigPatchGetOptimizerAttributeType(&o.Optimizer, v) } +// GetRedirects returns the Redirects field value if set, zero value otherwise. +func (o *ConfigPatch) GetRedirects() (res ConfigPatchGetRedirectsRetType) { + res, _ = o.GetRedirectsOk() + return +} + +// GetRedirectsOk returns a tuple with the Redirects field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ConfigPatch) GetRedirectsOk() (ret ConfigPatchGetRedirectsRetType, ok bool) { + return getConfigPatchGetRedirectsAttributeTypeOk(o.Redirects) +} + +// HasRedirects returns a boolean if a field has been set. +func (o *ConfigPatch) HasRedirects() bool { + _, ok := o.GetRedirectsOk() + return ok +} + +// SetRedirects gets a reference to the given RedirectConfig and assigns it to the Redirects field. +func (o *ConfigPatch) SetRedirects(v ConfigPatchGetRedirectsRetType) { + setConfigPatchGetRedirectsAttributeType(&o.Redirects, v) +} + // GetRegions returns the Regions field value if set, zero value otherwise. func (o *ConfigPatch) GetRegions() (res ConfigPatchGetRegionsRetType) { res, _ = o.GetRegionsOk() @@ -499,6 +543,9 @@ func (o ConfigPatch) ToMap() (map[string]interface{}, error) { if val, ok := getConfigPatchGetOptimizerAttributeTypeOk(o.Optimizer); ok { toSerialize["Optimizer"] = val } + if val, ok := getConfigPatchGetRedirectsAttributeTypeOk(o.Redirects); ok { + toSerialize["Redirects"] = val + } if val, ok := getConfigPatchGetRegionsAttributeTypeOk(o.Regions); ok { toSerialize["Regions"] = val } diff --git a/services/cdn/model_create_distribution_payload.go b/services/cdn/model_create_distribution_payload.go index db626dfba..377173465 100644 --- a/services/cdn/model_create_distribution_payload.go +++ b/services/cdn/model_create_distribution_payload.go @@ -179,6 +179,26 @@ func setCreateDistributionPayloadGetOptimizerAttributeType(arg *CreateDistributi *arg = &val } +/* + types and functions for redirects +*/ + +// isModel +type CreateDistributionPayloadGetRedirectsAttributeType = *RedirectConfig +type CreateDistributionPayloadGetRedirectsArgType = RedirectConfig +type CreateDistributionPayloadGetRedirectsRetType = RedirectConfig + +func getCreateDistributionPayloadGetRedirectsAttributeTypeOk(arg CreateDistributionPayloadGetRedirectsAttributeType) (ret CreateDistributionPayloadGetRedirectsRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCreateDistributionPayloadGetRedirectsAttributeType(arg *CreateDistributionPayloadGetRedirectsAttributeType, val CreateDistributionPayloadGetRedirectsRetType) { + *arg = &val +} + /* types and functions for regions */ @@ -235,6 +255,7 @@ type CreateDistributionPayload struct { // Sets the monthly limit of bandwidth in bytes that the pullzone is allowed to use. MonthlyLimitBytes CreateDistributionPayloadGetMonthlyLimitBytesAttributeType `json:"monthlyLimitBytes,omitempty"` Optimizer CreateDistributionPayloadGetOptimizerAttributeType `json:"optimizer,omitempty"` + Redirects CreateDistributionPayloadGetRedirectsAttributeType `json:"redirects,omitempty"` // Define in which regions you would like your content to be cached. // REQUIRED Regions CreateDistributionPayloadGetRegionsAttributeType `json:"regions" required:"true"` @@ -440,6 +461,29 @@ func (o *CreateDistributionPayload) SetOptimizer(v CreateDistributionPayloadGetO setCreateDistributionPayloadGetOptimizerAttributeType(&o.Optimizer, v) } +// GetRedirects returns the Redirects field value if set, zero value otherwise. +func (o *CreateDistributionPayload) GetRedirects() (res CreateDistributionPayloadGetRedirectsRetType) { + res, _ = o.GetRedirectsOk() + return +} + +// GetRedirectsOk returns a tuple with the Redirects field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateDistributionPayload) GetRedirectsOk() (ret CreateDistributionPayloadGetRedirectsRetType, ok bool) { + return getCreateDistributionPayloadGetRedirectsAttributeTypeOk(o.Redirects) +} + +// HasRedirects returns a boolean if a field has been set. +func (o *CreateDistributionPayload) HasRedirects() bool { + _, ok := o.GetRedirectsOk() + return ok +} + +// SetRedirects gets a reference to the given RedirectConfig and assigns it to the Redirects field. +func (o *CreateDistributionPayload) SetRedirects(v CreateDistributionPayloadGetRedirectsRetType) { + setCreateDistributionPayloadGetRedirectsAttributeType(&o.Redirects, v) +} + // GetRegions returns the Regions field value func (o *CreateDistributionPayload) GetRegions() (ret CreateDistributionPayloadGetRegionsRetType) { ret, _ = o.GetRegionsOk() @@ -506,6 +550,9 @@ func (o CreateDistributionPayload) ToMap() (map[string]interface{}, error) { if val, ok := getCreateDistributionPayloadGetOptimizerAttributeTypeOk(o.Optimizer); ok { toSerialize["Optimizer"] = val } + if val, ok := getCreateDistributionPayloadGetRedirectsAttributeTypeOk(o.Redirects); ok { + toSerialize["Redirects"] = val + } if val, ok := getCreateDistributionPayloadGetRegionsAttributeTypeOk(o.Regions); ok { toSerialize["Regions"] = val } diff --git a/services/cdn/model_match_condition.go b/services/cdn/model_match_condition.go new file mode 100644 index 000000000..b7f5bad43 --- /dev/null +++ b/services/cdn/model_match_condition.go @@ -0,0 +1,117 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" + "fmt" +) + +// MatchCondition Defines how multiple matchers within this rule are combined (ALL, ANY, NONE). Defaults to ANY. +type MatchCondition string + +// List of MatchCondition +const ( + MATCHCONDITION_ANY MatchCondition = "ANY" + MATCHCONDITION_ALL MatchCondition = "ALL" + MATCHCONDITION_NONE MatchCondition = "NONE" +) + +// All allowed values of MatchCondition enum +var AllowedMatchConditionEnumValues = []MatchCondition{ + "ANY", + "ALL", + "NONE", +} + +func (v *MatchCondition) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + // Allow unmarshalling zero value for testing purposes + var zeroValue string + if value == zeroValue { + return nil + } + enumTypeValue := MatchCondition(value) + for _, existing := range AllowedMatchConditionEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid MatchCondition", value) +} + +// NewMatchConditionFromValue returns a pointer to a valid MatchCondition +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewMatchConditionFromValue(v string) (*MatchCondition, error) { + ev := MatchCondition(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for MatchCondition: valid values are %v", v, AllowedMatchConditionEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v MatchCondition) IsValid() bool { + for _, existing := range AllowedMatchConditionEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to MatchCondition value +func (v MatchCondition) Ptr() *MatchCondition { + return &v +} + +type NullableMatchCondition struct { + value *MatchCondition + isSet bool +} + +func (v NullableMatchCondition) Get() *MatchCondition { + return v.value +} + +func (v *NullableMatchCondition) Set(val *MatchCondition) { + v.value = val + v.isSet = true +} + +func (v NullableMatchCondition) IsSet() bool { + return v.isSet +} + +func (v *NullableMatchCondition) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableMatchCondition(val *MatchCondition) *NullableMatchCondition { + return &NullableMatchCondition{value: val, isSet: true} +} + +func (v NullableMatchCondition) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableMatchCondition) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_match_condition_test.go b/services/cdn/model_match_condition_test.go new file mode 100644 index 000000000..d7e05bb41 --- /dev/null +++ b/services/cdn/model_match_condition_test.go @@ -0,0 +1,11 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn diff --git a/services/cdn/model_matcher.go b/services/cdn/model_matcher.go new file mode 100644 index 000000000..88a5ca989 --- /dev/null +++ b/services/cdn/model_matcher.go @@ -0,0 +1,175 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the Matcher type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Matcher{} + +/* + types and functions for valueMatchCondition +*/ + +// isEnumRef +type MatcherGetValueMatchConditionAttributeType = *MatchCondition +type MatcherGetValueMatchConditionArgType = MatchCondition +type MatcherGetValueMatchConditionRetType = MatchCondition + +func getMatcherGetValueMatchConditionAttributeTypeOk(arg MatcherGetValueMatchConditionAttributeType) (ret MatcherGetValueMatchConditionRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setMatcherGetValueMatchConditionAttributeType(arg *MatcherGetValueMatchConditionAttributeType, val MatcherGetValueMatchConditionRetType) { + *arg = &val +} + +/* + types and functions for values +*/ + +// isArray +type MatcherGetValuesAttributeType = *[]string +type MatcherGetValuesArgType = []string +type MatcherGetValuesRetType = []string + +func getMatcherGetValuesAttributeTypeOk(arg MatcherGetValuesAttributeType) (ret MatcherGetValuesRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setMatcherGetValuesAttributeType(arg *MatcherGetValuesAttributeType, val MatcherGetValuesRetType) { + *arg = &val +} + +// Matcher A matcher containing a list of string values to compare against the request path. +type Matcher struct { + ValueMatchCondition MatcherGetValueMatchConditionAttributeType `json:"valueMatchCondition,omitempty"` + // A list of glob patterns to match against the request path. At least one value is required. Examples: \"/shop/_*\" or \"*_/img/_*\" + // REQUIRED + Values MatcherGetValuesAttributeType `json:"values" required:"true"` +} + +type _Matcher Matcher + +// NewMatcher instantiates a new Matcher object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewMatcher(values MatcherGetValuesArgType) *Matcher { + this := Matcher{} + setMatcherGetValuesAttributeType(&this.Values, values) + return &this +} + +// NewMatcherWithDefaults instantiates a new Matcher object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewMatcherWithDefaults() *Matcher { + this := Matcher{} + var valueMatchCondition MatchCondition = MATCHCONDITION_ANY + this.ValueMatchCondition = &valueMatchCondition + return &this +} + +// GetValueMatchCondition returns the ValueMatchCondition field value if set, zero value otherwise. +func (o *Matcher) GetValueMatchCondition() (res MatcherGetValueMatchConditionRetType) { + res, _ = o.GetValueMatchConditionOk() + return +} + +// GetValueMatchConditionOk returns a tuple with the ValueMatchCondition field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Matcher) GetValueMatchConditionOk() (ret MatcherGetValueMatchConditionRetType, ok bool) { + return getMatcherGetValueMatchConditionAttributeTypeOk(o.ValueMatchCondition) +} + +// HasValueMatchCondition returns a boolean if a field has been set. +func (o *Matcher) HasValueMatchCondition() bool { + _, ok := o.GetValueMatchConditionOk() + return ok +} + +// SetValueMatchCondition gets a reference to the given MatchCondition and assigns it to the ValueMatchCondition field. +func (o *Matcher) SetValueMatchCondition(v MatcherGetValueMatchConditionRetType) { + setMatcherGetValueMatchConditionAttributeType(&o.ValueMatchCondition, v) +} + +// GetValues returns the Values field value +func (o *Matcher) GetValues() (ret MatcherGetValuesRetType) { + ret, _ = o.GetValuesOk() + return ret +} + +// GetValuesOk returns a tuple with the Values field value +// and a boolean to check if the value has been set. +func (o *Matcher) GetValuesOk() (ret MatcherGetValuesRetType, ok bool) { + return getMatcherGetValuesAttributeTypeOk(o.Values) +} + +// SetValues sets field value +func (o *Matcher) SetValues(v MatcherGetValuesRetType) { + setMatcherGetValuesAttributeType(&o.Values, v) +} + +func (o Matcher) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getMatcherGetValueMatchConditionAttributeTypeOk(o.ValueMatchCondition); ok { + toSerialize["ValueMatchCondition"] = val + } + if val, ok := getMatcherGetValuesAttributeTypeOk(o.Values); ok { + toSerialize["Values"] = val + } + return toSerialize, nil +} + +type NullableMatcher struct { + value *Matcher + isSet bool +} + +func (v NullableMatcher) Get() *Matcher { + return v.value +} + +func (v *NullableMatcher) Set(val *Matcher) { + v.value = val + v.isSet = true +} + +func (v NullableMatcher) IsSet() bool { + return v.isSet +} + +func (v *NullableMatcher) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableMatcher(val *Matcher) *NullableMatcher { + return &NullableMatcher{value: val, isSet: true} +} + +func (v NullableMatcher) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableMatcher) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_matcher_test.go b/services/cdn/model_matcher_test.go new file mode 100644 index 000000000..d7e05bb41 --- /dev/null +++ b/services/cdn/model_matcher_test.go @@ -0,0 +1,11 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn diff --git a/services/cdn/model_redirect_config.go b/services/cdn/model_redirect_config.go new file mode 100644 index 000000000..b844692ee --- /dev/null +++ b/services/cdn/model_redirect_config.go @@ -0,0 +1,128 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" +) + +// checks if the RedirectConfig type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &RedirectConfig{} + +/* + types and functions for rules +*/ + +// isArray +type RedirectConfigGetRulesAttributeType = *[]RedirectRule +type RedirectConfigGetRulesArgType = []RedirectRule +type RedirectConfigGetRulesRetType = []RedirectRule + +func getRedirectConfigGetRulesAttributeTypeOk(arg RedirectConfigGetRulesAttributeType) (ret RedirectConfigGetRulesRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setRedirectConfigGetRulesAttributeType(arg *RedirectConfigGetRulesAttributeType, val RedirectConfigGetRulesRetType) { + *arg = &val +} + +// RedirectConfig A wrapper for a list of redirect rules that allows for redirect settings on a distribution. +type RedirectConfig struct { + // A list of redirect rules. The order of rules matters for evaluation. + Rules RedirectConfigGetRulesAttributeType `json:"rules,omitempty"` +} + +// NewRedirectConfig instantiates a new RedirectConfig object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewRedirectConfig() *RedirectConfig { + this := RedirectConfig{} + return &this +} + +// NewRedirectConfigWithDefaults instantiates a new RedirectConfig object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewRedirectConfigWithDefaults() *RedirectConfig { + this := RedirectConfig{} + return &this +} + +// GetRules returns the Rules field value if set, zero value otherwise. +func (o *RedirectConfig) GetRules() (res RedirectConfigGetRulesRetType) { + res, _ = o.GetRulesOk() + return +} + +// GetRulesOk returns a tuple with the Rules field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RedirectConfig) GetRulesOk() (ret RedirectConfigGetRulesRetType, ok bool) { + return getRedirectConfigGetRulesAttributeTypeOk(o.Rules) +} + +// HasRules returns a boolean if a field has been set. +func (o *RedirectConfig) HasRules() bool { + _, ok := o.GetRulesOk() + return ok +} + +// SetRules gets a reference to the given []RedirectRule and assigns it to the Rules field. +func (o *RedirectConfig) SetRules(v RedirectConfigGetRulesRetType) { + setRedirectConfigGetRulesAttributeType(&o.Rules, v) +} + +func (o RedirectConfig) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getRedirectConfigGetRulesAttributeTypeOk(o.Rules); ok { + toSerialize["Rules"] = val + } + return toSerialize, nil +} + +type NullableRedirectConfig struct { + value *RedirectConfig + isSet bool +} + +func (v NullableRedirectConfig) Get() *RedirectConfig { + return v.value +} + +func (v *NullableRedirectConfig) Set(val *RedirectConfig) { + v.value = val + v.isSet = true +} + +func (v NullableRedirectConfig) IsSet() bool { + return v.isSet +} + +func (v *NullableRedirectConfig) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRedirectConfig(val *RedirectConfig) *NullableRedirectConfig { + return &NullableRedirectConfig{value: val, isSet: true} +} + +func (v NullableRedirectConfig) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRedirectConfig) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_redirect_config_test.go b/services/cdn/model_redirect_config_test.go new file mode 100644 index 000000000..d7e05bb41 --- /dev/null +++ b/services/cdn/model_redirect_config_test.go @@ -0,0 +1,11 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn diff --git a/services/cdn/model_redirect_rule.go b/services/cdn/model_redirect_rule.go new file mode 100644 index 000000000..17a337ea3 --- /dev/null +++ b/services/cdn/model_redirect_rule.go @@ -0,0 +1,475 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "encoding/json" + "fmt" +) + +// checks if the RedirectRule type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &RedirectRule{} + +/* + types and functions for description +*/ + +// isNotNullableString +type RedirectRuleGetDescriptionAttributeType = *string + +func getRedirectRuleGetDescriptionAttributeTypeOk(arg RedirectRuleGetDescriptionAttributeType) (ret RedirectRuleGetDescriptionRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setRedirectRuleGetDescriptionAttributeType(arg *RedirectRuleGetDescriptionAttributeType, val RedirectRuleGetDescriptionRetType) { + *arg = &val +} + +type RedirectRuleGetDescriptionArgType = string +type RedirectRuleGetDescriptionRetType = string + +/* + types and functions for enabled +*/ + +// isBoolean +type RedirectRulegetEnabledAttributeType = *bool +type RedirectRulegetEnabledArgType = bool +type RedirectRulegetEnabledRetType = bool + +func getRedirectRulegetEnabledAttributeTypeOk(arg RedirectRulegetEnabledAttributeType) (ret RedirectRulegetEnabledRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setRedirectRulegetEnabledAttributeType(arg *RedirectRulegetEnabledAttributeType, val RedirectRulegetEnabledRetType) { + *arg = &val +} + +/* + types and functions for matchers +*/ + +// isArray +type RedirectRuleGetMatchersAttributeType = *[]Matcher +type RedirectRuleGetMatchersArgType = []Matcher +type RedirectRuleGetMatchersRetType = []Matcher + +func getRedirectRuleGetMatchersAttributeTypeOk(arg RedirectRuleGetMatchersAttributeType) (ret RedirectRuleGetMatchersRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setRedirectRuleGetMatchersAttributeType(arg *RedirectRuleGetMatchersAttributeType, val RedirectRuleGetMatchersRetType) { + *arg = &val +} + +/* + types and functions for ruleMatchCondition +*/ + +// isEnumRef +type RedirectRuleGetRuleMatchConditionAttributeType = *MatchCondition +type RedirectRuleGetRuleMatchConditionArgType = MatchCondition +type RedirectRuleGetRuleMatchConditionRetType = MatchCondition + +func getRedirectRuleGetRuleMatchConditionAttributeTypeOk(arg RedirectRuleGetRuleMatchConditionAttributeType) (ret RedirectRuleGetRuleMatchConditionRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setRedirectRuleGetRuleMatchConditionAttributeType(arg *RedirectRuleGetRuleMatchConditionAttributeType, val RedirectRuleGetRuleMatchConditionRetType) { + *arg = &val +} + +/* + types and functions for statusCode +*/ + +// isEnum + +// RedirectRuleStatusCode The HTTP status code for the redirect. Must be one of 301, 302, 303, 307, or 308. +// value type for enums +type RedirectRuleStatusCode int + +// List of StatusCode +const ( + REDIRECTRULESTATUS_CODE__301 RedirectRuleStatusCode = 301 + REDIRECTRULESTATUS_CODE__302 RedirectRuleStatusCode = 302 + REDIRECTRULESTATUS_CODE__303 RedirectRuleStatusCode = 303 + REDIRECTRULESTATUS_CODE__307 RedirectRuleStatusCode = 307 + REDIRECTRULESTATUS_CODE__308 RedirectRuleStatusCode = 308 +) + +// All allowed values of RedirectRule enum +var AllowedRedirectRuleStatusCodeEnumValues = []RedirectRuleStatusCode{ + 301, + 302, + 303, + 307, + 308, +} + +func (v *RedirectRuleStatusCode) UnmarshalJSON(src []byte) error { + // use a type alias to prevent infinite recursion during unmarshal, + // see https://biscuit.ninja/posts/go-avoid-an-infitine-loop-with-custom-json-unmarshallers + type TmpJson RedirectRuleStatusCode + var value TmpJson + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + // Allow unmarshalling zero value for testing purposes + var zeroValue TmpJson + if value == zeroValue { + return nil + } + enumTypeValue := RedirectRuleStatusCode(value) + for _, existing := range AllowedRedirectRuleStatusCodeEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid RedirectRule", value) +} + +// NewRedirectRuleStatusCodeFromValue returns a pointer to a valid RedirectRuleStatusCode +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewRedirectRuleStatusCodeFromValue(v RedirectRuleStatusCode) (*RedirectRuleStatusCode, error) { + ev := RedirectRuleStatusCode(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for RedirectRuleStatusCode: valid values are %v", v, AllowedRedirectRuleStatusCodeEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v RedirectRuleStatusCode) IsValid() bool { + for _, existing := range AllowedRedirectRuleStatusCodeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to StatusCodeStatusCode value +func (v RedirectRuleStatusCode) Ptr() *RedirectRuleStatusCode { + return &v +} + +type NullableRedirectRuleStatusCode struct { + value *RedirectRuleStatusCode + isSet bool +} + +func (v NullableRedirectRuleStatusCode) Get() *RedirectRuleStatusCode { + return v.value +} + +func (v *NullableRedirectRuleStatusCode) Set(val *RedirectRuleStatusCode) { + v.value = val + v.isSet = true +} + +func (v NullableRedirectRuleStatusCode) IsSet() bool { + return v.isSet +} + +func (v *NullableRedirectRuleStatusCode) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRedirectRuleStatusCode(val *RedirectRuleStatusCode) *NullableRedirectRuleStatusCode { + return &NullableRedirectRuleStatusCode{value: val, isSet: true} +} + +func (v NullableRedirectRuleStatusCode) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRedirectRuleStatusCode) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type RedirectRuleGetStatusCodeAttributeType = *RedirectRuleStatusCode +type RedirectRuleGetStatusCodeArgType = RedirectRuleStatusCode +type RedirectRuleGetStatusCodeRetType = RedirectRuleStatusCode + +func getRedirectRuleGetStatusCodeAttributeTypeOk(arg RedirectRuleGetStatusCodeAttributeType) (ret RedirectRuleGetStatusCodeRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setRedirectRuleGetStatusCodeAttributeType(arg *RedirectRuleGetStatusCodeAttributeType, val RedirectRuleGetStatusCodeRetType) { + *arg = &val +} + +/* + types and functions for targetUrl +*/ + +// isNotNullableString +type RedirectRuleGetTargetUrlAttributeType = *string + +func getRedirectRuleGetTargetUrlAttributeTypeOk(arg RedirectRuleGetTargetUrlAttributeType) (ret RedirectRuleGetTargetUrlRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setRedirectRuleGetTargetUrlAttributeType(arg *RedirectRuleGetTargetUrlAttributeType, val RedirectRuleGetTargetUrlRetType) { + *arg = &val +} + +type RedirectRuleGetTargetUrlArgType = string +type RedirectRuleGetTargetUrlRetType = string + +// RedirectRule A single redirect rule defining a source pattern and a target URL. +type RedirectRule struct { + // An optional description for the redirect rule. + Description RedirectRuleGetDescriptionAttributeType `json:"description,omitempty"` + // A toggle to enable or disable the redirect rule. + Enabled RedirectRulegetEnabledAttributeType `json:"enabled,omitempty"` + // A list of matchers that define when this rule should apply. At least one matcher is required. + // REQUIRED + Matchers RedirectRuleGetMatchersAttributeType `json:"matchers" required:"true"` + RuleMatchCondition RedirectRuleGetRuleMatchConditionAttributeType `json:"ruleMatchCondition,omitempty"` + // The HTTP status code for the redirect. Must be one of 301, 302, 303, 307, or 308. + // Can be cast to int32 without loss of precision. + // REQUIRED + StatusCode RedirectRuleGetStatusCodeAttributeType `json:"statusCode" required:"true"` + // The target URL to redirect to. Must be a valid URI. + // REQUIRED + TargetUrl RedirectRuleGetTargetUrlAttributeType `json:"targetUrl" required:"true"` +} + +type _RedirectRule RedirectRule + +// NewRedirectRule instantiates a new RedirectRule object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewRedirectRule(matchers RedirectRuleGetMatchersArgType, statusCode RedirectRuleGetStatusCodeArgType, targetUrl RedirectRuleGetTargetUrlArgType) *RedirectRule { + this := RedirectRule{} + setRedirectRuleGetMatchersAttributeType(&this.Matchers, matchers) + setRedirectRuleGetStatusCodeAttributeType(&this.StatusCode, statusCode) + setRedirectRuleGetTargetUrlAttributeType(&this.TargetUrl, targetUrl) + return &this +} + +// NewRedirectRuleWithDefaults instantiates a new RedirectRule object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewRedirectRuleWithDefaults() *RedirectRule { + this := RedirectRule{} + var enabled bool = true + this.Enabled = &enabled + var ruleMatchCondition MatchCondition = MATCHCONDITION_ANY + this.RuleMatchCondition = &ruleMatchCondition + return &this +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *RedirectRule) GetDescription() (res RedirectRuleGetDescriptionRetType) { + res, _ = o.GetDescriptionOk() + return +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RedirectRule) GetDescriptionOk() (ret RedirectRuleGetDescriptionRetType, ok bool) { + return getRedirectRuleGetDescriptionAttributeTypeOk(o.Description) +} + +// HasDescription returns a boolean if a field has been set. +func (o *RedirectRule) HasDescription() bool { + _, ok := o.GetDescriptionOk() + return ok +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *RedirectRule) SetDescription(v RedirectRuleGetDescriptionRetType) { + setRedirectRuleGetDescriptionAttributeType(&o.Description, v) +} + +// GetEnabled returns the Enabled field value if set, zero value otherwise. +func (o *RedirectRule) GetEnabled() (res RedirectRulegetEnabledRetType) { + res, _ = o.GetEnabledOk() + return +} + +// GetEnabledOk returns a tuple with the Enabled field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RedirectRule) GetEnabledOk() (ret RedirectRulegetEnabledRetType, ok bool) { + return getRedirectRulegetEnabledAttributeTypeOk(o.Enabled) +} + +// HasEnabled returns a boolean if a field has been set. +func (o *RedirectRule) HasEnabled() bool { + _, ok := o.GetEnabledOk() + return ok +} + +// SetEnabled gets a reference to the given bool and assigns it to the Enabled field. +func (o *RedirectRule) SetEnabled(v RedirectRulegetEnabledRetType) { + setRedirectRulegetEnabledAttributeType(&o.Enabled, v) +} + +// GetMatchers returns the Matchers field value +func (o *RedirectRule) GetMatchers() (ret RedirectRuleGetMatchersRetType) { + ret, _ = o.GetMatchersOk() + return ret +} + +// GetMatchersOk returns a tuple with the Matchers field value +// and a boolean to check if the value has been set. +func (o *RedirectRule) GetMatchersOk() (ret RedirectRuleGetMatchersRetType, ok bool) { + return getRedirectRuleGetMatchersAttributeTypeOk(o.Matchers) +} + +// SetMatchers sets field value +func (o *RedirectRule) SetMatchers(v RedirectRuleGetMatchersRetType) { + setRedirectRuleGetMatchersAttributeType(&o.Matchers, v) +} + +// GetRuleMatchCondition returns the RuleMatchCondition field value if set, zero value otherwise. +func (o *RedirectRule) GetRuleMatchCondition() (res RedirectRuleGetRuleMatchConditionRetType) { + res, _ = o.GetRuleMatchConditionOk() + return +} + +// GetRuleMatchConditionOk returns a tuple with the RuleMatchCondition field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RedirectRule) GetRuleMatchConditionOk() (ret RedirectRuleGetRuleMatchConditionRetType, ok bool) { + return getRedirectRuleGetRuleMatchConditionAttributeTypeOk(o.RuleMatchCondition) +} + +// HasRuleMatchCondition returns a boolean if a field has been set. +func (o *RedirectRule) HasRuleMatchCondition() bool { + _, ok := o.GetRuleMatchConditionOk() + return ok +} + +// SetRuleMatchCondition gets a reference to the given MatchCondition and assigns it to the RuleMatchCondition field. +func (o *RedirectRule) SetRuleMatchCondition(v RedirectRuleGetRuleMatchConditionRetType) { + setRedirectRuleGetRuleMatchConditionAttributeType(&o.RuleMatchCondition, v) +} + +// GetStatusCode returns the StatusCode field value +func (o *RedirectRule) GetStatusCode() (ret RedirectRuleGetStatusCodeRetType) { + ret, _ = o.GetStatusCodeOk() + return ret +} + +// GetStatusCodeOk returns a tuple with the StatusCode field value +// and a boolean to check if the value has been set. +func (o *RedirectRule) GetStatusCodeOk() (ret RedirectRuleGetStatusCodeRetType, ok bool) { + return getRedirectRuleGetStatusCodeAttributeTypeOk(o.StatusCode) +} + +// SetStatusCode sets field value +func (o *RedirectRule) SetStatusCode(v RedirectRuleGetStatusCodeRetType) { + setRedirectRuleGetStatusCodeAttributeType(&o.StatusCode, v) +} + +// GetTargetUrl returns the TargetUrl field value +func (o *RedirectRule) GetTargetUrl() (ret RedirectRuleGetTargetUrlRetType) { + ret, _ = o.GetTargetUrlOk() + return ret +} + +// GetTargetUrlOk returns a tuple with the TargetUrl field value +// and a boolean to check if the value has been set. +func (o *RedirectRule) GetTargetUrlOk() (ret RedirectRuleGetTargetUrlRetType, ok bool) { + return getRedirectRuleGetTargetUrlAttributeTypeOk(o.TargetUrl) +} + +// SetTargetUrl sets field value +func (o *RedirectRule) SetTargetUrl(v RedirectRuleGetTargetUrlRetType) { + setRedirectRuleGetTargetUrlAttributeType(&o.TargetUrl, v) +} + +func (o RedirectRule) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getRedirectRuleGetDescriptionAttributeTypeOk(o.Description); ok { + toSerialize["Description"] = val + } + if val, ok := getRedirectRulegetEnabledAttributeTypeOk(o.Enabled); ok { + toSerialize["Enabled"] = val + } + if val, ok := getRedirectRuleGetMatchersAttributeTypeOk(o.Matchers); ok { + toSerialize["Matchers"] = val + } + if val, ok := getRedirectRuleGetRuleMatchConditionAttributeTypeOk(o.RuleMatchCondition); ok { + toSerialize["RuleMatchCondition"] = val + } + if val, ok := getRedirectRuleGetStatusCodeAttributeTypeOk(o.StatusCode); ok { + toSerialize["StatusCode"] = val + } + if val, ok := getRedirectRuleGetTargetUrlAttributeTypeOk(o.TargetUrl); ok { + toSerialize["TargetUrl"] = val + } + return toSerialize, nil +} + +type NullableRedirectRule struct { + value *RedirectRule + isSet bool +} + +func (v NullableRedirectRule) Get() *RedirectRule { + return v.value +} + +func (v *NullableRedirectRule) Set(val *RedirectRule) { + v.value = val + v.isSet = true +} + +func (v NullableRedirectRule) IsSet() bool { + return v.isSet +} + +func (v *NullableRedirectRule) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRedirectRule(val *RedirectRule) *NullableRedirectRule { + return &NullableRedirectRule{value: val, isSet: true} +} + +func (v NullableRedirectRule) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRedirectRule) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/cdn/model_redirect_rule_test.go b/services/cdn/model_redirect_rule_test.go new file mode 100644 index 000000000..f91e38730 --- /dev/null +++ b/services/cdn/model_redirect_rule_test.go @@ -0,0 +1,79 @@ +/* +CDN API + +API used to create and manage your CDN distributions. + +API version: 1.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cdn + +import ( + "testing" +) + +// isEnum + +func TestRedirectRuleStatusCode_UnmarshalJSON(t *testing.T) { + type args struct { + src []byte + } + tests := []struct { + name string + args args + wantErr bool + }{ + { + name: `success - possible enum value no. 1`, + args: args{ + src: []byte(`301`), + }, + wantErr: false, + }, + { + name: `success - possible enum value no. 2`, + args: args{ + src: []byte(`302`), + }, + wantErr: false, + }, + { + name: `success - possible enum value no. 3`, + args: args{ + src: []byte(`303`), + }, + wantErr: false, + }, + { + name: `success - possible enum value no. 4`, + args: args{ + src: []byte(`307`), + }, + wantErr: false, + }, + { + name: `success - possible enum value no. 5`, + args: args{ + src: []byte(`308`), + }, + wantErr: false, + }, + { + name: "fail", + args: args{ + src: []byte("\"FOOBAR\""), + }, + wantErr: true, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + v := RedirectRuleStatusCode(-1) + if err := v.UnmarshalJSON(tt.args.src); (err != nil) != tt.wantErr { + t.Errorf("UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} diff --git a/services/cdn/model_status_error.go b/services/cdn/model_status_error.go index 139ea7cbf..587e2210a 100644 --- a/services/cdn/model_status_error.go +++ b/services/cdn/model_status_error.go @@ -77,6 +77,7 @@ const ( STATUSERRORKEY_CUSTOM_DOMAIN_ALREADY_IN_USE StatusErrorKey = "CUSTOM_DOMAIN_ALREADY_IN_USE" STATUSERRORKEY_PUBLIC_BETA_QUOTA_REACHED StatusErrorKey = "PUBLIC_BETA_QUOTA_REACHED" STATUSERRORKEY_LOG_SINK_INSTANCE_UNAVAILABLE StatusErrorKey = "LOG_SINK_INSTANCE_UNAVAILABLE" + STATUSERRORKEY_EXTERNAL_QUOTA_REACHED StatusErrorKey = "EXTERNAL_QUOTA_REACHED" ) // All allowed values of StatusError enum @@ -86,6 +87,7 @@ var AllowedStatusErrorKeyEnumValues = []StatusErrorKey{ "CUSTOM_DOMAIN_ALREADY_IN_USE", "PUBLIC_BETA_QUOTA_REACHED", "LOG_SINK_INSTANCE_UNAVAILABLE", + "EXTERNAL_QUOTA_REACHED", } func (v *StatusErrorKey) UnmarshalJSON(src []byte) error { diff --git a/services/cdn/model_status_error_test.go b/services/cdn/model_status_error_test.go index 4a43aa4d1..7f9b99a13 100644 --- a/services/cdn/model_status_error_test.go +++ b/services/cdn/model_status_error_test.go @@ -60,6 +60,13 @@ func TestStatusErrorKey_UnmarshalJSON(t *testing.T) { }, wantErr: false, }, + { + name: `success - possible enum value no. 6`, + args: args{ + src: []byte(`"EXTERNAL_QUOTA_REACHED"`), + }, + wantErr: false, + }, { name: "fail", args: args{ diff --git a/services/cdn/oas_commit b/services/cdn/oas_commit new file mode 100644 index 000000000..f6e220b2f --- /dev/null +++ b/services/cdn/oas_commit @@ -0,0 +1 @@ +31b8992a3308a74f07c972b9976ef3428bdda76c