diff --git a/services/albwaf/oas_commit b/services/albwaf/oas_commit index 1538b64bb..2c4c06b10 100644 --- a/services/albwaf/oas_commit +++ b/services/albwaf/oas_commit @@ -1 +1 @@ -d5bd75f47f4b364fa6f71663efb4ba41ec703ac8 +8e01c1f335c52e1c478fae2753c2423866892bde diff --git a/services/albwaf/v1alphaapi/model_crs_rule.go b/services/albwaf/v1alphaapi/model_crs_rule.go index c61d71a41..a8a932c08 100644 --- a/services/albwaf/v1alphaapi/model_crs_rule.go +++ b/services/albwaf/v1alphaapi/model_crs_rule.go @@ -20,8 +20,8 @@ var _ MappedNullable = &CRSRule{} // CRSRule Rule represents an individual security or validation rule. type CRSRule struct { // SQL Injection Attack Detected via libinjection - Description *string `json:"description,omitempty"` - Mode *OWASPCoreRuleSet `json:"mode,omitempty"` + Description *string `json:"description,omitempty"` + Mode *Mode `json:"mode,omitempty"` // Impact level. Severity *string `json:"severity,omitempty" validate:"regexp=^(CRITICAL|ERROR|WARNING|INFO)$"` AdditionalProperties map[string]interface{} @@ -79,9 +79,9 @@ func (o *CRSRule) SetDescription(v string) { } // GetMode returns the Mode field value if set, zero value otherwise. -func (o *CRSRule) GetMode() OWASPCoreRuleSet { +func (o *CRSRule) GetMode() Mode { if o == nil || IsNil(o.Mode) { - var ret OWASPCoreRuleSet + var ret Mode return ret } return *o.Mode @@ -89,7 +89,7 @@ func (o *CRSRule) GetMode() OWASPCoreRuleSet { // GetModeOk returns a tuple with the Mode field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *CRSRule) GetModeOk() (*OWASPCoreRuleSet, bool) { +func (o *CRSRule) GetModeOk() (*Mode, bool) { if o == nil || IsNil(o.Mode) { return nil, false } @@ -105,8 +105,8 @@ func (o *CRSRule) HasMode() bool { return false } -// SetMode gets a reference to the given OWASPCoreRuleSet and assigns it to the Mode field. -func (o *CRSRule) SetMode(v OWASPCoreRuleSet) { +// SetMode gets a reference to the given Mode and assigns it to the Mode field. +func (o *CRSRule) SetMode(v Mode) { o.Mode = &v } diff --git a/services/albwaf/v1alphaapi/model_mode.go b/services/albwaf/v1alphaapi/model_mode.go new file mode 100644 index 000000000..cdcfb3ac2 --- /dev/null +++ b/services/albwaf/v1alphaapi/model_mode.go @@ -0,0 +1,115 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +### DEPRECATED! Use v1beta instead. Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" + "fmt" +) + +// Mode The current mode of the rule. +type Mode string + +// List of Mode +const ( + MODE_MODE_ENABLED Mode = "MODE_ENABLED" + MODE_MODE_DISABLED Mode = "MODE_DISABLED" + MODE_MODE_LOG_ONLY Mode = "MODE_LOG_ONLY" + MODE_UNKNOWN_DEFAULT_OPEN_API Mode = "unknown_default_open_api" +) + +// All allowed values of Mode enum +var AllowedModeEnumValues = []Mode{ + "MODE_ENABLED", + "MODE_DISABLED", + "MODE_LOG_ONLY", + "unknown_default_open_api", +} + +func (v *Mode) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + enumTypeValue := Mode(value) + for _, existing := range AllowedModeEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + *v = MODE_UNKNOWN_DEFAULT_OPEN_API + return nil +} + +// NewModeFromValue returns a pointer to a valid Mode +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewModeFromValue(v string) (*Mode, error) { + ev := Mode(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for Mode: valid values are %v", v, AllowedModeEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v Mode) IsValid() bool { + for _, existing := range AllowedModeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to Mode value +func (v Mode) Ptr() *Mode { + return &v +} + +type NullableMode struct { + value *Mode + isSet bool +} + +func (v NullableMode) Get() *Mode { + return v.value +} + +func (v *NullableMode) Set(val *Mode) { + v.value = val + v.isSet = true +} + +func (v NullableMode) IsSet() bool { + return v.isSet +} + +func (v *NullableMode) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableMode(val *Mode) *NullableMode { + return &NullableMode{value: val, isSet: true} +} + +func (v NullableMode) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableMode) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_owasp_core_rule_set.go b/services/albwaf/v1alphaapi/model_owasp_core_rule_set.go deleted file mode 100644 index c27f8c97e..000000000 --- a/services/albwaf/v1alphaapi/model_owasp_core_rule_set.go +++ /dev/null @@ -1,117 +0,0 @@ -/* -STACKIT Application Load Balancer Web Application Firewall API - -### DEPRECATED! Use v1beta instead. Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. - -API version: 1alpha.0.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package v1alphaapi - -import ( - "encoding/json" - "fmt" -) - -// OWASPCoreRuleSet The current mode of the rule. -type OWASPCoreRuleSet string - -// List of OWASP_Core_Rule_Set -const ( - OWASPCORERULESET_MODE_UNSPECIFIED OWASPCoreRuleSet = "MODE_UNSPECIFIED" - OWASPCORERULESET_MODE_ENABLED OWASPCoreRuleSet = "MODE_ENABLED" - OWASPCORERULESET_MODE_DISABLED OWASPCoreRuleSet = "MODE_DISABLED" - OWASPCORERULESET_MODE_LOG_ONLY OWASPCoreRuleSet = "MODE_LOG_ONLY" - OWASPCORERULESET_UNKNOWN_DEFAULT_OPEN_API OWASPCoreRuleSet = "unknown_default_open_api" -) - -// All allowed values of OWASPCoreRuleSet enum -var AllowedOWASPCoreRuleSetEnumValues = []OWASPCoreRuleSet{ - "MODE_UNSPECIFIED", - "MODE_ENABLED", - "MODE_DISABLED", - "MODE_LOG_ONLY", - "unknown_default_open_api", -} - -func (v *OWASPCoreRuleSet) UnmarshalJSON(src []byte) error { - var value string - err := json.Unmarshal(src, &value) - if err != nil { - return err - } - enumTypeValue := OWASPCoreRuleSet(value) - for _, existing := range AllowedOWASPCoreRuleSetEnumValues { - if existing == enumTypeValue { - *v = enumTypeValue - return nil - } - } - - *v = OWASPCORERULESET_UNKNOWN_DEFAULT_OPEN_API - return nil -} - -// NewOWASPCoreRuleSetFromValue returns a pointer to a valid OWASPCoreRuleSet -// for the value passed as argument, or an error if the value passed is not allowed by the enum -func NewOWASPCoreRuleSetFromValue(v string) (*OWASPCoreRuleSet, error) { - ev := OWASPCoreRuleSet(v) - if ev.IsValid() { - return &ev, nil - } else { - return nil, fmt.Errorf("invalid value '%v' for OWASPCoreRuleSet: valid values are %v", v, AllowedOWASPCoreRuleSetEnumValues) - } -} - -// IsValid return true if the value is valid for the enum, false otherwise -func (v OWASPCoreRuleSet) IsValid() bool { - for _, existing := range AllowedOWASPCoreRuleSetEnumValues { - if existing == v { - return true - } - } - return false -} - -// Ptr returns reference to OWASP_Core_Rule_Set value -func (v OWASPCoreRuleSet) Ptr() *OWASPCoreRuleSet { - return &v -} - -type NullableOWASPCoreRuleSet struct { - value *OWASPCoreRuleSet - isSet bool -} - -func (v NullableOWASPCoreRuleSet) Get() *OWASPCoreRuleSet { - return v.value -} - -func (v *NullableOWASPCoreRuleSet) Set(val *OWASPCoreRuleSet) { - v.value = val - v.isSet = true -} - -func (v NullableOWASPCoreRuleSet) IsSet() bool { - return v.isSet -} - -func (v *NullableOWASPCoreRuleSet) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableOWASPCoreRuleSet(val *OWASPCoreRuleSet) *NullableOWASPCoreRuleSet { - return &NullableOWASPCoreRuleSet{value: val, isSet: true} -} - -func (v NullableOWASPCoreRuleSet) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableOWASPCoreRuleSet) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} diff --git a/services/albwaf/v1betaapi/api_default.go b/services/albwaf/v1betaapi/api_default.go index 7f0eecbe4..bea43c5d5 100644 --- a/services/albwaf/v1betaapi/api_default.go +++ b/services/albwaf/v1betaapi/api_default.go @@ -254,6 +254,23 @@ type DefaultAPI interface { // @return GetManagedRuleSetResponse PatchManagedRuleSetExecute(r ApiPatchManagedRuleSetRequest) (*GetManagedRuleSetResponse, error) + /* + UpdateCustomRuleGroup Update a CRG configuration + + Replaces the rules array of an existing CRG. The CRG name is immutable and used as the resource key. Send the complete desired rule set; per-rule partial merge is not supported. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId + @param region + @param name + @return ApiUpdateCustomRuleGroupRequest + */ + UpdateCustomRuleGroup(ctx context.Context, projectId string, region string, name string) ApiUpdateCustomRuleGroupRequest + + // UpdateCustomRuleGroupExecute executes the request + // @return GetCustomRuleGroupResponse + UpdateCustomRuleGroupExecute(r ApiUpdateCustomRuleGroupRequest) (*GetCustomRuleGroupResponse, error) + /* UpdateWAF Update a WAF configuration @@ -2339,6 +2356,159 @@ func (a *DefaultAPIService) PatchManagedRuleSetExecute(r ApiPatchManagedRuleSetR return localVarReturnValue, nil } +type ApiUpdateCustomRuleGroupRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + region string + name string + updateCustomRuleGroupPayload *UpdateCustomRuleGroupPayload +} + +func (r ApiUpdateCustomRuleGroupRequest) UpdateCustomRuleGroupPayload(updateCustomRuleGroupPayload UpdateCustomRuleGroupPayload) ApiUpdateCustomRuleGroupRequest { + r.updateCustomRuleGroupPayload = &updateCustomRuleGroupPayload + return r +} + +func (r ApiUpdateCustomRuleGroupRequest) Execute() (*GetCustomRuleGroupResponse, error) { + return r.ApiService.UpdateCustomRuleGroupExecute(r) +} + +/* +UpdateCustomRuleGroup Update a CRG configuration + +Replaces the rules array of an existing CRG. The CRG name is immutable and used as the resource key. Send the complete desired rule set; per-rule partial merge is not supported. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId + @param region + @param name + @return ApiUpdateCustomRuleGroupRequest +*/ +func (a *DefaultAPIService) UpdateCustomRuleGroup(ctx context.Context, projectId string, region string, name string) ApiUpdateCustomRuleGroupRequest { + return ApiUpdateCustomRuleGroupRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// Execute executes the request +// +// @return GetCustomRuleGroupResponse +func (a *DefaultAPIService) UpdateCustomRuleGroupExecute(r ApiUpdateCustomRuleGroupRequest) (*GetCustomRuleGroupResponse, error) { + var ( + localVarHTTPMethod = http.MethodPut + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *GetCustomRuleGroupResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.UpdateCustomRuleGroup") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{region}/custom-rule-groups/{name}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(parameterValueToString(r.region, "region")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"name"+"}", url.PathEscape(parameterValueToString(r.name, "name")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.updateCustomRuleGroupPayload == nil { + return localVarReturnValue, reportError("updateCustomRuleGroupPayload is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json", "*/*"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.updateCustomRuleGroupPayload + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + type ApiUpdateWAFRequest struct { ctx context.Context ApiService DefaultAPI diff --git a/services/albwaf/v1betaapi/api_default_mock.go b/services/albwaf/v1betaapi/api_default_mock.go index c4188cd25..d0d57159a 100644 --- a/services/albwaf/v1betaapi/api_default_mock.go +++ b/services/albwaf/v1betaapi/api_default_mock.go @@ -48,6 +48,8 @@ type DefaultAPIServiceMock struct { ListWAFExecuteMock *func(r ApiListWAFRequest) (*ListWAFResponse, error) // PatchManagedRuleSetExecuteMock can be populated to implement the behavior of the PatchManagedRuleSetExecute function of this mock PatchManagedRuleSetExecuteMock *func(r ApiPatchManagedRuleSetRequest) (*GetManagedRuleSetResponse, error) + // UpdateCustomRuleGroupExecuteMock can be populated to implement the behavior of the UpdateCustomRuleGroupExecute function of this mock + UpdateCustomRuleGroupExecuteMock *func(r ApiUpdateCustomRuleGroupRequest) (*GetCustomRuleGroupResponse, error) // UpdateWAFExecuteMock can be populated to implement the behavior of the UpdateWAFExecute function of this mock UpdateWAFExecuteMock *func(r ApiUpdateWAFRequest) (*GetWAFResponse, error) } @@ -325,6 +327,26 @@ func (a DefaultAPIServiceMock) PatchManagedRuleSetExecute(r ApiPatchManagedRuleS return (*a.PatchManagedRuleSetExecuteMock)(r) } +func (a DefaultAPIServiceMock) UpdateCustomRuleGroup(ctx context.Context, projectId string, region string, name string) ApiUpdateCustomRuleGroupRequest { + return ApiUpdateCustomRuleGroupRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// UpdateCustomRuleGroupExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the UpdateCustomRuleGroupExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) UpdateCustomRuleGroupExecute(r ApiUpdateCustomRuleGroupRequest) (*GetCustomRuleGroupResponse, error) { + if a.UpdateCustomRuleGroupExecuteMock == nil { + var localVarReturnValue *GetCustomRuleGroupResponse + return localVarReturnValue, nil + } + + return (*a.UpdateCustomRuleGroupExecuteMock)(r) +} + func (a DefaultAPIServiceMock) UpdateWAF(ctx context.Context, projectId string, region string, name string) ApiUpdateWAFRequest { return ApiUpdateWAFRequest{ ApiService: a, diff --git a/services/albwaf/v1betaapi/model_update_custom_rule_group_payload.go b/services/albwaf/v1betaapi/model_update_custom_rule_group_payload.go new file mode 100644 index 000000000..059a33ad0 --- /dev/null +++ b/services/albwaf/v1betaapi/model_update_custom_rule_group_payload.go @@ -0,0 +1,273 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have Managed Rule Set (MRS) and in addition can have Custom Rule Group (CRG). To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1beta.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1betaapi + +import ( + "encoding/json" + "fmt" +) + +// checks if the UpdateCustomRuleGroupPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &UpdateCustomRuleGroupPayload{} + +// UpdateCustomRuleGroupPayload Request payload for updating an existing CRG. Replaces the rules array atomically. +type UpdateCustomRuleGroupPayload struct { + // Custom rule group name. Immutable resource key. Provided via URL path. + Name string `json:"name" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` + // Project identifier + ProjectId *string `json:"projectId,omitempty" validate:"regexp=^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"` + // Region + Region *string `json:"region,omitempty" validate:"regexp=^[a-z]{2,4}[0-9]{2}$"` + // The collection of custom rule group SecLang parameters forming this execution group. Replaces the existing rules atomically. + Rules []CreateCustomRule `json:"rules"` + AdditionalProperties map[string]interface{} +} + +type _UpdateCustomRuleGroupPayload UpdateCustomRuleGroupPayload + +// NewUpdateCustomRuleGroupPayload instantiates a new UpdateCustomRuleGroupPayload 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 NewUpdateCustomRuleGroupPayload(name string, rules []CreateCustomRule) *UpdateCustomRuleGroupPayload { + this := UpdateCustomRuleGroupPayload{} + this.Name = name + this.Rules = rules + return &this +} + +// NewUpdateCustomRuleGroupPayloadWithDefaults instantiates a new UpdateCustomRuleGroupPayload 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 NewUpdateCustomRuleGroupPayloadWithDefaults() *UpdateCustomRuleGroupPayload { + this := UpdateCustomRuleGroupPayload{} + return &this +} + +// GetName returns the Name field value +func (o *UpdateCustomRuleGroupPayload) GetName() string { + if o == nil { + var ret string + return ret + } + + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *UpdateCustomRuleGroupPayload) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value +func (o *UpdateCustomRuleGroupPayload) SetName(v string) { + o.Name = v +} + +// GetProjectId returns the ProjectId field value if set, zero value otherwise. +func (o *UpdateCustomRuleGroupPayload) GetProjectId() string { + if o == nil || IsNil(o.ProjectId) { + var ret string + return ret + } + return *o.ProjectId +} + +// GetProjectIdOk returns a tuple with the ProjectId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateCustomRuleGroupPayload) GetProjectIdOk() (*string, bool) { + if o == nil || IsNil(o.ProjectId) { + return nil, false + } + return o.ProjectId, true +} + +// HasProjectId returns a boolean if a field has been set. +func (o *UpdateCustomRuleGroupPayload) HasProjectId() bool { + if o != nil && !IsNil(o.ProjectId) { + return true + } + + return false +} + +// SetProjectId gets a reference to the given string and assigns it to the ProjectId field. +func (o *UpdateCustomRuleGroupPayload) SetProjectId(v string) { + o.ProjectId = &v +} + +// GetRegion returns the Region field value if set, zero value otherwise. +func (o *UpdateCustomRuleGroupPayload) GetRegion() string { + if o == nil || IsNil(o.Region) { + var ret string + return ret + } + return *o.Region +} + +// GetRegionOk returns a tuple with the Region field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateCustomRuleGroupPayload) GetRegionOk() (*string, bool) { + if o == nil || IsNil(o.Region) { + return nil, false + } + return o.Region, true +} + +// HasRegion returns a boolean if a field has been set. +func (o *UpdateCustomRuleGroupPayload) HasRegion() bool { + if o != nil && !IsNil(o.Region) { + return true + } + + return false +} + +// SetRegion gets a reference to the given string and assigns it to the Region field. +func (o *UpdateCustomRuleGroupPayload) SetRegion(v string) { + o.Region = &v +} + +// GetRules returns the Rules field value +func (o *UpdateCustomRuleGroupPayload) GetRules() []CreateCustomRule { + if o == nil { + var ret []CreateCustomRule + return ret + } + + return o.Rules +} + +// GetRulesOk returns a tuple with the Rules field value +// and a boolean to check if the value has been set. +func (o *UpdateCustomRuleGroupPayload) GetRulesOk() ([]CreateCustomRule, bool) { + if o == nil { + return nil, false + } + return o.Rules, true +} + +// SetRules sets field value +func (o *UpdateCustomRuleGroupPayload) SetRules(v []CreateCustomRule) { + o.Rules = v +} + +func (o UpdateCustomRuleGroupPayload) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o UpdateCustomRuleGroupPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["name"] = o.Name + if !IsNil(o.ProjectId) { + toSerialize["projectId"] = o.ProjectId + } + if !IsNil(o.Region) { + toSerialize["region"] = o.Region + } + toSerialize["rules"] = o.Rules + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *UpdateCustomRuleGroupPayload) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "name", + "rules", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err + } + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varUpdateCustomRuleGroupPayload := _UpdateCustomRuleGroupPayload{} + + err = json.Unmarshal(data, &varUpdateCustomRuleGroupPayload) + + if err != nil { + return err + } + + *o = UpdateCustomRuleGroupPayload(varUpdateCustomRuleGroupPayload) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "name") + delete(additionalProperties, "projectId") + delete(additionalProperties, "region") + delete(additionalProperties, "rules") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableUpdateCustomRuleGroupPayload struct { + value *UpdateCustomRuleGroupPayload + isSet bool +} + +func (v NullableUpdateCustomRuleGroupPayload) Get() *UpdateCustomRuleGroupPayload { + return v.value +} + +func (v *NullableUpdateCustomRuleGroupPayload) Set(val *UpdateCustomRuleGroupPayload) { + v.value = val + v.isSet = true +} + +func (v NullableUpdateCustomRuleGroupPayload) IsSet() bool { + return v.isSet +} + +func (v *NullableUpdateCustomRuleGroupPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableUpdateCustomRuleGroupPayload(val *UpdateCustomRuleGroupPayload) *NullableUpdateCustomRuleGroupPayload { + return &NullableUpdateCustomRuleGroupPayload{value: val, isSet: true} +} + +func (v NullableUpdateCustomRuleGroupPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableUpdateCustomRuleGroupPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +}