From 650f5757d9c06245f399f303993bd06bf8332e4f Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Tue, 12 May 2026 12:41:18 +0000 Subject: [PATCH] Generate albwaf --- services/albwaf/oas_commit | 2 +- services/albwaf/v1alphaapi/api_default.go | 186 ++++++++++- .../albwaf/v1alphaapi/api_default_mock.go | 28 +- .../model_create_core_rule_set_response.go | 230 ------------- services/albwaf/v1alphaapi/model_crs_rule.go | 44 +-- .../albwaf/v1alphaapi/model_crs_rule_group.go | 19 +- .../model_get_core_rule_set_response.go | 19 +- .../model_patch_core_rule_set_payload.go | 306 ++++++++++++++++++ .../albwaf/v1alphaapi/model_patch_crs_rule.go | 154 +++++++++ .../v1alphaapi/model_patch_crs_rule_group.go | 153 +++++++++ .../model_update_core_rule_set_payload.go | 40 ++- .../model_update_core_rule_set_response.go | 2 +- 12 files changed, 898 insertions(+), 285 deletions(-) delete mode 100644 services/albwaf/v1alphaapi/model_create_core_rule_set_response.go create mode 100644 services/albwaf/v1alphaapi/model_patch_core_rule_set_payload.go create mode 100644 services/albwaf/v1alphaapi/model_patch_crs_rule.go create mode 100644 services/albwaf/v1alphaapi/model_patch_crs_rule_group.go diff --git a/services/albwaf/oas_commit b/services/albwaf/oas_commit index b129c2291..f4a2ce25c 100644 --- a/services/albwaf/oas_commit +++ b/services/albwaf/oas_commit @@ -1 +1 @@ -98c11e0ee4834ddaaa474eccc437d234e6276a70 +8f43ed707da765654e4427642c9d978f80d504e1 diff --git a/services/albwaf/v1alphaapi/api_default.go b/services/albwaf/v1alphaapi/api_default.go index 4f39c9b69..37a24a13d 100644 --- a/services/albwaf/v1alphaapi/api_default.go +++ b/services/albwaf/v1alphaapi/api_default.go @@ -36,8 +36,8 @@ type DefaultAPI interface { CreateCoreRuleSet(ctx context.Context, projectId string, region string) ApiCreateCoreRuleSetRequest // CreateCoreRuleSetExecute executes the request - // @return CreateCoreRuleSetResponse - CreateCoreRuleSetExecute(r ApiCreateCoreRuleSetRequest) (*CreateCoreRuleSetResponse, error) + // @return GetCoreRuleSetResponse + CreateCoreRuleSetExecute(r ApiCreateCoreRuleSetRequest) (*GetCoreRuleSetResponse, error) /* CreateRules Create a rule configuration @@ -237,10 +237,27 @@ type DefaultAPI interface { // @return ListWAFResponse ListWAFExecute(r ApiListWAFRequest) (*ListWAFResponse, error) + /* + PatchCoreRuleSet Granularly update a CRS configuration + + Accepts the same structure as the GET response. Only fields provided with values will be updated. + + @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 ApiPatchCoreRuleSetRequest + */ + PatchCoreRuleSet(ctx context.Context, projectId string, region string, name string) ApiPatchCoreRuleSetRequest + + // PatchCoreRuleSetExecute executes the request + // @return GetCoreRuleSetResponse + PatchCoreRuleSetExecute(r ApiPatchCoreRuleSetRequest) (*GetCoreRuleSetResponse, error) + /* UpdateCoreRuleSet Update a CRS configuration - This endpoint will update an existing core rule set (CRS) configuration and also inturn update all WAF configurations that reference it. + DEPRECATED: Use PatchCoreRuleSet @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param projectId @@ -305,7 +322,7 @@ func (r ApiCreateCoreRuleSetRequest) CreateCoreRuleSetPayload(createCoreRuleSetP return r } -func (r ApiCreateCoreRuleSetRequest) Execute() (*CreateCoreRuleSetResponse, error) { +func (r ApiCreateCoreRuleSetRequest) Execute() (*GetCoreRuleSetResponse, error) { return r.ApiService.CreateCoreRuleSetExecute(r) } @@ -330,13 +347,13 @@ func (a *DefaultAPIService) CreateCoreRuleSet(ctx context.Context, projectId str // Execute executes the request // -// @return CreateCoreRuleSetResponse -func (a *DefaultAPIService) CreateCoreRuleSetExecute(r ApiCreateCoreRuleSetRequest) (*CreateCoreRuleSetResponse, error) { +// @return GetCoreRuleSetResponse +func (a *DefaultAPIService) CreateCoreRuleSetExecute(r ApiCreateCoreRuleSetRequest) (*GetCoreRuleSetResponse, error) { var ( localVarHTTPMethod = http.MethodPost localVarPostBody interface{} formFiles []formFile - localVarReturnValue *CreateCoreRuleSetResponse + localVarReturnValue *GetCoreRuleSetResponse ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.CreateCoreRuleSet") @@ -2203,6 +2220,159 @@ func (a *DefaultAPIService) ListWAFExecute(r ApiListWAFRequest) (*ListWAFRespons return localVarReturnValue, nil } +type ApiPatchCoreRuleSetRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + region string + name string + patchCoreRuleSetPayload *PatchCoreRuleSetPayload +} + +func (r ApiPatchCoreRuleSetRequest) PatchCoreRuleSetPayload(patchCoreRuleSetPayload PatchCoreRuleSetPayload) ApiPatchCoreRuleSetRequest { + r.patchCoreRuleSetPayload = &patchCoreRuleSetPayload + return r +} + +func (r ApiPatchCoreRuleSetRequest) Execute() (*GetCoreRuleSetResponse, error) { + return r.ApiService.PatchCoreRuleSetExecute(r) +} + +/* +PatchCoreRuleSet Granularly update a CRS configuration + +Accepts the same structure as the GET response. Only fields provided with values will be updated. + + @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 ApiPatchCoreRuleSetRequest +*/ +func (a *DefaultAPIService) PatchCoreRuleSet(ctx context.Context, projectId string, region string, name string) ApiPatchCoreRuleSetRequest { + return ApiPatchCoreRuleSetRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// Execute executes the request +// +// @return GetCoreRuleSetResponse +func (a *DefaultAPIService) PatchCoreRuleSetExecute(r ApiPatchCoreRuleSetRequest) (*GetCoreRuleSetResponse, error) { + var ( + localVarHTTPMethod = http.MethodPatch + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *GetCoreRuleSetResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.PatchCoreRuleSet") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{region}/core-rule-sets/{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.patchCoreRuleSetPayload == nil { + return localVarReturnValue, reportError("patchCoreRuleSetPayload 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.patchCoreRuleSetPayload + 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 ApiUpdateCoreRuleSetRequest struct { ctx context.Context ApiService DefaultAPI @@ -2224,7 +2394,7 @@ func (r ApiUpdateCoreRuleSetRequest) Execute() (*UpdateCoreRuleSetResponse, erro /* UpdateCoreRuleSet Update a CRS configuration -This endpoint will update an existing core rule set (CRS) configuration and also inturn update all WAF configurations that reference it. +DEPRECATED: Use PatchCoreRuleSet @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param projectId diff --git a/services/albwaf/v1alphaapi/api_default_mock.go b/services/albwaf/v1alphaapi/api_default_mock.go index f28316e17..8a8419ae4 100644 --- a/services/albwaf/v1alphaapi/api_default_mock.go +++ b/services/albwaf/v1alphaapi/api_default_mock.go @@ -21,7 +21,7 @@ var _ DefaultAPI = &DefaultAPIServiceMock{} // By default all FooExecute() implementations are a no-op. Behavior of the mock can be customized by populating the callbacks in this struct. type DefaultAPIServiceMock struct { // CreateCoreRuleSetExecuteMock can be populated to implement the behavior of the CreateCoreRuleSetExecute function of this mock - CreateCoreRuleSetExecuteMock *func(r ApiCreateCoreRuleSetRequest) (*CreateCoreRuleSetResponse, error) + CreateCoreRuleSetExecuteMock *func(r ApiCreateCoreRuleSetRequest) (*GetCoreRuleSetResponse, error) // CreateRulesExecuteMock can be populated to implement the behavior of the CreateRulesExecute function of this mock CreateRulesExecuteMock *func(r ApiCreateRulesRequest) (*CreateRulesResponse, error) // CreateWAFExecuteMock can be populated to implement the behavior of the CreateWAFExecute function of this mock @@ -46,6 +46,8 @@ type DefaultAPIServiceMock struct { ListRulesExecuteMock *func(r ApiListRulesRequest) (*ListRulesResponse, error) // ListWAFExecuteMock can be populated to implement the behavior of the ListWAFExecute function of this mock ListWAFExecuteMock *func(r ApiListWAFRequest) (*ListWAFResponse, error) + // PatchCoreRuleSetExecuteMock can be populated to implement the behavior of the PatchCoreRuleSetExecute function of this mock + PatchCoreRuleSetExecuteMock *func(r ApiPatchCoreRuleSetRequest) (*GetCoreRuleSetResponse, error) // UpdateCoreRuleSetExecuteMock can be populated to implement the behavior of the UpdateCoreRuleSetExecute function of this mock UpdateCoreRuleSetExecuteMock *func(r ApiUpdateCoreRuleSetRequest) (*UpdateCoreRuleSetResponse, error) // UpdateRulesExecuteMock can be populated to implement the behavior of the UpdateRulesExecute function of this mock @@ -64,9 +66,9 @@ func (a DefaultAPIServiceMock) CreateCoreRuleSet(ctx context.Context, projectId } // CreateCoreRuleSetExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the CreateCoreRuleSetExecuteMock field in the DefaultAPIServiceMock struct. -func (a DefaultAPIServiceMock) CreateCoreRuleSetExecute(r ApiCreateCoreRuleSetRequest) (*CreateCoreRuleSetResponse, error) { +func (a DefaultAPIServiceMock) CreateCoreRuleSetExecute(r ApiCreateCoreRuleSetRequest) (*GetCoreRuleSetResponse, error) { if a.CreateCoreRuleSetExecuteMock == nil { - var localVarReturnValue *CreateCoreRuleSetResponse + var localVarReturnValue *GetCoreRuleSetResponse return localVarReturnValue, nil } @@ -307,6 +309,26 @@ func (a DefaultAPIServiceMock) ListWAFExecute(r ApiListWAFRequest) (*ListWAFResp return (*a.ListWAFExecuteMock)(r) } +func (a DefaultAPIServiceMock) PatchCoreRuleSet(ctx context.Context, projectId string, region string, name string) ApiPatchCoreRuleSetRequest { + return ApiPatchCoreRuleSetRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// PatchCoreRuleSetExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the PatchCoreRuleSetExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) PatchCoreRuleSetExecute(r ApiPatchCoreRuleSetRequest) (*GetCoreRuleSetResponse, error) { + if a.PatchCoreRuleSetExecuteMock == nil { + var localVarReturnValue *GetCoreRuleSetResponse + return localVarReturnValue, nil + } + + return (*a.PatchCoreRuleSetExecuteMock)(r) +} + func (a DefaultAPIServiceMock) UpdateCoreRuleSet(ctx context.Context, projectId string, region string, name string) ApiUpdateCoreRuleSetRequest { return ApiUpdateCoreRuleSetRequest{ ApiService: a, diff --git a/services/albwaf/v1alphaapi/model_create_core_rule_set_response.go b/services/albwaf/v1alphaapi/model_create_core_rule_set_response.go deleted file mode 100644 index 420a93e07..000000000 --- a/services/albwaf/v1alphaapi/model_create_core_rule_set_response.go +++ /dev/null @@ -1,230 +0,0 @@ -/* -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 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" -) - -// checks if the CreateCoreRuleSetResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &CreateCoreRuleSetResponse{} - -// CreateCoreRuleSetResponse CreateCoreRuleSetResponse returns rule configuration name and it's rules. -type CreateCoreRuleSetResponse struct { - // Indicates if the OWASP core rule set is active. - Active *bool `json:"active,omitempty"` - // Core rule set configuration name. - Name *string `json:"name,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` - // Region - Region *string `json:"region,omitempty" validate:"regexp=^[a-z]{2,4}[0-9]{2}$"` - AdditionalProperties map[string]interface{} -} - -type _CreateCoreRuleSetResponse CreateCoreRuleSetResponse - -// NewCreateCoreRuleSetResponse instantiates a new CreateCoreRuleSetResponse 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 NewCreateCoreRuleSetResponse() *CreateCoreRuleSetResponse { - this := CreateCoreRuleSetResponse{} - return &this -} - -// NewCreateCoreRuleSetResponseWithDefaults instantiates a new CreateCoreRuleSetResponse 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 NewCreateCoreRuleSetResponseWithDefaults() *CreateCoreRuleSetResponse { - this := CreateCoreRuleSetResponse{} - return &this -} - -// GetActive returns the Active field value if set, zero value otherwise. -func (o *CreateCoreRuleSetResponse) GetActive() bool { - if o == nil || IsNil(o.Active) { - var ret bool - return ret - } - return *o.Active -} - -// GetActiveOk returns a tuple with the Active field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *CreateCoreRuleSetResponse) GetActiveOk() (*bool, bool) { - if o == nil || IsNil(o.Active) { - return nil, false - } - return o.Active, true -} - -// HasActive returns a boolean if a field has been set. -func (o *CreateCoreRuleSetResponse) HasActive() bool { - if o != nil && !IsNil(o.Active) { - return true - } - - return false -} - -// SetActive gets a reference to the given bool and assigns it to the Active field. -func (o *CreateCoreRuleSetResponse) SetActive(v bool) { - o.Active = &v -} - -// GetName returns the Name field value if set, zero value otherwise. -func (o *CreateCoreRuleSetResponse) GetName() string { - if o == nil || IsNil(o.Name) { - var ret string - return ret - } - return *o.Name -} - -// GetNameOk returns a tuple with the Name field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *CreateCoreRuleSetResponse) GetNameOk() (*string, bool) { - if o == nil || IsNil(o.Name) { - return nil, false - } - return o.Name, true -} - -// HasName returns a boolean if a field has been set. -func (o *CreateCoreRuleSetResponse) HasName() bool { - if o != nil && !IsNil(o.Name) { - return true - } - - return false -} - -// SetName gets a reference to the given string and assigns it to the Name field. -func (o *CreateCoreRuleSetResponse) SetName(v string) { - o.Name = &v -} - -// GetRegion returns the Region field value if set, zero value otherwise. -func (o *CreateCoreRuleSetResponse) 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 *CreateCoreRuleSetResponse) 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 *CreateCoreRuleSetResponse) 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 *CreateCoreRuleSetResponse) SetRegion(v string) { - o.Region = &v -} - -func (o CreateCoreRuleSetResponse) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o CreateCoreRuleSetResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Active) { - toSerialize["active"] = o.Active - } - if !IsNil(o.Name) { - toSerialize["name"] = o.Name - } - if !IsNil(o.Region) { - toSerialize["region"] = o.Region - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *CreateCoreRuleSetResponse) UnmarshalJSON(data []byte) (err error) { - varCreateCoreRuleSetResponse := _CreateCoreRuleSetResponse{} - - err = json.Unmarshal(data, &varCreateCoreRuleSetResponse) - - if err != nil { - return err - } - - *o = CreateCoreRuleSetResponse(varCreateCoreRuleSetResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "active") - delete(additionalProperties, "name") - delete(additionalProperties, "region") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableCreateCoreRuleSetResponse struct { - value *CreateCoreRuleSetResponse - isSet bool -} - -func (v NullableCreateCoreRuleSetResponse) Get() *CreateCoreRuleSetResponse { - return v.value -} - -func (v *NullableCreateCoreRuleSetResponse) Set(val *CreateCoreRuleSetResponse) { - v.value = val - v.isSet = true -} - -func (v NullableCreateCoreRuleSetResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableCreateCoreRuleSetResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableCreateCoreRuleSetResponse(val *CreateCoreRuleSetResponse) *NullableCreateCoreRuleSetResponse { - return &NullableCreateCoreRuleSetResponse{value: val, isSet: true} -} - -func (v NullableCreateCoreRuleSetResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableCreateCoreRuleSetResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} diff --git a/services/albwaf/v1alphaapi/model_crs_rule.go b/services/albwaf/v1alphaapi/model_crs_rule.go index b7ba6795b..33d78541f 100644 --- a/services/albwaf/v1alphaapi/model_crs_rule.go +++ b/services/albwaf/v1alphaapi/model_crs_rule.go @@ -19,11 +19,11 @@ var _ MappedNullable = &CRSRule{} // CRSRule Rule represents an individual security or validation rule. type CRSRule struct { - // Description of the specific rule. + // SQL Injection Attack Detected via libinjection Description *string `json:"description,omitempty"` - // The unique numeric ID of the rule. - Id *int32 `json:"id,omitempty"` - // The impact level of the rule trigger. + // The current mode of the rule. + Mode *string `json:"mode,omitempty" validate:"regexp=^(MODE_ENABLED|MODE_DISABLED|MODE_LOG_ONLY)$"` + // Impact level. Severity *string `json:"severity,omitempty" validate:"regexp=^(CRITICAL|ERROR|WARNING|INFO)$"` AdditionalProperties map[string]interface{} } @@ -79,36 +79,36 @@ func (o *CRSRule) SetDescription(v string) { o.Description = &v } -// GetId returns the Id field value if set, zero value otherwise. -func (o *CRSRule) GetId() int32 { - if o == nil || IsNil(o.Id) { - var ret int32 +// GetMode returns the Mode field value if set, zero value otherwise. +func (o *CRSRule) GetMode() string { + if o == nil || IsNil(o.Mode) { + var ret string return ret } - return *o.Id + return *o.Mode } -// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// 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) GetIdOk() (*int32, bool) { - if o == nil || IsNil(o.Id) { +func (o *CRSRule) GetModeOk() (*string, bool) { + if o == nil || IsNil(o.Mode) { return nil, false } - return o.Id, true + return o.Mode, true } -// HasId returns a boolean if a field has been set. -func (o *CRSRule) HasId() bool { - if o != nil && !IsNil(o.Id) { +// HasMode returns a boolean if a field has been set. +func (o *CRSRule) HasMode() bool { + if o != nil && !IsNil(o.Mode) { return true } return false } -// SetId gets a reference to the given int32 and assigns it to the Id field. -func (o *CRSRule) SetId(v int32) { - o.Id = &v +// SetMode gets a reference to the given string and assigns it to the Mode field. +func (o *CRSRule) SetMode(v string) { + o.Mode = &v } // GetSeverity returns the Severity field value if set, zero value otherwise. @@ -156,8 +156,8 @@ func (o CRSRule) ToMap() (map[string]interface{}, error) { if !IsNil(o.Description) { toSerialize["description"] = o.Description } - if !IsNil(o.Id) { - toSerialize["id"] = o.Id + if !IsNil(o.Mode) { + toSerialize["mode"] = o.Mode } if !IsNil(o.Severity) { toSerialize["severity"] = o.Severity @@ -185,7 +185,7 @@ func (o *CRSRule) UnmarshalJSON(data []byte) (err error) { if err = json.Unmarshal(data, &additionalProperties); err == nil { delete(additionalProperties, "description") - delete(additionalProperties, "id") + delete(additionalProperties, "mode") delete(additionalProperties, "severity") o.AdditionalProperties = additionalProperties } diff --git a/services/albwaf/v1alphaapi/model_crs_rule_group.go b/services/albwaf/v1alphaapi/model_crs_rule_group.go index 25e99ea31..07da4fb9f 100644 --- a/services/albwaf/v1alphaapi/model_crs_rule_group.go +++ b/services/albwaf/v1alphaapi/model_crs_rule_group.go @@ -22,9 +22,8 @@ type CRSRuleGroup struct { // A description of what this group covers. Description *string `json:"description,omitempty"` // The name for the rule group. - GroupName *string `json:"groupName,omitempty" validate:"regexp=^[a-zA-Z\\\\(\\\\) ]+$"` - // The list of individual rules contained within this group. - Rules []CRSRule `json:"rules,omitempty"` + GroupName *string `json:"groupName,omitempty" validate:"regexp=^[a-zA-Z\\\\(\\\\) ]+$"` + Rules *map[string]CRSRule `json:"rules,omitempty"` AdditionalProperties map[string]interface{} } @@ -112,17 +111,17 @@ func (o *CRSRuleGroup) SetGroupName(v string) { } // GetRules returns the Rules field value if set, zero value otherwise. -func (o *CRSRuleGroup) GetRules() []CRSRule { +func (o *CRSRuleGroup) GetRules() map[string]CRSRule { if o == nil || IsNil(o.Rules) { - var ret []CRSRule + var ret map[string]CRSRule return ret } - return o.Rules + return *o.Rules } // 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 *CRSRuleGroup) GetRulesOk() ([]CRSRule, bool) { +func (o *CRSRuleGroup) GetRulesOk() (*map[string]CRSRule, bool) { if o == nil || IsNil(o.Rules) { return nil, false } @@ -138,9 +137,9 @@ func (o *CRSRuleGroup) HasRules() bool { return false } -// SetRules gets a reference to the given []CRSRule and assigns it to the Rules field. -func (o *CRSRuleGroup) SetRules(v []CRSRule) { - o.Rules = v +// SetRules gets a reference to the given map[string]CRSRule and assigns it to the Rules field. +func (o *CRSRuleGroup) SetRules(v map[string]CRSRule) { + o.Rules = &v } func (o CRSRuleGroup) MarshalJSON() ([]byte, error) { diff --git a/services/albwaf/v1alphaapi/model_get_core_rule_set_response.go b/services/albwaf/v1alphaapi/model_get_core_rule_set_response.go index 3b0c3dc71..1be9f31f4 100644 --- a/services/albwaf/v1alphaapi/model_get_core_rule_set_response.go +++ b/services/albwaf/v1alphaapi/model_get_core_rule_set_response.go @@ -20,8 +20,9 @@ var _ MappedNullable = &GetCoreRuleSetResponse{} // GetCoreRuleSetResponse GetCoreRuleSetResponse returns rule configuration name and it's rules. type GetCoreRuleSetResponse struct { // Indicates if the OWASP core rule set is active. - Active *bool `json:"active,omitempty"` - Groups []CRSRuleGroup `json:"groups,omitempty"` + Active *bool `json:"active,omitempty"` + // Inventory of all available Core Rule Set groups and their current configuration. The key is the unique Group ID. + Groups *map[string]CRSRuleGroup `json:"groups,omitempty"` // Core rule set configuration name. Name *string `json:"name,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` // Region @@ -83,17 +84,17 @@ func (o *GetCoreRuleSetResponse) SetActive(v bool) { } // GetGroups returns the Groups field value if set, zero value otherwise. -func (o *GetCoreRuleSetResponse) GetGroups() []CRSRuleGroup { +func (o *GetCoreRuleSetResponse) GetGroups() map[string]CRSRuleGroup { if o == nil || IsNil(o.Groups) { - var ret []CRSRuleGroup + var ret map[string]CRSRuleGroup return ret } - return o.Groups + return *o.Groups } // GetGroupsOk returns a tuple with the Groups field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *GetCoreRuleSetResponse) GetGroupsOk() ([]CRSRuleGroup, bool) { +func (o *GetCoreRuleSetResponse) GetGroupsOk() (*map[string]CRSRuleGroup, bool) { if o == nil || IsNil(o.Groups) { return nil, false } @@ -109,9 +110,9 @@ func (o *GetCoreRuleSetResponse) HasGroups() bool { return false } -// SetGroups gets a reference to the given []CRSRuleGroup and assigns it to the Groups field. -func (o *GetCoreRuleSetResponse) SetGroups(v []CRSRuleGroup) { - o.Groups = v +// SetGroups gets a reference to the given map[string]CRSRuleGroup and assigns it to the Groups field. +func (o *GetCoreRuleSetResponse) SetGroups(v map[string]CRSRuleGroup) { + o.Groups = &v } // GetName returns the Name field value if set, zero value otherwise. diff --git a/services/albwaf/v1alphaapi/model_patch_core_rule_set_payload.go b/services/albwaf/v1alphaapi/model_patch_core_rule_set_payload.go new file mode 100644 index 000000000..c08b1fdeb --- /dev/null +++ b/services/albwaf/v1alphaapi/model_patch_core_rule_set_payload.go @@ -0,0 +1,306 @@ +/* +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 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" +) + +// checks if the PatchCoreRuleSetPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &PatchCoreRuleSetPayload{} + +// PatchCoreRuleSetPayload PatchCoreRuleSetRequest updates a rules configuration. +type PatchCoreRuleSetPayload struct { + // To activate the OWASP core rule set, set this boolean to true. + Active *bool `json:"active,omitempty"` + // Map of Core Rule Set groups to be patched. The key is the Group ID (e.g., 942 for SQL Injection). Only provided rules within the group will be updated; others remain unchanged. + Groups *map[string]PatchCRSRuleGroup `json:"groups,omitempty"` + // Core rule set configuration name. + Name *string `json:"name,omitempty" 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}$"` + AdditionalProperties map[string]interface{} +} + +type _PatchCoreRuleSetPayload PatchCoreRuleSetPayload + +// NewPatchCoreRuleSetPayload instantiates a new PatchCoreRuleSetPayload 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 NewPatchCoreRuleSetPayload() *PatchCoreRuleSetPayload { + this := PatchCoreRuleSetPayload{} + return &this +} + +// NewPatchCoreRuleSetPayloadWithDefaults instantiates a new PatchCoreRuleSetPayload 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 NewPatchCoreRuleSetPayloadWithDefaults() *PatchCoreRuleSetPayload { + this := PatchCoreRuleSetPayload{} + return &this +} + +// GetActive returns the Active field value if set, zero value otherwise. +func (o *PatchCoreRuleSetPayload) GetActive() bool { + if o == nil || IsNil(o.Active) { + var ret bool + return ret + } + return *o.Active +} + +// GetActiveOk returns a tuple with the Active field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchCoreRuleSetPayload) GetActiveOk() (*bool, bool) { + if o == nil || IsNil(o.Active) { + return nil, false + } + return o.Active, true +} + +// HasActive returns a boolean if a field has been set. +func (o *PatchCoreRuleSetPayload) HasActive() bool { + if o != nil && !IsNil(o.Active) { + return true + } + + return false +} + +// SetActive gets a reference to the given bool and assigns it to the Active field. +func (o *PatchCoreRuleSetPayload) SetActive(v bool) { + o.Active = &v +} + +// GetGroups returns the Groups field value if set, zero value otherwise. +func (o *PatchCoreRuleSetPayload) GetGroups() map[string]PatchCRSRuleGroup { + if o == nil || IsNil(o.Groups) { + var ret map[string]PatchCRSRuleGroup + return ret + } + return *o.Groups +} + +// GetGroupsOk returns a tuple with the Groups field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchCoreRuleSetPayload) GetGroupsOk() (*map[string]PatchCRSRuleGroup, bool) { + if o == nil || IsNil(o.Groups) { + return nil, false + } + return o.Groups, true +} + +// HasGroups returns a boolean if a field has been set. +func (o *PatchCoreRuleSetPayload) HasGroups() bool { + if o != nil && !IsNil(o.Groups) { + return true + } + + return false +} + +// SetGroups gets a reference to the given map[string]PatchCRSRuleGroup and assigns it to the Groups field. +func (o *PatchCoreRuleSetPayload) SetGroups(v map[string]PatchCRSRuleGroup) { + o.Groups = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *PatchCoreRuleSetPayload) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchCoreRuleSetPayload) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *PatchCoreRuleSetPayload) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *PatchCoreRuleSetPayload) SetName(v string) { + o.Name = &v +} + +// GetProjectId returns the ProjectId field value if set, zero value otherwise. +func (o *PatchCoreRuleSetPayload) 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 *PatchCoreRuleSetPayload) 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 *PatchCoreRuleSetPayload) 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 *PatchCoreRuleSetPayload) SetProjectId(v string) { + o.ProjectId = &v +} + +// GetRegion returns the Region field value if set, zero value otherwise. +func (o *PatchCoreRuleSetPayload) 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 *PatchCoreRuleSetPayload) 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 *PatchCoreRuleSetPayload) 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 *PatchCoreRuleSetPayload) SetRegion(v string) { + o.Region = &v +} + +func (o PatchCoreRuleSetPayload) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o PatchCoreRuleSetPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Active) { + toSerialize["active"] = o.Active + } + if !IsNil(o.Groups) { + toSerialize["groups"] = o.Groups + } + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.ProjectId) { + toSerialize["projectId"] = o.ProjectId + } + if !IsNil(o.Region) { + toSerialize["region"] = o.Region + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *PatchCoreRuleSetPayload) UnmarshalJSON(data []byte) (err error) { + varPatchCoreRuleSetPayload := _PatchCoreRuleSetPayload{} + + err = json.Unmarshal(data, &varPatchCoreRuleSetPayload) + + if err != nil { + return err + } + + *o = PatchCoreRuleSetPayload(varPatchCoreRuleSetPayload) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "active") + delete(additionalProperties, "groups") + delete(additionalProperties, "name") + delete(additionalProperties, "projectId") + delete(additionalProperties, "region") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullablePatchCoreRuleSetPayload struct { + value *PatchCoreRuleSetPayload + isSet bool +} + +func (v NullablePatchCoreRuleSetPayload) Get() *PatchCoreRuleSetPayload { + return v.value +} + +func (v *NullablePatchCoreRuleSetPayload) Set(val *PatchCoreRuleSetPayload) { + v.value = val + v.isSet = true +} + +func (v NullablePatchCoreRuleSetPayload) IsSet() bool { + return v.isSet +} + +func (v *NullablePatchCoreRuleSetPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePatchCoreRuleSetPayload(val *PatchCoreRuleSetPayload) *NullablePatchCoreRuleSetPayload { + return &NullablePatchCoreRuleSetPayload{value: val, isSet: true} +} + +func (v NullablePatchCoreRuleSetPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePatchCoreRuleSetPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_patch_crs_rule.go b/services/albwaf/v1alphaapi/model_patch_crs_rule.go new file mode 100644 index 000000000..3d19cffcf --- /dev/null +++ b/services/albwaf/v1alphaapi/model_patch_crs_rule.go @@ -0,0 +1,154 @@ +/* +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 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" +) + +// checks if the PatchCRSRule type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &PatchCRSRule{} + +// PatchCRSRule struct for PatchCRSRule +type PatchCRSRule struct { + // The current mode of the rule. + Mode *string `json:"mode,omitempty" validate:"regexp=^(MODE_ENABLED|MODE_DISABLED|MODE_LOG_ONLY)$"` + AdditionalProperties map[string]interface{} +} + +type _PatchCRSRule PatchCRSRule + +// NewPatchCRSRule instantiates a new PatchCRSRule 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 NewPatchCRSRule() *PatchCRSRule { + this := PatchCRSRule{} + return &this +} + +// NewPatchCRSRuleWithDefaults instantiates a new PatchCRSRule 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 NewPatchCRSRuleWithDefaults() *PatchCRSRule { + this := PatchCRSRule{} + return &this +} + +// GetMode returns the Mode field value if set, zero value otherwise. +func (o *PatchCRSRule) GetMode() string { + if o == nil || IsNil(o.Mode) { + var ret string + return ret + } + return *o.Mode +} + +// 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 *PatchCRSRule) GetModeOk() (*string, bool) { + if o == nil || IsNil(o.Mode) { + return nil, false + } + return o.Mode, true +} + +// HasMode returns a boolean if a field has been set. +func (o *PatchCRSRule) HasMode() bool { + if o != nil && !IsNil(o.Mode) { + return true + } + + return false +} + +// SetMode gets a reference to the given string and assigns it to the Mode field. +func (o *PatchCRSRule) SetMode(v string) { + o.Mode = &v +} + +func (o PatchCRSRule) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o PatchCRSRule) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Mode) { + toSerialize["mode"] = o.Mode + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *PatchCRSRule) UnmarshalJSON(data []byte) (err error) { + varPatchCRSRule := _PatchCRSRule{} + + err = json.Unmarshal(data, &varPatchCRSRule) + + if err != nil { + return err + } + + *o = PatchCRSRule(varPatchCRSRule) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "mode") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullablePatchCRSRule struct { + value *PatchCRSRule + isSet bool +} + +func (v NullablePatchCRSRule) Get() *PatchCRSRule { + return v.value +} + +func (v *NullablePatchCRSRule) Set(val *PatchCRSRule) { + v.value = val + v.isSet = true +} + +func (v NullablePatchCRSRule) IsSet() bool { + return v.isSet +} + +func (v *NullablePatchCRSRule) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePatchCRSRule(val *PatchCRSRule) *NullablePatchCRSRule { + return &NullablePatchCRSRule{value: val, isSet: true} +} + +func (v NullablePatchCRSRule) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePatchCRSRule) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_patch_crs_rule_group.go b/services/albwaf/v1alphaapi/model_patch_crs_rule_group.go new file mode 100644 index 000000000..0d2c0933b --- /dev/null +++ b/services/albwaf/v1alphaapi/model_patch_crs_rule_group.go @@ -0,0 +1,153 @@ +/* +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 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" +) + +// checks if the PatchCRSRuleGroup type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &PatchCRSRuleGroup{} + +// PatchCRSRuleGroup struct for PatchCRSRuleGroup +type PatchCRSRuleGroup struct { + Rules *map[string]PatchCRSRule `json:"rules,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _PatchCRSRuleGroup PatchCRSRuleGroup + +// NewPatchCRSRuleGroup instantiates a new PatchCRSRuleGroup 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 NewPatchCRSRuleGroup() *PatchCRSRuleGroup { + this := PatchCRSRuleGroup{} + return &this +} + +// NewPatchCRSRuleGroupWithDefaults instantiates a new PatchCRSRuleGroup 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 NewPatchCRSRuleGroupWithDefaults() *PatchCRSRuleGroup { + this := PatchCRSRuleGroup{} + return &this +} + +// GetRules returns the Rules field value if set, zero value otherwise. +func (o *PatchCRSRuleGroup) GetRules() map[string]PatchCRSRule { + if o == nil || IsNil(o.Rules) { + var ret map[string]PatchCRSRule + return ret + } + return *o.Rules +} + +// 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 *PatchCRSRuleGroup) GetRulesOk() (*map[string]PatchCRSRule, bool) { + if o == nil || IsNil(o.Rules) { + return nil, false + } + return o.Rules, true +} + +// HasRules returns a boolean if a field has been set. +func (o *PatchCRSRuleGroup) HasRules() bool { + if o != nil && !IsNil(o.Rules) { + return true + } + + return false +} + +// SetRules gets a reference to the given map[string]PatchCRSRule and assigns it to the Rules field. +func (o *PatchCRSRuleGroup) SetRules(v map[string]PatchCRSRule) { + o.Rules = &v +} + +func (o PatchCRSRuleGroup) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o PatchCRSRuleGroup) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Rules) { + toSerialize["rules"] = o.Rules + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *PatchCRSRuleGroup) UnmarshalJSON(data []byte) (err error) { + varPatchCRSRuleGroup := _PatchCRSRuleGroup{} + + err = json.Unmarshal(data, &varPatchCRSRuleGroup) + + if err != nil { + return err + } + + *o = PatchCRSRuleGroup(varPatchCRSRuleGroup) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "rules") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullablePatchCRSRuleGroup struct { + value *PatchCRSRuleGroup + isSet bool +} + +func (v NullablePatchCRSRuleGroup) Get() *PatchCRSRuleGroup { + return v.value +} + +func (v *NullablePatchCRSRuleGroup) Set(val *PatchCRSRuleGroup) { + v.value = val + v.isSet = true +} + +func (v NullablePatchCRSRuleGroup) IsSet() bool { + return v.isSet +} + +func (v *NullablePatchCRSRuleGroup) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePatchCRSRuleGroup(val *PatchCRSRuleGroup) *NullablePatchCRSRuleGroup { + return &NullablePatchCRSRuleGroup{value: val, isSet: true} +} + +func (v NullablePatchCRSRuleGroup) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePatchCRSRuleGroup) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_update_core_rule_set_payload.go b/services/albwaf/v1alphaapi/model_update_core_rule_set_payload.go index fb0f717f1..0e2dbaa5f 100644 --- a/services/albwaf/v1alphaapi/model_update_core_rule_set_payload.go +++ b/services/albwaf/v1alphaapi/model_update_core_rule_set_payload.go @@ -17,10 +17,12 @@ import ( // checks if the UpdateCoreRuleSetPayload type satisfies the MappedNullable interface at compile time var _ MappedNullable = &UpdateCoreRuleSetPayload{} -// UpdateCoreRuleSetPayload UpdateCoreRuleSetRequest updates a rules configuration, but only if it changed. +// UpdateCoreRuleSetPayload UpdateCoreRuleSetRequest updates a rules configuration, but only if it changed. DEPRECATED use PatchCoreRuleSet type UpdateCoreRuleSetPayload struct { // To activate the OWASP core rule set, set this boolean to true. Active *bool `json:"active,omitempty"` + // Map of Core Rule Set groups to be patched. The key is the Group ID (e.g., 942 for SQL Injection). Only provided rules within the group will be updated; others remain unchanged. + Groups *map[string]PatchCRSRuleGroup `json:"groups,omitempty"` // Core rule set configuration name. Name *string `json:"name,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` // Project identifier @@ -81,6 +83,38 @@ func (o *UpdateCoreRuleSetPayload) SetActive(v bool) { o.Active = &v } +// GetGroups returns the Groups field value if set, zero value otherwise. +func (o *UpdateCoreRuleSetPayload) GetGroups() map[string]PatchCRSRuleGroup { + if o == nil || IsNil(o.Groups) { + var ret map[string]PatchCRSRuleGroup + return ret + } + return *o.Groups +} + +// GetGroupsOk returns a tuple with the Groups field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateCoreRuleSetPayload) GetGroupsOk() (*map[string]PatchCRSRuleGroup, bool) { + if o == nil || IsNil(o.Groups) { + return nil, false + } + return o.Groups, true +} + +// HasGroups returns a boolean if a field has been set. +func (o *UpdateCoreRuleSetPayload) HasGroups() bool { + if o != nil && !IsNil(o.Groups) { + return true + } + + return false +} + +// SetGroups gets a reference to the given map[string]PatchCRSRuleGroup and assigns it to the Groups field. +func (o *UpdateCoreRuleSetPayload) SetGroups(v map[string]PatchCRSRuleGroup) { + o.Groups = &v +} + // GetName returns the Name field value if set, zero value otherwise. func (o *UpdateCoreRuleSetPayload) GetName() string { if o == nil || IsNil(o.Name) { @@ -190,6 +224,9 @@ func (o UpdateCoreRuleSetPayload) ToMap() (map[string]interface{}, error) { if !IsNil(o.Active) { toSerialize["active"] = o.Active } + if !IsNil(o.Groups) { + toSerialize["groups"] = o.Groups + } if !IsNil(o.Name) { toSerialize["name"] = o.Name } @@ -222,6 +259,7 @@ func (o *UpdateCoreRuleSetPayload) UnmarshalJSON(data []byte) (err error) { if err = json.Unmarshal(data, &additionalProperties); err == nil { delete(additionalProperties, "active") + delete(additionalProperties, "groups") delete(additionalProperties, "name") delete(additionalProperties, "projectId") delete(additionalProperties, "region") diff --git a/services/albwaf/v1alphaapi/model_update_core_rule_set_response.go b/services/albwaf/v1alphaapi/model_update_core_rule_set_response.go index 573f65c1b..b3cd815ad 100644 --- a/services/albwaf/v1alphaapi/model_update_core_rule_set_response.go +++ b/services/albwaf/v1alphaapi/model_update_core_rule_set_response.go @@ -17,7 +17,7 @@ import ( // checks if the UpdateCoreRuleSetResponse type satisfies the MappedNullable interface at compile time var _ MappedNullable = &UpdateCoreRuleSetResponse{} -// UpdateCoreRuleSetResponse UpdateCoreRuleSetResponse returns rule configuration name and it's rules. +// UpdateCoreRuleSetResponse DEPRECATED use PatchCoreRuleSet type UpdateCoreRuleSetResponse struct { // Indicates if the OWASP core rule set is active. Active *bool `json:"active,omitempty"`