diff --git a/services/albwaf/oas_commit b/services/albwaf/oas_commit index e3713dde3..272dcd7b3 100644 --- a/services/albwaf/oas_commit +++ b/services/albwaf/oas_commit @@ -1 +1 @@ -0e64886dd0847341800d7191ed193b75413be998 +7387ad1600ca8bb2a3f15a5df04cd5831d75852f diff --git a/services/albwaf/v1alphaapi/api_default.go b/services/albwaf/v1alphaapi/api_default.go index 0d625b00b..af8ccee44 100644 --- a/services/albwaf/v1alphaapi/api_default.go +++ b/services/albwaf/v1alphaapi/api_default.go @@ -139,6 +139,22 @@ type DefaultAPI interface { // @return GetCoreRuleSetResponse GetCoreRuleSetExecute(r ApiGetCoreRuleSetRequest) (*GetCoreRuleSetResponse, error) + /* + GetQuota Get the quota for WAF resources in a project. + + Retrieves the configured WAF resource quotas for the project. Limit can be changed via service request. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId + @param region + @return ApiGetQuotaRequest + */ + GetQuota(ctx context.Context, projectId string, region string) ApiGetQuotaRequest + + // GetQuotaExecute executes the request + // @return GetQuotaResponse + GetQuotaExecute(r ApiGetQuotaRequest) (*GetQuotaResponse, error) + /* GetRules Retrieve a rule configuration @@ -1305,6 +1321,146 @@ func (a *DefaultAPIService) GetCoreRuleSetExecute(r ApiGetCoreRuleSetRequest) (* return localVarReturnValue, nil } +type ApiGetQuotaRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + region string +} + +func (r ApiGetQuotaRequest) Execute() (*GetQuotaResponse, error) { + return r.ApiService.GetQuotaExecute(r) +} + +/* +GetQuota Get the quota for WAF resources in a project. + +Retrieves the configured WAF resource quotas for the project. Limit can be changed via service request. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId + @param region + @return ApiGetQuotaRequest +*/ +func (a *DefaultAPIService) GetQuota(ctx context.Context, projectId string, region string) ApiGetQuotaRequest { + return ApiGetQuotaRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + } +} + +// Execute executes the request +// +// @return GetQuotaResponse +func (a *DefaultAPIService) GetQuotaExecute(r ApiGetQuotaRequest) (*GetQuotaResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *GetQuotaResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.GetQuota") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{region}/quotas" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(parameterValueToString(r.region, "region")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json", "text/plain"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + 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 string + 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 + 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 + 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 ApiGetRulesRequest struct { ctx context.Context ApiService DefaultAPI diff --git a/services/albwaf/v1alphaapi/api_default_mock.go b/services/albwaf/v1alphaapi/api_default_mock.go index 9cf69252e..f28316e17 100644 --- a/services/albwaf/v1alphaapi/api_default_mock.go +++ b/services/albwaf/v1alphaapi/api_default_mock.go @@ -34,6 +34,8 @@ type DefaultAPIServiceMock struct { DeleteWAFExecuteMock *func(r ApiDeleteWAFRequest) (map[string]interface{}, error) // GetCoreRuleSetExecuteMock can be populated to implement the behavior of the GetCoreRuleSetExecute function of this mock GetCoreRuleSetExecuteMock *func(r ApiGetCoreRuleSetRequest) (*GetCoreRuleSetResponse, error) + // GetQuotaExecuteMock can be populated to implement the behavior of the GetQuotaExecute function of this mock + GetQuotaExecuteMock *func(r ApiGetQuotaRequest) (*GetQuotaResponse, error) // GetRulesExecuteMock can be populated to implement the behavior of the GetRulesExecute function of this mock GetRulesExecuteMock *func(r ApiGetRulesRequest) (*GetRulesResponse, error) // GetWAFExecuteMock can be populated to implement the behavior of the GetWAFExecute function of this mock @@ -189,6 +191,25 @@ func (a DefaultAPIServiceMock) GetCoreRuleSetExecute(r ApiGetCoreRuleSetRequest) return (*a.GetCoreRuleSetExecuteMock)(r) } +func (a DefaultAPIServiceMock) GetQuota(ctx context.Context, projectId string, region string) ApiGetQuotaRequest { + return ApiGetQuotaRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + } +} + +// GetQuotaExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the GetQuotaExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) GetQuotaExecute(r ApiGetQuotaRequest) (*GetQuotaResponse, error) { + if a.GetQuotaExecuteMock == nil { + var localVarReturnValue *GetQuotaResponse + return localVarReturnValue, nil + } + + return (*a.GetQuotaExecuteMock)(r) +} + func (a DefaultAPIServiceMock) GetRules(ctx context.Context, projectId string, region string, name string) ApiGetRulesRequest { return ApiGetRulesRequest{ ApiService: a, diff --git a/services/albwaf/v1alphaapi/model_crs_config_quota.go b/services/albwaf/v1alphaapi/model_crs_config_quota.go new file mode 100644 index 000000000..1843cc682 --- /dev/null +++ b/services/albwaf/v1alphaapi/model_crs_config_quota.go @@ -0,0 +1,192 @@ +/* +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 CRSConfigQuota type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &CRSConfigQuota{} + +// CRSConfigQuota CRS Config quota holds the limit and usage for Core Rule Set configuration resources +type CRSConfigQuota struct { + // The maximum number of Core Rule Set configurations in this project. + Limit *int32 `json:"limit,omitempty"` + // The number of Core Rule Set configurations that are currently existing in this project. + Usage *int32 `json:"usage,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _CRSConfigQuota CRSConfigQuota + +// NewCRSConfigQuota instantiates a new CRSConfigQuota 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 NewCRSConfigQuota() *CRSConfigQuota { + this := CRSConfigQuota{} + return &this +} + +// NewCRSConfigQuotaWithDefaults instantiates a new CRSConfigQuota 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 NewCRSConfigQuotaWithDefaults() *CRSConfigQuota { + this := CRSConfigQuota{} + return &this +} + +// GetLimit returns the Limit field value if set, zero value otherwise. +func (o *CRSConfigQuota) GetLimit() int32 { + if o == nil || IsNil(o.Limit) { + var ret int32 + return ret + } + return *o.Limit +} + +// GetLimitOk returns a tuple with the Limit field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CRSConfigQuota) GetLimitOk() (*int32, bool) { + if o == nil || IsNil(o.Limit) { + return nil, false + } + return o.Limit, true +} + +// HasLimit returns a boolean if a field has been set. +func (o *CRSConfigQuota) HasLimit() bool { + if o != nil && !IsNil(o.Limit) { + return true + } + + return false +} + +// SetLimit gets a reference to the given int32 and assigns it to the Limit field. +func (o *CRSConfigQuota) SetLimit(v int32) { + o.Limit = &v +} + +// GetUsage returns the Usage field value if set, zero value otherwise. +func (o *CRSConfigQuota) GetUsage() int32 { + if o == nil || IsNil(o.Usage) { + var ret int32 + return ret + } + return *o.Usage +} + +// GetUsageOk returns a tuple with the Usage field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CRSConfigQuota) GetUsageOk() (*int32, bool) { + if o == nil || IsNil(o.Usage) { + return nil, false + } + return o.Usage, true +} + +// HasUsage returns a boolean if a field has been set. +func (o *CRSConfigQuota) HasUsage() bool { + if o != nil && !IsNil(o.Usage) { + return true + } + + return false +} + +// SetUsage gets a reference to the given int32 and assigns it to the Usage field. +func (o *CRSConfigQuota) SetUsage(v int32) { + o.Usage = &v +} + +func (o CRSConfigQuota) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o CRSConfigQuota) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Limit) { + toSerialize["limit"] = o.Limit + } + if !IsNil(o.Usage) { + toSerialize["usage"] = o.Usage + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *CRSConfigQuota) UnmarshalJSON(data []byte) (err error) { + varCRSConfigQuota := _CRSConfigQuota{} + + err = json.Unmarshal(data, &varCRSConfigQuota) + + if err != nil { + return err + } + + *o = CRSConfigQuota(varCRSConfigQuota) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "limit") + delete(additionalProperties, "usage") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableCRSConfigQuota struct { + value *CRSConfigQuota + isSet bool +} + +func (v NullableCRSConfigQuota) Get() *CRSConfigQuota { + return v.value +} + +func (v *NullableCRSConfigQuota) Set(val *CRSConfigQuota) { + v.value = val + v.isSet = true +} + +func (v NullableCRSConfigQuota) IsSet() bool { + return v.isSet +} + +func (v *NullableCRSConfigQuota) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCRSConfigQuota(val *CRSConfigQuota) *NullableCRSConfigQuota { + return &NullableCRSConfigQuota{value: val, isSet: true} +} + +func (v NullableCRSConfigQuota) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCRSConfigQuota) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_custom_rules_quota.go b/services/albwaf/v1alphaapi/model_custom_rules_quota.go new file mode 100644 index 000000000..3f36f56a0 --- /dev/null +++ b/services/albwaf/v1alphaapi/model_custom_rules_quota.go @@ -0,0 +1,192 @@ +/* +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 CustomRulesQuota type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &CustomRulesQuota{} + +// CustomRulesQuota Custom rules quotas holds the limit and usage for custom rules resources +type CustomRulesQuota struct { + // The maximum number of custom rules in this project. + Limit *int32 `json:"limit,omitempty"` + // The number of custom rules that currently existing in this project. + Usage *int32 `json:"usage,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _CustomRulesQuota CustomRulesQuota + +// NewCustomRulesQuota instantiates a new CustomRulesQuota 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 NewCustomRulesQuota() *CustomRulesQuota { + this := CustomRulesQuota{} + return &this +} + +// NewCustomRulesQuotaWithDefaults instantiates a new CustomRulesQuota 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 NewCustomRulesQuotaWithDefaults() *CustomRulesQuota { + this := CustomRulesQuota{} + return &this +} + +// GetLimit returns the Limit field value if set, zero value otherwise. +func (o *CustomRulesQuota) GetLimit() int32 { + if o == nil || IsNil(o.Limit) { + var ret int32 + return ret + } + return *o.Limit +} + +// GetLimitOk returns a tuple with the Limit field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CustomRulesQuota) GetLimitOk() (*int32, bool) { + if o == nil || IsNil(o.Limit) { + return nil, false + } + return o.Limit, true +} + +// HasLimit returns a boolean if a field has been set. +func (o *CustomRulesQuota) HasLimit() bool { + if o != nil && !IsNil(o.Limit) { + return true + } + + return false +} + +// SetLimit gets a reference to the given int32 and assigns it to the Limit field. +func (o *CustomRulesQuota) SetLimit(v int32) { + o.Limit = &v +} + +// GetUsage returns the Usage field value if set, zero value otherwise. +func (o *CustomRulesQuota) GetUsage() int32 { + if o == nil || IsNil(o.Usage) { + var ret int32 + return ret + } + return *o.Usage +} + +// GetUsageOk returns a tuple with the Usage field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CustomRulesQuota) GetUsageOk() (*int32, bool) { + if o == nil || IsNil(o.Usage) { + return nil, false + } + return o.Usage, true +} + +// HasUsage returns a boolean if a field has been set. +func (o *CustomRulesQuota) HasUsage() bool { + if o != nil && !IsNil(o.Usage) { + return true + } + + return false +} + +// SetUsage gets a reference to the given int32 and assigns it to the Usage field. +func (o *CustomRulesQuota) SetUsage(v int32) { + o.Usage = &v +} + +func (o CustomRulesQuota) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o CustomRulesQuota) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Limit) { + toSerialize["limit"] = o.Limit + } + if !IsNil(o.Usage) { + toSerialize["usage"] = o.Usage + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *CustomRulesQuota) UnmarshalJSON(data []byte) (err error) { + varCustomRulesQuota := _CustomRulesQuota{} + + err = json.Unmarshal(data, &varCustomRulesQuota) + + if err != nil { + return err + } + + *o = CustomRulesQuota(varCustomRulesQuota) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "limit") + delete(additionalProperties, "usage") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableCustomRulesQuota struct { + value *CustomRulesQuota + isSet bool +} + +func (v NullableCustomRulesQuota) Get() *CustomRulesQuota { + return v.value +} + +func (v *NullableCustomRulesQuota) Set(val *CustomRulesQuota) { + v.value = val + v.isSet = true +} + +func (v NullableCustomRulesQuota) IsSet() bool { + return v.isSet +} + +func (v *NullableCustomRulesQuota) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCustomRulesQuota(val *CustomRulesQuota) *NullableCustomRulesQuota { + return &NullableCustomRulesQuota{value: val, isSet: true} +} + +func (v NullableCustomRulesQuota) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCustomRulesQuota) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_get_quota_response.go b/services/albwaf/v1alphaapi/model_get_quota_response.go new file mode 100644 index 000000000..0a016f7ad --- /dev/null +++ b/services/albwaf/v1alphaapi/model_get_quota_response.go @@ -0,0 +1,229 @@ +/* +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 GetQuotaResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &GetQuotaResponse{} + +// GetQuotaResponse struct for GetQuotaResponse +type GetQuotaResponse struct { + // 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}$"` + Quotas *Quotas `json:"quotas,omitempty"` + // Region + Region *string `json:"region,omitempty" validate:"regexp=^[a-z]{2,4}[0-9]{2}$"` + AdditionalProperties map[string]interface{} +} + +type _GetQuotaResponse GetQuotaResponse + +// NewGetQuotaResponse instantiates a new GetQuotaResponse 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 NewGetQuotaResponse() *GetQuotaResponse { + this := GetQuotaResponse{} + return &this +} + +// NewGetQuotaResponseWithDefaults instantiates a new GetQuotaResponse 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 NewGetQuotaResponseWithDefaults() *GetQuotaResponse { + this := GetQuotaResponse{} + return &this +} + +// GetProjectId returns the ProjectId field value if set, zero value otherwise. +func (o *GetQuotaResponse) 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 *GetQuotaResponse) 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 *GetQuotaResponse) 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 *GetQuotaResponse) SetProjectId(v string) { + o.ProjectId = &v +} + +// GetQuotas returns the Quotas field value if set, zero value otherwise. +func (o *GetQuotaResponse) GetQuotas() Quotas { + if o == nil || IsNil(o.Quotas) { + var ret Quotas + return ret + } + return *o.Quotas +} + +// GetQuotasOk returns a tuple with the Quotas field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetQuotaResponse) GetQuotasOk() (*Quotas, bool) { + if o == nil || IsNil(o.Quotas) { + return nil, false + } + return o.Quotas, true +} + +// HasQuotas returns a boolean if a field has been set. +func (o *GetQuotaResponse) HasQuotas() bool { + if o != nil && !IsNil(o.Quotas) { + return true + } + + return false +} + +// SetQuotas gets a reference to the given Quotas and assigns it to the Quotas field. +func (o *GetQuotaResponse) SetQuotas(v Quotas) { + o.Quotas = &v +} + +// GetRegion returns the Region field value if set, zero value otherwise. +func (o *GetQuotaResponse) 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 *GetQuotaResponse) 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 *GetQuotaResponse) 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 *GetQuotaResponse) SetRegion(v string) { + o.Region = &v +} + +func (o GetQuotaResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o GetQuotaResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.ProjectId) { + toSerialize["projectId"] = o.ProjectId + } + if !IsNil(o.Quotas) { + toSerialize["quotas"] = o.Quotas + } + if !IsNil(o.Region) { + toSerialize["region"] = o.Region + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *GetQuotaResponse) UnmarshalJSON(data []byte) (err error) { + varGetQuotaResponse := _GetQuotaResponse{} + + err = json.Unmarshal(data, &varGetQuotaResponse) + + if err != nil { + return err + } + + *o = GetQuotaResponse(varGetQuotaResponse) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "projectId") + delete(additionalProperties, "quotas") + delete(additionalProperties, "region") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableGetQuotaResponse struct { + value *GetQuotaResponse + isSet bool +} + +func (v NullableGetQuotaResponse) Get() *GetQuotaResponse { + return v.value +} + +func (v *NullableGetQuotaResponse) Set(val *GetQuotaResponse) { + v.value = val + v.isSet = true +} + +func (v NullableGetQuotaResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableGetQuotaResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableGetQuotaResponse(val *GetQuotaResponse) *NullableGetQuotaResponse { + return &NullableGetQuotaResponse{value: val, isSet: true} +} + +func (v NullableGetQuotaResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableGetQuotaResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_quotas.go b/services/albwaf/v1alphaapi/model_quotas.go new file mode 100644 index 000000000..ac63c19bc --- /dev/null +++ b/services/albwaf/v1alphaapi/model_quotas.go @@ -0,0 +1,227 @@ +/* +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 Quotas type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Quotas{} + +// Quotas Quotas holds the specific quota elements for different resources +type Quotas struct { + CoreRuleSet *CRSConfigQuota `json:"coreRuleSet,omitempty"` + CustomRules *CustomRulesQuota `json:"customRules,omitempty"` + WebApplicationFirewall *WAFConfigQuota `json:"webApplicationFirewall,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _Quotas Quotas + +// NewQuotas instantiates a new Quotas 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 NewQuotas() *Quotas { + this := Quotas{} + return &this +} + +// NewQuotasWithDefaults instantiates a new Quotas 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 NewQuotasWithDefaults() *Quotas { + this := Quotas{} + return &this +} + +// GetCoreRuleSet returns the CoreRuleSet field value if set, zero value otherwise. +func (o *Quotas) GetCoreRuleSet() CRSConfigQuota { + if o == nil || IsNil(o.CoreRuleSet) { + var ret CRSConfigQuota + return ret + } + return *o.CoreRuleSet +} + +// GetCoreRuleSetOk returns a tuple with the CoreRuleSet field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Quotas) GetCoreRuleSetOk() (*CRSConfigQuota, bool) { + if o == nil || IsNil(o.CoreRuleSet) { + return nil, false + } + return o.CoreRuleSet, true +} + +// HasCoreRuleSet returns a boolean if a field has been set. +func (o *Quotas) HasCoreRuleSet() bool { + if o != nil && !IsNil(o.CoreRuleSet) { + return true + } + + return false +} + +// SetCoreRuleSet gets a reference to the given CRSConfigQuota and assigns it to the CoreRuleSet field. +func (o *Quotas) SetCoreRuleSet(v CRSConfigQuota) { + o.CoreRuleSet = &v +} + +// GetCustomRules returns the CustomRules field value if set, zero value otherwise. +func (o *Quotas) GetCustomRules() CustomRulesQuota { + if o == nil || IsNil(o.CustomRules) { + var ret CustomRulesQuota + return ret + } + return *o.CustomRules +} + +// GetCustomRulesOk returns a tuple with the CustomRules field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Quotas) GetCustomRulesOk() (*CustomRulesQuota, bool) { + if o == nil || IsNil(o.CustomRules) { + return nil, false + } + return o.CustomRules, true +} + +// HasCustomRules returns a boolean if a field has been set. +func (o *Quotas) HasCustomRules() bool { + if o != nil && !IsNil(o.CustomRules) { + return true + } + + return false +} + +// SetCustomRules gets a reference to the given CustomRulesQuota and assigns it to the CustomRules field. +func (o *Quotas) SetCustomRules(v CustomRulesQuota) { + o.CustomRules = &v +} + +// GetWebApplicationFirewall returns the WebApplicationFirewall field value if set, zero value otherwise. +func (o *Quotas) GetWebApplicationFirewall() WAFConfigQuota { + if o == nil || IsNil(o.WebApplicationFirewall) { + var ret WAFConfigQuota + return ret + } + return *o.WebApplicationFirewall +} + +// GetWebApplicationFirewallOk returns a tuple with the WebApplicationFirewall field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Quotas) GetWebApplicationFirewallOk() (*WAFConfigQuota, bool) { + if o == nil || IsNil(o.WebApplicationFirewall) { + return nil, false + } + return o.WebApplicationFirewall, true +} + +// HasWebApplicationFirewall returns a boolean if a field has been set. +func (o *Quotas) HasWebApplicationFirewall() bool { + if o != nil && !IsNil(o.WebApplicationFirewall) { + return true + } + + return false +} + +// SetWebApplicationFirewall gets a reference to the given WAFConfigQuota and assigns it to the WebApplicationFirewall field. +func (o *Quotas) SetWebApplicationFirewall(v WAFConfigQuota) { + o.WebApplicationFirewall = &v +} + +func (o Quotas) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o Quotas) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.CoreRuleSet) { + toSerialize["coreRuleSet"] = o.CoreRuleSet + } + if !IsNil(o.CustomRules) { + toSerialize["customRules"] = o.CustomRules + } + if !IsNil(o.WebApplicationFirewall) { + toSerialize["webApplicationFirewall"] = o.WebApplicationFirewall + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *Quotas) UnmarshalJSON(data []byte) (err error) { + varQuotas := _Quotas{} + + err = json.Unmarshal(data, &varQuotas) + + if err != nil { + return err + } + + *o = Quotas(varQuotas) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "coreRuleSet") + delete(additionalProperties, "customRules") + delete(additionalProperties, "webApplicationFirewall") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableQuotas struct { + value *Quotas + isSet bool +} + +func (v NullableQuotas) Get() *Quotas { + return v.value +} + +func (v *NullableQuotas) Set(val *Quotas) { + v.value = val + v.isSet = true +} + +func (v NullableQuotas) IsSet() bool { + return v.isSet +} + +func (v *NullableQuotas) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableQuotas(val *Quotas) *NullableQuotas { + return &NullableQuotas{value: val, isSet: true} +} + +func (v NullableQuotas) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableQuotas) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_waf_config_quota.go b/services/albwaf/v1alphaapi/model_waf_config_quota.go new file mode 100644 index 000000000..b40d80128 --- /dev/null +++ b/services/albwaf/v1alphaapi/model_waf_config_quota.go @@ -0,0 +1,192 @@ +/* +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 WAFConfigQuota type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &WAFConfigQuota{} + +// WAFConfigQuota WAF Config quota holds the limit and usage for Web Application Firewall configuration resources +type WAFConfigQuota struct { + // The maximum number of Web Application Firewall configurations in this project. + Limit *int32 `json:"limit,omitempty"` + // The number of Web Application Firewall configurations that are currently existing in this project. + Usage *int32 `json:"usage,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _WAFConfigQuota WAFConfigQuota + +// NewWAFConfigQuota instantiates a new WAFConfigQuota 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 NewWAFConfigQuota() *WAFConfigQuota { + this := WAFConfigQuota{} + return &this +} + +// NewWAFConfigQuotaWithDefaults instantiates a new WAFConfigQuota 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 NewWAFConfigQuotaWithDefaults() *WAFConfigQuota { + this := WAFConfigQuota{} + return &this +} + +// GetLimit returns the Limit field value if set, zero value otherwise. +func (o *WAFConfigQuota) GetLimit() int32 { + if o == nil || IsNil(o.Limit) { + var ret int32 + return ret + } + return *o.Limit +} + +// GetLimitOk returns a tuple with the Limit field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *WAFConfigQuota) GetLimitOk() (*int32, bool) { + if o == nil || IsNil(o.Limit) { + return nil, false + } + return o.Limit, true +} + +// HasLimit returns a boolean if a field has been set. +func (o *WAFConfigQuota) HasLimit() bool { + if o != nil && !IsNil(o.Limit) { + return true + } + + return false +} + +// SetLimit gets a reference to the given int32 and assigns it to the Limit field. +func (o *WAFConfigQuota) SetLimit(v int32) { + o.Limit = &v +} + +// GetUsage returns the Usage field value if set, zero value otherwise. +func (o *WAFConfigQuota) GetUsage() int32 { + if o == nil || IsNil(o.Usage) { + var ret int32 + return ret + } + return *o.Usage +} + +// GetUsageOk returns a tuple with the Usage field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *WAFConfigQuota) GetUsageOk() (*int32, bool) { + if o == nil || IsNil(o.Usage) { + return nil, false + } + return o.Usage, true +} + +// HasUsage returns a boolean if a field has been set. +func (o *WAFConfigQuota) HasUsage() bool { + if o != nil && !IsNil(o.Usage) { + return true + } + + return false +} + +// SetUsage gets a reference to the given int32 and assigns it to the Usage field. +func (o *WAFConfigQuota) SetUsage(v int32) { + o.Usage = &v +} + +func (o WAFConfigQuota) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o WAFConfigQuota) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Limit) { + toSerialize["limit"] = o.Limit + } + if !IsNil(o.Usage) { + toSerialize["usage"] = o.Usage + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *WAFConfigQuota) UnmarshalJSON(data []byte) (err error) { + varWAFConfigQuota := _WAFConfigQuota{} + + err = json.Unmarshal(data, &varWAFConfigQuota) + + if err != nil { + return err + } + + *o = WAFConfigQuota(varWAFConfigQuota) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "limit") + delete(additionalProperties, "usage") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableWAFConfigQuota struct { + value *WAFConfigQuota + isSet bool +} + +func (v NullableWAFConfigQuota) Get() *WAFConfigQuota { + return v.value +} + +func (v *NullableWAFConfigQuota) Set(val *WAFConfigQuota) { + v.value = val + v.isSet = true +} + +func (v NullableWAFConfigQuota) IsSet() bool { + return v.isSet +} + +func (v *NullableWAFConfigQuota) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableWAFConfigQuota(val *WAFConfigQuota) *NullableWAFConfigQuota { + return &NullableWAFConfigQuota{value: val, isSet: true} +} + +func (v NullableWAFConfigQuota) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableWAFConfigQuota) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +}