From d45f4ebc1831788af9f8c3b0b80b0beb5cb5219d Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Thu, 5 Mar 2026 10:52:15 +0000 Subject: [PATCH] Generate albwaf --- go.work | 1 + services/albwaf/LICENSE.md | 201 ++ services/albwaf/go.mod | 10 + services/albwaf/go.sum | 8 + services/albwaf/oas_commit | 1 + services/albwaf/package.go | 1 + services/albwaf/v1alphaapi/api_default.go | 2539 +++++++++++++++++ .../albwaf/v1alphaapi/api_default_mock.go | 347 +++ services/albwaf/v1alphaapi/client.go | 658 +++++ services/albwaf/v1alphaapi/configuration.go | 37 + .../model_create_core_rule_set_payload.go | 236 ++ .../model_create_core_rule_set_response.go | 199 ++ .../v1alphaapi/model_create_rules_payload.go | 236 ++ .../v1alphaapi/model_create_rules_response.go | 199 ++ .../v1alphaapi/model_create_waf_payload.go | 273 ++ .../v1alphaapi/model_create_waf_response.go | 236 ++ .../model_get_core_rule_set_response.go | 199 ++ .../v1alphaapi/model_get_rules_response.go | 199 ++ .../v1alphaapi/model_get_waf_response.go | 236 ++ .../v1alphaapi/model_google_protobuf_any.go | 154 + .../model_list_core_rule_set_response.go | 161 ++ .../v1alphaapi/model_list_rules_response.go | 161 ++ .../v1alphaapi/model_list_waf_response.go | 161 ++ services/albwaf/v1alphaapi/model_status.go | 199 ++ .../model_update_core_rule_set_payload.go | 236 ++ .../model_update_core_rule_set_response.go | 199 ++ .../v1alphaapi/model_update_rules_payload.go | 236 ++ .../v1alphaapi/model_update_rules_response.go | 199 ++ .../v1alphaapi/model_update_waf_payload.go | 273 ++ .../v1alphaapi/model_update_waf_response.go | 236 ++ services/albwaf/v1alphaapi/response.go | 47 + services/albwaf/v1alphaapi/utils.go | 361 +++ 32 files changed, 8439 insertions(+) create mode 100644 services/albwaf/LICENSE.md create mode 100644 services/albwaf/go.mod create mode 100644 services/albwaf/go.sum create mode 100644 services/albwaf/oas_commit create mode 100644 services/albwaf/package.go create mode 100644 services/albwaf/v1alphaapi/api_default.go create mode 100644 services/albwaf/v1alphaapi/api_default_mock.go create mode 100644 services/albwaf/v1alphaapi/client.go create mode 100644 services/albwaf/v1alphaapi/configuration.go create mode 100644 services/albwaf/v1alphaapi/model_create_core_rule_set_payload.go create mode 100644 services/albwaf/v1alphaapi/model_create_core_rule_set_response.go create mode 100644 services/albwaf/v1alphaapi/model_create_rules_payload.go create mode 100644 services/albwaf/v1alphaapi/model_create_rules_response.go create mode 100644 services/albwaf/v1alphaapi/model_create_waf_payload.go create mode 100644 services/albwaf/v1alphaapi/model_create_waf_response.go create mode 100644 services/albwaf/v1alphaapi/model_get_core_rule_set_response.go create mode 100644 services/albwaf/v1alphaapi/model_get_rules_response.go create mode 100644 services/albwaf/v1alphaapi/model_get_waf_response.go create mode 100644 services/albwaf/v1alphaapi/model_google_protobuf_any.go create mode 100644 services/albwaf/v1alphaapi/model_list_core_rule_set_response.go create mode 100644 services/albwaf/v1alphaapi/model_list_rules_response.go create mode 100644 services/albwaf/v1alphaapi/model_list_waf_response.go create mode 100644 services/albwaf/v1alphaapi/model_status.go create mode 100644 services/albwaf/v1alphaapi/model_update_core_rule_set_payload.go create mode 100644 services/albwaf/v1alphaapi/model_update_core_rule_set_response.go create mode 100644 services/albwaf/v1alphaapi/model_update_rules_payload.go create mode 100644 services/albwaf/v1alphaapi/model_update_rules_response.go create mode 100644 services/albwaf/v1alphaapi/model_update_waf_payload.go create mode 100644 services/albwaf/v1alphaapi/model_update_waf_response.go create mode 100644 services/albwaf/v1alphaapi/response.go create mode 100644 services/albwaf/v1alphaapi/utils.go diff --git a/go.work b/go.work index edfc1f700..03c9cb9dc 100644 --- a/go.work +++ b/go.work @@ -35,6 +35,7 @@ use ( ./examples/sqlserverflex ./examples/waiter ./services/alb + ./services/albwaf ./services/archiving ./services/auditlog ./services/authorization diff --git a/services/albwaf/LICENSE.md b/services/albwaf/LICENSE.md new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/services/albwaf/LICENSE.md @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/services/albwaf/go.mod b/services/albwaf/go.mod new file mode 100644 index 000000000..5f739df74 --- /dev/null +++ b/services/albwaf/go.mod @@ -0,0 +1,10 @@ +module github.com/stackitcloud/stackit-sdk-go/services/albwaf + +go 1.21 + +require github.com/stackitcloud/stackit-sdk-go/core v0.22.0 + +require ( + github.com/golang-jwt/jwt/v5 v5.3.1 // indirect + github.com/google/uuid v1.6.0 // indirect +) diff --git a/services/albwaf/go.sum b/services/albwaf/go.sum new file mode 100644 index 000000000..195011dd5 --- /dev/null +++ b/services/albwaf/go.sum @@ -0,0 +1,8 @@ +github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY= +github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/stackitcloud/stackit-sdk-go/core v0.22.0 h1:6rViz7GnNwXSh51Lur5xuDzO8EWSZfN9J0HvEkBKq6c= +github.com/stackitcloud/stackit-sdk-go/core v0.22.0/go.mod h1:osMglDby4csGZ5sIfhNyYq1bS1TxIdPY88+skE/kkmI= diff --git a/services/albwaf/oas_commit b/services/albwaf/oas_commit new file mode 100644 index 000000000..bf3189995 --- /dev/null +++ b/services/albwaf/oas_commit @@ -0,0 +1 @@ +3e9c109388be83b40c16d8cb5ab146aa314eb6e8 diff --git a/services/albwaf/package.go b/services/albwaf/package.go new file mode 100644 index 000000000..a2bf77bc6 --- /dev/null +++ b/services/albwaf/package.go @@ -0,0 +1 @@ +package albwaf diff --git a/services/albwaf/v1alphaapi/api_default.go b/services/albwaf/v1alphaapi/api_default.go new file mode 100644 index 000000000..0d625b00b --- /dev/null +++ b/services/albwaf/v1alphaapi/api_default.go @@ -0,0 +1,2539 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. +package v1alphaapi + +import ( + "bytes" + "context" + "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 + // @return CreateCoreRuleSetResponse + CreateCoreRuleSetExecute(r ApiCreateCoreRuleSetRequest) (*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 + // @return CreateRulesResponse + CreateRulesExecute(r ApiCreateRulesRequest) (*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 + // @return CreateWAFResponse + CreateWAFExecute(r ApiCreateWAFRequest) (*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 + // @return map[string]interface{} + DeleteCoreRuleSetExecute(r ApiDeleteCoreRuleSetRequest) (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 + // @return map[string]interface{} + DeleteRulesExecute(r ApiDeleteRulesRequest) (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 + // @return map[string]interface{} + DeleteWAFExecute(r ApiDeleteWAFRequest) (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 + // @return GetCoreRuleSetResponse + GetCoreRuleSetExecute(r ApiGetCoreRuleSetRequest) (*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 + // @return GetRulesResponse + GetRulesExecute(r ApiGetRulesRequest) (*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 + // @return GetWAFResponse + GetWAFExecute(r ApiGetWAFRequest) (*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 + // @return ListCoreRuleSetResponse + ListCoreRuleSetsExecute(r ApiListCoreRuleSetsRequest) (*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 + // @return ListRulesResponse + ListRulesExecute(r ApiListRulesRequest) (*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 + // @return ListWAFResponse + ListWAFExecute(r ApiListWAFRequest) (*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 + // @return UpdateCoreRuleSetResponse + UpdateCoreRuleSetExecute(r ApiUpdateCoreRuleSetRequest) (*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 + // @return UpdateRulesResponse + UpdateRulesExecute(r ApiUpdateRulesRequest) (*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 + // @return UpdateWAFResponse + UpdateWAFExecute(r ApiUpdateWAFRequest) (*UpdateWAFResponse, error) +} + +// DefaultAPIService DefaultAPI service +type DefaultAPIService service + +type ApiCreateCoreRuleSetRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + region string + createCoreRuleSetPayload *CreateCoreRuleSetPayload +} + +func (r ApiCreateCoreRuleSetRequest) CreateCoreRuleSetPayload(createCoreRuleSetPayload CreateCoreRuleSetPayload) ApiCreateCoreRuleSetRequest { + r.createCoreRuleSetPayload = &createCoreRuleSetPayload + return r +} + +func (r ApiCreateCoreRuleSetRequest) Execute() (*CreateCoreRuleSetResponse, error) { + return r.ApiService.CreateCoreRuleSetExecute(r) +} + +/* +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 *DefaultAPIService) CreateCoreRuleSet(ctx context.Context, projectId string, region string) ApiCreateCoreRuleSetRequest { + return ApiCreateCoreRuleSetRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + } +} + +// Execute executes the request +// +// @return CreateCoreRuleSetResponse +func (a *DefaultAPIService) CreateCoreRuleSetExecute(r ApiCreateCoreRuleSetRequest) (*CreateCoreRuleSetResponse, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *CreateCoreRuleSetResponse + ) + + localBasePath, err := a.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, reportError("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 := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiCreateRulesRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + region string + createRulesPayload *CreateRulesPayload +} + +func (r ApiCreateRulesRequest) CreateRulesPayload(createRulesPayload CreateRulesPayload) ApiCreateRulesRequest { + r.createRulesPayload = &createRulesPayload + return r +} + +func (r ApiCreateRulesRequest) Execute() (*CreateRulesResponse, error) { + return r.ApiService.CreateRulesExecute(r) +} + +/* +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 *DefaultAPIService) CreateRules(ctx context.Context, projectId string, region string) ApiCreateRulesRequest { + return ApiCreateRulesRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + } +} + +// Execute executes the request +// +// @return CreateRulesResponse +func (a *DefaultAPIService) CreateRulesExecute(r ApiCreateRulesRequest) (*CreateRulesResponse, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *CreateRulesResponse + ) + + localBasePath, err := a.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, reportError("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 := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiCreateWAFRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + region string + createWAFPayload *CreateWAFPayload +} + +func (r ApiCreateWAFRequest) CreateWAFPayload(createWAFPayload CreateWAFPayload) ApiCreateWAFRequest { + r.createWAFPayload = &createWAFPayload + return r +} + +func (r ApiCreateWAFRequest) Execute() (*CreateWAFResponse, error) { + return r.ApiService.CreateWAFExecute(r) +} + +/* +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 *DefaultAPIService) CreateWAF(ctx context.Context, projectId string, region string) ApiCreateWAFRequest { + return ApiCreateWAFRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + } +} + +// Execute executes the request +// +// @return CreateWAFResponse +func (a *DefaultAPIService) CreateWAFExecute(r ApiCreateWAFRequest) (*CreateWAFResponse, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *CreateWAFResponse + ) + + localBasePath, err := a.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, reportError("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 := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiDeleteCoreRuleSetRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + region string + name string +} + +func (r ApiDeleteCoreRuleSetRequest) Execute() (map[string]interface{}, error) { + return r.ApiService.DeleteCoreRuleSetExecute(r) +} + +/* +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 *DefaultAPIService) DeleteCoreRuleSet(ctx context.Context, projectId string, region string, name string) ApiDeleteCoreRuleSetRequest { + return ApiDeleteCoreRuleSetRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// Execute executes the request +// +// @return map[string]interface{} +func (a *DefaultAPIService) DeleteCoreRuleSetExecute(r ApiDeleteCoreRuleSetRequest) (map[string]interface{}, error) { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue map[string]interface{} + ) + + localBasePath, err := a.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 := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiDeleteRulesRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + region string + name string +} + +func (r ApiDeleteRulesRequest) Execute() (map[string]interface{}, error) { + return r.ApiService.DeleteRulesExecute(r) +} + +/* +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 *DefaultAPIService) DeleteRules(ctx context.Context, projectId string, region string, name string) ApiDeleteRulesRequest { + return ApiDeleteRulesRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// Execute executes the request +// +// @return map[string]interface{} +func (a *DefaultAPIService) DeleteRulesExecute(r ApiDeleteRulesRequest) (map[string]interface{}, error) { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue map[string]interface{} + ) + + localBasePath, err := a.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 := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiDeleteWAFRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + region string + name string +} + +func (r ApiDeleteWAFRequest) Execute() (map[string]interface{}, error) { + return r.ApiService.DeleteWAFExecute(r) +} + +/* +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 *DefaultAPIService) DeleteWAF(ctx context.Context, projectId string, region string, name string) ApiDeleteWAFRequest { + return ApiDeleteWAFRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// Execute executes the request +// +// @return map[string]interface{} +func (a *DefaultAPIService) DeleteWAFExecute(r ApiDeleteWAFRequest) (map[string]interface{}, error) { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue map[string]interface{} + ) + + localBasePath, err := a.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 := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiGetCoreRuleSetRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + region string + name string +} + +func (r ApiGetCoreRuleSetRequest) Execute() (*GetCoreRuleSetResponse, error) { + return r.ApiService.GetCoreRuleSetExecute(r) +} + +/* +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 *DefaultAPIService) GetCoreRuleSet(ctx context.Context, projectId string, region string, name string) ApiGetCoreRuleSetRequest { + return ApiGetCoreRuleSetRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// Execute executes the request +// +// @return GetCoreRuleSetResponse +func (a *DefaultAPIService) GetCoreRuleSetExecute(r ApiGetCoreRuleSetRequest) (*GetCoreRuleSetResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *GetCoreRuleSetResponse + ) + + localBasePath, err := a.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 := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiGetRulesRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + region string + name string +} + +func (r ApiGetRulesRequest) Execute() (*GetRulesResponse, error) { + return r.ApiService.GetRulesExecute(r) +} + +/* +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 *DefaultAPIService) GetRules(ctx context.Context, projectId string, region string, name string) ApiGetRulesRequest { + return ApiGetRulesRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// Execute executes the request +// +// @return GetRulesResponse +func (a *DefaultAPIService) GetRulesExecute(r ApiGetRulesRequest) (*GetRulesResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *GetRulesResponse + ) + + localBasePath, err := a.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 := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiGetWAFRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + region string + name string +} + +func (r ApiGetWAFRequest) Execute() (*GetWAFResponse, error) { + return r.ApiService.GetWAFExecute(r) +} + +/* +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 *DefaultAPIService) GetWAF(ctx context.Context, projectId string, region string, name string) ApiGetWAFRequest { + return ApiGetWAFRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// Execute executes the request +// +// @return GetWAFResponse +func (a *DefaultAPIService) GetWAFExecute(r ApiGetWAFRequest) (*GetWAFResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *GetWAFResponse + ) + + localBasePath, err := a.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 := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiListCoreRuleSetsRequest struct { + ctx context.Context + ApiService DefaultAPI + 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 ApiListCoreRuleSetsRequest) 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 ApiListCoreRuleSetsRequest) PageId(pageId string) ApiListCoreRuleSetsRequest { + r.pageId = &pageId + return r +} + +func (r ApiListCoreRuleSetsRequest) Execute() (*ListCoreRuleSetResponse, error) { + return r.ApiService.ListCoreRuleSetsExecute(r) +} + +/* +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 *DefaultAPIService) ListCoreRuleSets(ctx context.Context, projectId string, region string) ApiListCoreRuleSetsRequest { + return ApiListCoreRuleSetsRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + } +} + +// Execute executes the request +// +// @return ListCoreRuleSetResponse +func (a *DefaultAPIService) ListCoreRuleSetsExecute(r ApiListCoreRuleSetsRequest) (*ListCoreRuleSetResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ListCoreRuleSetResponse + ) + + localBasePath, err := a.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, "form", "") + } + if r.pageId != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "pageId", r.pageId, "form", "") + } + // 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 := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiListRulesRequest struct { + ctx context.Context + ApiService DefaultAPI + 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 ApiListRulesRequest) 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 ApiListRulesRequest) PageId(pageId string) ApiListRulesRequest { + r.pageId = &pageId + return r +} + +func (r ApiListRulesRequest) Execute() (*ListRulesResponse, error) { + return r.ApiService.ListRulesExecute(r) +} + +/* +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 *DefaultAPIService) ListRules(ctx context.Context, projectId string, region string) ApiListRulesRequest { + return ApiListRulesRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + } +} + +// Execute executes the request +// +// @return ListRulesResponse +func (a *DefaultAPIService) ListRulesExecute(r ApiListRulesRequest) (*ListRulesResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ListRulesResponse + ) + + localBasePath, err := a.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, "form", "") + } + if r.pageId != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "pageId", r.pageId, "form", "") + } + // 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 := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiListWAFRequest struct { + ctx context.Context + ApiService DefaultAPI + 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 ApiListWAFRequest) 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 ApiListWAFRequest) PageId(pageId string) ApiListWAFRequest { + r.pageId = &pageId + return r +} + +func (r ApiListWAFRequest) Execute() (*ListWAFResponse, error) { + return r.ApiService.ListWAFExecute(r) +} + +/* +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 *DefaultAPIService) ListWAF(ctx context.Context, projectId string, region string) ApiListWAFRequest { + return ApiListWAFRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + } +} + +// Execute executes the request +// +// @return ListWAFResponse +func (a *DefaultAPIService) ListWAFExecute(r ApiListWAFRequest) (*ListWAFResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ListWAFResponse + ) + + localBasePath, err := a.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, "form", "") + } + if r.pageId != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "pageId", r.pageId, "form", "") + } + // 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 := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiUpdateCoreRuleSetRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + region string + name string + updateCoreRuleSetPayload *UpdateCoreRuleSetPayload +} + +func (r ApiUpdateCoreRuleSetRequest) UpdateCoreRuleSetPayload(updateCoreRuleSetPayload UpdateCoreRuleSetPayload) ApiUpdateCoreRuleSetRequest { + r.updateCoreRuleSetPayload = &updateCoreRuleSetPayload + return r +} + +func (r ApiUpdateCoreRuleSetRequest) Execute() (*UpdateCoreRuleSetResponse, error) { + return r.ApiService.UpdateCoreRuleSetExecute(r) +} + +/* +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 *DefaultAPIService) UpdateCoreRuleSet(ctx context.Context, projectId string, region string, name string) ApiUpdateCoreRuleSetRequest { + return ApiUpdateCoreRuleSetRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// Execute executes the request +// +// @return UpdateCoreRuleSetResponse +func (a *DefaultAPIService) UpdateCoreRuleSetExecute(r ApiUpdateCoreRuleSetRequest) (*UpdateCoreRuleSetResponse, error) { + var ( + localVarHTTPMethod = http.MethodPut + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *UpdateCoreRuleSetResponse + ) + + localBasePath, err := a.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, reportError("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 := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiUpdateRulesRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + region string + name string + updateRulesPayload *UpdateRulesPayload +} + +func (r ApiUpdateRulesRequest) UpdateRulesPayload(updateRulesPayload UpdateRulesPayload) ApiUpdateRulesRequest { + r.updateRulesPayload = &updateRulesPayload + return r +} + +func (r ApiUpdateRulesRequest) Execute() (*UpdateRulesResponse, error) { + return r.ApiService.UpdateRulesExecute(r) +} + +/* +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 *DefaultAPIService) UpdateRules(ctx context.Context, projectId string, region string, name string) ApiUpdateRulesRequest { + return ApiUpdateRulesRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// Execute executes the request +// +// @return UpdateRulesResponse +func (a *DefaultAPIService) UpdateRulesExecute(r ApiUpdateRulesRequest) (*UpdateRulesResponse, error) { + var ( + localVarHTTPMethod = http.MethodPut + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *UpdateRulesResponse + ) + + localBasePath, err := a.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, reportError("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 := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiUpdateWAFRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + region string + name string + updateWAFPayload *UpdateWAFPayload +} + +func (r ApiUpdateWAFRequest) UpdateWAFPayload(updateWAFPayload UpdateWAFPayload) ApiUpdateWAFRequest { + r.updateWAFPayload = &updateWAFPayload + return r +} + +func (r ApiUpdateWAFRequest) Execute() (*UpdateWAFResponse, error) { + return r.ApiService.UpdateWAFExecute(r) +} + +/* +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 *DefaultAPIService) UpdateWAF(ctx context.Context, projectId string, region string, name string) ApiUpdateWAFRequest { + return ApiUpdateWAFRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// Execute executes the request +// +// @return UpdateWAFResponse +func (a *DefaultAPIService) UpdateWAFExecute(r ApiUpdateWAFRequest) (*UpdateWAFResponse, error) { + var ( + localVarHTTPMethod = http.MethodPut + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *UpdateWAFResponse + ) + + localBasePath, err := a.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, reportError("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 := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} diff --git a/services/albwaf/v1alphaapi/api_default_mock.go b/services/albwaf/v1alphaapi/api_default_mock.go new file mode 100644 index 000000000..9cf69252e --- /dev/null +++ b/services/albwaf/v1alphaapi/api_default_mock.go @@ -0,0 +1,347 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "context" +) + +// assert the implementation matches the interface +var _ DefaultAPI = &DefaultAPIServiceMock{} + +// DefaultAPIServiceMock is meant to be used for testing only as a replacement for DefaultAPIService. +// By default all FooExecute() implementations are a no-op. Behavior of the mock can be customized by populating the callbacks in this struct. +type DefaultAPIServiceMock struct { + // CreateCoreRuleSetExecuteMock can be populated to implement the behavior of the CreateCoreRuleSetExecute function of this mock + CreateCoreRuleSetExecuteMock *func(r ApiCreateCoreRuleSetRequest) (*CreateCoreRuleSetResponse, error) + // CreateRulesExecuteMock can be populated to implement the behavior of the CreateRulesExecute function of this mock + CreateRulesExecuteMock *func(r ApiCreateRulesRequest) (*CreateRulesResponse, error) + // CreateWAFExecuteMock can be populated to implement the behavior of the CreateWAFExecute function of this mock + CreateWAFExecuteMock *func(r ApiCreateWAFRequest) (*CreateWAFResponse, error) + // DeleteCoreRuleSetExecuteMock can be populated to implement the behavior of the DeleteCoreRuleSetExecute function of this mock + DeleteCoreRuleSetExecuteMock *func(r ApiDeleteCoreRuleSetRequest) (map[string]interface{}, error) + // DeleteRulesExecuteMock can be populated to implement the behavior of the DeleteRulesExecute function of this mock + DeleteRulesExecuteMock *func(r ApiDeleteRulesRequest) (map[string]interface{}, error) + // DeleteWAFExecuteMock can be populated to implement the behavior of the DeleteWAFExecute function of this mock + DeleteWAFExecuteMock *func(r ApiDeleteWAFRequest) (map[string]interface{}, error) + // GetCoreRuleSetExecuteMock can be populated to implement the behavior of the GetCoreRuleSetExecute function of this mock + GetCoreRuleSetExecuteMock *func(r ApiGetCoreRuleSetRequest) (*GetCoreRuleSetResponse, error) + // GetRulesExecuteMock can be populated to implement the behavior of the GetRulesExecute function of this mock + GetRulesExecuteMock *func(r ApiGetRulesRequest) (*GetRulesResponse, error) + // GetWAFExecuteMock can be populated to implement the behavior of the GetWAFExecute function of this mock + GetWAFExecuteMock *func(r ApiGetWAFRequest) (*GetWAFResponse, error) + // ListCoreRuleSetsExecuteMock can be populated to implement the behavior of the ListCoreRuleSetsExecute function of this mock + ListCoreRuleSetsExecuteMock *func(r ApiListCoreRuleSetsRequest) (*ListCoreRuleSetResponse, error) + // ListRulesExecuteMock can be populated to implement the behavior of the ListRulesExecute function of this mock + ListRulesExecuteMock *func(r ApiListRulesRequest) (*ListRulesResponse, error) + // ListWAFExecuteMock can be populated to implement the behavior of the ListWAFExecute function of this mock + ListWAFExecuteMock *func(r ApiListWAFRequest) (*ListWAFResponse, error) + // UpdateCoreRuleSetExecuteMock can be populated to implement the behavior of the UpdateCoreRuleSetExecute function of this mock + UpdateCoreRuleSetExecuteMock *func(r ApiUpdateCoreRuleSetRequest) (*UpdateCoreRuleSetResponse, error) + // UpdateRulesExecuteMock can be populated to implement the behavior of the UpdateRulesExecute function of this mock + UpdateRulesExecuteMock *func(r ApiUpdateRulesRequest) (*UpdateRulesResponse, error) + // UpdateWAFExecuteMock can be populated to implement the behavior of the UpdateWAFExecute function of this mock + UpdateWAFExecuteMock *func(r ApiUpdateWAFRequest) (*UpdateWAFResponse, error) +} + +func (a DefaultAPIServiceMock) CreateCoreRuleSet(ctx context.Context, projectId string, region string) ApiCreateCoreRuleSetRequest { + return ApiCreateCoreRuleSetRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + } +} + +// CreateCoreRuleSetExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the CreateCoreRuleSetExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) CreateCoreRuleSetExecute(r ApiCreateCoreRuleSetRequest) (*CreateCoreRuleSetResponse, error) { + if a.CreateCoreRuleSetExecuteMock == nil { + var localVarReturnValue *CreateCoreRuleSetResponse + return localVarReturnValue, nil + } + + return (*a.CreateCoreRuleSetExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) CreateRules(ctx context.Context, projectId string, region string) ApiCreateRulesRequest { + return ApiCreateRulesRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + } +} + +// CreateRulesExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the CreateRulesExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) CreateRulesExecute(r ApiCreateRulesRequest) (*CreateRulesResponse, error) { + if a.CreateRulesExecuteMock == nil { + var localVarReturnValue *CreateRulesResponse + return localVarReturnValue, nil + } + + return (*a.CreateRulesExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) CreateWAF(ctx context.Context, projectId string, region string) ApiCreateWAFRequest { + return ApiCreateWAFRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + } +} + +// CreateWAFExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the CreateWAFExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) CreateWAFExecute(r ApiCreateWAFRequest) (*CreateWAFResponse, error) { + if a.CreateWAFExecuteMock == nil { + var localVarReturnValue *CreateWAFResponse + return localVarReturnValue, nil + } + + return (*a.CreateWAFExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) DeleteCoreRuleSet(ctx context.Context, projectId string, region string, name string) ApiDeleteCoreRuleSetRequest { + return ApiDeleteCoreRuleSetRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// DeleteCoreRuleSetExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the DeleteCoreRuleSetExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) DeleteCoreRuleSetExecute(r ApiDeleteCoreRuleSetRequest) (map[string]interface{}, error) { + if a.DeleteCoreRuleSetExecuteMock == nil { + var localVarReturnValue map[string]interface{} + return localVarReturnValue, nil + } + + return (*a.DeleteCoreRuleSetExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) DeleteRules(ctx context.Context, projectId string, region string, name string) ApiDeleteRulesRequest { + return ApiDeleteRulesRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// DeleteRulesExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the DeleteRulesExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) DeleteRulesExecute(r ApiDeleteRulesRequest) (map[string]interface{}, error) { + if a.DeleteRulesExecuteMock == nil { + var localVarReturnValue map[string]interface{} + return localVarReturnValue, nil + } + + return (*a.DeleteRulesExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) DeleteWAF(ctx context.Context, projectId string, region string, name string) ApiDeleteWAFRequest { + return ApiDeleteWAFRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// DeleteWAFExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the DeleteWAFExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) DeleteWAFExecute(r ApiDeleteWAFRequest) (map[string]interface{}, error) { + if a.DeleteWAFExecuteMock == nil { + var localVarReturnValue map[string]interface{} + return localVarReturnValue, nil + } + + return (*a.DeleteWAFExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) GetCoreRuleSet(ctx context.Context, projectId string, region string, name string) ApiGetCoreRuleSetRequest { + return ApiGetCoreRuleSetRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// GetCoreRuleSetExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the GetCoreRuleSetExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) GetCoreRuleSetExecute(r ApiGetCoreRuleSetRequest) (*GetCoreRuleSetResponse, error) { + if a.GetCoreRuleSetExecuteMock == nil { + var localVarReturnValue *GetCoreRuleSetResponse + return localVarReturnValue, nil + } + + return (*a.GetCoreRuleSetExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) GetRules(ctx context.Context, projectId string, region string, name string) ApiGetRulesRequest { + return ApiGetRulesRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// GetRulesExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the GetRulesExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) GetRulesExecute(r ApiGetRulesRequest) (*GetRulesResponse, error) { + if a.GetRulesExecuteMock == nil { + var localVarReturnValue *GetRulesResponse + return localVarReturnValue, nil + } + + return (*a.GetRulesExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) GetWAF(ctx context.Context, projectId string, region string, name string) ApiGetWAFRequest { + return ApiGetWAFRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// GetWAFExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the GetWAFExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) GetWAFExecute(r ApiGetWAFRequest) (*GetWAFResponse, error) { + if a.GetWAFExecuteMock == nil { + var localVarReturnValue *GetWAFResponse + return localVarReturnValue, nil + } + + return (*a.GetWAFExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) ListCoreRuleSets(ctx context.Context, projectId string, region string) ApiListCoreRuleSetsRequest { + return ApiListCoreRuleSetsRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + } +} + +// ListCoreRuleSetsExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the ListCoreRuleSetsExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) ListCoreRuleSetsExecute(r ApiListCoreRuleSetsRequest) (*ListCoreRuleSetResponse, error) { + if a.ListCoreRuleSetsExecuteMock == nil { + var localVarReturnValue *ListCoreRuleSetResponse + return localVarReturnValue, nil + } + + return (*a.ListCoreRuleSetsExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) ListRules(ctx context.Context, projectId string, region string) ApiListRulesRequest { + return ApiListRulesRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + } +} + +// ListRulesExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the ListRulesExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) ListRulesExecute(r ApiListRulesRequest) (*ListRulesResponse, error) { + if a.ListRulesExecuteMock == nil { + var localVarReturnValue *ListRulesResponse + return localVarReturnValue, nil + } + + return (*a.ListRulesExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) ListWAF(ctx context.Context, projectId string, region string) ApiListWAFRequest { + return ApiListWAFRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + } +} + +// ListWAFExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the ListWAFExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) ListWAFExecute(r ApiListWAFRequest) (*ListWAFResponse, error) { + if a.ListWAFExecuteMock == nil { + var localVarReturnValue *ListWAFResponse + return localVarReturnValue, nil + } + + return (*a.ListWAFExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) UpdateCoreRuleSet(ctx context.Context, projectId string, region string, name string) ApiUpdateCoreRuleSetRequest { + return ApiUpdateCoreRuleSetRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// UpdateCoreRuleSetExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the UpdateCoreRuleSetExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) UpdateCoreRuleSetExecute(r ApiUpdateCoreRuleSetRequest) (*UpdateCoreRuleSetResponse, error) { + if a.UpdateCoreRuleSetExecuteMock == nil { + var localVarReturnValue *UpdateCoreRuleSetResponse + return localVarReturnValue, nil + } + + return (*a.UpdateCoreRuleSetExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) UpdateRules(ctx context.Context, projectId string, region string, name string) ApiUpdateRulesRequest { + return ApiUpdateRulesRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// UpdateRulesExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the UpdateRulesExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) UpdateRulesExecute(r ApiUpdateRulesRequest) (*UpdateRulesResponse, error) { + if a.UpdateRulesExecuteMock == nil { + var localVarReturnValue *UpdateRulesResponse + return localVarReturnValue, nil + } + + return (*a.UpdateRulesExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) UpdateWAF(ctx context.Context, projectId string, region string, name string) ApiUpdateWAFRequest { + return ApiUpdateWAFRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// UpdateWAFExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the UpdateWAFExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) UpdateWAFExecute(r ApiUpdateWAFRequest) (*UpdateWAFResponse, error) { + if a.UpdateWAFExecuteMock == nil { + var localVarReturnValue *UpdateWAFResponse + return localVarReturnValue, nil + } + + return (*a.UpdateWAFExecuteMock)(r) +} diff --git a/services/albwaf/v1alphaapi/client.go b/services/albwaf/v1alphaapi/client.go new file mode 100644 index 000000000..a21cbb7a1 --- /dev/null +++ b/services/albwaf/v1alphaapi/client.go @@ -0,0 +1,658 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. +package v1alphaapi + +import ( + "bytes" + "context" + "encoding/json" + "encoding/xml" + "errors" + "fmt" + "io" + "log" + "mime/multipart" + "net/http" + "net/http/httputil" + "net/url" + "os" + "path/filepath" + "reflect" + "regexp" + "strconv" + "strings" + "time" + "unicode/utf8" + + "github.com/stackitcloud/stackit-sdk-go/core/auth" + "github.com/stackitcloud/stackit-sdk-go/core/config" +) + +var ( + JsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?json)`) + XmlCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?xml)`) + queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`) + queryDescape = strings.NewReplacer("%5B", "[", "%5D", "]") +) + +// APIClient manages communication with the STACKIT Application Load Balancer Web Application Firewall API API v1alpha.0.0 +// In most cases there should be only one, shared, APIClient. +type APIClient struct { + cfg *config.Configuration + common service // Reuse a single struct instead of allocating one for each service on the heap. + + // API Services + + DefaultAPI DefaultAPI +} + +type service struct { + client *APIClient +} + +// NewAPIClient creates a new API client. Requires a userAgent string describing your application. +// optionally a custom http.Client to allow for advanced features such as caching. +func NewAPIClient(opts ...config.ConfigurationOption) (*APIClient, error) { + cfg := NewConfiguration() + + for _, option := range opts { + err := option(cfg) + if err != nil { + return nil, fmt.Errorf("configuring the client: %w", err) + } + } + + err := config.ConfigureRegion(cfg) + if err != nil { + return nil, fmt.Errorf("configuring region: %w", err) + } + + if cfg.HTTPClient == nil { + cfg.HTTPClient = &http.Client{} + } + + authRoundTripper, err := auth.SetupAuth(cfg) + if err != nil { + return nil, fmt.Errorf("setting up authentication: %w", err) + } + + roundTripper := authRoundTripper + if cfg.Middleware != nil { + roundTripper = config.ChainMiddleware(roundTripper, cfg.Middleware...) + } + + cfg.HTTPClient.Transport = roundTripper + + c := &APIClient{} + c.cfg = cfg + c.common.client = c + + // API Services + c.DefaultAPI = (*DefaultAPIService)(&c.common) + + return c, nil +} + +func atoi(in string) (int, error) { + return strconv.Atoi(in) +} + +// selectHeaderContentType select a content type from the available list. +func selectHeaderContentType(contentTypes []string) string { + if len(contentTypes) == 0 { + return "" + } + if contains(contentTypes, "application/json") { + return "application/json" + } + return contentTypes[0] // use the first content type specified in 'consumes' +} + +// selectHeaderAccept join all accept types and return +func selectHeaderAccept(accepts []string) string { + if len(accepts) == 0 { + return "" + } + + if contains(accepts, "application/json") { + return "application/json" + } + + return strings.Join(accepts, ",") +} + +// contains is a case insensitive match, finding needle in a haystack +func contains(haystack []string, needle string) bool { + for _, a := range haystack { + if strings.EqualFold(a, needle) { + return true + } + } + return false +} + +// Verify optional parameters are of the correct type. +func typeCheckParameter(obj interface{}, expected string, name string) error { + // Make sure there is an object. + if obj == nil { + return nil + } + + // Check the type is as expected. + if reflect.TypeOf(obj).String() != expected { + return fmt.Errorf("expected %s to be of type %s but received %s", name, expected, reflect.TypeOf(obj).String()) + } + return nil +} + +func parameterValueToString(obj interface{}, key string) string { + if reflect.TypeOf(obj).Kind() != reflect.Ptr { + if actualObj, ok := obj.(interface{ GetActualInstanceValue() interface{} }); ok { + return fmt.Sprintf("%v", actualObj.GetActualInstanceValue()) + } + + return fmt.Sprintf("%v", obj) + } + var param, ok = obj.(MappedNullable) + if !ok { + return "" + } + dataMap, err := param.ToMap() + if err != nil { + return "" + } + return fmt.Sprintf("%v", dataMap[key]) +} + +// parameterAddToHeaderOrQuery adds the provided object to the request header or url query +// supporting deep object syntax +func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix string, obj interface{}, style string, collectionType string) { + var v = reflect.ValueOf(obj) + var value = "" + if v == reflect.ValueOf(nil) { + value = "null" + } else { + switch v.Kind() { + case reflect.Invalid: + value = "invalid" + + case reflect.Struct: + if t, ok := obj.(MappedNullable); ok { + dataMap, err := t.ToMap() + if err != nil { + return + } + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, dataMap, style, collectionType) + return + } + if t, ok := obj.(time.Time); ok { + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, t.Format(time.RFC3339Nano), style, collectionType) + return + } + value = v.Type().String() + " value" + case reflect.Slice: + var indValue = reflect.ValueOf(obj) + if indValue == reflect.ValueOf(nil) { + return + } + var lenIndValue = indValue.Len() + for i := 0; i < lenIndValue; i++ { + var arrayValue = indValue.Index(i) + var keyPrefixForCollectionType = keyPrefix + if style == "deepObject" { + keyPrefixForCollectionType = keyPrefix + "[" + strconv.Itoa(i) + "]" + } + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefixForCollectionType, arrayValue.Interface(), style, collectionType) + } + return + + case reflect.Map: + var indValue = reflect.ValueOf(obj) + if indValue == reflect.ValueOf(nil) { + return + } + iter := indValue.MapRange() + for iter.Next() { + k, v := iter.Key(), iter.Value() + parameterAddToHeaderOrQuery(headerOrQueryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface(), style, collectionType) + } + return + + case reflect.Interface: + fallthrough + case reflect.Ptr: + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, v.Elem().Interface(), style, collectionType) + return + + case reflect.Int, reflect.Int8, reflect.Int16, + reflect.Int32, reflect.Int64: + value = strconv.FormatInt(v.Int(), 10) + case reflect.Uint, reflect.Uint8, reflect.Uint16, + reflect.Uint32, reflect.Uint64, reflect.Uintptr: + value = strconv.FormatUint(v.Uint(), 10) + case reflect.Float32, reflect.Float64: + value = strconv.FormatFloat(v.Float(), 'g', -1, 32) + case reflect.Bool: + value = strconv.FormatBool(v.Bool()) + case reflect.String: + value = v.String() + default: + value = v.Type().String() + " value" + } + } + + switch valuesMap := headerOrQueryParams.(type) { + case url.Values: + if collectionType == "csv" && valuesMap.Get(keyPrefix) != "" { + valuesMap.Set(keyPrefix, valuesMap.Get(keyPrefix)+","+value) + } else { + valuesMap.Add(keyPrefix, value) + } + break + case map[string]string: + valuesMap[keyPrefix] = value + break + } +} + +// helper for converting interface{} parameters to json strings +func parameterToJson(obj interface{}) (string, error) { + jsonBuf, err := json.Marshal(obj) + if err != nil { + return "", err + } + return string(jsonBuf), err +} + +// callAPI do the request. +func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { + if c.cfg.Debug { + dump, err := httputil.DumpRequestOut(request, true) + if err != nil { + return nil, err + } + log.Printf("\n%s\n", string(dump)) + } + + resp, err := c.cfg.HTTPClient.Do(request) + if err != nil { + return resp, err + } + + if c.cfg.Debug { + dump, err := httputil.DumpResponse(resp, true) + if err != nil { + return resp, err + } + log.Printf("\n%s\n", string(dump)) + } + return resp, err +} + +// Allow modification of underlying config for alternate implementations and testing +// Caution: modifying the configuration while live can cause data races and potentially unwanted behavior +func (c *APIClient) GetConfig() *config.Configuration { + return c.cfg +} + +type formFile struct { + fileBytes []byte + fileName string + formFileName string +} + +// prepareRequest build the request +func (c *APIClient) prepareRequest( + ctx context.Context, + path string, method string, + postBody interface{}, + headerParams map[string]string, + queryParams url.Values, + formParams url.Values, + formFiles []formFile) (localVarRequest *http.Request, err error) { + + var body *bytes.Buffer + + // Detect postBody type and post. + if postBody != nil { + contentType := headerParams["Content-Type"] + if contentType == "" { + contentType = detectContentType(postBody) + headerParams["Content-Type"] = contentType + } + + body, err = setBody(postBody, contentType) + if err != nil { + return nil, err + } + } + + // add form parameters and file if available. + if strings.HasPrefix(headerParams["Content-Type"], "multipart/form-data") && len(formParams) > 0 || (len(formFiles) > 0) { + if body != nil { + return nil, errors.New("Cannot specify postBody and multipart form at the same time.") + } + body = &bytes.Buffer{} + w := multipart.NewWriter(body) + + for k, v := range formParams { + for _, iv := range v { + if strings.HasPrefix(k, "@") { // file + err = addFile(w, k[1:], iv) + if err != nil { + return nil, err + } + } else { // form value + w.WriteField(k, iv) + } + } + } + for _, formFile := range formFiles { + if len(formFile.fileBytes) > 0 && formFile.fileName != "" { + w.Boundary() + part, err := w.CreateFormFile(formFile.formFileName, filepath.Base(formFile.fileName)) + if err != nil { + return nil, err + } + _, err = part.Write(formFile.fileBytes) + if err != nil { + return nil, err + } + } + } + + // Set the Boundary in the Content-Type + headerParams["Content-Type"] = w.FormDataContentType() + + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + w.Close() + } + + if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 { + if body != nil { + return nil, errors.New("Cannot specify postBody and x-www-form-urlencoded form at the same time.") + } + body = &bytes.Buffer{} + body.WriteString(formParams.Encode()) + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + } + + // Setup path and query parameters + url, err := url.Parse(path) + if err != nil { + return nil, err + } + + // Override request host, if applicable + if c.cfg.Host != "" { + url.Host = c.cfg.Host + } + + // Override request scheme, if applicable + if c.cfg.Scheme != "" { + url.Scheme = c.cfg.Scheme + } + + // Adding Query Param + query := url.Query() + for k, v := range queryParams { + for _, iv := range v { + query.Add(k, iv) + } + } + + // Encode the parameters. + url.RawQuery = queryParamSplit.ReplaceAllStringFunc(query.Encode(), func(s string) string { + pieces := strings.Split(s, "=") + pieces[0] = queryDescape.Replace(pieces[0]) + return strings.Join(pieces, "=") + }) + + // Generate a new request + if body != nil { + localVarRequest, err = http.NewRequest(method, url.String(), body) + } else { + localVarRequest, err = http.NewRequest(method, url.String(), nil) + } + if err != nil { + return nil, err + } + + // add header parameters, if any + if len(headerParams) > 0 { + headers := http.Header{} + for h, v := range headerParams { + headers[h] = []string{v} + } + localVarRequest.Header = headers + } + + // Add the user agent to the request. + localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) + + if ctx != nil { + // add context to the request + localVarRequest = localVarRequest.WithContext(ctx) + + // Walk through any authentication. + + } + + for header, value := range c.cfg.DefaultHeader { + localVarRequest.Header.Add(header, value) + } + return localVarRequest, nil +} + +func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { + if len(b) == 0 { + return nil + } + if s, ok := v.(*string); ok { + *s = string(b) + return nil + } + if f, ok := v.(*os.File); ok { + f, err = os.CreateTemp("", "HttpClientFile") + if err != nil { + return + } + _, err = f.Write(b) + if err != nil { + return + } + _, err = f.Seek(0, io.SeekStart) + return + } + if f, ok := v.(**os.File); ok { + *f, err = os.CreateTemp("", "HttpClientFile") + if err != nil { + return + } + _, err = (*f).Write(b) + if err != nil { + return + } + _, err = (*f).Seek(0, io.SeekStart) + return + } + if XmlCheck.MatchString(contentType) { + if err = xml.Unmarshal(b, v); err != nil { + return err + } + return nil + } + if JsonCheck.MatchString(contentType) { + if actualObj, ok := v.(interface{ GetActualInstance() interface{} }); ok { // oneOf, anyOf schemas + if unmarshalObj, ok := actualObj.(interface{ UnmarshalJSON([]byte) error }); ok { // make sure it has UnmarshalJSON defined + if err = unmarshalObj.UnmarshalJSON(b); err != nil { + return err + } + } else { + return errors.New("Unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined") + } + } else if err = json.Unmarshal(b, v); err != nil { // simple model + return err + } + return nil + } + return errors.New("undefined response type") +} + +// Add a file to the multipart request +func addFile(w *multipart.Writer, fieldName, path string) error { + file, err := os.Open(filepath.Clean(path)) + if err != nil { + return err + } + defer file.Close() + + part, err := w.CreateFormFile(fieldName, filepath.Base(path)) + if err != nil { + return err + } + _, err = io.Copy(part, file) + + return err +} + +// Set request body from an interface{} +func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { + if bodyBuf == nil { + bodyBuf = &bytes.Buffer{} + } + + if reader, ok := body.(io.Reader); ok { + _, err = bodyBuf.ReadFrom(reader) + } else if fp, ok := body.(*os.File); ok { + _, err = bodyBuf.ReadFrom(fp) + } else if b, ok := body.([]byte); ok { + _, err = bodyBuf.Write(b) + } else if s, ok := body.(string); ok { + _, err = bodyBuf.WriteString(s) + } else if s, ok := body.(*string); ok { + _, err = bodyBuf.WriteString(*s) + } else if JsonCheck.MatchString(contentType) { + err = json.NewEncoder(bodyBuf).Encode(body) + } else if XmlCheck.MatchString(contentType) { + var bs []byte + bs, err = xml.Marshal(body) + if err == nil { + bodyBuf.Write(bs) + } + } + + if err != nil { + return nil, err + } + + if bodyBuf.Len() == 0 { + err = fmt.Errorf("invalid body type %s\n", contentType) + return nil, err + } + return bodyBuf, nil +} + +// detectContentType method is used to figure out `Request.Body` content type for request header +func detectContentType(body interface{}) string { + contentType := "text/plain; charset=utf-8" + kind := reflect.TypeOf(body).Kind() + + switch kind { + case reflect.Struct, reflect.Map, reflect.Ptr: + contentType = "application/json; charset=utf-8" + case reflect.String: + contentType = "text/plain; charset=utf-8" + default: + if b, ok := body.([]byte); ok { + contentType = http.DetectContentType(b) + } else if kind == reflect.Slice { + contentType = "application/json; charset=utf-8" + } + } + + return contentType +} + +// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go +type cacheControl map[string]string + +func parseCacheControl(headers http.Header) cacheControl { + cc := cacheControl{} + ccHeader := headers.Get("Cache-Control") + for _, part := range strings.Split(ccHeader, ",") { + part = strings.Trim(part, " ") + if part == "" { + continue + } + if strings.ContainsRune(part, '=') { + keyval := strings.Split(part, "=") + cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") + } else { + cc[part] = "" + } + } + return cc +} + +// CacheExpires helper function to determine remaining time before repeating a request. +func CacheExpires(r *http.Response) time.Time { + // Figure out when the cache expires. + var expires time.Time + now, err := time.Parse(time.RFC1123, r.Header.Get("date")) + if err != nil { + return time.Now() + } + respCacheControl := parseCacheControl(r.Header) + + if maxAge, ok := respCacheControl["max-age"]; ok { + lifetime, err := time.ParseDuration(maxAge + "s") + if err != nil { + expires = now + } else { + expires = now.Add(lifetime) + } + } else { + expiresHeader := r.Header.Get("Expires") + if expiresHeader != "" { + expires, err = time.Parse(time.RFC1123, expiresHeader) + if err != nil { + expires = now + } + } + } + return expires +} + +func strlen(s string) int { + return utf8.RuneCountInString(s) +} + +// format error message using title and detail when model implements rfc7807 +func formatErrorMessage(status string, v interface{}) string { + str := "" + metaValue := reflect.ValueOf(v).Elem() + + if metaValue.Kind() == reflect.Struct { + field := metaValue.FieldByName("Title") + if field != (reflect.Value{}) { + str = fmt.Sprintf("%s", field.Interface()) + } + + field = metaValue.FieldByName("Detail") + if field != (reflect.Value{}) { + str = fmt.Sprintf("%s (%s)", str, field.Interface()) + } + } + + return strings.TrimSpace(fmt.Sprintf("%s %s", status, str)) +} diff --git a/services/albwaf/v1alphaapi/configuration.go b/services/albwaf/v1alphaapi/configuration.go new file mode 100644 index 000000000..7d9574f67 --- /dev/null +++ b/services/albwaf/v1alphaapi/configuration.go @@ -0,0 +1,37 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. +package v1alphaapi + +import ( + "github.com/stackitcloud/stackit-sdk-go/core/config" +) + +// NewConfiguration returns a new Configuration object +func NewConfiguration() *config.Configuration { + cfg := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "stackit-sdk-go/albwaf", + Debug: false, + Servers: config.ServerConfigurations{ + { + URL: "https://alb-waf.api.stackit.cloud", + Description: "No description provided", + Variables: map[string]config.ServerVariable{ + "region": { + Description: "No description provided", + DefaultValue: "global", + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + return cfg +} diff --git a/services/albwaf/v1alphaapi/model_create_core_rule_set_payload.go b/services/albwaf/v1alphaapi/model_create_core_rule_set_payload.go new file mode 100644 index 000000000..92363f264 --- /dev/null +++ b/services/albwaf/v1alphaapi/model_create_core_rule_set_payload.go @@ -0,0 +1,236 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the CreateCoreRuleSetPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &CreateCoreRuleSetPayload{} + +// CreateCoreRuleSetPayload CreateCoreRuleSetRequest creates a rule configuration. +type CreateCoreRuleSetPayload struct { + // To activate the OWASP core rule set, set this boolean to true. + Active *bool `json:"active,omitempty"` + // Core rule set configuration name. + Name *string `json:"name,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` + // Project identifier + ProjectId *string `json:"projectId,omitempty" validate:"regexp=^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"` + // Region + Region *string `json:"region,omitempty" validate:"regexp=^[a-z]{2,4}[0-9]{2}$"` +} + +// NewCreateCoreRuleSetPayload instantiates a new CreateCoreRuleSetPayload object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewCreateCoreRuleSetPayload() *CreateCoreRuleSetPayload { + this := CreateCoreRuleSetPayload{} + return &this +} + +// NewCreateCoreRuleSetPayloadWithDefaults instantiates a new CreateCoreRuleSetPayload object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewCreateCoreRuleSetPayloadWithDefaults() *CreateCoreRuleSetPayload { + this := CreateCoreRuleSetPayload{} + return &this +} + +// GetActive returns the Active field value if set, zero value otherwise. +func (o *CreateCoreRuleSetPayload) GetActive() bool { + if o == nil || IsNil(o.Active) { + var ret bool + return ret + } + return *o.Active +} + +// GetActiveOk returns a tuple with the Active field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateCoreRuleSetPayload) GetActiveOk() (*bool, bool) { + if o == nil || IsNil(o.Active) { + return nil, false + } + return o.Active, true +} + +// HasActive returns a boolean if a field has been set. +func (o *CreateCoreRuleSetPayload) HasActive() bool { + if o != nil && !IsNil(o.Active) { + return true + } + + return false +} + +// SetActive gets a reference to the given bool and assigns it to the Active field. +func (o *CreateCoreRuleSetPayload) SetActive(v bool) { + o.Active = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *CreateCoreRuleSetPayload) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateCoreRuleSetPayload) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *CreateCoreRuleSetPayload) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *CreateCoreRuleSetPayload) SetName(v string) { + o.Name = &v +} + +// GetProjectId returns the ProjectId field value if set, zero value otherwise. +func (o *CreateCoreRuleSetPayload) GetProjectId() string { + if o == nil || IsNil(o.ProjectId) { + var ret string + return ret + } + return *o.ProjectId +} + +// GetProjectIdOk returns a tuple with the ProjectId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateCoreRuleSetPayload) GetProjectIdOk() (*string, bool) { + if o == nil || IsNil(o.ProjectId) { + return nil, false + } + return o.ProjectId, true +} + +// HasProjectId returns a boolean if a field has been set. +func (o *CreateCoreRuleSetPayload) HasProjectId() bool { + if o != nil && !IsNil(o.ProjectId) { + return true + } + + return false +} + +// SetProjectId gets a reference to the given string and assigns it to the ProjectId field. +func (o *CreateCoreRuleSetPayload) SetProjectId(v string) { + o.ProjectId = &v +} + +// GetRegion returns the Region field value if set, zero value otherwise. +func (o *CreateCoreRuleSetPayload) GetRegion() string { + if o == nil || IsNil(o.Region) { + var ret string + return ret + } + return *o.Region +} + +// GetRegionOk returns a tuple with the Region field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateCoreRuleSetPayload) GetRegionOk() (*string, bool) { + if o == nil || IsNil(o.Region) { + return nil, false + } + return o.Region, true +} + +// HasRegion returns a boolean if a field has been set. +func (o *CreateCoreRuleSetPayload) HasRegion() bool { + if o != nil && !IsNil(o.Region) { + return true + } + + return false +} + +// SetRegion gets a reference to the given string and assigns it to the Region field. +func (o *CreateCoreRuleSetPayload) SetRegion(v string) { + o.Region = &v +} + +func (o CreateCoreRuleSetPayload) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o CreateCoreRuleSetPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Active) { + toSerialize["active"] = o.Active + } + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.ProjectId) { + toSerialize["projectId"] = o.ProjectId + } + if !IsNil(o.Region) { + toSerialize["region"] = o.Region + } + return toSerialize, nil +} + +type NullableCreateCoreRuleSetPayload struct { + value *CreateCoreRuleSetPayload + isSet bool +} + +func (v NullableCreateCoreRuleSetPayload) Get() *CreateCoreRuleSetPayload { + return v.value +} + +func (v *NullableCreateCoreRuleSetPayload) Set(val *CreateCoreRuleSetPayload) { + v.value = val + v.isSet = true +} + +func (v NullableCreateCoreRuleSetPayload) IsSet() bool { + return v.isSet +} + +func (v *NullableCreateCoreRuleSetPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCreateCoreRuleSetPayload(val *CreateCoreRuleSetPayload) *NullableCreateCoreRuleSetPayload { + return &NullableCreateCoreRuleSetPayload{value: val, isSet: true} +} + +func (v NullableCreateCoreRuleSetPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCreateCoreRuleSetPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_create_core_rule_set_response.go b/services/albwaf/v1alphaapi/model_create_core_rule_set_response.go new file mode 100644 index 000000000..49d7ef0c9 --- /dev/null +++ b/services/albwaf/v1alphaapi/model_create_core_rule_set_response.go @@ -0,0 +1,199 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the CreateCoreRuleSetResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &CreateCoreRuleSetResponse{} + +// CreateCoreRuleSetResponse CreateCoreRuleSetResponse returns rule configuration name and it's rules. +type CreateCoreRuleSetResponse struct { + // Indicates if the OWASP core rule set is active. + Active *bool `json:"active,omitempty"` + // Core rule set configuration name. + Name *string `json:"name,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` + // Region + Region *string `json:"region,omitempty" validate:"regexp=^[a-z]{2,4}[0-9]{2}$"` +} + +// NewCreateCoreRuleSetResponse instantiates a new CreateCoreRuleSetResponse object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewCreateCoreRuleSetResponse() *CreateCoreRuleSetResponse { + this := CreateCoreRuleSetResponse{} + return &this +} + +// NewCreateCoreRuleSetResponseWithDefaults instantiates a new CreateCoreRuleSetResponse object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewCreateCoreRuleSetResponseWithDefaults() *CreateCoreRuleSetResponse { + this := CreateCoreRuleSetResponse{} + return &this +} + +// GetActive returns the Active field value if set, zero value otherwise. +func (o *CreateCoreRuleSetResponse) GetActive() bool { + if o == nil || IsNil(o.Active) { + var ret bool + return ret + } + return *o.Active +} + +// GetActiveOk returns a tuple with the Active field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateCoreRuleSetResponse) GetActiveOk() (*bool, bool) { + if o == nil || IsNil(o.Active) { + return nil, false + } + return o.Active, true +} + +// HasActive returns a boolean if a field has been set. +func (o *CreateCoreRuleSetResponse) HasActive() bool { + if o != nil && !IsNil(o.Active) { + return true + } + + return false +} + +// SetActive gets a reference to the given bool and assigns it to the Active field. +func (o *CreateCoreRuleSetResponse) SetActive(v bool) { + o.Active = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *CreateCoreRuleSetResponse) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateCoreRuleSetResponse) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *CreateCoreRuleSetResponse) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *CreateCoreRuleSetResponse) SetName(v string) { + o.Name = &v +} + +// GetRegion returns the Region field value if set, zero value otherwise. +func (o *CreateCoreRuleSetResponse) GetRegion() string { + if o == nil || IsNil(o.Region) { + var ret string + return ret + } + return *o.Region +} + +// GetRegionOk returns a tuple with the Region field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateCoreRuleSetResponse) GetRegionOk() (*string, bool) { + if o == nil || IsNil(o.Region) { + return nil, false + } + return o.Region, true +} + +// HasRegion returns a boolean if a field has been set. +func (o *CreateCoreRuleSetResponse) HasRegion() bool { + if o != nil && !IsNil(o.Region) { + return true + } + + return false +} + +// SetRegion gets a reference to the given string and assigns it to the Region field. +func (o *CreateCoreRuleSetResponse) SetRegion(v string) { + o.Region = &v +} + +func (o CreateCoreRuleSetResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o CreateCoreRuleSetResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Active) { + toSerialize["active"] = o.Active + } + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.Region) { + toSerialize["region"] = o.Region + } + return toSerialize, nil +} + +type NullableCreateCoreRuleSetResponse struct { + value *CreateCoreRuleSetResponse + isSet bool +} + +func (v NullableCreateCoreRuleSetResponse) Get() *CreateCoreRuleSetResponse { + return v.value +} + +func (v *NullableCreateCoreRuleSetResponse) Set(val *CreateCoreRuleSetResponse) { + v.value = val + v.isSet = true +} + +func (v NullableCreateCoreRuleSetResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableCreateCoreRuleSetResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCreateCoreRuleSetResponse(val *CreateCoreRuleSetResponse) *NullableCreateCoreRuleSetResponse { + return &NullableCreateCoreRuleSetResponse{value: val, isSet: true} +} + +func (v NullableCreateCoreRuleSetResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCreateCoreRuleSetResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_create_rules_payload.go b/services/albwaf/v1alphaapi/model_create_rules_payload.go new file mode 100644 index 000000000..753afbdd6 --- /dev/null +++ b/services/albwaf/v1alphaapi/model_create_rules_payload.go @@ -0,0 +1,236 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the CreateRulesPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &CreateRulesPayload{} + +// CreateRulesPayload CreateRulesRequest creates a rule configuration. +type CreateRulesPayload struct { + // Rule configuration name. + Name *string `json:"name,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` + // Project identifier + ProjectId *string `json:"projectId,omitempty" validate:"regexp=^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"` + // Region + Region *string `json:"region,omitempty" validate:"regexp=^[a-z]{2,4}[0-9]{2}$"` + // Custom rules for WAF written in Seclang syntax. + Rules *string `json:"rules,omitempty"` +} + +// NewCreateRulesPayload instantiates a new CreateRulesPayload object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewCreateRulesPayload() *CreateRulesPayload { + this := CreateRulesPayload{} + return &this +} + +// NewCreateRulesPayloadWithDefaults instantiates a new CreateRulesPayload object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewCreateRulesPayloadWithDefaults() *CreateRulesPayload { + this := CreateRulesPayload{} + return &this +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *CreateRulesPayload) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateRulesPayload) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *CreateRulesPayload) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *CreateRulesPayload) SetName(v string) { + o.Name = &v +} + +// GetProjectId returns the ProjectId field value if set, zero value otherwise. +func (o *CreateRulesPayload) GetProjectId() string { + if o == nil || IsNil(o.ProjectId) { + var ret string + return ret + } + return *o.ProjectId +} + +// GetProjectIdOk returns a tuple with the ProjectId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateRulesPayload) GetProjectIdOk() (*string, bool) { + if o == nil || IsNil(o.ProjectId) { + return nil, false + } + return o.ProjectId, true +} + +// HasProjectId returns a boolean if a field has been set. +func (o *CreateRulesPayload) HasProjectId() bool { + if o != nil && !IsNil(o.ProjectId) { + return true + } + + return false +} + +// SetProjectId gets a reference to the given string and assigns it to the ProjectId field. +func (o *CreateRulesPayload) SetProjectId(v string) { + o.ProjectId = &v +} + +// GetRegion returns the Region field value if set, zero value otherwise. +func (o *CreateRulesPayload) GetRegion() string { + if o == nil || IsNil(o.Region) { + var ret string + return ret + } + return *o.Region +} + +// GetRegionOk returns a tuple with the Region field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateRulesPayload) GetRegionOk() (*string, bool) { + if o == nil || IsNil(o.Region) { + return nil, false + } + return o.Region, true +} + +// HasRegion returns a boolean if a field has been set. +func (o *CreateRulesPayload) HasRegion() bool { + if o != nil && !IsNil(o.Region) { + return true + } + + return false +} + +// SetRegion gets a reference to the given string and assigns it to the Region field. +func (o *CreateRulesPayload) SetRegion(v string) { + o.Region = &v +} + +// GetRules returns the Rules field value if set, zero value otherwise. +func (o *CreateRulesPayload) GetRules() string { + if o == nil || IsNil(o.Rules) { + var ret string + return ret + } + return *o.Rules +} + +// GetRulesOk returns a tuple with the Rules field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateRulesPayload) GetRulesOk() (*string, bool) { + if o == nil || IsNil(o.Rules) { + return nil, false + } + return o.Rules, true +} + +// HasRules returns a boolean if a field has been set. +func (o *CreateRulesPayload) HasRules() bool { + if o != nil && !IsNil(o.Rules) { + return true + } + + return false +} + +// SetRules gets a reference to the given string and assigns it to the Rules field. +func (o *CreateRulesPayload) SetRules(v string) { + o.Rules = &v +} + +func (o CreateRulesPayload) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o CreateRulesPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.ProjectId) { + toSerialize["projectId"] = o.ProjectId + } + if !IsNil(o.Region) { + toSerialize["region"] = o.Region + } + if !IsNil(o.Rules) { + toSerialize["rules"] = o.Rules + } + return toSerialize, nil +} + +type NullableCreateRulesPayload struct { + value *CreateRulesPayload + isSet bool +} + +func (v NullableCreateRulesPayload) Get() *CreateRulesPayload { + return v.value +} + +func (v *NullableCreateRulesPayload) Set(val *CreateRulesPayload) { + v.value = val + v.isSet = true +} + +func (v NullableCreateRulesPayload) IsSet() bool { + return v.isSet +} + +func (v *NullableCreateRulesPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCreateRulesPayload(val *CreateRulesPayload) *NullableCreateRulesPayload { + return &NullableCreateRulesPayload{value: val, isSet: true} +} + +func (v NullableCreateRulesPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCreateRulesPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_create_rules_response.go b/services/albwaf/v1alphaapi/model_create_rules_response.go new file mode 100644 index 000000000..250eea8f0 --- /dev/null +++ b/services/albwaf/v1alphaapi/model_create_rules_response.go @@ -0,0 +1,199 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the CreateRulesResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &CreateRulesResponse{} + +// CreateRulesResponse CreateRulesResponse returns rule configuration name and it's rules. +type CreateRulesResponse struct { + // Rule configuration name. + Name *string `json:"name,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` + // Region + Region *string `json:"region,omitempty" validate:"regexp=^[a-z]{2,4}[0-9]{2}$"` + // Custom rules written in Seclang syntax. + Rules *string `json:"rules,omitempty"` +} + +// NewCreateRulesResponse instantiates a new CreateRulesResponse object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewCreateRulesResponse() *CreateRulesResponse { + this := CreateRulesResponse{} + return &this +} + +// NewCreateRulesResponseWithDefaults instantiates a new CreateRulesResponse object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewCreateRulesResponseWithDefaults() *CreateRulesResponse { + this := CreateRulesResponse{} + return &this +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *CreateRulesResponse) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateRulesResponse) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *CreateRulesResponse) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *CreateRulesResponse) SetName(v string) { + o.Name = &v +} + +// GetRegion returns the Region field value if set, zero value otherwise. +func (o *CreateRulesResponse) GetRegion() string { + if o == nil || IsNil(o.Region) { + var ret string + return ret + } + return *o.Region +} + +// GetRegionOk returns a tuple with the Region field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateRulesResponse) GetRegionOk() (*string, bool) { + if o == nil || IsNil(o.Region) { + return nil, false + } + return o.Region, true +} + +// HasRegion returns a boolean if a field has been set. +func (o *CreateRulesResponse) HasRegion() bool { + if o != nil && !IsNil(o.Region) { + return true + } + + return false +} + +// SetRegion gets a reference to the given string and assigns it to the Region field. +func (o *CreateRulesResponse) SetRegion(v string) { + o.Region = &v +} + +// GetRules returns the Rules field value if set, zero value otherwise. +func (o *CreateRulesResponse) GetRules() string { + if o == nil || IsNil(o.Rules) { + var ret string + return ret + } + return *o.Rules +} + +// GetRulesOk returns a tuple with the Rules field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateRulesResponse) GetRulesOk() (*string, bool) { + if o == nil || IsNil(o.Rules) { + return nil, false + } + return o.Rules, true +} + +// HasRules returns a boolean if a field has been set. +func (o *CreateRulesResponse) HasRules() bool { + if o != nil && !IsNil(o.Rules) { + return true + } + + return false +} + +// SetRules gets a reference to the given string and assigns it to the Rules field. +func (o *CreateRulesResponse) SetRules(v string) { + o.Rules = &v +} + +func (o CreateRulesResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o CreateRulesResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.Region) { + toSerialize["region"] = o.Region + } + if !IsNil(o.Rules) { + toSerialize["rules"] = o.Rules + } + return toSerialize, nil +} + +type NullableCreateRulesResponse struct { + value *CreateRulesResponse + isSet bool +} + +func (v NullableCreateRulesResponse) Get() *CreateRulesResponse { + return v.value +} + +func (v *NullableCreateRulesResponse) Set(val *CreateRulesResponse) { + v.value = val + v.isSet = true +} + +func (v NullableCreateRulesResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableCreateRulesResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCreateRulesResponse(val *CreateRulesResponse) *NullableCreateRulesResponse { + return &NullableCreateRulesResponse{value: val, isSet: true} +} + +func (v NullableCreateRulesResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCreateRulesResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_create_waf_payload.go b/services/albwaf/v1alphaapi/model_create_waf_payload.go new file mode 100644 index 000000000..8c79e9906 --- /dev/null +++ b/services/albwaf/v1alphaapi/model_create_waf_payload.go @@ -0,0 +1,273 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the CreateWAFPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &CreateWAFPayload{} + +// CreateWAFPayload CreateWAFRequest creates a WAF with rules. +type CreateWAFPayload struct { + // Name of the core rule set configuration for that WAF. + CoreRuleSetName *string `json:"coreRuleSetName,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` + // WAF name + Name *string `json:"name,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` + // Project identifier + ProjectId *string `json:"projectId,omitempty" validate:"regexp=^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"` + // Region + Region *string `json:"region,omitempty" validate:"regexp=^[a-z]{2,4}[0-9]{2}$"` + // Name of the rule configuration for that WAF. + RulesConfigName *string `json:"rulesConfigName,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` +} + +// NewCreateWAFPayload instantiates a new CreateWAFPayload object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewCreateWAFPayload() *CreateWAFPayload { + this := CreateWAFPayload{} + return &this +} + +// NewCreateWAFPayloadWithDefaults instantiates a new CreateWAFPayload object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewCreateWAFPayloadWithDefaults() *CreateWAFPayload { + this := CreateWAFPayload{} + return &this +} + +// GetCoreRuleSetName returns the CoreRuleSetName field value if set, zero value otherwise. +func (o *CreateWAFPayload) GetCoreRuleSetName() string { + if o == nil || IsNil(o.CoreRuleSetName) { + var ret string + return ret + } + return *o.CoreRuleSetName +} + +// GetCoreRuleSetNameOk returns a tuple with the CoreRuleSetName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateWAFPayload) GetCoreRuleSetNameOk() (*string, bool) { + if o == nil || IsNil(o.CoreRuleSetName) { + return nil, false + } + return o.CoreRuleSetName, true +} + +// HasCoreRuleSetName returns a boolean if a field has been set. +func (o *CreateWAFPayload) HasCoreRuleSetName() bool { + if o != nil && !IsNil(o.CoreRuleSetName) { + return true + } + + return false +} + +// SetCoreRuleSetName gets a reference to the given string and assigns it to the CoreRuleSetName field. +func (o *CreateWAFPayload) SetCoreRuleSetName(v string) { + o.CoreRuleSetName = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *CreateWAFPayload) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateWAFPayload) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *CreateWAFPayload) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *CreateWAFPayload) SetName(v string) { + o.Name = &v +} + +// GetProjectId returns the ProjectId field value if set, zero value otherwise. +func (o *CreateWAFPayload) GetProjectId() string { + if o == nil || IsNil(o.ProjectId) { + var ret string + return ret + } + return *o.ProjectId +} + +// GetProjectIdOk returns a tuple with the ProjectId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateWAFPayload) GetProjectIdOk() (*string, bool) { + if o == nil || IsNil(o.ProjectId) { + return nil, false + } + return o.ProjectId, true +} + +// HasProjectId returns a boolean if a field has been set. +func (o *CreateWAFPayload) HasProjectId() bool { + if o != nil && !IsNil(o.ProjectId) { + return true + } + + return false +} + +// SetProjectId gets a reference to the given string and assigns it to the ProjectId field. +func (o *CreateWAFPayload) SetProjectId(v string) { + o.ProjectId = &v +} + +// GetRegion returns the Region field value if set, zero value otherwise. +func (o *CreateWAFPayload) GetRegion() string { + if o == nil || IsNil(o.Region) { + var ret string + return ret + } + return *o.Region +} + +// GetRegionOk returns a tuple with the Region field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateWAFPayload) GetRegionOk() (*string, bool) { + if o == nil || IsNil(o.Region) { + return nil, false + } + return o.Region, true +} + +// HasRegion returns a boolean if a field has been set. +func (o *CreateWAFPayload) HasRegion() bool { + if o != nil && !IsNil(o.Region) { + return true + } + + return false +} + +// SetRegion gets a reference to the given string and assigns it to the Region field. +func (o *CreateWAFPayload) SetRegion(v string) { + o.Region = &v +} + +// GetRulesConfigName returns the RulesConfigName field value if set, zero value otherwise. +func (o *CreateWAFPayload) GetRulesConfigName() string { + if o == nil || IsNil(o.RulesConfigName) { + var ret string + return ret + } + return *o.RulesConfigName +} + +// GetRulesConfigNameOk returns a tuple with the RulesConfigName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateWAFPayload) GetRulesConfigNameOk() (*string, bool) { + if o == nil || IsNil(o.RulesConfigName) { + return nil, false + } + return o.RulesConfigName, true +} + +// HasRulesConfigName returns a boolean if a field has been set. +func (o *CreateWAFPayload) HasRulesConfigName() bool { + if o != nil && !IsNil(o.RulesConfigName) { + return true + } + + return false +} + +// SetRulesConfigName gets a reference to the given string and assigns it to the RulesConfigName field. +func (o *CreateWAFPayload) SetRulesConfigName(v string) { + o.RulesConfigName = &v +} + +func (o CreateWAFPayload) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o CreateWAFPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.CoreRuleSetName) { + toSerialize["coreRuleSetName"] = o.CoreRuleSetName + } + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.ProjectId) { + toSerialize["projectId"] = o.ProjectId + } + if !IsNil(o.Region) { + toSerialize["region"] = o.Region + } + if !IsNil(o.RulesConfigName) { + toSerialize["rulesConfigName"] = o.RulesConfigName + } + return toSerialize, nil +} + +type NullableCreateWAFPayload struct { + value *CreateWAFPayload + isSet bool +} + +func (v NullableCreateWAFPayload) Get() *CreateWAFPayload { + return v.value +} + +func (v *NullableCreateWAFPayload) Set(val *CreateWAFPayload) { + v.value = val + v.isSet = true +} + +func (v NullableCreateWAFPayload) IsSet() bool { + return v.isSet +} + +func (v *NullableCreateWAFPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCreateWAFPayload(val *CreateWAFPayload) *NullableCreateWAFPayload { + return &NullableCreateWAFPayload{value: val, isSet: true} +} + +func (v NullableCreateWAFPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCreateWAFPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_create_waf_response.go b/services/albwaf/v1alphaapi/model_create_waf_response.go new file mode 100644 index 000000000..105c5d960 --- /dev/null +++ b/services/albwaf/v1alphaapi/model_create_waf_response.go @@ -0,0 +1,236 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the CreateWAFResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &CreateWAFResponse{} + +// CreateWAFResponse CreateWAFResponse returns name and custom rules. +type CreateWAFResponse struct { + // Name of the core rule set configuration for that WAF. + CoreRuleSetName *string `json:"coreRuleSetName,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` + // WAF name + Name *string `json:"name,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` + // Region + Region *string `json:"region,omitempty" validate:"regexp=^[a-z]{2,4}[0-9]{2}$"` + // Name of the rule configuration for that WAF. + RulesConfigName *string `json:"rulesConfigName,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` +} + +// NewCreateWAFResponse instantiates a new CreateWAFResponse object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewCreateWAFResponse() *CreateWAFResponse { + this := CreateWAFResponse{} + return &this +} + +// NewCreateWAFResponseWithDefaults instantiates a new CreateWAFResponse object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewCreateWAFResponseWithDefaults() *CreateWAFResponse { + this := CreateWAFResponse{} + return &this +} + +// GetCoreRuleSetName returns the CoreRuleSetName field value if set, zero value otherwise. +func (o *CreateWAFResponse) GetCoreRuleSetName() string { + if o == nil || IsNil(o.CoreRuleSetName) { + var ret string + return ret + } + return *o.CoreRuleSetName +} + +// GetCoreRuleSetNameOk returns a tuple with the CoreRuleSetName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateWAFResponse) GetCoreRuleSetNameOk() (*string, bool) { + if o == nil || IsNil(o.CoreRuleSetName) { + return nil, false + } + return o.CoreRuleSetName, true +} + +// HasCoreRuleSetName returns a boolean if a field has been set. +func (o *CreateWAFResponse) HasCoreRuleSetName() bool { + if o != nil && !IsNil(o.CoreRuleSetName) { + return true + } + + return false +} + +// SetCoreRuleSetName gets a reference to the given string and assigns it to the CoreRuleSetName field. +func (o *CreateWAFResponse) SetCoreRuleSetName(v string) { + o.CoreRuleSetName = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *CreateWAFResponse) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateWAFResponse) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *CreateWAFResponse) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *CreateWAFResponse) SetName(v string) { + o.Name = &v +} + +// GetRegion returns the Region field value if set, zero value otherwise. +func (o *CreateWAFResponse) GetRegion() string { + if o == nil || IsNil(o.Region) { + var ret string + return ret + } + return *o.Region +} + +// GetRegionOk returns a tuple with the Region field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateWAFResponse) GetRegionOk() (*string, bool) { + if o == nil || IsNil(o.Region) { + return nil, false + } + return o.Region, true +} + +// HasRegion returns a boolean if a field has been set. +func (o *CreateWAFResponse) HasRegion() bool { + if o != nil && !IsNil(o.Region) { + return true + } + + return false +} + +// SetRegion gets a reference to the given string and assigns it to the Region field. +func (o *CreateWAFResponse) SetRegion(v string) { + o.Region = &v +} + +// GetRulesConfigName returns the RulesConfigName field value if set, zero value otherwise. +func (o *CreateWAFResponse) GetRulesConfigName() string { + if o == nil || IsNil(o.RulesConfigName) { + var ret string + return ret + } + return *o.RulesConfigName +} + +// GetRulesConfigNameOk returns a tuple with the RulesConfigName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateWAFResponse) GetRulesConfigNameOk() (*string, bool) { + if o == nil || IsNil(o.RulesConfigName) { + return nil, false + } + return o.RulesConfigName, true +} + +// HasRulesConfigName returns a boolean if a field has been set. +func (o *CreateWAFResponse) HasRulesConfigName() bool { + if o != nil && !IsNil(o.RulesConfigName) { + return true + } + + return false +} + +// SetRulesConfigName gets a reference to the given string and assigns it to the RulesConfigName field. +func (o *CreateWAFResponse) SetRulesConfigName(v string) { + o.RulesConfigName = &v +} + +func (o CreateWAFResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o CreateWAFResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.CoreRuleSetName) { + toSerialize["coreRuleSetName"] = o.CoreRuleSetName + } + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.Region) { + toSerialize["region"] = o.Region + } + if !IsNil(o.RulesConfigName) { + toSerialize["rulesConfigName"] = o.RulesConfigName + } + return toSerialize, nil +} + +type NullableCreateWAFResponse struct { + value *CreateWAFResponse + isSet bool +} + +func (v NullableCreateWAFResponse) Get() *CreateWAFResponse { + return v.value +} + +func (v *NullableCreateWAFResponse) Set(val *CreateWAFResponse) { + v.value = val + v.isSet = true +} + +func (v NullableCreateWAFResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableCreateWAFResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCreateWAFResponse(val *CreateWAFResponse) *NullableCreateWAFResponse { + return &NullableCreateWAFResponse{value: val, isSet: true} +} + +func (v NullableCreateWAFResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCreateWAFResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_get_core_rule_set_response.go b/services/albwaf/v1alphaapi/model_get_core_rule_set_response.go new file mode 100644 index 000000000..ba1edb1db --- /dev/null +++ b/services/albwaf/v1alphaapi/model_get_core_rule_set_response.go @@ -0,0 +1,199 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the GetCoreRuleSetResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &GetCoreRuleSetResponse{} + +// GetCoreRuleSetResponse GetCoreRuleSetResponse returns rule configuration name and it's rules. +type GetCoreRuleSetResponse struct { + // Indicates if the OWASP core rule set is active. + Active *bool `json:"active,omitempty"` + // Core rule set configuration name. + Name *string `json:"name,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` + // Region + Region *string `json:"region,omitempty" validate:"regexp=^[a-z]{2,4}[0-9]{2}$"` +} + +// NewGetCoreRuleSetResponse instantiates a new GetCoreRuleSetResponse object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewGetCoreRuleSetResponse() *GetCoreRuleSetResponse { + this := GetCoreRuleSetResponse{} + return &this +} + +// NewGetCoreRuleSetResponseWithDefaults instantiates a new GetCoreRuleSetResponse object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewGetCoreRuleSetResponseWithDefaults() *GetCoreRuleSetResponse { + this := GetCoreRuleSetResponse{} + return &this +} + +// GetActive returns the Active field value if set, zero value otherwise. +func (o *GetCoreRuleSetResponse) GetActive() bool { + if o == nil || IsNil(o.Active) { + var ret bool + return ret + } + return *o.Active +} + +// GetActiveOk returns a tuple with the Active field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetCoreRuleSetResponse) GetActiveOk() (*bool, bool) { + if o == nil || IsNil(o.Active) { + return nil, false + } + return o.Active, true +} + +// HasActive returns a boolean if a field has been set. +func (o *GetCoreRuleSetResponse) HasActive() bool { + if o != nil && !IsNil(o.Active) { + return true + } + + return false +} + +// SetActive gets a reference to the given bool and assigns it to the Active field. +func (o *GetCoreRuleSetResponse) SetActive(v bool) { + o.Active = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *GetCoreRuleSetResponse) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetCoreRuleSetResponse) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *GetCoreRuleSetResponse) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *GetCoreRuleSetResponse) SetName(v string) { + o.Name = &v +} + +// GetRegion returns the Region field value if set, zero value otherwise. +func (o *GetCoreRuleSetResponse) GetRegion() string { + if o == nil || IsNil(o.Region) { + var ret string + return ret + } + return *o.Region +} + +// GetRegionOk returns a tuple with the Region field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetCoreRuleSetResponse) GetRegionOk() (*string, bool) { + if o == nil || IsNil(o.Region) { + return nil, false + } + return o.Region, true +} + +// HasRegion returns a boolean if a field has been set. +func (o *GetCoreRuleSetResponse) HasRegion() bool { + if o != nil && !IsNil(o.Region) { + return true + } + + return false +} + +// SetRegion gets a reference to the given string and assigns it to the Region field. +func (o *GetCoreRuleSetResponse) SetRegion(v string) { + o.Region = &v +} + +func (o GetCoreRuleSetResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o GetCoreRuleSetResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Active) { + toSerialize["active"] = o.Active + } + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.Region) { + toSerialize["region"] = o.Region + } + return toSerialize, nil +} + +type NullableGetCoreRuleSetResponse struct { + value *GetCoreRuleSetResponse + isSet bool +} + +func (v NullableGetCoreRuleSetResponse) Get() *GetCoreRuleSetResponse { + return v.value +} + +func (v *NullableGetCoreRuleSetResponse) Set(val *GetCoreRuleSetResponse) { + v.value = val + v.isSet = true +} + +func (v NullableGetCoreRuleSetResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableGetCoreRuleSetResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableGetCoreRuleSetResponse(val *GetCoreRuleSetResponse) *NullableGetCoreRuleSetResponse { + return &NullableGetCoreRuleSetResponse{value: val, isSet: true} +} + +func (v NullableGetCoreRuleSetResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableGetCoreRuleSetResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_get_rules_response.go b/services/albwaf/v1alphaapi/model_get_rules_response.go new file mode 100644 index 000000000..12f5cd35b --- /dev/null +++ b/services/albwaf/v1alphaapi/model_get_rules_response.go @@ -0,0 +1,199 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the GetRulesResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &GetRulesResponse{} + +// GetRulesResponse GetRulesResponse returns rule configuration name and it's rules. +type GetRulesResponse struct { + // Rule configuration name. + Name *string `json:"name,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` + // Region + Region *string `json:"region,omitempty" validate:"regexp=^[a-z]{2,4}[0-9]{2}$"` + // Custom rules written in Seclang syntax. + Rules *string `json:"rules,omitempty"` +} + +// NewGetRulesResponse instantiates a new GetRulesResponse object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewGetRulesResponse() *GetRulesResponse { + this := GetRulesResponse{} + return &this +} + +// NewGetRulesResponseWithDefaults instantiates a new GetRulesResponse object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewGetRulesResponseWithDefaults() *GetRulesResponse { + this := GetRulesResponse{} + return &this +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *GetRulesResponse) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetRulesResponse) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *GetRulesResponse) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *GetRulesResponse) SetName(v string) { + o.Name = &v +} + +// GetRegion returns the Region field value if set, zero value otherwise. +func (o *GetRulesResponse) GetRegion() string { + if o == nil || IsNil(o.Region) { + var ret string + return ret + } + return *o.Region +} + +// GetRegionOk returns a tuple with the Region field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetRulesResponse) GetRegionOk() (*string, bool) { + if o == nil || IsNil(o.Region) { + return nil, false + } + return o.Region, true +} + +// HasRegion returns a boolean if a field has been set. +func (o *GetRulesResponse) HasRegion() bool { + if o != nil && !IsNil(o.Region) { + return true + } + + return false +} + +// SetRegion gets a reference to the given string and assigns it to the Region field. +func (o *GetRulesResponse) SetRegion(v string) { + o.Region = &v +} + +// GetRules returns the Rules field value if set, zero value otherwise. +func (o *GetRulesResponse) GetRules() string { + if o == nil || IsNil(o.Rules) { + var ret string + return ret + } + return *o.Rules +} + +// GetRulesOk returns a tuple with the Rules field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetRulesResponse) GetRulesOk() (*string, bool) { + if o == nil || IsNil(o.Rules) { + return nil, false + } + return o.Rules, true +} + +// HasRules returns a boolean if a field has been set. +func (o *GetRulesResponse) HasRules() bool { + if o != nil && !IsNil(o.Rules) { + return true + } + + return false +} + +// SetRules gets a reference to the given string and assigns it to the Rules field. +func (o *GetRulesResponse) SetRules(v string) { + o.Rules = &v +} + +func (o GetRulesResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o GetRulesResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.Region) { + toSerialize["region"] = o.Region + } + if !IsNil(o.Rules) { + toSerialize["rules"] = o.Rules + } + return toSerialize, nil +} + +type NullableGetRulesResponse struct { + value *GetRulesResponse + isSet bool +} + +func (v NullableGetRulesResponse) Get() *GetRulesResponse { + return v.value +} + +func (v *NullableGetRulesResponse) Set(val *GetRulesResponse) { + v.value = val + v.isSet = true +} + +func (v NullableGetRulesResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableGetRulesResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableGetRulesResponse(val *GetRulesResponse) *NullableGetRulesResponse { + return &NullableGetRulesResponse{value: val, isSet: true} +} + +func (v NullableGetRulesResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableGetRulesResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_get_waf_response.go b/services/albwaf/v1alphaapi/model_get_waf_response.go new file mode 100644 index 000000000..e07bd1273 --- /dev/null +++ b/services/albwaf/v1alphaapi/model_get_waf_response.go @@ -0,0 +1,236 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the GetWAFResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &GetWAFResponse{} + +// GetWAFResponse GetWAFResponse returns id, name and custom rules. +type GetWAFResponse struct { + // Name of the core rule set configuration for that WAF. + CoreRuleSetName *string `json:"coreRuleSetName,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` + // WAF name + Name *string `json:"name,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` + // Region + Region *string `json:"region,omitempty" validate:"regexp=^[a-z]{2,4}[0-9]{2}$"` + // Name of the rule configuration for that WAF. + RulesConfigName *string `json:"rulesConfigName,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` +} + +// NewGetWAFResponse instantiates a new GetWAFResponse object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewGetWAFResponse() *GetWAFResponse { + this := GetWAFResponse{} + return &this +} + +// NewGetWAFResponseWithDefaults instantiates a new GetWAFResponse object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewGetWAFResponseWithDefaults() *GetWAFResponse { + this := GetWAFResponse{} + return &this +} + +// GetCoreRuleSetName returns the CoreRuleSetName field value if set, zero value otherwise. +func (o *GetWAFResponse) GetCoreRuleSetName() string { + if o == nil || IsNil(o.CoreRuleSetName) { + var ret string + return ret + } + return *o.CoreRuleSetName +} + +// GetCoreRuleSetNameOk returns a tuple with the CoreRuleSetName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetWAFResponse) GetCoreRuleSetNameOk() (*string, bool) { + if o == nil || IsNil(o.CoreRuleSetName) { + return nil, false + } + return o.CoreRuleSetName, true +} + +// HasCoreRuleSetName returns a boolean if a field has been set. +func (o *GetWAFResponse) HasCoreRuleSetName() bool { + if o != nil && !IsNil(o.CoreRuleSetName) { + return true + } + + return false +} + +// SetCoreRuleSetName gets a reference to the given string and assigns it to the CoreRuleSetName field. +func (o *GetWAFResponse) SetCoreRuleSetName(v string) { + o.CoreRuleSetName = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *GetWAFResponse) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetWAFResponse) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *GetWAFResponse) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *GetWAFResponse) SetName(v string) { + o.Name = &v +} + +// GetRegion returns the Region field value if set, zero value otherwise. +func (o *GetWAFResponse) GetRegion() string { + if o == nil || IsNil(o.Region) { + var ret string + return ret + } + return *o.Region +} + +// GetRegionOk returns a tuple with the Region field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetWAFResponse) GetRegionOk() (*string, bool) { + if o == nil || IsNil(o.Region) { + return nil, false + } + return o.Region, true +} + +// HasRegion returns a boolean if a field has been set. +func (o *GetWAFResponse) HasRegion() bool { + if o != nil && !IsNil(o.Region) { + return true + } + + return false +} + +// SetRegion gets a reference to the given string and assigns it to the Region field. +func (o *GetWAFResponse) SetRegion(v string) { + o.Region = &v +} + +// GetRulesConfigName returns the RulesConfigName field value if set, zero value otherwise. +func (o *GetWAFResponse) GetRulesConfigName() string { + if o == nil || IsNil(o.RulesConfigName) { + var ret string + return ret + } + return *o.RulesConfigName +} + +// GetRulesConfigNameOk returns a tuple with the RulesConfigName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetWAFResponse) GetRulesConfigNameOk() (*string, bool) { + if o == nil || IsNil(o.RulesConfigName) { + return nil, false + } + return o.RulesConfigName, true +} + +// HasRulesConfigName returns a boolean if a field has been set. +func (o *GetWAFResponse) HasRulesConfigName() bool { + if o != nil && !IsNil(o.RulesConfigName) { + return true + } + + return false +} + +// SetRulesConfigName gets a reference to the given string and assigns it to the RulesConfigName field. +func (o *GetWAFResponse) SetRulesConfigName(v string) { + o.RulesConfigName = &v +} + +func (o GetWAFResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o GetWAFResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.CoreRuleSetName) { + toSerialize["coreRuleSetName"] = o.CoreRuleSetName + } + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.Region) { + toSerialize["region"] = o.Region + } + if !IsNil(o.RulesConfigName) { + toSerialize["rulesConfigName"] = o.RulesConfigName + } + return toSerialize, nil +} + +type NullableGetWAFResponse struct { + value *GetWAFResponse + isSet bool +} + +func (v NullableGetWAFResponse) Get() *GetWAFResponse { + return v.value +} + +func (v *NullableGetWAFResponse) Set(val *GetWAFResponse) { + v.value = val + v.isSet = true +} + +func (v NullableGetWAFResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableGetWAFResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableGetWAFResponse(val *GetWAFResponse) *NullableGetWAFResponse { + return &NullableGetWAFResponse{value: val, isSet: true} +} + +func (v NullableGetWAFResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableGetWAFResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_google_protobuf_any.go b/services/albwaf/v1alphaapi/model_google_protobuf_any.go new file mode 100644 index 000000000..0508a5d04 --- /dev/null +++ b/services/albwaf/v1alphaapi/model_google_protobuf_any.go @@ -0,0 +1,154 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the GoogleProtobufAny type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &GoogleProtobufAny{} + +// GoogleProtobufAny Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. +type GoogleProtobufAny struct { + // The type of the serialized message. + Type *string `json:"@type,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _GoogleProtobufAny GoogleProtobufAny + +// NewGoogleProtobufAny instantiates a new GoogleProtobufAny object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewGoogleProtobufAny() *GoogleProtobufAny { + this := GoogleProtobufAny{} + return &this +} + +// NewGoogleProtobufAnyWithDefaults instantiates a new GoogleProtobufAny object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewGoogleProtobufAnyWithDefaults() *GoogleProtobufAny { + this := GoogleProtobufAny{} + return &this +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *GoogleProtobufAny) GetType() string { + if o == nil || IsNil(o.Type) { + var ret string + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GoogleProtobufAny) GetTypeOk() (*string, bool) { + if o == nil || IsNil(o.Type) { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *GoogleProtobufAny) HasType() bool { + if o != nil && !IsNil(o.Type) { + return true + } + + return false +} + +// SetType gets a reference to the given string and assigns it to the Type field. +func (o *GoogleProtobufAny) SetType(v string) { + o.Type = &v +} + +func (o GoogleProtobufAny) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o GoogleProtobufAny) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Type) { + toSerialize["@type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *GoogleProtobufAny) UnmarshalJSON(data []byte) (err error) { + varGoogleProtobufAny := _GoogleProtobufAny{} + + err = json.Unmarshal(data, &varGoogleProtobufAny) + + if err != nil { + return err + } + + *o = GoogleProtobufAny(varGoogleProtobufAny) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "@type") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableGoogleProtobufAny struct { + value *GoogleProtobufAny + isSet bool +} + +func (v NullableGoogleProtobufAny) Get() *GoogleProtobufAny { + return v.value +} + +func (v *NullableGoogleProtobufAny) Set(val *GoogleProtobufAny) { + v.value = val + v.isSet = true +} + +func (v NullableGoogleProtobufAny) IsSet() bool { + return v.isSet +} + +func (v *NullableGoogleProtobufAny) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableGoogleProtobufAny(val *GoogleProtobufAny) *NullableGoogleProtobufAny { + return &NullableGoogleProtobufAny{value: val, isSet: true} +} + +func (v NullableGoogleProtobufAny) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableGoogleProtobufAny) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_list_core_rule_set_response.go b/services/albwaf/v1alphaapi/model_list_core_rule_set_response.go new file mode 100644 index 000000000..9023bab2f --- /dev/null +++ b/services/albwaf/v1alphaapi/model_list_core_rule_set_response.go @@ -0,0 +1,161 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the ListCoreRuleSetResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ListCoreRuleSetResponse{} + +// ListCoreRuleSetResponse ListCoreRuleSetResponse returns a list of rule configuration responses. +type ListCoreRuleSetResponse struct { + Items []GetCoreRuleSetResponse `json:"items,omitempty"` + // Continue token from the ListCoreRuleSetResponse with Limit option + NextPageId *string `json:"nextPageId,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` +} + +// NewListCoreRuleSetResponse instantiates a new ListCoreRuleSetResponse object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewListCoreRuleSetResponse() *ListCoreRuleSetResponse { + this := ListCoreRuleSetResponse{} + return &this +} + +// NewListCoreRuleSetResponseWithDefaults instantiates a new ListCoreRuleSetResponse object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewListCoreRuleSetResponseWithDefaults() *ListCoreRuleSetResponse { + this := ListCoreRuleSetResponse{} + return &this +} + +// GetItems returns the Items field value if set, zero value otherwise. +func (o *ListCoreRuleSetResponse) GetItems() []GetCoreRuleSetResponse { + if o == nil || IsNil(o.Items) { + var ret []GetCoreRuleSetResponse + return ret + } + return o.Items +} + +// GetItemsOk returns a tuple with the Items field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ListCoreRuleSetResponse) GetItemsOk() ([]GetCoreRuleSetResponse, bool) { + if o == nil || IsNil(o.Items) { + return nil, false + } + return o.Items, true +} + +// HasItems returns a boolean if a field has been set. +func (o *ListCoreRuleSetResponse) HasItems() bool { + if o != nil && !IsNil(o.Items) { + return true + } + + return false +} + +// SetItems gets a reference to the given []GetCoreRuleSetResponse and assigns it to the Items field. +func (o *ListCoreRuleSetResponse) SetItems(v []GetCoreRuleSetResponse) { + o.Items = v +} + +// GetNextPageId returns the NextPageId field value if set, zero value otherwise. +func (o *ListCoreRuleSetResponse) GetNextPageId() string { + if o == nil || IsNil(o.NextPageId) { + var ret string + return ret + } + return *o.NextPageId +} + +// GetNextPageIdOk returns a tuple with the NextPageId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ListCoreRuleSetResponse) GetNextPageIdOk() (*string, bool) { + if o == nil || IsNil(o.NextPageId) { + return nil, false + } + return o.NextPageId, true +} + +// HasNextPageId returns a boolean if a field has been set. +func (o *ListCoreRuleSetResponse) HasNextPageId() bool { + if o != nil && !IsNil(o.NextPageId) { + return true + } + + return false +} + +// SetNextPageId gets a reference to the given string and assigns it to the NextPageId field. +func (o *ListCoreRuleSetResponse) SetNextPageId(v string) { + o.NextPageId = &v +} + +func (o ListCoreRuleSetResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ListCoreRuleSetResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Items) { + toSerialize["items"] = o.Items + } + if !IsNil(o.NextPageId) { + toSerialize["nextPageId"] = o.NextPageId + } + return toSerialize, nil +} + +type NullableListCoreRuleSetResponse struct { + value *ListCoreRuleSetResponse + isSet bool +} + +func (v NullableListCoreRuleSetResponse) Get() *ListCoreRuleSetResponse { + return v.value +} + +func (v *NullableListCoreRuleSetResponse) Set(val *ListCoreRuleSetResponse) { + v.value = val + v.isSet = true +} + +func (v NullableListCoreRuleSetResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableListCoreRuleSetResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableListCoreRuleSetResponse(val *ListCoreRuleSetResponse) *NullableListCoreRuleSetResponse { + return &NullableListCoreRuleSetResponse{value: val, isSet: true} +} + +func (v NullableListCoreRuleSetResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableListCoreRuleSetResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_list_rules_response.go b/services/albwaf/v1alphaapi/model_list_rules_response.go new file mode 100644 index 000000000..28866e645 --- /dev/null +++ b/services/albwaf/v1alphaapi/model_list_rules_response.go @@ -0,0 +1,161 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the ListRulesResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ListRulesResponse{} + +// ListRulesResponse ListRulesResponse returns a list of rule configuration responses. +type ListRulesResponse struct { + Items []GetRulesResponse `json:"items,omitempty"` + // Continue token from the ListRulesResponse with Limit option + NextPageId *string `json:"nextPageId,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` +} + +// NewListRulesResponse instantiates a new ListRulesResponse object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewListRulesResponse() *ListRulesResponse { + this := ListRulesResponse{} + return &this +} + +// NewListRulesResponseWithDefaults instantiates a new ListRulesResponse object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewListRulesResponseWithDefaults() *ListRulesResponse { + this := ListRulesResponse{} + return &this +} + +// GetItems returns the Items field value if set, zero value otherwise. +func (o *ListRulesResponse) GetItems() []GetRulesResponse { + if o == nil || IsNil(o.Items) { + var ret []GetRulesResponse + return ret + } + return o.Items +} + +// GetItemsOk returns a tuple with the Items field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ListRulesResponse) GetItemsOk() ([]GetRulesResponse, bool) { + if o == nil || IsNil(o.Items) { + return nil, false + } + return o.Items, true +} + +// HasItems returns a boolean if a field has been set. +func (o *ListRulesResponse) HasItems() bool { + if o != nil && !IsNil(o.Items) { + return true + } + + return false +} + +// SetItems gets a reference to the given []GetRulesResponse and assigns it to the Items field. +func (o *ListRulesResponse) SetItems(v []GetRulesResponse) { + o.Items = v +} + +// GetNextPageId returns the NextPageId field value if set, zero value otherwise. +func (o *ListRulesResponse) GetNextPageId() string { + if o == nil || IsNil(o.NextPageId) { + var ret string + return ret + } + return *o.NextPageId +} + +// GetNextPageIdOk returns a tuple with the NextPageId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ListRulesResponse) GetNextPageIdOk() (*string, bool) { + if o == nil || IsNil(o.NextPageId) { + return nil, false + } + return o.NextPageId, true +} + +// HasNextPageId returns a boolean if a field has been set. +func (o *ListRulesResponse) HasNextPageId() bool { + if o != nil && !IsNil(o.NextPageId) { + return true + } + + return false +} + +// SetNextPageId gets a reference to the given string and assigns it to the NextPageId field. +func (o *ListRulesResponse) SetNextPageId(v string) { + o.NextPageId = &v +} + +func (o ListRulesResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ListRulesResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Items) { + toSerialize["items"] = o.Items + } + if !IsNil(o.NextPageId) { + toSerialize["nextPageId"] = o.NextPageId + } + return toSerialize, nil +} + +type NullableListRulesResponse struct { + value *ListRulesResponse + isSet bool +} + +func (v NullableListRulesResponse) Get() *ListRulesResponse { + return v.value +} + +func (v *NullableListRulesResponse) Set(val *ListRulesResponse) { + v.value = val + v.isSet = true +} + +func (v NullableListRulesResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableListRulesResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableListRulesResponse(val *ListRulesResponse) *NullableListRulesResponse { + return &NullableListRulesResponse{value: val, isSet: true} +} + +func (v NullableListRulesResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableListRulesResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_list_waf_response.go b/services/albwaf/v1alphaapi/model_list_waf_response.go new file mode 100644 index 000000000..ceeaa0dd6 --- /dev/null +++ b/services/albwaf/v1alphaapi/model_list_waf_response.go @@ -0,0 +1,161 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the ListWAFResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ListWAFResponse{} + +// ListWAFResponse ListWAFResponse returns a list of WAF responses. +type ListWAFResponse struct { + Items []GetWAFResponse `json:"items,omitempty"` + // Continue token from the ListWAFResponse with Limit option + NextPageId *string `json:"nextPageId,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` +} + +// NewListWAFResponse instantiates a new ListWAFResponse object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewListWAFResponse() *ListWAFResponse { + this := ListWAFResponse{} + return &this +} + +// NewListWAFResponseWithDefaults instantiates a new ListWAFResponse object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewListWAFResponseWithDefaults() *ListWAFResponse { + this := ListWAFResponse{} + return &this +} + +// GetItems returns the Items field value if set, zero value otherwise. +func (o *ListWAFResponse) GetItems() []GetWAFResponse { + if o == nil || IsNil(o.Items) { + var ret []GetWAFResponse + return ret + } + return o.Items +} + +// GetItemsOk returns a tuple with the Items field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ListWAFResponse) GetItemsOk() ([]GetWAFResponse, bool) { + if o == nil || IsNil(o.Items) { + return nil, false + } + return o.Items, true +} + +// HasItems returns a boolean if a field has been set. +func (o *ListWAFResponse) HasItems() bool { + if o != nil && !IsNil(o.Items) { + return true + } + + return false +} + +// SetItems gets a reference to the given []GetWAFResponse and assigns it to the Items field. +func (o *ListWAFResponse) SetItems(v []GetWAFResponse) { + o.Items = v +} + +// GetNextPageId returns the NextPageId field value if set, zero value otherwise. +func (o *ListWAFResponse) GetNextPageId() string { + if o == nil || IsNil(o.NextPageId) { + var ret string + return ret + } + return *o.NextPageId +} + +// GetNextPageIdOk returns a tuple with the NextPageId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ListWAFResponse) GetNextPageIdOk() (*string, bool) { + if o == nil || IsNil(o.NextPageId) { + return nil, false + } + return o.NextPageId, true +} + +// HasNextPageId returns a boolean if a field has been set. +func (o *ListWAFResponse) HasNextPageId() bool { + if o != nil && !IsNil(o.NextPageId) { + return true + } + + return false +} + +// SetNextPageId gets a reference to the given string and assigns it to the NextPageId field. +func (o *ListWAFResponse) SetNextPageId(v string) { + o.NextPageId = &v +} + +func (o ListWAFResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ListWAFResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Items) { + toSerialize["items"] = o.Items + } + if !IsNil(o.NextPageId) { + toSerialize["nextPageId"] = o.NextPageId + } + return toSerialize, nil +} + +type NullableListWAFResponse struct { + value *ListWAFResponse + isSet bool +} + +func (v NullableListWAFResponse) Get() *ListWAFResponse { + return v.value +} + +func (v *NullableListWAFResponse) Set(val *ListWAFResponse) { + v.value = val + v.isSet = true +} + +func (v NullableListWAFResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableListWAFResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableListWAFResponse(val *ListWAFResponse) *NullableListWAFResponse { + return &NullableListWAFResponse{value: val, isSet: true} +} + +func (v NullableListWAFResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableListWAFResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_status.go b/services/albwaf/v1alphaapi/model_status.go new file mode 100644 index 000000000..a6df30dd9 --- /dev/null +++ b/services/albwaf/v1alphaapi/model_status.go @@ -0,0 +1,199 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the Status type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Status{} + +// Status The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). +type Status struct { + // The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. + Code *int32 `json:"code,omitempty"` + // A list of messages that carry the error details. There is a common set of message types for APIs to use. + Details []GoogleProtobufAny `json:"details,omitempty"` + // A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. + Message *string `json:"message,omitempty"` +} + +// NewStatus instantiates a new Status object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewStatus() *Status { + this := Status{} + return &this +} + +// NewStatusWithDefaults instantiates a new Status object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewStatusWithDefaults() *Status { + this := Status{} + return &this +} + +// GetCode returns the Code field value if set, zero value otherwise. +func (o *Status) GetCode() int32 { + if o == nil || IsNil(o.Code) { + var ret int32 + return ret + } + return *o.Code +} + +// GetCodeOk returns a tuple with the Code field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Status) GetCodeOk() (*int32, bool) { + if o == nil || IsNil(o.Code) { + return nil, false + } + return o.Code, true +} + +// HasCode returns a boolean if a field has been set. +func (o *Status) HasCode() bool { + if o != nil && !IsNil(o.Code) { + return true + } + + return false +} + +// SetCode gets a reference to the given int32 and assigns it to the Code field. +func (o *Status) SetCode(v int32) { + o.Code = &v +} + +// GetDetails returns the Details field value if set, zero value otherwise. +func (o *Status) GetDetails() []GoogleProtobufAny { + if o == nil || IsNil(o.Details) { + var ret []GoogleProtobufAny + return ret + } + return o.Details +} + +// GetDetailsOk returns a tuple with the Details field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Status) GetDetailsOk() ([]GoogleProtobufAny, bool) { + if o == nil || IsNil(o.Details) { + return nil, false + } + return o.Details, true +} + +// HasDetails returns a boolean if a field has been set. +func (o *Status) HasDetails() bool { + if o != nil && !IsNil(o.Details) { + return true + } + + return false +} + +// SetDetails gets a reference to the given []GoogleProtobufAny and assigns it to the Details field. +func (o *Status) SetDetails(v []GoogleProtobufAny) { + o.Details = v +} + +// GetMessage returns the Message field value if set, zero value otherwise. +func (o *Status) GetMessage() string { + if o == nil || IsNil(o.Message) { + var ret string + return ret + } + return *o.Message +} + +// GetMessageOk returns a tuple with the Message field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Status) GetMessageOk() (*string, bool) { + if o == nil || IsNil(o.Message) { + return nil, false + } + return o.Message, true +} + +// HasMessage returns a boolean if a field has been set. +func (o *Status) HasMessage() bool { + if o != nil && !IsNil(o.Message) { + return true + } + + return false +} + +// SetMessage gets a reference to the given string and assigns it to the Message field. +func (o *Status) SetMessage(v string) { + o.Message = &v +} + +func (o Status) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o Status) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Code) { + toSerialize["code"] = o.Code + } + if !IsNil(o.Details) { + toSerialize["details"] = o.Details + } + if !IsNil(o.Message) { + toSerialize["message"] = o.Message + } + return toSerialize, nil +} + +type NullableStatus struct { + value *Status + isSet bool +} + +func (v NullableStatus) Get() *Status { + return v.value +} + +func (v *NullableStatus) Set(val *Status) { + v.value = val + v.isSet = true +} + +func (v NullableStatus) IsSet() bool { + return v.isSet +} + +func (v *NullableStatus) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableStatus(val *Status) *NullableStatus { + return &NullableStatus{value: val, isSet: true} +} + +func (v NullableStatus) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableStatus) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_update_core_rule_set_payload.go b/services/albwaf/v1alphaapi/model_update_core_rule_set_payload.go new file mode 100644 index 000000000..3601370cf --- /dev/null +++ b/services/albwaf/v1alphaapi/model_update_core_rule_set_payload.go @@ -0,0 +1,236 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the UpdateCoreRuleSetPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &UpdateCoreRuleSetPayload{} + +// UpdateCoreRuleSetPayload UpdateCoreRuleSetRequest updates a rules configuration, but only if it changed. +type UpdateCoreRuleSetPayload struct { + // To activate the OWASP core rule set, set this boolean to true. + Active *bool `json:"active,omitempty"` + // Core rule set configuration name. + Name *string `json:"name,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` + // Project identifier + ProjectId *string `json:"projectId,omitempty" validate:"regexp=^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"` + // Region + Region *string `json:"region,omitempty" validate:"regexp=^[a-z]{2,4}[0-9]{2}$"` +} + +// NewUpdateCoreRuleSetPayload instantiates a new UpdateCoreRuleSetPayload object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewUpdateCoreRuleSetPayload() *UpdateCoreRuleSetPayload { + this := UpdateCoreRuleSetPayload{} + return &this +} + +// NewUpdateCoreRuleSetPayloadWithDefaults instantiates a new UpdateCoreRuleSetPayload object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewUpdateCoreRuleSetPayloadWithDefaults() *UpdateCoreRuleSetPayload { + this := UpdateCoreRuleSetPayload{} + return &this +} + +// GetActive returns the Active field value if set, zero value otherwise. +func (o *UpdateCoreRuleSetPayload) GetActive() bool { + if o == nil || IsNil(o.Active) { + var ret bool + return ret + } + return *o.Active +} + +// GetActiveOk returns a tuple with the Active field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateCoreRuleSetPayload) GetActiveOk() (*bool, bool) { + if o == nil || IsNil(o.Active) { + return nil, false + } + return o.Active, true +} + +// HasActive returns a boolean if a field has been set. +func (o *UpdateCoreRuleSetPayload) HasActive() bool { + if o != nil && !IsNil(o.Active) { + return true + } + + return false +} + +// SetActive gets a reference to the given bool and assigns it to the Active field. +func (o *UpdateCoreRuleSetPayload) SetActive(v bool) { + o.Active = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *UpdateCoreRuleSetPayload) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateCoreRuleSetPayload) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *UpdateCoreRuleSetPayload) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *UpdateCoreRuleSetPayload) SetName(v string) { + o.Name = &v +} + +// GetProjectId returns the ProjectId field value if set, zero value otherwise. +func (o *UpdateCoreRuleSetPayload) GetProjectId() string { + if o == nil || IsNil(o.ProjectId) { + var ret string + return ret + } + return *o.ProjectId +} + +// GetProjectIdOk returns a tuple with the ProjectId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateCoreRuleSetPayload) GetProjectIdOk() (*string, bool) { + if o == nil || IsNil(o.ProjectId) { + return nil, false + } + return o.ProjectId, true +} + +// HasProjectId returns a boolean if a field has been set. +func (o *UpdateCoreRuleSetPayload) HasProjectId() bool { + if o != nil && !IsNil(o.ProjectId) { + return true + } + + return false +} + +// SetProjectId gets a reference to the given string and assigns it to the ProjectId field. +func (o *UpdateCoreRuleSetPayload) SetProjectId(v string) { + o.ProjectId = &v +} + +// GetRegion returns the Region field value if set, zero value otherwise. +func (o *UpdateCoreRuleSetPayload) GetRegion() string { + if o == nil || IsNil(o.Region) { + var ret string + return ret + } + return *o.Region +} + +// GetRegionOk returns a tuple with the Region field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateCoreRuleSetPayload) GetRegionOk() (*string, bool) { + if o == nil || IsNil(o.Region) { + return nil, false + } + return o.Region, true +} + +// HasRegion returns a boolean if a field has been set. +func (o *UpdateCoreRuleSetPayload) HasRegion() bool { + if o != nil && !IsNil(o.Region) { + return true + } + + return false +} + +// SetRegion gets a reference to the given string and assigns it to the Region field. +func (o *UpdateCoreRuleSetPayload) SetRegion(v string) { + o.Region = &v +} + +func (o UpdateCoreRuleSetPayload) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o UpdateCoreRuleSetPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Active) { + toSerialize["active"] = o.Active + } + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.ProjectId) { + toSerialize["projectId"] = o.ProjectId + } + if !IsNil(o.Region) { + toSerialize["region"] = o.Region + } + return toSerialize, nil +} + +type NullableUpdateCoreRuleSetPayload struct { + value *UpdateCoreRuleSetPayload + isSet bool +} + +func (v NullableUpdateCoreRuleSetPayload) Get() *UpdateCoreRuleSetPayload { + return v.value +} + +func (v *NullableUpdateCoreRuleSetPayload) Set(val *UpdateCoreRuleSetPayload) { + v.value = val + v.isSet = true +} + +func (v NullableUpdateCoreRuleSetPayload) IsSet() bool { + return v.isSet +} + +func (v *NullableUpdateCoreRuleSetPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableUpdateCoreRuleSetPayload(val *UpdateCoreRuleSetPayload) *NullableUpdateCoreRuleSetPayload { + return &NullableUpdateCoreRuleSetPayload{value: val, isSet: true} +} + +func (v NullableUpdateCoreRuleSetPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableUpdateCoreRuleSetPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_update_core_rule_set_response.go b/services/albwaf/v1alphaapi/model_update_core_rule_set_response.go new file mode 100644 index 000000000..f9010240a --- /dev/null +++ b/services/albwaf/v1alphaapi/model_update_core_rule_set_response.go @@ -0,0 +1,199 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the UpdateCoreRuleSetResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &UpdateCoreRuleSetResponse{} + +// UpdateCoreRuleSetResponse UpdateCoreRuleSetResponse returns rule configuration name and it's rules. +type UpdateCoreRuleSetResponse struct { + // Indicates if the OWASP core rule set is active. + Active *bool `json:"active,omitempty"` + // Core rule set configuration name. + Name *string `json:"name,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` + // Region + Region *string `json:"region,omitempty" validate:"regexp=^[a-z]{2,4}[0-9]{2}$"` +} + +// NewUpdateCoreRuleSetResponse instantiates a new UpdateCoreRuleSetResponse object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewUpdateCoreRuleSetResponse() *UpdateCoreRuleSetResponse { + this := UpdateCoreRuleSetResponse{} + return &this +} + +// NewUpdateCoreRuleSetResponseWithDefaults instantiates a new UpdateCoreRuleSetResponse object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewUpdateCoreRuleSetResponseWithDefaults() *UpdateCoreRuleSetResponse { + this := UpdateCoreRuleSetResponse{} + return &this +} + +// GetActive returns the Active field value if set, zero value otherwise. +func (o *UpdateCoreRuleSetResponse) GetActive() bool { + if o == nil || IsNil(o.Active) { + var ret bool + return ret + } + return *o.Active +} + +// GetActiveOk returns a tuple with the Active field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateCoreRuleSetResponse) GetActiveOk() (*bool, bool) { + if o == nil || IsNil(o.Active) { + return nil, false + } + return o.Active, true +} + +// HasActive returns a boolean if a field has been set. +func (o *UpdateCoreRuleSetResponse) HasActive() bool { + if o != nil && !IsNil(o.Active) { + return true + } + + return false +} + +// SetActive gets a reference to the given bool and assigns it to the Active field. +func (o *UpdateCoreRuleSetResponse) SetActive(v bool) { + o.Active = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *UpdateCoreRuleSetResponse) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateCoreRuleSetResponse) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *UpdateCoreRuleSetResponse) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *UpdateCoreRuleSetResponse) SetName(v string) { + o.Name = &v +} + +// GetRegion returns the Region field value if set, zero value otherwise. +func (o *UpdateCoreRuleSetResponse) GetRegion() string { + if o == nil || IsNil(o.Region) { + var ret string + return ret + } + return *o.Region +} + +// GetRegionOk returns a tuple with the Region field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateCoreRuleSetResponse) GetRegionOk() (*string, bool) { + if o == nil || IsNil(o.Region) { + return nil, false + } + return o.Region, true +} + +// HasRegion returns a boolean if a field has been set. +func (o *UpdateCoreRuleSetResponse) HasRegion() bool { + if o != nil && !IsNil(o.Region) { + return true + } + + return false +} + +// SetRegion gets a reference to the given string and assigns it to the Region field. +func (o *UpdateCoreRuleSetResponse) SetRegion(v string) { + o.Region = &v +} + +func (o UpdateCoreRuleSetResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o UpdateCoreRuleSetResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Active) { + toSerialize["active"] = o.Active + } + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.Region) { + toSerialize["region"] = o.Region + } + return toSerialize, nil +} + +type NullableUpdateCoreRuleSetResponse struct { + value *UpdateCoreRuleSetResponse + isSet bool +} + +func (v NullableUpdateCoreRuleSetResponse) Get() *UpdateCoreRuleSetResponse { + return v.value +} + +func (v *NullableUpdateCoreRuleSetResponse) Set(val *UpdateCoreRuleSetResponse) { + v.value = val + v.isSet = true +} + +func (v NullableUpdateCoreRuleSetResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableUpdateCoreRuleSetResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableUpdateCoreRuleSetResponse(val *UpdateCoreRuleSetResponse) *NullableUpdateCoreRuleSetResponse { + return &NullableUpdateCoreRuleSetResponse{value: val, isSet: true} +} + +func (v NullableUpdateCoreRuleSetResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableUpdateCoreRuleSetResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_update_rules_payload.go b/services/albwaf/v1alphaapi/model_update_rules_payload.go new file mode 100644 index 000000000..cdfbccb2f --- /dev/null +++ b/services/albwaf/v1alphaapi/model_update_rules_payload.go @@ -0,0 +1,236 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the UpdateRulesPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &UpdateRulesPayload{} + +// UpdateRulesPayload UpdateRulesRequest updates a rules configuration, but only if it changed. +type UpdateRulesPayload struct { + // Rule configuration name. + Name *string `json:"name,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` + // Project identifier + ProjectId *string `json:"projectId,omitempty" validate:"regexp=^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"` + // Region + Region *string `json:"region,omitempty" validate:"regexp=^[a-z]{2,4}[0-9]{2}$"` + // Custom rules for WAF written in Seclang syntax. + Rules *string `json:"rules,omitempty"` +} + +// NewUpdateRulesPayload instantiates a new UpdateRulesPayload object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewUpdateRulesPayload() *UpdateRulesPayload { + this := UpdateRulesPayload{} + return &this +} + +// NewUpdateRulesPayloadWithDefaults instantiates a new UpdateRulesPayload object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewUpdateRulesPayloadWithDefaults() *UpdateRulesPayload { + this := UpdateRulesPayload{} + return &this +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *UpdateRulesPayload) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateRulesPayload) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *UpdateRulesPayload) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *UpdateRulesPayload) SetName(v string) { + o.Name = &v +} + +// GetProjectId returns the ProjectId field value if set, zero value otherwise. +func (o *UpdateRulesPayload) GetProjectId() string { + if o == nil || IsNil(o.ProjectId) { + var ret string + return ret + } + return *o.ProjectId +} + +// GetProjectIdOk returns a tuple with the ProjectId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateRulesPayload) GetProjectIdOk() (*string, bool) { + if o == nil || IsNil(o.ProjectId) { + return nil, false + } + return o.ProjectId, true +} + +// HasProjectId returns a boolean if a field has been set. +func (o *UpdateRulesPayload) HasProjectId() bool { + if o != nil && !IsNil(o.ProjectId) { + return true + } + + return false +} + +// SetProjectId gets a reference to the given string and assigns it to the ProjectId field. +func (o *UpdateRulesPayload) SetProjectId(v string) { + o.ProjectId = &v +} + +// GetRegion returns the Region field value if set, zero value otherwise. +func (o *UpdateRulesPayload) GetRegion() string { + if o == nil || IsNil(o.Region) { + var ret string + return ret + } + return *o.Region +} + +// GetRegionOk returns a tuple with the Region field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateRulesPayload) GetRegionOk() (*string, bool) { + if o == nil || IsNil(o.Region) { + return nil, false + } + return o.Region, true +} + +// HasRegion returns a boolean if a field has been set. +func (o *UpdateRulesPayload) HasRegion() bool { + if o != nil && !IsNil(o.Region) { + return true + } + + return false +} + +// SetRegion gets a reference to the given string and assigns it to the Region field. +func (o *UpdateRulesPayload) SetRegion(v string) { + o.Region = &v +} + +// GetRules returns the Rules field value if set, zero value otherwise. +func (o *UpdateRulesPayload) GetRules() string { + if o == nil || IsNil(o.Rules) { + var ret string + return ret + } + return *o.Rules +} + +// GetRulesOk returns a tuple with the Rules field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateRulesPayload) GetRulesOk() (*string, bool) { + if o == nil || IsNil(o.Rules) { + return nil, false + } + return o.Rules, true +} + +// HasRules returns a boolean if a field has been set. +func (o *UpdateRulesPayload) HasRules() bool { + if o != nil && !IsNil(o.Rules) { + return true + } + + return false +} + +// SetRules gets a reference to the given string and assigns it to the Rules field. +func (o *UpdateRulesPayload) SetRules(v string) { + o.Rules = &v +} + +func (o UpdateRulesPayload) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o UpdateRulesPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.ProjectId) { + toSerialize["projectId"] = o.ProjectId + } + if !IsNil(o.Region) { + toSerialize["region"] = o.Region + } + if !IsNil(o.Rules) { + toSerialize["rules"] = o.Rules + } + return toSerialize, nil +} + +type NullableUpdateRulesPayload struct { + value *UpdateRulesPayload + isSet bool +} + +func (v NullableUpdateRulesPayload) Get() *UpdateRulesPayload { + return v.value +} + +func (v *NullableUpdateRulesPayload) Set(val *UpdateRulesPayload) { + v.value = val + v.isSet = true +} + +func (v NullableUpdateRulesPayload) IsSet() bool { + return v.isSet +} + +func (v *NullableUpdateRulesPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableUpdateRulesPayload(val *UpdateRulesPayload) *NullableUpdateRulesPayload { + return &NullableUpdateRulesPayload{value: val, isSet: true} +} + +func (v NullableUpdateRulesPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableUpdateRulesPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_update_rules_response.go b/services/albwaf/v1alphaapi/model_update_rules_response.go new file mode 100644 index 000000000..123afb838 --- /dev/null +++ b/services/albwaf/v1alphaapi/model_update_rules_response.go @@ -0,0 +1,199 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the UpdateRulesResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &UpdateRulesResponse{} + +// UpdateRulesResponse UpdateRulesResponse returns rule configuration name and it's rules. +type UpdateRulesResponse struct { + // Rule configuration name. + Name *string `json:"name,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` + // Region + Region *string `json:"region,omitempty" validate:"regexp=^[a-z]{2,4}[0-9]{2}$"` + // Custom rules written in Seclang syntax. + Rules *string `json:"rules,omitempty"` +} + +// NewUpdateRulesResponse instantiates a new UpdateRulesResponse object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewUpdateRulesResponse() *UpdateRulesResponse { + this := UpdateRulesResponse{} + return &this +} + +// NewUpdateRulesResponseWithDefaults instantiates a new UpdateRulesResponse object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewUpdateRulesResponseWithDefaults() *UpdateRulesResponse { + this := UpdateRulesResponse{} + return &this +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *UpdateRulesResponse) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateRulesResponse) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *UpdateRulesResponse) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *UpdateRulesResponse) SetName(v string) { + o.Name = &v +} + +// GetRegion returns the Region field value if set, zero value otherwise. +func (o *UpdateRulesResponse) GetRegion() string { + if o == nil || IsNil(o.Region) { + var ret string + return ret + } + return *o.Region +} + +// GetRegionOk returns a tuple with the Region field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateRulesResponse) GetRegionOk() (*string, bool) { + if o == nil || IsNil(o.Region) { + return nil, false + } + return o.Region, true +} + +// HasRegion returns a boolean if a field has been set. +func (o *UpdateRulesResponse) HasRegion() bool { + if o != nil && !IsNil(o.Region) { + return true + } + + return false +} + +// SetRegion gets a reference to the given string and assigns it to the Region field. +func (o *UpdateRulesResponse) SetRegion(v string) { + o.Region = &v +} + +// GetRules returns the Rules field value if set, zero value otherwise. +func (o *UpdateRulesResponse) GetRules() string { + if o == nil || IsNil(o.Rules) { + var ret string + return ret + } + return *o.Rules +} + +// GetRulesOk returns a tuple with the Rules field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateRulesResponse) GetRulesOk() (*string, bool) { + if o == nil || IsNil(o.Rules) { + return nil, false + } + return o.Rules, true +} + +// HasRules returns a boolean if a field has been set. +func (o *UpdateRulesResponse) HasRules() bool { + if o != nil && !IsNil(o.Rules) { + return true + } + + return false +} + +// SetRules gets a reference to the given string and assigns it to the Rules field. +func (o *UpdateRulesResponse) SetRules(v string) { + o.Rules = &v +} + +func (o UpdateRulesResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o UpdateRulesResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.Region) { + toSerialize["region"] = o.Region + } + if !IsNil(o.Rules) { + toSerialize["rules"] = o.Rules + } + return toSerialize, nil +} + +type NullableUpdateRulesResponse struct { + value *UpdateRulesResponse + isSet bool +} + +func (v NullableUpdateRulesResponse) Get() *UpdateRulesResponse { + return v.value +} + +func (v *NullableUpdateRulesResponse) Set(val *UpdateRulesResponse) { + v.value = val + v.isSet = true +} + +func (v NullableUpdateRulesResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableUpdateRulesResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableUpdateRulesResponse(val *UpdateRulesResponse) *NullableUpdateRulesResponse { + return &NullableUpdateRulesResponse{value: val, isSet: true} +} + +func (v NullableUpdateRulesResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableUpdateRulesResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_update_waf_payload.go b/services/albwaf/v1alphaapi/model_update_waf_payload.go new file mode 100644 index 000000000..a18460c81 --- /dev/null +++ b/services/albwaf/v1alphaapi/model_update_waf_payload.go @@ -0,0 +1,273 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the UpdateWAFPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &UpdateWAFPayload{} + +// UpdateWAFPayload UpdateWAFRequest updates a WAF if rules changed. +type UpdateWAFPayload struct { + // Name of the core rule set configuration for that WAF. + CoreRuleSetName *string `json:"coreRuleSetName,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` + // WAF name + Name *string `json:"name,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` + // Project identifier + ProjectId *string `json:"projectId,omitempty" validate:"regexp=^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"` + // Region + Region *string `json:"region,omitempty" validate:"regexp=^[a-z]{2,4}[0-9]{2}$"` + // Name of the rule configuration for that WAF. + RulesConfigName *string `json:"rulesConfigName,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` +} + +// NewUpdateWAFPayload instantiates a new UpdateWAFPayload object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewUpdateWAFPayload() *UpdateWAFPayload { + this := UpdateWAFPayload{} + return &this +} + +// NewUpdateWAFPayloadWithDefaults instantiates a new UpdateWAFPayload object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewUpdateWAFPayloadWithDefaults() *UpdateWAFPayload { + this := UpdateWAFPayload{} + return &this +} + +// GetCoreRuleSetName returns the CoreRuleSetName field value if set, zero value otherwise. +func (o *UpdateWAFPayload) GetCoreRuleSetName() string { + if o == nil || IsNil(o.CoreRuleSetName) { + var ret string + return ret + } + return *o.CoreRuleSetName +} + +// GetCoreRuleSetNameOk returns a tuple with the CoreRuleSetName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateWAFPayload) GetCoreRuleSetNameOk() (*string, bool) { + if o == nil || IsNil(o.CoreRuleSetName) { + return nil, false + } + return o.CoreRuleSetName, true +} + +// HasCoreRuleSetName returns a boolean if a field has been set. +func (o *UpdateWAFPayload) HasCoreRuleSetName() bool { + if o != nil && !IsNil(o.CoreRuleSetName) { + return true + } + + return false +} + +// SetCoreRuleSetName gets a reference to the given string and assigns it to the CoreRuleSetName field. +func (o *UpdateWAFPayload) SetCoreRuleSetName(v string) { + o.CoreRuleSetName = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *UpdateWAFPayload) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateWAFPayload) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *UpdateWAFPayload) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *UpdateWAFPayload) SetName(v string) { + o.Name = &v +} + +// GetProjectId returns the ProjectId field value if set, zero value otherwise. +func (o *UpdateWAFPayload) GetProjectId() string { + if o == nil || IsNil(o.ProjectId) { + var ret string + return ret + } + return *o.ProjectId +} + +// GetProjectIdOk returns a tuple with the ProjectId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateWAFPayload) GetProjectIdOk() (*string, bool) { + if o == nil || IsNil(o.ProjectId) { + return nil, false + } + return o.ProjectId, true +} + +// HasProjectId returns a boolean if a field has been set. +func (o *UpdateWAFPayload) HasProjectId() bool { + if o != nil && !IsNil(o.ProjectId) { + return true + } + + return false +} + +// SetProjectId gets a reference to the given string and assigns it to the ProjectId field. +func (o *UpdateWAFPayload) SetProjectId(v string) { + o.ProjectId = &v +} + +// GetRegion returns the Region field value if set, zero value otherwise. +func (o *UpdateWAFPayload) GetRegion() string { + if o == nil || IsNil(o.Region) { + var ret string + return ret + } + return *o.Region +} + +// GetRegionOk returns a tuple with the Region field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateWAFPayload) GetRegionOk() (*string, bool) { + if o == nil || IsNil(o.Region) { + return nil, false + } + return o.Region, true +} + +// HasRegion returns a boolean if a field has been set. +func (o *UpdateWAFPayload) HasRegion() bool { + if o != nil && !IsNil(o.Region) { + return true + } + + return false +} + +// SetRegion gets a reference to the given string and assigns it to the Region field. +func (o *UpdateWAFPayload) SetRegion(v string) { + o.Region = &v +} + +// GetRulesConfigName returns the RulesConfigName field value if set, zero value otherwise. +func (o *UpdateWAFPayload) GetRulesConfigName() string { + if o == nil || IsNil(o.RulesConfigName) { + var ret string + return ret + } + return *o.RulesConfigName +} + +// GetRulesConfigNameOk returns a tuple with the RulesConfigName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateWAFPayload) GetRulesConfigNameOk() (*string, bool) { + if o == nil || IsNil(o.RulesConfigName) { + return nil, false + } + return o.RulesConfigName, true +} + +// HasRulesConfigName returns a boolean if a field has been set. +func (o *UpdateWAFPayload) HasRulesConfigName() bool { + if o != nil && !IsNil(o.RulesConfigName) { + return true + } + + return false +} + +// SetRulesConfigName gets a reference to the given string and assigns it to the RulesConfigName field. +func (o *UpdateWAFPayload) SetRulesConfigName(v string) { + o.RulesConfigName = &v +} + +func (o UpdateWAFPayload) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o UpdateWAFPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.CoreRuleSetName) { + toSerialize["coreRuleSetName"] = o.CoreRuleSetName + } + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.ProjectId) { + toSerialize["projectId"] = o.ProjectId + } + if !IsNil(o.Region) { + toSerialize["region"] = o.Region + } + if !IsNil(o.RulesConfigName) { + toSerialize["rulesConfigName"] = o.RulesConfigName + } + return toSerialize, nil +} + +type NullableUpdateWAFPayload struct { + value *UpdateWAFPayload + isSet bool +} + +func (v NullableUpdateWAFPayload) Get() *UpdateWAFPayload { + return v.value +} + +func (v *NullableUpdateWAFPayload) Set(val *UpdateWAFPayload) { + v.value = val + v.isSet = true +} + +func (v NullableUpdateWAFPayload) IsSet() bool { + return v.isSet +} + +func (v *NullableUpdateWAFPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableUpdateWAFPayload(val *UpdateWAFPayload) *NullableUpdateWAFPayload { + return &NullableUpdateWAFPayload{value: val, isSet: true} +} + +func (v NullableUpdateWAFPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableUpdateWAFPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/model_update_waf_response.go b/services/albwaf/v1alphaapi/model_update_waf_response.go new file mode 100644 index 000000000..603d583c8 --- /dev/null +++ b/services/albwaf/v1alphaapi/model_update_waf_response.go @@ -0,0 +1,236 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the UpdateWAFResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &UpdateWAFResponse{} + +// UpdateWAFResponse UpdateWAFResponse returns name and custom rules. +type UpdateWAFResponse struct { + // Name of the core rule set configuration for that WAF. + CoreRuleSetName *string `json:"coreRuleSetName,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` + // WAF name + Name *string `json:"name,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` + // Region + Region *string `json:"region,omitempty" validate:"regexp=^[a-z]{2,4}[0-9]{2}$"` + // Name of the rule configuration for that WAF. + RulesConfigName *string `json:"rulesConfigName,omitempty" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$"` +} + +// NewUpdateWAFResponse instantiates a new UpdateWAFResponse object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewUpdateWAFResponse() *UpdateWAFResponse { + this := UpdateWAFResponse{} + return &this +} + +// NewUpdateWAFResponseWithDefaults instantiates a new UpdateWAFResponse object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewUpdateWAFResponseWithDefaults() *UpdateWAFResponse { + this := UpdateWAFResponse{} + return &this +} + +// GetCoreRuleSetName returns the CoreRuleSetName field value if set, zero value otherwise. +func (o *UpdateWAFResponse) GetCoreRuleSetName() string { + if o == nil || IsNil(o.CoreRuleSetName) { + var ret string + return ret + } + return *o.CoreRuleSetName +} + +// GetCoreRuleSetNameOk returns a tuple with the CoreRuleSetName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateWAFResponse) GetCoreRuleSetNameOk() (*string, bool) { + if o == nil || IsNil(o.CoreRuleSetName) { + return nil, false + } + return o.CoreRuleSetName, true +} + +// HasCoreRuleSetName returns a boolean if a field has been set. +func (o *UpdateWAFResponse) HasCoreRuleSetName() bool { + if o != nil && !IsNil(o.CoreRuleSetName) { + return true + } + + return false +} + +// SetCoreRuleSetName gets a reference to the given string and assigns it to the CoreRuleSetName field. +func (o *UpdateWAFResponse) SetCoreRuleSetName(v string) { + o.CoreRuleSetName = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *UpdateWAFResponse) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateWAFResponse) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *UpdateWAFResponse) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *UpdateWAFResponse) SetName(v string) { + o.Name = &v +} + +// GetRegion returns the Region field value if set, zero value otherwise. +func (o *UpdateWAFResponse) GetRegion() string { + if o == nil || IsNil(o.Region) { + var ret string + return ret + } + return *o.Region +} + +// GetRegionOk returns a tuple with the Region field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateWAFResponse) GetRegionOk() (*string, bool) { + if o == nil || IsNil(o.Region) { + return nil, false + } + return o.Region, true +} + +// HasRegion returns a boolean if a field has been set. +func (o *UpdateWAFResponse) HasRegion() bool { + if o != nil && !IsNil(o.Region) { + return true + } + + return false +} + +// SetRegion gets a reference to the given string and assigns it to the Region field. +func (o *UpdateWAFResponse) SetRegion(v string) { + o.Region = &v +} + +// GetRulesConfigName returns the RulesConfigName field value if set, zero value otherwise. +func (o *UpdateWAFResponse) GetRulesConfigName() string { + if o == nil || IsNil(o.RulesConfigName) { + var ret string + return ret + } + return *o.RulesConfigName +} + +// GetRulesConfigNameOk returns a tuple with the RulesConfigName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateWAFResponse) GetRulesConfigNameOk() (*string, bool) { + if o == nil || IsNil(o.RulesConfigName) { + return nil, false + } + return o.RulesConfigName, true +} + +// HasRulesConfigName returns a boolean if a field has been set. +func (o *UpdateWAFResponse) HasRulesConfigName() bool { + if o != nil && !IsNil(o.RulesConfigName) { + return true + } + + return false +} + +// SetRulesConfigName gets a reference to the given string and assigns it to the RulesConfigName field. +func (o *UpdateWAFResponse) SetRulesConfigName(v string) { + o.RulesConfigName = &v +} + +func (o UpdateWAFResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o UpdateWAFResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.CoreRuleSetName) { + toSerialize["coreRuleSetName"] = o.CoreRuleSetName + } + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.Region) { + toSerialize["region"] = o.Region + } + if !IsNil(o.RulesConfigName) { + toSerialize["rulesConfigName"] = o.RulesConfigName + } + return toSerialize, nil +} + +type NullableUpdateWAFResponse struct { + value *UpdateWAFResponse + isSet bool +} + +func (v NullableUpdateWAFResponse) Get() *UpdateWAFResponse { + return v.value +} + +func (v *NullableUpdateWAFResponse) Set(val *UpdateWAFResponse) { + v.value = val + v.isSet = true +} + +func (v NullableUpdateWAFResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableUpdateWAFResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableUpdateWAFResponse(val *UpdateWAFResponse) *NullableUpdateWAFResponse { + return &NullableUpdateWAFResponse{value: val, isSet: true} +} + +func (v NullableUpdateWAFResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableUpdateWAFResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/albwaf/v1alphaapi/response.go b/services/albwaf/v1alphaapi/response.go new file mode 100644 index 000000000..b613c7b63 --- /dev/null +++ b/services/albwaf/v1alphaapi/response.go @@ -0,0 +1,47 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "net/http" +) + +// APIResponse stores the API response returned by the server. +type APIResponse struct { + *http.Response `json:"-"` + Message string `json:"message,omitempty"` + // Operation is the name of the OpenAPI operation. + Operation string `json:"operation,omitempty"` + // RequestURL is the request URL. This value is always available, even if the + // embedded *http.Response is nil. + RequestURL string `json:"url,omitempty"` + // Method is the HTTP method used for the request. This value is always + // available, even if the embedded *http.Response is nil. + Method string `json:"method,omitempty"` + // Payload holds the contents of the response body (which may be nil or empty). + // This is provided here as the raw response.Body() reader will have already + // been drained. + Payload []byte `json:"-"` +} + +// NewAPIResponse returns a new APIResponse object. +func NewAPIResponse(r *http.Response) *APIResponse { + + response := &APIResponse{Response: r} + return response +} + +// NewAPIResponseWithError returns a new APIResponse object with the provided error message. +func NewAPIResponseWithError(errorMessage string) *APIResponse { + + response := &APIResponse{Message: errorMessage} + return response +} diff --git a/services/albwaf/v1alphaapi/utils.go b/services/albwaf/v1alphaapi/utils.go new file mode 100644 index 000000000..71356a62a --- /dev/null +++ b/services/albwaf/v1alphaapi/utils.go @@ -0,0 +1,361 @@ +/* +STACKIT Application Load Balancer Web Application Firewall API + +Generate a Web Application Firewall (WAF) to use with Application Load Balancers (ALB). The name of the WAF configuration is used in the listener of the ALB. This will activate the WAF for that ALB. An ALB with a WAF can have OWASP core rule set enabled and in addition can have custom rule configurations. To create a WAF one first needs to create all the configurations that are referenced in the WAF configuration. Currently this only consists of a rule configuration, which is written in Seclang. Once all configurations are created and referenced in the WAF configuration it can be used with an ALB. Currently updating a WAF configuration will not update an existing ALB until the Load Balancer VMs are restarted. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "bytes" + "encoding/json" + "fmt" + "reflect" + "time" +) + +// PtrBool is a helper routine that returns a pointer to given boolean value. +func PtrBool(v bool) *bool { return &v } + +// PtrInt is a helper routine that returns a pointer to given integer value. +func PtrInt(v int) *int { return &v } + +// PtrInt32 is a helper routine that returns a pointer to given integer value. +func PtrInt32(v int32) *int32 { return &v } + +// PtrInt64 is a helper routine that returns a pointer to given integer value. +func PtrInt64(v int64) *int64 { return &v } + +// PtrFloat32 is a helper routine that returns a pointer to given float value. +func PtrFloat32(v float32) *float32 { return &v } + +// PtrFloat64 is a helper routine that returns a pointer to given float value. +func PtrFloat64(v float64) *float64 { return &v } + +// PtrString is a helper routine that returns a pointer to given string value. +func PtrString(v string) *string { return &v } + +// PtrTime is helper routine that returns a pointer to given Time value. +func PtrTime(v time.Time) *time.Time { return &v } + +type NullableBool struct { + value *bool + isSet bool +} + +func (v NullableBool) Get() *bool { + return v.value +} + +func (v *NullableBool) Set(val *bool) { + v.value = val + v.isSet = true +} + +func (v NullableBool) IsSet() bool { + return v.isSet +} + +func (v *NullableBool) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableBool(val *bool) *NullableBool { + return &NullableBool{value: val, isSet: true} +} + +func (v NullableBool) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableBool) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableInt struct { + value *int + isSet bool +} + +func (v NullableInt) Get() *int { + return v.value +} + +func (v *NullableInt) Set(val *int) { + v.value = val + v.isSet = true +} + +func (v NullableInt) IsSet() bool { + return v.isSet +} + +func (v *NullableInt) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInt(val *int) *NullableInt { + return &NullableInt{value: val, isSet: true} +} + +func (v NullableInt) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInt) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableInt32 struct { + value *int32 + isSet bool +} + +func (v NullableInt32) Get() *int32 { + return v.value +} + +func (v *NullableInt32) Set(val *int32) { + v.value = val + v.isSet = true +} + +func (v NullableInt32) IsSet() bool { + return v.isSet +} + +func (v *NullableInt32) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInt32(val *int32) *NullableInt32 { + return &NullableInt32{value: val, isSet: true} +} + +func (v NullableInt32) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInt32) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableInt64 struct { + value *int64 + isSet bool +} + +func (v NullableInt64) Get() *int64 { + return v.value +} + +func (v *NullableInt64) Set(val *int64) { + v.value = val + v.isSet = true +} + +func (v NullableInt64) IsSet() bool { + return v.isSet +} + +func (v *NullableInt64) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInt64(val *int64) *NullableInt64 { + return &NullableInt64{value: val, isSet: true} +} + +func (v NullableInt64) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInt64) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableFloat32 struct { + value *float32 + isSet bool +} + +func (v NullableFloat32) Get() *float32 { + return v.value +} + +func (v *NullableFloat32) Set(val *float32) { + v.value = val + v.isSet = true +} + +func (v NullableFloat32) IsSet() bool { + return v.isSet +} + +func (v *NullableFloat32) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableFloat32(val *float32) *NullableFloat32 { + return &NullableFloat32{value: val, isSet: true} +} + +func (v NullableFloat32) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableFloat32) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableFloat64 struct { + value *float64 + isSet bool +} + +func (v NullableFloat64) Get() *float64 { + return v.value +} + +func (v *NullableFloat64) Set(val *float64) { + v.value = val + v.isSet = true +} + +func (v NullableFloat64) IsSet() bool { + return v.isSet +} + +func (v *NullableFloat64) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableFloat64(val *float64) *NullableFloat64 { + return &NullableFloat64{value: val, isSet: true} +} + +func (v NullableFloat64) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableFloat64) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableString struct { + value *string + isSet bool +} + +func (v NullableString) Get() *string { + return v.value +} + +func (v *NullableString) Set(val *string) { + v.value = val + v.isSet = true +} + +func (v NullableString) IsSet() bool { + return v.isSet +} + +func (v *NullableString) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableString(val *string) *NullableString { + return &NullableString{value: val, isSet: true} +} + +func (v NullableString) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableString) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableTime struct { + value *time.Time + isSet bool +} + +func (v NullableTime) Get() *time.Time { + return v.value +} + +func (v *NullableTime) Set(val *time.Time) { + v.value = val + v.isSet = true +} + +func (v NullableTime) IsSet() bool { + return v.isSet +} + +func (v *NullableTime) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableTime(val *time.Time) *NullableTime { + return &NullableTime{value: val, isSet: true} +} + +func (v NullableTime) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableTime) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +// IsNil checks if an input is nil +func IsNil(i interface{}) bool { + if i == nil { + return true + } + switch reflect.TypeOf(i).Kind() { + case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.UnsafePointer, reflect.Interface, reflect.Slice: + return reflect.ValueOf(i).IsNil() + case reflect.Array: + return reflect.ValueOf(i).IsZero() + } + return false +} + +type MappedNullable interface { + ToMap() (map[string]interface{}, error) +} + +// A wrapper for strict JSON decoding +func newStrictDecoder(data []byte) *json.Decoder { + dec := json.NewDecoder(bytes.NewBuffer(data)) + dec.DisallowUnknownFields() + return dec +} + +// Prevent trying to import "fmt" +func reportError(format string, a ...interface{}) error { + return fmt.Errorf(format, a...) +}