/* 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 albwafalpha import ( "bytes" "context" "fmt" "io" "net/http" "net/url" "strings" "github.com/stackitcloud/stackit-sdk-go/core/config" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" ) type DefaultApi interface { /* CreateCoreRuleSet Create a CRS configuration With this endpoint a core rule set (CRS) configuration is created and stored in this project. Currently it is only possible to enable it. This rule configuration is supposed to be referenced by a WAF configuration. It can be referenced by any number of WAF configurations in the same project. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param projectId @param region @return ApiCreateCoreRuleSetRequest */ CreateCoreRuleSet(ctx context.Context, projectId string, region string) ApiCreateCoreRuleSetRequest /* CreateCoreRuleSetExecute executes the request @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param projectId @param region @return CreateCoreRuleSetResponse */ CreateCoreRuleSetExecute(ctx context.Context, projectId string, region string) (*CreateCoreRuleSetResponse, error) /* CreateRules Create a rule configuration With this endpoint a rule configuration is created and stored in this project. The rules are written in Seclang. This rule configuration is supposed to be referenced by a WAF configuration. It can be referenced by any number of WAF configurations in the same project. There is a limit of 1 MB of data on these rules. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param projectId @param region @return ApiCreateRulesRequest */ CreateRules(ctx context.Context, projectId string, region string) ApiCreateRulesRequest /* CreateRulesExecute executes the request @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param projectId @param region @return CreateRulesResponse */ CreateRulesExecute(ctx context.Context, projectId string, region string) (*CreateRulesResponse, error) /* CreateWAF Create a WAF configuration This endpoint will create and store a WAF configuration in a project. The name of this WAF configuration is supposed to be used in the listener of an Application Load Balancer, which will activate this configuration and in addition it is possible to enable the core rule set. This WAF configuration can be used by any number of Application Load Balancers in the same project. The configuration has a reference to a rule configuration. This rule configuration has to exist when trying to create a WAF configuration. Later other configuration references will be added to this object. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param projectId @param region @return ApiCreateWAFRequest */ CreateWAF(ctx context.Context, projectId string, region string) ApiCreateWAFRequest /* CreateWAFExecute executes the request @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param projectId @param region @return CreateWAFResponse */ CreateWAFExecute(ctx context.Context, projectId string, region string) (*CreateWAFResponse, error) /* DeleteCoreRuleSet Delete a CRS configuration To delete a core rule set (CRS) configuration this endpoint is used, but it is only possible to delete it if no WAF configuration is referencing it. @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 ApiDeleteCoreRuleSetRequest */ DeleteCoreRuleSet(ctx context.Context, projectId string, region string, name string) ApiDeleteCoreRuleSetRequest /* DeleteCoreRuleSetExecute executes the request @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 map[string]interface{} */ DeleteCoreRuleSetExecute(ctx context.Context, projectId string, region string, name string) (map[string]interface{}, error) /* DeleteRules Delete a rule configuration To delete a rule configuration this endpoint is used, but it is only possible to delete it if no WAF configuration is referencing it. @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 ApiDeleteRulesRequest */ DeleteRules(ctx context.Context, projectId string, region string, name string) ApiDeleteRulesRequest /* DeleteRulesExecute executes the request @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 map[string]interface{} */ DeleteRulesExecute(ctx context.Context, projectId string, region string, name string) (map[string]interface{}, error) /* DeleteWAF Delete a WAF configuration This will delete the specified WAF configuration, but only if it is not used by any Application Load Balancer in the project. @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 ApiDeleteWAFRequest */ DeleteWAF(ctx context.Context, projectId string, region string, name string) ApiDeleteWAFRequest /* DeleteWAFExecute executes the request @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 map[string]interface{} */ DeleteWAFExecute(ctx context.Context, projectId string, region string, name string) (map[string]interface{}, error) /* GetCoreRuleSet Retrieve a CRS configuration To retrieve an existing core rule set (CRS) configuration this endpoint can be used. @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 ApiGetCoreRuleSetRequest */ GetCoreRuleSet(ctx context.Context, projectId string, region string, name string) ApiGetCoreRuleSetRequest /* GetCoreRuleSetExecute executes the request @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 GetCoreRuleSetResponse */ GetCoreRuleSetExecute(ctx context.Context, projectId string, region string, name string) (*GetCoreRuleSetResponse, error) /* GetRules Retrieve a rule configuration To retrieve an existing rule configuration this endpoint can be used. @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 ApiGetRulesRequest */ GetRules(ctx context.Context, projectId string, region string, name string) ApiGetRulesRequest /* GetRulesExecute executes the request @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 GetRulesResponse */ GetRulesExecute(ctx context.Context, projectId string, region string, name string) (*GetRulesResponse, error) /* GetWAF Retrieve a WAF configuration This endpoint will return the specified WAF configuration. @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 ApiGetWAFRequest */ GetWAF(ctx context.Context, projectId string, region string, name string) ApiGetWAFRequest /* GetWAFExecute executes the request @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 GetWAFResponse */ GetWAFExecute(ctx context.Context, projectId string, region string, name string) (*GetWAFResponse, error) /* ListCoreRuleSets List of CRS configurations List all existing core rule set (CRS) configurations that are stored in the project. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param projectId @param region @return ApiListCoreRuleSetsRequest */ ListCoreRuleSets(ctx context.Context, projectId string, region string) ApiListCoreRuleSetsRequest /* ListCoreRuleSetsExecute executes the request @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param projectId @param region @return ListCoreRuleSetResponse */ ListCoreRuleSetsExecute(ctx context.Context, projectId string, region string) (*ListCoreRuleSetResponse, error) /* ListRules List of rule configurations List all existing rule configurations that are stored in the project. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param projectId @param region @return ApiListRulesRequest */ ListRules(ctx context.Context, projectId string, region string) ApiListRulesRequest /* ListRulesExecute executes the request @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param projectId @param region @return ListRulesResponse */ ListRulesExecute(ctx context.Context, projectId string, region string) (*ListRulesResponse, error) /* ListWAF List of WAF configurations To list all WAF configurations stored in a project, use this endpoint. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param projectId @param region @return ApiListWAFRequest */ ListWAF(ctx context.Context, projectId string, region string) ApiListWAFRequest /* ListWAFExecute executes the request @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param projectId @param region @return ListWAFResponse */ ListWAFExecute(ctx context.Context, projectId string, region string) (*ListWAFResponse, 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. @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 ApiUpdateCoreRuleSetRequest */ UpdateCoreRuleSet(ctx context.Context, projectId string, region string, name string) ApiUpdateCoreRuleSetRequest /* UpdateCoreRuleSetExecute executes the request @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 UpdateCoreRuleSetResponse */ UpdateCoreRuleSetExecute(ctx context.Context, projectId string, region string, name string) (*UpdateCoreRuleSetResponse, error) /* UpdateRules Update a rule configuration This endpoint will update an existing rules configuration and also inturn update all WAF configurations that reference it. There is a limit of 1 MB of data on these rules. @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 ApiUpdateRulesRequest */ UpdateRules(ctx context.Context, projectId string, region string, name string) ApiUpdateRulesRequest /* UpdateRulesExecute executes the request @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 UpdateRulesResponse */ UpdateRulesExecute(ctx context.Context, projectId string, region string, name string) (*UpdateRulesResponse, error) /* UpdateWAF Update a WAF configuration The update endpoint will update a stored WAF configuration in project and not yet but later will also update the Load Balancers that reference it. @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 ApiUpdateWAFRequest */ UpdateWAF(ctx context.Context, projectId string, region string, name string) ApiUpdateWAFRequest /* UpdateWAFExecute executes the request @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 UpdateWAFResponse */ UpdateWAFExecute(ctx context.Context, projectId string, region string, name string) (*UpdateWAFResponse, error) } type ApiCreateCoreRuleSetRequest interface { CreateCoreRuleSetPayload(createCoreRuleSetPayload CreateCoreRuleSetPayload) ApiCreateCoreRuleSetRequest Execute() (*CreateCoreRuleSetResponse, error) } type ApiCreateRulesRequest interface { CreateRulesPayload(createRulesPayload CreateRulesPayload) ApiCreateRulesRequest Execute() (*CreateRulesResponse, error) } type ApiCreateWAFRequest interface { CreateWAFPayload(createWAFPayload CreateWAFPayload) ApiCreateWAFRequest Execute() (*CreateWAFResponse, error) } type ApiDeleteCoreRuleSetRequest interface { Execute() (map[string]interface{}, error) } type ApiDeleteRulesRequest interface { Execute() (map[string]interface{}, error) } type ApiDeleteWAFRequest interface { Execute() (map[string]interface{}, error) } type ApiGetCoreRuleSetRequest interface { Execute() (*GetCoreRuleSetResponse, error) } type ApiGetRulesRequest interface { Execute() (*GetRulesResponse, error) } type ApiGetWAFRequest interface { Execute() (*GetWAFResponse, error) } type ApiListCoreRuleSetsRequest interface { // page_size specifies how many rule configurations should be returned on this page. Must be a positive number <= 1000 PageSize(pageSize string) ApiListCoreRuleSetsRequest // page_id is a page identifier returned by the previous response and is used to request the next page PageId(pageId string) ApiListCoreRuleSetsRequest Execute() (*ListCoreRuleSetResponse, error) } type ApiListRulesRequest interface { // page_size specifies how many rule configurations should be returned on this page. Must be a positive number <= 1000 PageSize(pageSize string) ApiListRulesRequest // page_id is a page identifier returned by the previous response and is used to request the next page PageId(pageId string) ApiListRulesRequest Execute() (*ListRulesResponse, error) } type ApiListWAFRequest interface { // page_size specifies how many WAFs should be returned on this page. Must be a positive number <= 1000 PageSize(pageSize string) ApiListWAFRequest // page_id is a page identifier returned by the previous response and is used to request the next page PageId(pageId string) ApiListWAFRequest Execute() (*ListWAFResponse, error) } type ApiUpdateCoreRuleSetRequest interface { UpdateCoreRuleSetPayload(updateCoreRuleSetPayload UpdateCoreRuleSetPayload) ApiUpdateCoreRuleSetRequest Execute() (*UpdateCoreRuleSetResponse, error) } type ApiUpdateRulesRequest interface { UpdateRulesPayload(updateRulesPayload UpdateRulesPayload) ApiUpdateRulesRequest Execute() (*UpdateRulesResponse, error) } type ApiUpdateWAFRequest interface { UpdateWAFPayload(updateWAFPayload UpdateWAFPayload) ApiUpdateWAFRequest Execute() (*UpdateWAFResponse, error) } // DefaultApiService DefaultApi service type DefaultApiService service type CreateCoreRuleSetRequest struct { ctx context.Context apiService *DefaultApiService projectId string region string createCoreRuleSetPayload *CreateCoreRuleSetPayload } func (r CreateCoreRuleSetRequest) CreateCoreRuleSetPayload(createCoreRuleSetPayload CreateCoreRuleSetPayload) ApiCreateCoreRuleSetRequest { r.createCoreRuleSetPayload = &createCoreRuleSetPayload return r } func (r CreateCoreRuleSetRequest) Execute() (*CreateCoreRuleSetResponse, error) { var ( localVarHTTPMethod = http.MethodPost localVarPostBody interface{} formFiles []formFile localVarReturnValue *CreateCoreRuleSetResponse ) a := r.apiService client, ok := a.client.(*APIClient) if !ok { return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient") } localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.CreateCoreRuleSet") if err != nil { return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} } localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{region}/core-rule-sets" 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{} if r.createCoreRuleSetPayload == nil { return localVarReturnValue, fmt.Errorf("createCoreRuleSetPayload 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.createCoreRuleSetPayload req, err := 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 := 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{ StatusCode: localVarHTTPResponse.StatusCode, Body: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } if localVarHTTPResponse.StatusCode == 401 { var v Status err = 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 = 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 = 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 } /* CreateCoreRuleSet: Create a CRS configuration With this endpoint a core rule set (CRS) configuration is created and stored in this project. Currently it is only possible to enable it. This rule configuration is supposed to be referenced by a WAF configuration. It can be referenced by any number of WAF configurations in the same project. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param projectId @param region @return ApiCreateCoreRuleSetRequest */ func (a *APIClient) CreateCoreRuleSet(ctx context.Context, projectId string, region string) ApiCreateCoreRuleSetRequest { return CreateCoreRuleSetRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, } } func (a *APIClient) CreateCoreRuleSetExecute(ctx context.Context, projectId string, region string) (*CreateCoreRuleSetResponse, error) { r := CreateCoreRuleSetRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, } return r.Execute() } type CreateRulesRequest struct { ctx context.Context apiService *DefaultApiService projectId string region string createRulesPayload *CreateRulesPayload } func (r CreateRulesRequest) CreateRulesPayload(createRulesPayload CreateRulesPayload) ApiCreateRulesRequest { r.createRulesPayload = &createRulesPayload return r } func (r CreateRulesRequest) Execute() (*CreateRulesResponse, error) { var ( localVarHTTPMethod = http.MethodPost localVarPostBody interface{} formFiles []formFile localVarReturnValue *CreateRulesResponse ) a := r.apiService client, ok := a.client.(*APIClient) if !ok { return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient") } localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.CreateRules") if err != nil { return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} } localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{region}/rules" 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{} if r.createRulesPayload == nil { return localVarReturnValue, fmt.Errorf("createRulesPayload 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.createRulesPayload req, err := 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 := 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{ StatusCode: localVarHTTPResponse.StatusCode, Body: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } if localVarHTTPResponse.StatusCode == 401 { var v Status err = 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 = 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 = 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 } /* CreateRules: Create a rule configuration With this endpoint a rule configuration is created and stored in this project. The rules are written in Seclang. This rule configuration is supposed to be referenced by a WAF configuration. It can be referenced by any number of WAF configurations in the same project. There is a limit of 1 MB of data on these rules. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param projectId @param region @return ApiCreateRulesRequest */ func (a *APIClient) CreateRules(ctx context.Context, projectId string, region string) ApiCreateRulesRequest { return CreateRulesRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, } } func (a *APIClient) CreateRulesExecute(ctx context.Context, projectId string, region string) (*CreateRulesResponse, error) { r := CreateRulesRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, } return r.Execute() } type CreateWAFRequest struct { ctx context.Context apiService *DefaultApiService projectId string region string createWAFPayload *CreateWAFPayload } func (r CreateWAFRequest) CreateWAFPayload(createWAFPayload CreateWAFPayload) ApiCreateWAFRequest { r.createWAFPayload = &createWAFPayload return r } func (r CreateWAFRequest) Execute() (*CreateWAFResponse, error) { var ( localVarHTTPMethod = http.MethodPost localVarPostBody interface{} formFiles []formFile localVarReturnValue *CreateWAFResponse ) a := r.apiService client, ok := a.client.(*APIClient) if !ok { return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient") } localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.CreateWAF") if err != nil { return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} } localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{region}/wafs" 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{} if r.createWAFPayload == nil { return localVarReturnValue, fmt.Errorf("createWAFPayload 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.createWAFPayload req, err := 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 := 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{ StatusCode: localVarHTTPResponse.StatusCode, Body: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } if localVarHTTPResponse.StatusCode == 401 { var v Status err = 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 = 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 = 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 } /* CreateWAF: Create a WAF configuration This endpoint will create and store a WAF configuration in a project. The name of this WAF configuration is supposed to be used in the listener of an Application Load Balancer, which will activate this configuration and in addition it is possible to enable the core rule set. This WAF configuration can be used by any number of Application Load Balancers in the same project. The configuration has a reference to a rule configuration. This rule configuration has to exist when trying to create a WAF configuration. Later other configuration references will be added to this object. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param projectId @param region @return ApiCreateWAFRequest */ func (a *APIClient) CreateWAF(ctx context.Context, projectId string, region string) ApiCreateWAFRequest { return CreateWAFRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, } } func (a *APIClient) CreateWAFExecute(ctx context.Context, projectId string, region string) (*CreateWAFResponse, error) { r := CreateWAFRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, } return r.Execute() } type DeleteCoreRuleSetRequest struct { ctx context.Context apiService *DefaultApiService projectId string region string name string } func (r DeleteCoreRuleSetRequest) Execute() (map[string]interface{}, error) { var ( localVarHTTPMethod = http.MethodDelete localVarPostBody interface{} formFiles []formFile localVarReturnValue map[string]interface{} ) a := r.apiService client, ok := a.client.(*APIClient) if !ok { return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient") } localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.DeleteCoreRuleSet") 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{} // 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", "*/*"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) if localVarHTTPHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept } req, err := 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 := 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{ StatusCode: localVarHTTPResponse.StatusCode, Body: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } if localVarHTTPResponse.StatusCode == 401 { var v Status err = 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 = 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 = 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 } /* DeleteCoreRuleSet: Delete a CRS configuration To delete a core rule set (CRS) configuration this endpoint is used, but it is only possible to delete it if no WAF configuration is referencing it. @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 ApiDeleteCoreRuleSetRequest */ func (a *APIClient) DeleteCoreRuleSet(ctx context.Context, projectId string, region string, name string) ApiDeleteCoreRuleSetRequest { return DeleteCoreRuleSetRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, name: name, } } func (a *APIClient) DeleteCoreRuleSetExecute(ctx context.Context, projectId string, region string, name string) (map[string]interface{}, error) { r := DeleteCoreRuleSetRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, name: name, } return r.Execute() } type DeleteRulesRequest struct { ctx context.Context apiService *DefaultApiService projectId string region string name string } func (r DeleteRulesRequest) Execute() (map[string]interface{}, error) { var ( localVarHTTPMethod = http.MethodDelete localVarPostBody interface{} formFiles []formFile localVarReturnValue map[string]interface{} ) a := r.apiService client, ok := a.client.(*APIClient) if !ok { return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient") } localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.DeleteRules") if err != nil { return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} } localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{region}/rules/{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{} // 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", "*/*"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) if localVarHTTPHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept } req, err := 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 := 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{ StatusCode: localVarHTTPResponse.StatusCode, Body: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } if localVarHTTPResponse.StatusCode == 401 { var v Status err = 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 = 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 = 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 } /* DeleteRules: Delete a rule configuration To delete a rule configuration this endpoint is used, but it is only possible to delete it if no WAF configuration is referencing it. @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 ApiDeleteRulesRequest */ func (a *APIClient) DeleteRules(ctx context.Context, projectId string, region string, name string) ApiDeleteRulesRequest { return DeleteRulesRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, name: name, } } func (a *APIClient) DeleteRulesExecute(ctx context.Context, projectId string, region string, name string) (map[string]interface{}, error) { r := DeleteRulesRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, name: name, } return r.Execute() } type DeleteWAFRequest struct { ctx context.Context apiService *DefaultApiService projectId string region string name string } func (r DeleteWAFRequest) Execute() (map[string]interface{}, error) { var ( localVarHTTPMethod = http.MethodDelete localVarPostBody interface{} formFiles []formFile localVarReturnValue map[string]interface{} ) a := r.apiService client, ok := a.client.(*APIClient) if !ok { return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient") } localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.DeleteWAF") if err != nil { return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} } localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{region}/wafs/{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{} // 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", "*/*"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) if localVarHTTPHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept } req, err := 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 := 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{ StatusCode: localVarHTTPResponse.StatusCode, Body: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } if localVarHTTPResponse.StatusCode == 401 { var v Status err = 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 = 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 = 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 } /* DeleteWAF: Delete a WAF configuration This will delete the specified WAF configuration, but only if it is not used by any Application Load Balancer in the project. @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 ApiDeleteWAFRequest */ func (a *APIClient) DeleteWAF(ctx context.Context, projectId string, region string, name string) ApiDeleteWAFRequest { return DeleteWAFRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, name: name, } } func (a *APIClient) DeleteWAFExecute(ctx context.Context, projectId string, region string, name string) (map[string]interface{}, error) { r := DeleteWAFRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, name: name, } return r.Execute() } type GetCoreRuleSetRequest struct { ctx context.Context apiService *DefaultApiService projectId string region string name string } func (r GetCoreRuleSetRequest) Execute() (*GetCoreRuleSetResponse, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile localVarReturnValue *GetCoreRuleSetResponse ) a := r.apiService client, ok := a.client.(*APIClient) if !ok { return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient") } localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetCoreRuleSet") 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{} // 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", "*/*"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) if localVarHTTPHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept } req, err := 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 := 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{ StatusCode: localVarHTTPResponse.StatusCode, Body: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } if localVarHTTPResponse.StatusCode == 401 { var v Status err = 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 = 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 = 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 } /* GetCoreRuleSet: Retrieve a CRS configuration To retrieve an existing core rule set (CRS) configuration this endpoint can be used. @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 ApiGetCoreRuleSetRequest */ func (a *APIClient) GetCoreRuleSet(ctx context.Context, projectId string, region string, name string) ApiGetCoreRuleSetRequest { return GetCoreRuleSetRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, name: name, } } func (a *APIClient) GetCoreRuleSetExecute(ctx context.Context, projectId string, region string, name string) (*GetCoreRuleSetResponse, error) { r := GetCoreRuleSetRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, name: name, } return r.Execute() } type GetRulesRequest struct { ctx context.Context apiService *DefaultApiService projectId string region string name string } func (r GetRulesRequest) Execute() (*GetRulesResponse, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile localVarReturnValue *GetRulesResponse ) a := r.apiService client, ok := a.client.(*APIClient) if !ok { return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient") } localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetRules") if err != nil { return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} } localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{region}/rules/{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{} // 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", "*/*"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) if localVarHTTPHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept } req, err := 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 := 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{ StatusCode: localVarHTTPResponse.StatusCode, Body: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } if localVarHTTPResponse.StatusCode == 401 { var v Status err = 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 = 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 = 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 } /* GetRules: Retrieve a rule configuration To retrieve an existing rule configuration this endpoint can be used. @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 ApiGetRulesRequest */ func (a *APIClient) GetRules(ctx context.Context, projectId string, region string, name string) ApiGetRulesRequest { return GetRulesRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, name: name, } } func (a *APIClient) GetRulesExecute(ctx context.Context, projectId string, region string, name string) (*GetRulesResponse, error) { r := GetRulesRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, name: name, } return r.Execute() } type GetWAFRequest struct { ctx context.Context apiService *DefaultApiService projectId string region string name string } func (r GetWAFRequest) Execute() (*GetWAFResponse, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile localVarReturnValue *GetWAFResponse ) a := r.apiService client, ok := a.client.(*APIClient) if !ok { return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient") } localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetWAF") if err != nil { return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} } localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{region}/wafs/{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{} // 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", "*/*"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) if localVarHTTPHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept } req, err := 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 := 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{ StatusCode: localVarHTTPResponse.StatusCode, Body: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } if localVarHTTPResponse.StatusCode == 401 { var v Status err = 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 = 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 = 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 } /* GetWAF: Retrieve a WAF configuration This endpoint will return the specified WAF configuration. @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 ApiGetWAFRequest */ func (a *APIClient) GetWAF(ctx context.Context, projectId string, region string, name string) ApiGetWAFRequest { return GetWAFRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, name: name, } } func (a *APIClient) GetWAFExecute(ctx context.Context, projectId string, region string, name string) (*GetWAFResponse, error) { r := GetWAFRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, name: name, } return r.Execute() } type ListCoreRuleSetsRequest struct { ctx context.Context apiService *DefaultApiService projectId string region string pageSize *string pageId *string } // page_size specifies how many rule configurations should be returned on this page. Must be a positive number <= 1000 func (r ListCoreRuleSetsRequest) PageSize(pageSize string) ApiListCoreRuleSetsRequest { r.pageSize = &pageSize return r } // page_id is a page identifier returned by the previous response and is used to request the next page func (r ListCoreRuleSetsRequest) PageId(pageId string) ApiListCoreRuleSetsRequest { r.pageId = &pageId return r } func (r ListCoreRuleSetsRequest) Execute() (*ListCoreRuleSetResponse, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile localVarReturnValue *ListCoreRuleSetResponse ) a := r.apiService client, ok := a.client.(*APIClient) if !ok { return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient") } localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListCoreRuleSets") if err != nil { return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} } localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{region}/core-rule-sets" 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{} if r.pageSize != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "pageSize", r.pageSize, "") } if r.pageId != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "pageId", r.pageId, "") } // 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", "*/*"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) if localVarHTTPHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept } req, err := 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 := 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{ StatusCode: localVarHTTPResponse.StatusCode, Body: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } if localVarHTTPResponse.StatusCode == 401 { var v Status err = 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 = 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 = 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 } /* ListCoreRuleSets: List of CRS configurations List all existing core rule set (CRS) configurations that are stored in the project. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param projectId @param region @return ApiListCoreRuleSetsRequest */ func (a *APIClient) ListCoreRuleSets(ctx context.Context, projectId string, region string) ApiListCoreRuleSetsRequest { return ListCoreRuleSetsRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, } } func (a *APIClient) ListCoreRuleSetsExecute(ctx context.Context, projectId string, region string) (*ListCoreRuleSetResponse, error) { r := ListCoreRuleSetsRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, } return r.Execute() } type ListRulesRequest struct { ctx context.Context apiService *DefaultApiService projectId string region string pageSize *string pageId *string } // page_size specifies how many rule configurations should be returned on this page. Must be a positive number <= 1000 func (r ListRulesRequest) PageSize(pageSize string) ApiListRulesRequest { r.pageSize = &pageSize return r } // page_id is a page identifier returned by the previous response and is used to request the next page func (r ListRulesRequest) PageId(pageId string) ApiListRulesRequest { r.pageId = &pageId return r } func (r ListRulesRequest) Execute() (*ListRulesResponse, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile localVarReturnValue *ListRulesResponse ) a := r.apiService client, ok := a.client.(*APIClient) if !ok { return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient") } localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListRules") if err != nil { return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} } localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{region}/rules" 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{} if r.pageSize != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "pageSize", r.pageSize, "") } if r.pageId != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "pageId", r.pageId, "") } // 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", "*/*"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) if localVarHTTPHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept } req, err := 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 := 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{ StatusCode: localVarHTTPResponse.StatusCode, Body: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } if localVarHTTPResponse.StatusCode == 401 { var v Status err = 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 = 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 = 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 } /* ListRules: List of rule configurations List all existing rule configurations that are stored in the project. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param projectId @param region @return ApiListRulesRequest */ func (a *APIClient) ListRules(ctx context.Context, projectId string, region string) ApiListRulesRequest { return ListRulesRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, } } func (a *APIClient) ListRulesExecute(ctx context.Context, projectId string, region string) (*ListRulesResponse, error) { r := ListRulesRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, } return r.Execute() } type ListWAFRequest struct { ctx context.Context apiService *DefaultApiService projectId string region string pageSize *string pageId *string } // page_size specifies how many WAFs should be returned on this page. Must be a positive number <= 1000 func (r ListWAFRequest) PageSize(pageSize string) ApiListWAFRequest { r.pageSize = &pageSize return r } // page_id is a page identifier returned by the previous response and is used to request the next page func (r ListWAFRequest) PageId(pageId string) ApiListWAFRequest { r.pageId = &pageId return r } func (r ListWAFRequest) Execute() (*ListWAFResponse, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile localVarReturnValue *ListWAFResponse ) a := r.apiService client, ok := a.client.(*APIClient) if !ok { return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient") } localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListWAF") if err != nil { return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} } localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{region}/wafs" 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{} if r.pageSize != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "pageSize", r.pageSize, "") } if r.pageId != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "pageId", r.pageId, "") } // 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", "*/*"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) if localVarHTTPHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept } req, err := 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 := 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{ StatusCode: localVarHTTPResponse.StatusCode, Body: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } if localVarHTTPResponse.StatusCode == 401 { var v Status err = 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 = 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 = 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 } /* ListWAF: List of WAF configurations To list all WAF configurations stored in a project, use this endpoint. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param projectId @param region @return ApiListWAFRequest */ func (a *APIClient) ListWAF(ctx context.Context, projectId string, region string) ApiListWAFRequest { return ListWAFRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, } } func (a *APIClient) ListWAFExecute(ctx context.Context, projectId string, region string) (*ListWAFResponse, error) { r := ListWAFRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, } return r.Execute() } type UpdateCoreRuleSetRequest struct { ctx context.Context apiService *DefaultApiService projectId string region string name string updateCoreRuleSetPayload *UpdateCoreRuleSetPayload } func (r UpdateCoreRuleSetRequest) UpdateCoreRuleSetPayload(updateCoreRuleSetPayload UpdateCoreRuleSetPayload) ApiUpdateCoreRuleSetRequest { r.updateCoreRuleSetPayload = &updateCoreRuleSetPayload return r } func (r UpdateCoreRuleSetRequest) Execute() (*UpdateCoreRuleSetResponse, error) { var ( localVarHTTPMethod = http.MethodPut localVarPostBody interface{} formFiles []formFile localVarReturnValue *UpdateCoreRuleSetResponse ) a := r.apiService client, ok := a.client.(*APIClient) if !ok { return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient") } localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.UpdateCoreRuleSet") 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.updateCoreRuleSetPayload == nil { return localVarReturnValue, fmt.Errorf("updateCoreRuleSetPayload 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.updateCoreRuleSetPayload req, err := 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 := 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{ StatusCode: localVarHTTPResponse.StatusCode, Body: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } if localVarHTTPResponse.StatusCode == 401 { var v Status err = 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 = 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 = 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 } /* 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. @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 ApiUpdateCoreRuleSetRequest */ func (a *APIClient) UpdateCoreRuleSet(ctx context.Context, projectId string, region string, name string) ApiUpdateCoreRuleSetRequest { return UpdateCoreRuleSetRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, name: name, } } func (a *APIClient) UpdateCoreRuleSetExecute(ctx context.Context, projectId string, region string, name string) (*UpdateCoreRuleSetResponse, error) { r := UpdateCoreRuleSetRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, name: name, } return r.Execute() } type UpdateRulesRequest struct { ctx context.Context apiService *DefaultApiService projectId string region string name string updateRulesPayload *UpdateRulesPayload } func (r UpdateRulesRequest) UpdateRulesPayload(updateRulesPayload UpdateRulesPayload) ApiUpdateRulesRequest { r.updateRulesPayload = &updateRulesPayload return r } func (r UpdateRulesRequest) Execute() (*UpdateRulesResponse, error) { var ( localVarHTTPMethod = http.MethodPut localVarPostBody interface{} formFiles []formFile localVarReturnValue *UpdateRulesResponse ) a := r.apiService client, ok := a.client.(*APIClient) if !ok { return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient") } localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.UpdateRules") if err != nil { return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} } localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{region}/rules/{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.updateRulesPayload == nil { return localVarReturnValue, fmt.Errorf("updateRulesPayload 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.updateRulesPayload req, err := 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 := 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{ StatusCode: localVarHTTPResponse.StatusCode, Body: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } if localVarHTTPResponse.StatusCode == 401 { var v Status err = 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 = 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 = 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 } /* UpdateRules: Update a rule configuration This endpoint will update an existing rules configuration and also inturn update all WAF configurations that reference it. There is a limit of 1 MB of data on these rules. @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 ApiUpdateRulesRequest */ func (a *APIClient) UpdateRules(ctx context.Context, projectId string, region string, name string) ApiUpdateRulesRequest { return UpdateRulesRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, name: name, } } func (a *APIClient) UpdateRulesExecute(ctx context.Context, projectId string, region string, name string) (*UpdateRulesResponse, error) { r := UpdateRulesRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, name: name, } return r.Execute() } type UpdateWAFRequest struct { ctx context.Context apiService *DefaultApiService projectId string region string name string updateWAFPayload *UpdateWAFPayload } func (r UpdateWAFRequest) UpdateWAFPayload(updateWAFPayload UpdateWAFPayload) ApiUpdateWAFRequest { r.updateWAFPayload = &updateWAFPayload return r } func (r UpdateWAFRequest) Execute() (*UpdateWAFResponse, error) { var ( localVarHTTPMethod = http.MethodPut localVarPostBody interface{} formFiles []formFile localVarReturnValue *UpdateWAFResponse ) a := r.apiService client, ok := a.client.(*APIClient) if !ok { return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient") } localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.UpdateWAF") if err != nil { return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} } localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{region}/wafs/{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.updateWAFPayload == nil { return localVarReturnValue, fmt.Errorf("updateWAFPayload 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.updateWAFPayload req, err := 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 := 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{ StatusCode: localVarHTTPResponse.StatusCode, Body: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } if localVarHTTPResponse.StatusCode == 401 { var v Status err = 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 = 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 = 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 } /* UpdateWAF: Update a WAF configuration The update endpoint will update a stored WAF configuration in project and not yet but later will also update the Load Balancers that reference it. @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 ApiUpdateWAFRequest */ func (a *APIClient) UpdateWAF(ctx context.Context, projectId string, region string, name string) ApiUpdateWAFRequest { return UpdateWAFRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, name: name, } } func (a *APIClient) UpdateWAFExecute(ctx context.Context, projectId string, region string, name string) (*UpdateWAFResponse, error) { r := UpdateWAFRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, region: region, name: name, } return r.Execute() }