diff --git a/go.work b/go.work index 570ca9e4d..73706b77e 100644 --- a/go.work +++ b/go.work @@ -76,5 +76,6 @@ use ( ./services/sqlserverflex ./services/stackitmarketplace ./services/telemetryrouter + ./services/ufw ./services/vpn ) diff --git a/services/ufw/LICENSE.md b/services/ufw/LICENSE.md new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/services/ufw/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/ufw/go.mod b/services/ufw/go.mod new file mode 100644 index 000000000..1b5ed90f4 --- /dev/null +++ b/services/ufw/go.mod @@ -0,0 +1,10 @@ +module github.com/stackitcloud/stackit-sdk-go/services/ufw + +go 1.25 + +require github.com/stackitcloud/stackit-sdk-go/core v0.26.0 + +require ( + github.com/golang-jwt/jwt/v5 v5.3.1 // indirect + github.com/google/uuid v1.6.0 // indirect +) diff --git a/services/ufw/go.sum b/services/ufw/go.sum new file mode 100644 index 000000000..3712a0c87 --- /dev/null +++ b/services/ufw/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.26.0 h1:jQEb9gkehfp6VCP6TcYk7BI10cz4l0KM2L6hqYBH2QA= +github.com/stackitcloud/stackit-sdk-go/core v0.26.0/go.mod h1:WU1hhxnjXw2EV7CYa1nlEvNpMiRY6CvmIOaHuL3pOaA= diff --git a/services/ufw/oas_commit b/services/ufw/oas_commit new file mode 100644 index 000000000..c08a6770d --- /dev/null +++ b/services/ufw/oas_commit @@ -0,0 +1 @@ +4407196dbbef4e53e6798809e856725cbc84ae05 diff --git a/services/ufw/package.go b/services/ufw/package.go new file mode 100644 index 000000000..bebcc30a8 --- /dev/null +++ b/services/ufw/package.go @@ -0,0 +1 @@ +package ufw diff --git a/services/ufw/v1betaapi/api_default.go b/services/ufw/v1betaapi/api_default.go new file mode 100644 index 000000000..f2e894dfa --- /dev/null +++ b/services/ufw/v1betaapi/api_default.go @@ -0,0 +1,1348 @@ +/* +STACKIT Unified Firewall API + +API for managing and controlling the STACKIT Unified Firewall. + +API version: 1beta.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. +package v1betaapi + +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 { + + /* + CreateRule Create rule for a project + + Returns the created rule for a specific project + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the resource is located in. + @return ApiCreateRuleRequest + */ + CreateRule(ctx context.Context, projectId string, regionId string) ApiCreateRuleRequest + + // CreateRuleExecute executes the request + // @return SecurityRuleResponse + CreateRuleExecute(r ApiCreateRuleRequest) (*SecurityRuleResponse, error) + + /* + DeleteRule Delete rule for a project + + Returns success + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the resource is located in. + @return ApiDeleteRuleRequest + */ + DeleteRule(ctx context.Context, projectId string, regionId string) ApiDeleteRuleRequest + + // DeleteRuleExecute executes the request + // @return SecurityRuleResponse + DeleteRuleExecute(r ApiDeleteRuleRequest) (*SecurityRuleResponse, error) + + /* + ListInstancesForService Get a list of available instances. + + Get a list of available instances per service 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 The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the resource is located in. + @param serviceId The STACKIT service the resource belongs to. + @return ApiListInstancesForServiceRequest + */ + ListInstancesForService(ctx context.Context, projectId string, regionId string, serviceId string) ApiListInstancesForServiceRequest + + // ListInstancesForServiceExecute executes the request + // @return []ServicesResponse + ListInstancesForServiceExecute(r ApiListInstancesForServiceRequest) ([]ServicesResponse, error) + + /* + ListProviderOptions Get Provider Options + + Returns a list of supported configuration options for this region. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param regionId The STACKIT region name the resource is located in. + @return ApiListProviderOptionsRequest + */ + ListProviderOptions(ctx context.Context, regionId string) ApiListProviderOptionsRequest + + // ListProviderOptionsExecute executes the request + // @return []ProviderOptionsResponse + ListProviderOptionsExecute(r ApiListProviderOptionsRequest) ([]ProviderOptionsResponse, error) + + /* + ListRules Get rules for a project + + Returns a list of rules for a specific project + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the resource is located in. + @return ApiListRulesRequest + */ + ListRules(ctx context.Context, projectId string, regionId string) ApiListRulesRequest + + // ListRulesExecute executes the request + // @return SecurityRulesResponse + ListRulesExecute(r ApiListRulesRequest) (*SecurityRulesResponse, error) + + /* + UpdateRule Update rule for a project + + Returns the updated rule for a specific project + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the resource is located in. + @return ApiUpdateRuleRequest + */ + UpdateRule(ctx context.Context, projectId string, regionId string) ApiUpdateRuleRequest + + // UpdateRuleExecute executes the request + // @return SecurityRuleResponse + UpdateRuleExecute(r ApiUpdateRuleRequest) (*SecurityRuleResponse, error) +} + +// DefaultAPIService DefaultAPI service +type DefaultAPIService service + +type ApiCreateRuleRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + regionId string + createRulePayload *CreateRulePayload +} + +// Request an Rule creation. +func (r ApiCreateRuleRequest) CreateRulePayload(createRulePayload CreateRulePayload) ApiCreateRuleRequest { + r.createRulePayload = &createRulePayload + return r +} + +func (r ApiCreateRuleRequest) Execute() (*SecurityRuleResponse, error) { + return r.ApiService.CreateRuleExecute(r) +} + +/* +CreateRule Create rule for a project + +Returns the created rule for a specific project + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the resource is located in. + @return ApiCreateRuleRequest +*/ +func (a *DefaultAPIService) CreateRule(ctx context.Context, projectId string, regionId string) ApiCreateRuleRequest { + return ApiCreateRuleRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + } +} + +// Execute executes the request +// +// @return SecurityRuleResponse +func (a *DefaultAPIService) CreateRuleExecute(r ApiCreateRuleRequest) (*SecurityRuleResponse, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *SecurityRuleResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.CreateRule") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{regionId}/rules" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(parameterValueToString(r.regionId, "regionId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // 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.createRulePayload + 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 == 400 { + var v ErrorResponse + 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 + } + if localVarHTTPResponse.StatusCode == 401 { + var v ErrorResponse + 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 + } + if localVarHTTPResponse.StatusCode == 403 { + var v ErrorResponse + 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 + } + if localVarHTTPResponse.StatusCode == 404 { + var v ErrorResponse + 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 + } + if localVarHTTPResponse.StatusCode == 500 { + var v ErrorResponse + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiDeleteRuleRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + regionId string + product *string + instanceId *string + type_ *string + sourceIP *string + offset *int32 + securityGroupId *string +} + +// The product service (e.g., Load Balancer, Redis). +func (r ApiDeleteRuleRequest) Product(product string) ApiDeleteRuleRequest { + r.product = &product + return r +} + +// The ID of the source, similar to a project ID but for the product service instance. +func (r ApiDeleteRuleRequest) InstanceId(instanceId string) ApiDeleteRuleRequest { + r.instanceId = &instanceId + return r +} + +// The type of the rule (e.g., \"ACL\", \"PublicIP\", \"SecurityRule\"). +func (r ApiDeleteRuleRequest) Type_(type_ string) ApiDeleteRuleRequest { + r.type_ = &type_ + return r +} + +// The IP for the rule. +func (r ApiDeleteRuleRequest) SourceIP(sourceIP string) ApiDeleteRuleRequest { + r.sourceIP = &sourceIP + return r +} + +// The offset for the rule in the instance it is associated with. +func (r ApiDeleteRuleRequest) Offset(offset int32) ApiDeleteRuleRequest { + r.offset = &offset + return r +} + +// The UUID of the group. +func (r ApiDeleteRuleRequest) SecurityGroupId(securityGroupId string) ApiDeleteRuleRequest { + r.securityGroupId = &securityGroupId + return r +} + +func (r ApiDeleteRuleRequest) Execute() (*SecurityRuleResponse, error) { + return r.ApiService.DeleteRuleExecute(r) +} + +/* +DeleteRule Delete rule for a project + +Returns success + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the resource is located in. + @return ApiDeleteRuleRequest +*/ +func (a *DefaultAPIService) DeleteRule(ctx context.Context, projectId string, regionId string) ApiDeleteRuleRequest { + return ApiDeleteRuleRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + } +} + +// Execute executes the request +// +// @return SecurityRuleResponse +func (a *DefaultAPIService) DeleteRuleExecute(r ApiDeleteRuleRequest) (*SecurityRuleResponse, error) { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *SecurityRuleResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.DeleteRule") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{regionId}/rules" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(parameterValueToString(r.regionId, "regionId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if r.product != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "product", r.product, "form", "") + } + if r.instanceId != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "instanceId", r.instanceId, "form", "") + } + if r.type_ != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "type", r.type_, "form", "") + } + if r.sourceIP != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "sourceIP", r.sourceIP, "form", "") + } + if r.offset != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "offset", r.offset, "form", "") + } + if r.securityGroupId != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "securityGroupId", r.securityGroupId, "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 == 400 { + var v ErrorResponse + 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 + } + if localVarHTTPResponse.StatusCode == 401 { + var v ErrorResponse + 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 + } + if localVarHTTPResponse.StatusCode == 403 { + var v ErrorResponse + 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 + } + if localVarHTTPResponse.StatusCode == 404 { + var v ErrorResponse + 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 + } + if localVarHTTPResponse.StatusCode == 500 { + var v ErrorResponse + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiListInstancesForServiceRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + regionId string + serviceId string +} + +func (r ApiListInstancesForServiceRequest) Execute() ([]ServicesResponse, error) { + return r.ApiService.ListInstancesForServiceExecute(r) +} + +/* +ListInstancesForService Get a list of available instances. + +Get a list of available instances per service 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 The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the resource is located in. + @param serviceId The STACKIT service the resource belongs to. + @return ApiListInstancesForServiceRequest +*/ +func (a *DefaultAPIService) ListInstancesForService(ctx context.Context, projectId string, regionId string, serviceId string) ApiListInstancesForServiceRequest { + return ApiListInstancesForServiceRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + serviceId: serviceId, + } +} + +// Execute executes the request +// +// @return []ServicesResponse +func (a *DefaultAPIService) ListInstancesForServiceExecute(r ApiListInstancesForServiceRequest) ([]ServicesResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue []ServicesResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ListInstancesForService") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{regionId}/services/{serviceId}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(parameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"serviceId"+"}", url.PathEscape(parameterValueToString(r.serviceId, "serviceId")), -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 == 400 { + var v ErrorResponse + 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 + } + if localVarHTTPResponse.StatusCode == 401 { + var v ErrorResponse + 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 + } + if localVarHTTPResponse.StatusCode == 403 { + var v ErrorResponse + 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 + } + if localVarHTTPResponse.StatusCode == 404 { + var v ErrorResponse + 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 + } + if localVarHTTPResponse.StatusCode == 500 { + var v ErrorResponse + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiListProviderOptionsRequest struct { + ctx context.Context + ApiService DefaultAPI + regionId string +} + +func (r ApiListProviderOptionsRequest) Execute() ([]ProviderOptionsResponse, error) { + return r.ApiService.ListProviderOptionsExecute(r) +} + +/* +ListProviderOptions Get Provider Options + +Returns a list of supported configuration options for this region. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param regionId The STACKIT region name the resource is located in. + @return ApiListProviderOptionsRequest +*/ +func (a *DefaultAPIService) ListProviderOptions(ctx context.Context, regionId string) ApiListProviderOptionsRequest { + return ApiListProviderOptionsRequest{ + ApiService: a, + ctx: ctx, + regionId: regionId, + } +} + +// Execute executes the request +// +// @return []ProviderOptionsResponse +func (a *DefaultAPIService) ListProviderOptionsExecute(r ApiListProviderOptionsRequest) ([]ProviderOptionsResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue []ProviderOptionsResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ListProviderOptions") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/regions/{regionId}/provider-options" + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(parameterValueToString(r.regionId, "regionId")), -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 == 400 { + var v ErrorResponse + 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 + } + if localVarHTTPResponse.StatusCode == 401 { + var v ErrorResponse + 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 + } + if localVarHTTPResponse.StatusCode == 500 { + var v ErrorResponse + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiListRulesRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + regionId string + securityGroupId *string + product *string + instanceId *string + type_ *string + sourceIP *string + portRange *string + protocol *string + direction *string + etherType *string + sortBy *string + sortOrder *string + limit *int32 + cursor *string +} + +// The UUID of the group. +func (r ApiListRulesRequest) SecurityGroupId(securityGroupId string) ApiListRulesRequest { + r.securityGroupId = &securityGroupId + return r +} + +// The product service (e.g., Load Balancer, Redis). +func (r ApiListRulesRequest) Product(product string) ApiListRulesRequest { + r.product = &product + return r +} + +// The ID of the source, similar to a project ID but for the product service instance. +func (r ApiListRulesRequest) InstanceId(instanceId string) ApiListRulesRequest { + r.instanceId = &instanceId + return r +} + +// The type of the rule (e.g., \"ACL\", \"PublicIP\", \"SecurityRule\"). +func (r ApiListRulesRequest) Type_(type_ string) ApiListRulesRequest { + r.type_ = &type_ + return r +} + +// The IP for the rule. +func (r ApiListRulesRequest) SourceIP(sourceIP string) ApiListRulesRequest { + r.sourceIP = &sourceIP + return r +} + +// The port range for the rule. +func (r ApiListRulesRequest) PortRange(portRange string) ApiListRulesRequest { + r.portRange = &portRange + return r +} + +// The protocol for the rule (e.g., \"tcp\", \"udp\"). +func (r ApiListRulesRequest) Protocol(protocol string) ApiListRulesRequest { + r.protocol = &protocol + return r +} + +// The direction of the rule (e.g., \"ingress\", \"egress\"). +func (r ApiListRulesRequest) Direction(direction string) ApiListRulesRequest { + r.direction = &direction + return r +} + +// The ether type for the rule. +func (r ApiListRulesRequest) EtherType(etherType string) ApiListRulesRequest { + r.etherType = ðerType + return r +} + +// The field to sort the response by. +func (r ApiListRulesRequest) SortBy(sortBy string) ApiListRulesRequest { + r.sortBy = &sortBy + return r +} + +// The order to sort the response by. +func (r ApiListRulesRequest) SortOrder(sortOrder string) ApiListRulesRequest { + r.sortOrder = &sortOrder + return r +} + +// The maximum number of items to return in the response. If maximum is exceeded, maximum is used. +func (r ApiListRulesRequest) Limit(limit int32) ApiListRulesRequest { + r.limit = &limit + return r +} + +// A pagination cursor that represents a position in the dataset. If given, results will be returned from the item after the cursor. If not given, results will be returned from the beginning. +func (r ApiListRulesRequest) Cursor(cursor string) ApiListRulesRequest { + r.cursor = &cursor + return r +} + +func (r ApiListRulesRequest) Execute() (*SecurityRulesResponse, error) { + return r.ApiService.ListRulesExecute(r) +} + +/* +ListRules Get rules for a project + +Returns a list of rules for a specific project + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the resource is located in. + @return ApiListRulesRequest +*/ +func (a *DefaultAPIService) ListRules(ctx context.Context, projectId string, regionId string) ApiListRulesRequest { + return ApiListRulesRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + } +} + +// Execute executes the request +// +// @return SecurityRulesResponse +func (a *DefaultAPIService) ListRulesExecute(r ApiListRulesRequest) (*SecurityRulesResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *SecurityRulesResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ListRules") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{regionId}/rules" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(parameterValueToString(r.regionId, "regionId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if r.securityGroupId != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "securityGroupId", r.securityGroupId, "form", "") + } + if r.product != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "product", r.product, "form", "") + } + if r.instanceId != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "instanceId", r.instanceId, "form", "") + } + if r.type_ != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "type", r.type_, "form", "") + } + if r.sourceIP != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "sourceIP", r.sourceIP, "form", "") + } + if r.portRange != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "portRange", r.portRange, "form", "") + } + if r.protocol != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "protocol", r.protocol, "form", "") + } + if r.direction != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "direction", r.direction, "form", "") + } + if r.etherType != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "etherType", r.etherType, "form", "") + } + if r.sortBy != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "sortBy", r.sortBy, "form", "") + } + if r.sortOrder != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "sortOrder", r.sortOrder, "form", "") + } + if r.limit != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "form", "") + } + if r.cursor != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "cursor", r.cursor, "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 == 400 { + var v ErrorResponse + 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 + } + if localVarHTTPResponse.StatusCode == 401 { + var v ErrorResponse + 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 + } + if localVarHTTPResponse.StatusCode == 403 { + var v ErrorResponse + 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 + } + if localVarHTTPResponse.StatusCode == 404 { + var v ErrorResponse + 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 + } + if localVarHTTPResponse.StatusCode == 500 { + var v ErrorResponse + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiUpdateRuleRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + regionId string + updateRulePayload *UpdateRulePayload +} + +// Request an Rule update. +func (r ApiUpdateRuleRequest) UpdateRulePayload(updateRulePayload UpdateRulePayload) ApiUpdateRuleRequest { + r.updateRulePayload = &updateRulePayload + return r +} + +func (r ApiUpdateRuleRequest) Execute() (*SecurityRuleResponse, error) { + return r.ApiService.UpdateRuleExecute(r) +} + +/* +UpdateRule Update rule for a project + +Returns the updated rule for a specific project + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the key ring is part of. + @param regionId The STACKIT region name the resource is located in. + @return ApiUpdateRuleRequest +*/ +func (a *DefaultAPIService) UpdateRule(ctx context.Context, projectId string, regionId string) ApiUpdateRuleRequest { + return ApiUpdateRuleRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + } +} + +// Execute executes the request +// +// @return SecurityRuleResponse +func (a *DefaultAPIService) UpdateRuleExecute(r ApiUpdateRuleRequest) (*SecurityRuleResponse, error) { + var ( + localVarHTTPMethod = http.MethodPut + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *SecurityRuleResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.UpdateRule") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1beta/projects/{projectId}/regions/{regionId}/rules" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(parameterValueToString(r.regionId, "regionId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // 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.updateRulePayload + 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 == 400 { + var v ErrorResponse + 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 + } + if localVarHTTPResponse.StatusCode == 401 { + var v ErrorResponse + 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 + } + if localVarHTTPResponse.StatusCode == 403 { + var v ErrorResponse + 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 + } + if localVarHTTPResponse.StatusCode == 404 { + var v ErrorResponse + 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 + } + if localVarHTTPResponse.StatusCode == 500 { + var v ErrorResponse + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} diff --git a/services/ufw/v1betaapi/api_default_mock.go b/services/ufw/v1betaapi/api_default_mock.go new file mode 100644 index 000000000..d664916e0 --- /dev/null +++ b/services/ufw/v1betaapi/api_default_mock.go @@ -0,0 +1,149 @@ +/* +STACKIT Unified Firewall API + +API for managing and controlling the STACKIT Unified Firewall. + +API version: 1beta.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1betaapi + +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 { + // CreateRuleExecuteMock can be populated to implement the behavior of the CreateRuleExecute function of this mock + CreateRuleExecuteMock *func(r ApiCreateRuleRequest) (*SecurityRuleResponse, error) + // DeleteRuleExecuteMock can be populated to implement the behavior of the DeleteRuleExecute function of this mock + DeleteRuleExecuteMock *func(r ApiDeleteRuleRequest) (*SecurityRuleResponse, error) + // ListInstancesForServiceExecuteMock can be populated to implement the behavior of the ListInstancesForServiceExecute function of this mock + ListInstancesForServiceExecuteMock *func(r ApiListInstancesForServiceRequest) ([]ServicesResponse, error) + // ListProviderOptionsExecuteMock can be populated to implement the behavior of the ListProviderOptionsExecute function of this mock + ListProviderOptionsExecuteMock *func(r ApiListProviderOptionsRequest) ([]ProviderOptionsResponse, error) + // ListRulesExecuteMock can be populated to implement the behavior of the ListRulesExecute function of this mock + ListRulesExecuteMock *func(r ApiListRulesRequest) (*SecurityRulesResponse, error) + // UpdateRuleExecuteMock can be populated to implement the behavior of the UpdateRuleExecute function of this mock + UpdateRuleExecuteMock *func(r ApiUpdateRuleRequest) (*SecurityRuleResponse, error) +} + +func (a DefaultAPIServiceMock) CreateRule(ctx context.Context, projectId string, regionId string) ApiCreateRuleRequest { + return ApiCreateRuleRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + } +} + +// CreateRuleExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the CreateRuleExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) CreateRuleExecute(r ApiCreateRuleRequest) (*SecurityRuleResponse, error) { + if a.CreateRuleExecuteMock == nil { + var localVarReturnValue *SecurityRuleResponse + return localVarReturnValue, nil + } + + return (*a.CreateRuleExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) DeleteRule(ctx context.Context, projectId string, regionId string) ApiDeleteRuleRequest { + return ApiDeleteRuleRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + } +} + +// DeleteRuleExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the DeleteRuleExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) DeleteRuleExecute(r ApiDeleteRuleRequest) (*SecurityRuleResponse, error) { + if a.DeleteRuleExecuteMock == nil { + var localVarReturnValue *SecurityRuleResponse + return localVarReturnValue, nil + } + + return (*a.DeleteRuleExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) ListInstancesForService(ctx context.Context, projectId string, regionId string, serviceId string) ApiListInstancesForServiceRequest { + return ApiListInstancesForServiceRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + serviceId: serviceId, + } +} + +// ListInstancesForServiceExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the ListInstancesForServiceExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) ListInstancesForServiceExecute(r ApiListInstancesForServiceRequest) ([]ServicesResponse, error) { + if a.ListInstancesForServiceExecuteMock == nil { + var localVarReturnValue []ServicesResponse + return localVarReturnValue, nil + } + + return (*a.ListInstancesForServiceExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) ListProviderOptions(ctx context.Context, regionId string) ApiListProviderOptionsRequest { + return ApiListProviderOptionsRequest{ + ApiService: a, + ctx: ctx, + regionId: regionId, + } +} + +// ListProviderOptionsExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the ListProviderOptionsExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) ListProviderOptionsExecute(r ApiListProviderOptionsRequest) ([]ProviderOptionsResponse, error) { + if a.ListProviderOptionsExecuteMock == nil { + var localVarReturnValue []ProviderOptionsResponse + return localVarReturnValue, nil + } + + return (*a.ListProviderOptionsExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) ListRules(ctx context.Context, projectId string, regionId string) ApiListRulesRequest { + return ApiListRulesRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + } +} + +// 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) (*SecurityRulesResponse, error) { + if a.ListRulesExecuteMock == nil { + var localVarReturnValue *SecurityRulesResponse + return localVarReturnValue, nil + } + + return (*a.ListRulesExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) UpdateRule(ctx context.Context, projectId string, regionId string) ApiUpdateRuleRequest { + return ApiUpdateRuleRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + } +} + +// UpdateRuleExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the UpdateRuleExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) UpdateRuleExecute(r ApiUpdateRuleRequest) (*SecurityRuleResponse, error) { + if a.UpdateRuleExecuteMock == nil { + var localVarReturnValue *SecurityRuleResponse + return localVarReturnValue, nil + } + + return (*a.UpdateRuleExecuteMock)(r) +} diff --git a/services/ufw/v1betaapi/client.go b/services/ufw/v1betaapi/client.go new file mode 100644 index 000000000..1878b62e8 --- /dev/null +++ b/services/ufw/v1betaapi/client.go @@ -0,0 +1,658 @@ +/* +STACKIT Unified Firewall API + +API for managing and controlling the STACKIT Unified Firewall. + +API version: 1beta.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. +package v1betaapi + +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 Unified Firewall API API v1beta.0.1 +// 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/ufw/v1betaapi/configuration.go b/services/ufw/v1betaapi/configuration.go new file mode 100644 index 000000000..d86fe8560 --- /dev/null +++ b/services/ufw/v1betaapi/configuration.go @@ -0,0 +1,37 @@ +/* +STACKIT Unified Firewall API + +API for managing and controlling the STACKIT Unified Firewall. + +API version: 1beta.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. +package v1betaapi + +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/ufw", + Debug: false, + Servers: config.ServerConfigurations{ + { + URL: "https://ufw.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/ufw/v1betaapi/model_create_rule_payload.go b/services/ufw/v1betaapi/model_create_rule_payload.go new file mode 100644 index 000000000..69d119316 --- /dev/null +++ b/services/ufw/v1betaapi/model_create_rule_payload.go @@ -0,0 +1,523 @@ +/* +STACKIT Unified Firewall API + +API for managing and controlling the STACKIT Unified Firewall. + +API version: 1beta.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1betaapi + +import ( + "encoding/json" + "fmt" +) + +// checks if the CreateRulePayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &CreateRulePayload{} + +// CreateRulePayload The request body for creating a new security rule. +type CreateRulePayload struct { + // A description for the rule. + Description *string `json:"description,omitempty"` + // The direction of the traffic, typically \"ingress\" or \"egress\". + Direction *string `json:"direction,omitempty"` + // Specifies the bound of the rule. + EtherType *string `json:"etherType,omitempty"` + // The ID of the product, similar to a project ID. + InstanceId string `json:"instanceId"` + // Position in the list. + Offset *int32 `json:"offset,omitempty"` + // The Port range to which the rule applies. + PortRange *string `json:"portRange,omitempty"` + // The source service (e.g., Load Balancer, Redis). + Product string `json:"product"` + // The network protocol (e.g., \"TCP\", \"UDP\", \"ICMP\"). + Protocol *string `json:"protocol,omitempty"` + // The ID of the Group. + SecurityGroupId *string `json:"securityGroupId,omitempty"` + // The IP (CIDR) to which the rule applies. + SourceIP string `json:"sourceIP"` + // The type of the rule (e.g., \"ACL\", \"PublicIP\", \"SecurityRule\"). + Type string `json:"type"` + AdditionalProperties map[string]interface{} +} + +type _CreateRulePayload CreateRulePayload + +// NewCreateRulePayload instantiates a new CreateRulePayload 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 NewCreateRulePayload(instanceId string, product string, sourceIP string, types string) *CreateRulePayload { + this := CreateRulePayload{} + this.InstanceId = instanceId + this.Product = product + this.SourceIP = sourceIP + this.Type = types + return &this +} + +// NewCreateRulePayloadWithDefaults instantiates a new CreateRulePayload 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 NewCreateRulePayloadWithDefaults() *CreateRulePayload { + this := CreateRulePayload{} + return &this +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *CreateRulePayload) GetDescription() string { + if o == nil || IsNil(o.Description) { + var ret string + return ret + } + return *o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateRulePayload) GetDescriptionOk() (*string, bool) { + if o == nil || IsNil(o.Description) { + return nil, false + } + return o.Description, true +} + +// HasDescription returns a boolean if a field has been set. +func (o *CreateRulePayload) HasDescription() bool { + if o != nil && !IsNil(o.Description) { + return true + } + + return false +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *CreateRulePayload) SetDescription(v string) { + o.Description = &v +} + +// GetDirection returns the Direction field value if set, zero value otherwise. +func (o *CreateRulePayload) GetDirection() string { + if o == nil || IsNil(o.Direction) { + var ret string + return ret + } + return *o.Direction +} + +// GetDirectionOk returns a tuple with the Direction field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateRulePayload) GetDirectionOk() (*string, bool) { + if o == nil || IsNil(o.Direction) { + return nil, false + } + return o.Direction, true +} + +// HasDirection returns a boolean if a field has been set. +func (o *CreateRulePayload) HasDirection() bool { + if o != nil && !IsNil(o.Direction) { + return true + } + + return false +} + +// SetDirection gets a reference to the given string and assigns it to the Direction field. +func (o *CreateRulePayload) SetDirection(v string) { + o.Direction = &v +} + +// GetEtherType returns the EtherType field value if set, zero value otherwise. +func (o *CreateRulePayload) GetEtherType() string { + if o == nil || IsNil(o.EtherType) { + var ret string + return ret + } + return *o.EtherType +} + +// GetEtherTypeOk returns a tuple with the EtherType field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateRulePayload) GetEtherTypeOk() (*string, bool) { + if o == nil || IsNil(o.EtherType) { + return nil, false + } + return o.EtherType, true +} + +// HasEtherType returns a boolean if a field has been set. +func (o *CreateRulePayload) HasEtherType() bool { + if o != nil && !IsNil(o.EtherType) { + return true + } + + return false +} + +// SetEtherType gets a reference to the given string and assigns it to the EtherType field. +func (o *CreateRulePayload) SetEtherType(v string) { + o.EtherType = &v +} + +// GetInstanceId returns the InstanceId field value +func (o *CreateRulePayload) GetInstanceId() string { + if o == nil { + var ret string + return ret + } + + return o.InstanceId +} + +// GetInstanceIdOk returns a tuple with the InstanceId field value +// and a boolean to check if the value has been set. +func (o *CreateRulePayload) GetInstanceIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.InstanceId, true +} + +// SetInstanceId sets field value +func (o *CreateRulePayload) SetInstanceId(v string) { + o.InstanceId = v +} + +// GetOffset returns the Offset field value if set, zero value otherwise. +func (o *CreateRulePayload) GetOffset() int32 { + if o == nil || IsNil(o.Offset) { + var ret int32 + return ret + } + return *o.Offset +} + +// GetOffsetOk returns a tuple with the Offset field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateRulePayload) GetOffsetOk() (*int32, bool) { + if o == nil || IsNil(o.Offset) { + return nil, false + } + return o.Offset, true +} + +// HasOffset returns a boolean if a field has been set. +func (o *CreateRulePayload) HasOffset() bool { + if o != nil && !IsNil(o.Offset) { + return true + } + + return false +} + +// SetOffset gets a reference to the given int32 and assigns it to the Offset field. +func (o *CreateRulePayload) SetOffset(v int32) { + o.Offset = &v +} + +// GetPortRange returns the PortRange field value if set, zero value otherwise. +func (o *CreateRulePayload) GetPortRange() string { + if o == nil || IsNil(o.PortRange) { + var ret string + return ret + } + return *o.PortRange +} + +// GetPortRangeOk returns a tuple with the PortRange field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateRulePayload) GetPortRangeOk() (*string, bool) { + if o == nil || IsNil(o.PortRange) { + return nil, false + } + return o.PortRange, true +} + +// HasPortRange returns a boolean if a field has been set. +func (o *CreateRulePayload) HasPortRange() bool { + if o != nil && !IsNil(o.PortRange) { + return true + } + + return false +} + +// SetPortRange gets a reference to the given string and assigns it to the PortRange field. +func (o *CreateRulePayload) SetPortRange(v string) { + o.PortRange = &v +} + +// GetProduct returns the Product field value +func (o *CreateRulePayload) GetProduct() string { + if o == nil { + var ret string + return ret + } + + return o.Product +} + +// GetProductOk returns a tuple with the Product field value +// and a boolean to check if the value has been set. +func (o *CreateRulePayload) GetProductOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Product, true +} + +// SetProduct sets field value +func (o *CreateRulePayload) SetProduct(v string) { + o.Product = v +} + +// GetProtocol returns the Protocol field value if set, zero value otherwise. +func (o *CreateRulePayload) GetProtocol() string { + if o == nil || IsNil(o.Protocol) { + var ret string + return ret + } + return *o.Protocol +} + +// GetProtocolOk returns a tuple with the Protocol field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateRulePayload) GetProtocolOk() (*string, bool) { + if o == nil || IsNil(o.Protocol) { + return nil, false + } + return o.Protocol, true +} + +// HasProtocol returns a boolean if a field has been set. +func (o *CreateRulePayload) HasProtocol() bool { + if o != nil && !IsNil(o.Protocol) { + return true + } + + return false +} + +// SetProtocol gets a reference to the given string and assigns it to the Protocol field. +func (o *CreateRulePayload) SetProtocol(v string) { + o.Protocol = &v +} + +// GetSecurityGroupId returns the SecurityGroupId field value if set, zero value otherwise. +func (o *CreateRulePayload) GetSecurityGroupId() string { + if o == nil || IsNil(o.SecurityGroupId) { + var ret string + return ret + } + return *o.SecurityGroupId +} + +// GetSecurityGroupIdOk returns a tuple with the SecurityGroupId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateRulePayload) GetSecurityGroupIdOk() (*string, bool) { + if o == nil || IsNil(o.SecurityGroupId) { + return nil, false + } + return o.SecurityGroupId, true +} + +// HasSecurityGroupId returns a boolean if a field has been set. +func (o *CreateRulePayload) HasSecurityGroupId() bool { + if o != nil && !IsNil(o.SecurityGroupId) { + return true + } + + return false +} + +// SetSecurityGroupId gets a reference to the given string and assigns it to the SecurityGroupId field. +func (o *CreateRulePayload) SetSecurityGroupId(v string) { + o.SecurityGroupId = &v +} + +// GetSourceIP returns the SourceIP field value +func (o *CreateRulePayload) GetSourceIP() string { + if o == nil { + var ret string + return ret + } + + return o.SourceIP +} + +// GetSourceIPOk returns a tuple with the SourceIP field value +// and a boolean to check if the value has been set. +func (o *CreateRulePayload) GetSourceIPOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.SourceIP, true +} + +// SetSourceIP sets field value +func (o *CreateRulePayload) SetSourceIP(v string) { + o.SourceIP = v +} + +// GetType returns the Type field value +func (o *CreateRulePayload) GetType() string { + if o == nil { + var ret string + return ret + } + + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *CreateRulePayload) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value +func (o *CreateRulePayload) SetType(v string) { + o.Type = v +} + +func (o CreateRulePayload) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o CreateRulePayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Description) { + toSerialize["description"] = o.Description + } + if !IsNil(o.Direction) { + toSerialize["direction"] = o.Direction + } + if !IsNil(o.EtherType) { + toSerialize["etherType"] = o.EtherType + } + toSerialize["instanceId"] = o.InstanceId + if !IsNil(o.Offset) { + toSerialize["offset"] = o.Offset + } + if !IsNil(o.PortRange) { + toSerialize["portRange"] = o.PortRange + } + toSerialize["product"] = o.Product + if !IsNil(o.Protocol) { + toSerialize["protocol"] = o.Protocol + } + if !IsNil(o.SecurityGroupId) { + toSerialize["securityGroupId"] = o.SecurityGroupId + } + toSerialize["sourceIP"] = o.SourceIP + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *CreateRulePayload) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "instanceId", + "product", + "sourceIP", + "type", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err + } + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varCreateRulePayload := _CreateRulePayload{} + + err = json.Unmarshal(data, &varCreateRulePayload) + + if err != nil { + return err + } + + *o = CreateRulePayload(varCreateRulePayload) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "description") + delete(additionalProperties, "direction") + delete(additionalProperties, "etherType") + delete(additionalProperties, "instanceId") + delete(additionalProperties, "offset") + delete(additionalProperties, "portRange") + delete(additionalProperties, "product") + delete(additionalProperties, "protocol") + delete(additionalProperties, "securityGroupId") + delete(additionalProperties, "sourceIP") + delete(additionalProperties, "type") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableCreateRulePayload struct { + value *CreateRulePayload + isSet bool +} + +func (v NullableCreateRulePayload) Get() *CreateRulePayload { + return v.value +} + +func (v *NullableCreateRulePayload) Set(val *CreateRulePayload) { + v.value = val + v.isSet = true +} + +func (v NullableCreateRulePayload) IsSet() bool { + return v.isSet +} + +func (v *NullableCreateRulePayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCreateRulePayload(val *CreateRulePayload) *NullableCreateRulePayload { + return &NullableCreateRulePayload{value: val, isSet: true} +} + +func (v NullableCreateRulePayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCreateRulePayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/ufw/v1betaapi/model_error_response.go b/services/ufw/v1betaapi/model_error_response.go new file mode 100644 index 000000000..e72df6112 --- /dev/null +++ b/services/ufw/v1betaapi/model_error_response.go @@ -0,0 +1,190 @@ +/* +STACKIT Unified Firewall API + +API for managing and controlling the STACKIT Unified Firewall. + +API version: 1beta.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1betaapi + +import ( + "encoding/json" +) + +// checks if the ErrorResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ErrorResponse{} + +// ErrorResponse struct for ErrorResponse +type ErrorResponse struct { + Code *int32 `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _ErrorResponse ErrorResponse + +// NewErrorResponse instantiates a new ErrorResponse 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 NewErrorResponse() *ErrorResponse { + this := ErrorResponse{} + return &this +} + +// NewErrorResponseWithDefaults instantiates a new ErrorResponse 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 NewErrorResponseWithDefaults() *ErrorResponse { + this := ErrorResponse{} + return &this +} + +// GetCode returns the Code field value if set, zero value otherwise. +func (o *ErrorResponse) 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 *ErrorResponse) 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 *ErrorResponse) 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 *ErrorResponse) SetCode(v int32) { + o.Code = &v +} + +// GetMessage returns the Message field value if set, zero value otherwise. +func (o *ErrorResponse) 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 *ErrorResponse) 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 *ErrorResponse) 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 *ErrorResponse) SetMessage(v string) { + o.Message = &v +} + +func (o ErrorResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ErrorResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Code) { + toSerialize["code"] = o.Code + } + if !IsNil(o.Message) { + toSerialize["message"] = o.Message + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *ErrorResponse) UnmarshalJSON(data []byte) (err error) { + varErrorResponse := _ErrorResponse{} + + err = json.Unmarshal(data, &varErrorResponse) + + if err != nil { + return err + } + + *o = ErrorResponse(varErrorResponse) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "code") + delete(additionalProperties, "message") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableErrorResponse struct { + value *ErrorResponse + isSet bool +} + +func (v NullableErrorResponse) Get() *ErrorResponse { + return v.value +} + +func (v *NullableErrorResponse) Set(val *ErrorResponse) { + v.value = val + v.isSet = true +} + +func (v NullableErrorResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableErrorResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableErrorResponse(val *ErrorResponse) *NullableErrorResponse { + return &NullableErrorResponse{value: val, isSet: true} +} + +func (v NullableErrorResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableErrorResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/ufw/v1betaapi/model_provider_options_product_meta.go b/services/ufw/v1betaapi/model_provider_options_product_meta.go new file mode 100644 index 000000000..497529798 --- /dev/null +++ b/services/ufw/v1betaapi/model_provider_options_product_meta.go @@ -0,0 +1,195 @@ +/* +STACKIT Unified Firewall API + +API for managing and controlling the STACKIT Unified Firewall. + +API version: 1beta.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1betaapi + +import ( + "encoding/json" + "fmt" +) + +// checks if the ProviderOptionsProductMeta type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ProviderOptionsProductMeta{} + +// ProviderOptionsProductMeta struct for ProviderOptionsProductMeta +type ProviderOptionsProductMeta struct { + Actions []string `json:"actions"` + Types []string `json:"types"` + AdditionalProperties map[string]interface{} +} + +type _ProviderOptionsProductMeta ProviderOptionsProductMeta + +// NewProviderOptionsProductMeta instantiates a new ProviderOptionsProductMeta 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 NewProviderOptionsProductMeta(actions []string, types []string) *ProviderOptionsProductMeta { + this := ProviderOptionsProductMeta{} + this.Actions = actions + this.Types = types + return &this +} + +// NewProviderOptionsProductMetaWithDefaults instantiates a new ProviderOptionsProductMeta 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 NewProviderOptionsProductMetaWithDefaults() *ProviderOptionsProductMeta { + this := ProviderOptionsProductMeta{} + return &this +} + +// GetActions returns the Actions field value +func (o *ProviderOptionsProductMeta) GetActions() []string { + if o == nil { + var ret []string + return ret + } + + return o.Actions +} + +// GetActionsOk returns a tuple with the Actions field value +// and a boolean to check if the value has been set. +func (o *ProviderOptionsProductMeta) GetActionsOk() ([]string, bool) { + if o == nil { + return nil, false + } + return o.Actions, true +} + +// SetActions sets field value +func (o *ProviderOptionsProductMeta) SetActions(v []string) { + o.Actions = v +} + +// GetTypes returns the Types field value +func (o *ProviderOptionsProductMeta) GetTypes() []string { + if o == nil { + var ret []string + return ret + } + + return o.Types +} + +// GetTypesOk returns a tuple with the Types field value +// and a boolean to check if the value has been set. +func (o *ProviderOptionsProductMeta) GetTypesOk() ([]string, bool) { + if o == nil { + return nil, false + } + return o.Types, true +} + +// SetTypes sets field value +func (o *ProviderOptionsProductMeta) SetTypes(v []string) { + o.Types = v +} + +func (o ProviderOptionsProductMeta) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ProviderOptionsProductMeta) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["actions"] = o.Actions + toSerialize["types"] = o.Types + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *ProviderOptionsProductMeta) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "actions", + "types", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err + } + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varProviderOptionsProductMeta := _ProviderOptionsProductMeta{} + + err = json.Unmarshal(data, &varProviderOptionsProductMeta) + + if err != nil { + return err + } + + *o = ProviderOptionsProductMeta(varProviderOptionsProductMeta) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "actions") + delete(additionalProperties, "types") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableProviderOptionsProductMeta struct { + value *ProviderOptionsProductMeta + isSet bool +} + +func (v NullableProviderOptionsProductMeta) Get() *ProviderOptionsProductMeta { + return v.value +} + +func (v *NullableProviderOptionsProductMeta) Set(val *ProviderOptionsProductMeta) { + v.value = val + v.isSet = true +} + +func (v NullableProviderOptionsProductMeta) IsSet() bool { + return v.isSet +} + +func (v *NullableProviderOptionsProductMeta) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableProviderOptionsProductMeta(val *ProviderOptionsProductMeta) *NullableProviderOptionsProductMeta { + return &NullableProviderOptionsProductMeta{value: val, isSet: true} +} + +func (v NullableProviderOptionsProductMeta) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableProviderOptionsProductMeta) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/ufw/v1betaapi/model_provider_options_response.go b/services/ufw/v1betaapi/model_provider_options_response.go new file mode 100644 index 000000000..bdda70b3f --- /dev/null +++ b/services/ufw/v1betaapi/model_provider_options_response.go @@ -0,0 +1,224 @@ +/* +STACKIT Unified Firewall API + +API for managing and controlling the STACKIT Unified Firewall. + +API version: 1beta.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1betaapi + +import ( + "encoding/json" + "fmt" +) + +// checks if the ProviderOptionsResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ProviderOptionsResponse{} + +// ProviderOptionsResponse struct for ProviderOptionsResponse +type ProviderOptionsResponse struct { + ProductMeta map[string]ProviderOptionsProductMeta `json:"productMeta"` + Products []string `json:"products"` + Types []string `json:"types"` + AdditionalProperties map[string]interface{} +} + +type _ProviderOptionsResponse ProviderOptionsResponse + +// NewProviderOptionsResponse instantiates a new ProviderOptionsResponse 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 NewProviderOptionsResponse(productMeta map[string]ProviderOptionsProductMeta, products []string, types []string) *ProviderOptionsResponse { + this := ProviderOptionsResponse{} + this.ProductMeta = productMeta + this.Products = products + this.Types = types + return &this +} + +// NewProviderOptionsResponseWithDefaults instantiates a new ProviderOptionsResponse 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 NewProviderOptionsResponseWithDefaults() *ProviderOptionsResponse { + this := ProviderOptionsResponse{} + return &this +} + +// GetProductMeta returns the ProductMeta field value +func (o *ProviderOptionsResponse) GetProductMeta() map[string]ProviderOptionsProductMeta { + if o == nil { + var ret map[string]ProviderOptionsProductMeta + return ret + } + + return o.ProductMeta +} + +// GetProductMetaOk returns a tuple with the ProductMeta field value +// and a boolean to check if the value has been set. +func (o *ProviderOptionsResponse) GetProductMetaOk() (*map[string]ProviderOptionsProductMeta, bool) { + if o == nil { + return nil, false + } + return &o.ProductMeta, true +} + +// SetProductMeta sets field value +func (o *ProviderOptionsResponse) SetProductMeta(v map[string]ProviderOptionsProductMeta) { + o.ProductMeta = v +} + +// GetProducts returns the Products field value +func (o *ProviderOptionsResponse) GetProducts() []string { + if o == nil { + var ret []string + return ret + } + + return o.Products +} + +// GetProductsOk returns a tuple with the Products field value +// and a boolean to check if the value has been set. +func (o *ProviderOptionsResponse) GetProductsOk() ([]string, bool) { + if o == nil { + return nil, false + } + return o.Products, true +} + +// SetProducts sets field value +func (o *ProviderOptionsResponse) SetProducts(v []string) { + o.Products = v +} + +// GetTypes returns the Types field value +func (o *ProviderOptionsResponse) GetTypes() []string { + if o == nil { + var ret []string + return ret + } + + return o.Types +} + +// GetTypesOk returns a tuple with the Types field value +// and a boolean to check if the value has been set. +func (o *ProviderOptionsResponse) GetTypesOk() ([]string, bool) { + if o == nil { + return nil, false + } + return o.Types, true +} + +// SetTypes sets field value +func (o *ProviderOptionsResponse) SetTypes(v []string) { + o.Types = v +} + +func (o ProviderOptionsResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ProviderOptionsResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["productMeta"] = o.ProductMeta + toSerialize["products"] = o.Products + toSerialize["types"] = o.Types + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *ProviderOptionsResponse) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "productMeta", + "products", + "types", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err + } + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varProviderOptionsResponse := _ProviderOptionsResponse{} + + err = json.Unmarshal(data, &varProviderOptionsResponse) + + if err != nil { + return err + } + + *o = ProviderOptionsResponse(varProviderOptionsResponse) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "productMeta") + delete(additionalProperties, "products") + delete(additionalProperties, "types") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableProviderOptionsResponse struct { + value *ProviderOptionsResponse + isSet bool +} + +func (v NullableProviderOptionsResponse) Get() *ProviderOptionsResponse { + return v.value +} + +func (v *NullableProviderOptionsResponse) Set(val *ProviderOptionsResponse) { + v.value = val + v.isSet = true +} + +func (v NullableProviderOptionsResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableProviderOptionsResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableProviderOptionsResponse(val *ProviderOptionsResponse) *NullableProviderOptionsResponse { + return &NullableProviderOptionsResponse{value: val, isSet: true} +} + +func (v NullableProviderOptionsResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableProviderOptionsResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/ufw/v1betaapi/model_rule_response.go b/services/ufw/v1betaapi/model_rule_response.go new file mode 100644 index 000000000..def3414bc --- /dev/null +++ b/services/ufw/v1betaapi/model_rule_response.go @@ -0,0 +1,792 @@ +/* +STACKIT Unified Firewall API + +API for managing and controlling the STACKIT Unified Firewall. + +API version: 1beta.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1betaapi + +import ( + "encoding/json" + "fmt" +) + +// checks if the RuleResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &RuleResponse{} + +// RuleResponse struct for RuleResponse +type RuleResponse struct { + Description *string `json:"description,omitempty"` + Destination string `json:"destination"` + Direction *string `json:"direction,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + EtherType *string `json:"etherType,omitempty"` + InstanceId string `json:"instanceId"` + InstanceName *string `json:"instanceName,omitempty"` + IpRange string `json:"ipRange"` + Offset *int32 `json:"offset,omitempty"` + PortRange *string `json:"portRange,omitempty"` + Product string `json:"product"` + Protocol *string `json:"protocol,omitempty"` + Region *string `json:"region,omitempty"` + RemoteSecurityGroupId *string `json:"remoteSecurityGroupId,omitempty"` + SecurityGroup *string `json:"securityGroup,omitempty"` + SecurityGroupId *string `json:"securityGroupId,omitempty"` + SourceIP string `json:"sourceIP"` + Status *string `json:"status,omitempty"` + Type string `json:"type"` + AdditionalProperties map[string]interface{} +} + +type _RuleResponse RuleResponse + +// NewRuleResponse instantiates a new RuleResponse 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 NewRuleResponse(destination string, instanceId string, ipRange string, product string, sourceIP string, types string) *RuleResponse { + this := RuleResponse{} + this.Destination = destination + this.InstanceId = instanceId + this.IpRange = ipRange + this.Product = product + this.SourceIP = sourceIP + this.Type = types + return &this +} + +// NewRuleResponseWithDefaults instantiates a new RuleResponse 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 NewRuleResponseWithDefaults() *RuleResponse { + this := RuleResponse{} + return &this +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *RuleResponse) GetDescription() string { + if o == nil || IsNil(o.Description) { + var ret string + return ret + } + return *o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RuleResponse) GetDescriptionOk() (*string, bool) { + if o == nil || IsNil(o.Description) { + return nil, false + } + return o.Description, true +} + +// HasDescription returns a boolean if a field has been set. +func (o *RuleResponse) HasDescription() bool { + if o != nil && !IsNil(o.Description) { + return true + } + + return false +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *RuleResponse) SetDescription(v string) { + o.Description = &v +} + +// GetDestination returns the Destination field value +func (o *RuleResponse) GetDestination() string { + if o == nil { + var ret string + return ret + } + + return o.Destination +} + +// GetDestinationOk returns a tuple with the Destination field value +// and a boolean to check if the value has been set. +func (o *RuleResponse) GetDestinationOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Destination, true +} + +// SetDestination sets field value +func (o *RuleResponse) SetDestination(v string) { + o.Destination = v +} + +// GetDirection returns the Direction field value if set, zero value otherwise. +func (o *RuleResponse) GetDirection() string { + if o == nil || IsNil(o.Direction) { + var ret string + return ret + } + return *o.Direction +} + +// GetDirectionOk returns a tuple with the Direction field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RuleResponse) GetDirectionOk() (*string, bool) { + if o == nil || IsNil(o.Direction) { + return nil, false + } + return o.Direction, true +} + +// HasDirection returns a boolean if a field has been set. +func (o *RuleResponse) HasDirection() bool { + if o != nil && !IsNil(o.Direction) { + return true + } + + return false +} + +// SetDirection gets a reference to the given string and assigns it to the Direction field. +func (o *RuleResponse) SetDirection(v string) { + o.Direction = &v +} + +// GetErrorMessage returns the ErrorMessage field value if set, zero value otherwise. +func (o *RuleResponse) GetErrorMessage() string { + if o == nil || IsNil(o.ErrorMessage) { + var ret string + return ret + } + return *o.ErrorMessage +} + +// GetErrorMessageOk returns a tuple with the ErrorMessage field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RuleResponse) GetErrorMessageOk() (*string, bool) { + if o == nil || IsNil(o.ErrorMessage) { + return nil, false + } + return o.ErrorMessage, true +} + +// HasErrorMessage returns a boolean if a field has been set. +func (o *RuleResponse) HasErrorMessage() bool { + if o != nil && !IsNil(o.ErrorMessage) { + return true + } + + return false +} + +// SetErrorMessage gets a reference to the given string and assigns it to the ErrorMessage field. +func (o *RuleResponse) SetErrorMessage(v string) { + o.ErrorMessage = &v +} + +// GetEtherType returns the EtherType field value if set, zero value otherwise. +func (o *RuleResponse) GetEtherType() string { + if o == nil || IsNil(o.EtherType) { + var ret string + return ret + } + return *o.EtherType +} + +// GetEtherTypeOk returns a tuple with the EtherType field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RuleResponse) GetEtherTypeOk() (*string, bool) { + if o == nil || IsNil(o.EtherType) { + return nil, false + } + return o.EtherType, true +} + +// HasEtherType returns a boolean if a field has been set. +func (o *RuleResponse) HasEtherType() bool { + if o != nil && !IsNil(o.EtherType) { + return true + } + + return false +} + +// SetEtherType gets a reference to the given string and assigns it to the EtherType field. +func (o *RuleResponse) SetEtherType(v string) { + o.EtherType = &v +} + +// GetInstanceId returns the InstanceId field value +func (o *RuleResponse) GetInstanceId() string { + if o == nil { + var ret string + return ret + } + + return o.InstanceId +} + +// GetInstanceIdOk returns a tuple with the InstanceId field value +// and a boolean to check if the value has been set. +func (o *RuleResponse) GetInstanceIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.InstanceId, true +} + +// SetInstanceId sets field value +func (o *RuleResponse) SetInstanceId(v string) { + o.InstanceId = v +} + +// GetInstanceName returns the InstanceName field value if set, zero value otherwise. +func (o *RuleResponse) GetInstanceName() string { + if o == nil || IsNil(o.InstanceName) { + var ret string + return ret + } + return *o.InstanceName +} + +// GetInstanceNameOk returns a tuple with the InstanceName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RuleResponse) GetInstanceNameOk() (*string, bool) { + if o == nil || IsNil(o.InstanceName) { + return nil, false + } + return o.InstanceName, true +} + +// HasInstanceName returns a boolean if a field has been set. +func (o *RuleResponse) HasInstanceName() bool { + if o != nil && !IsNil(o.InstanceName) { + return true + } + + return false +} + +// SetInstanceName gets a reference to the given string and assigns it to the InstanceName field. +func (o *RuleResponse) SetInstanceName(v string) { + o.InstanceName = &v +} + +// GetIpRange returns the IpRange field value +func (o *RuleResponse) GetIpRange() string { + if o == nil { + var ret string + return ret + } + + return o.IpRange +} + +// GetIpRangeOk returns a tuple with the IpRange field value +// and a boolean to check if the value has been set. +func (o *RuleResponse) GetIpRangeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.IpRange, true +} + +// SetIpRange sets field value +func (o *RuleResponse) SetIpRange(v string) { + o.IpRange = v +} + +// GetOffset returns the Offset field value if set, zero value otherwise. +func (o *RuleResponse) GetOffset() int32 { + if o == nil || IsNil(o.Offset) { + var ret int32 + return ret + } + return *o.Offset +} + +// GetOffsetOk returns a tuple with the Offset field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RuleResponse) GetOffsetOk() (*int32, bool) { + if o == nil || IsNil(o.Offset) { + return nil, false + } + return o.Offset, true +} + +// HasOffset returns a boolean if a field has been set. +func (o *RuleResponse) HasOffset() bool { + if o != nil && !IsNil(o.Offset) { + return true + } + + return false +} + +// SetOffset gets a reference to the given int32 and assigns it to the Offset field. +func (o *RuleResponse) SetOffset(v int32) { + o.Offset = &v +} + +// GetPortRange returns the PortRange field value if set, zero value otherwise. +func (o *RuleResponse) GetPortRange() string { + if o == nil || IsNil(o.PortRange) { + var ret string + return ret + } + return *o.PortRange +} + +// GetPortRangeOk returns a tuple with the PortRange field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RuleResponse) GetPortRangeOk() (*string, bool) { + if o == nil || IsNil(o.PortRange) { + return nil, false + } + return o.PortRange, true +} + +// HasPortRange returns a boolean if a field has been set. +func (o *RuleResponse) HasPortRange() bool { + if o != nil && !IsNil(o.PortRange) { + return true + } + + return false +} + +// SetPortRange gets a reference to the given string and assigns it to the PortRange field. +func (o *RuleResponse) SetPortRange(v string) { + o.PortRange = &v +} + +// GetProduct returns the Product field value +func (o *RuleResponse) GetProduct() string { + if o == nil { + var ret string + return ret + } + + return o.Product +} + +// GetProductOk returns a tuple with the Product field value +// and a boolean to check if the value has been set. +func (o *RuleResponse) GetProductOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Product, true +} + +// SetProduct sets field value +func (o *RuleResponse) SetProduct(v string) { + o.Product = v +} + +// GetProtocol returns the Protocol field value if set, zero value otherwise. +func (o *RuleResponse) GetProtocol() string { + if o == nil || IsNil(o.Protocol) { + var ret string + return ret + } + return *o.Protocol +} + +// GetProtocolOk returns a tuple with the Protocol field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RuleResponse) GetProtocolOk() (*string, bool) { + if o == nil || IsNil(o.Protocol) { + return nil, false + } + return o.Protocol, true +} + +// HasProtocol returns a boolean if a field has been set. +func (o *RuleResponse) HasProtocol() bool { + if o != nil && !IsNil(o.Protocol) { + return true + } + + return false +} + +// SetProtocol gets a reference to the given string and assigns it to the Protocol field. +func (o *RuleResponse) SetProtocol(v string) { + o.Protocol = &v +} + +// GetRegion returns the Region field value if set, zero value otherwise. +func (o *RuleResponse) 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 *RuleResponse) 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 *RuleResponse) 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 *RuleResponse) SetRegion(v string) { + o.Region = &v +} + +// GetRemoteSecurityGroupId returns the RemoteSecurityGroupId field value if set, zero value otherwise. +func (o *RuleResponse) GetRemoteSecurityGroupId() string { + if o == nil || IsNil(o.RemoteSecurityGroupId) { + var ret string + return ret + } + return *o.RemoteSecurityGroupId +} + +// GetRemoteSecurityGroupIdOk returns a tuple with the RemoteSecurityGroupId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RuleResponse) GetRemoteSecurityGroupIdOk() (*string, bool) { + if o == nil || IsNil(o.RemoteSecurityGroupId) { + return nil, false + } + return o.RemoteSecurityGroupId, true +} + +// HasRemoteSecurityGroupId returns a boolean if a field has been set. +func (o *RuleResponse) HasRemoteSecurityGroupId() bool { + if o != nil && !IsNil(o.RemoteSecurityGroupId) { + return true + } + + return false +} + +// SetRemoteSecurityGroupId gets a reference to the given string and assigns it to the RemoteSecurityGroupId field. +func (o *RuleResponse) SetRemoteSecurityGroupId(v string) { + o.RemoteSecurityGroupId = &v +} + +// GetSecurityGroup returns the SecurityGroup field value if set, zero value otherwise. +func (o *RuleResponse) GetSecurityGroup() string { + if o == nil || IsNil(o.SecurityGroup) { + var ret string + return ret + } + return *o.SecurityGroup +} + +// GetSecurityGroupOk returns a tuple with the SecurityGroup field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RuleResponse) GetSecurityGroupOk() (*string, bool) { + if o == nil || IsNil(o.SecurityGroup) { + return nil, false + } + return o.SecurityGroup, true +} + +// HasSecurityGroup returns a boolean if a field has been set. +func (o *RuleResponse) HasSecurityGroup() bool { + if o != nil && !IsNil(o.SecurityGroup) { + return true + } + + return false +} + +// SetSecurityGroup gets a reference to the given string and assigns it to the SecurityGroup field. +func (o *RuleResponse) SetSecurityGroup(v string) { + o.SecurityGroup = &v +} + +// GetSecurityGroupId returns the SecurityGroupId field value if set, zero value otherwise. +func (o *RuleResponse) GetSecurityGroupId() string { + if o == nil || IsNil(o.SecurityGroupId) { + var ret string + return ret + } + return *o.SecurityGroupId +} + +// GetSecurityGroupIdOk returns a tuple with the SecurityGroupId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RuleResponse) GetSecurityGroupIdOk() (*string, bool) { + if o == nil || IsNil(o.SecurityGroupId) { + return nil, false + } + return o.SecurityGroupId, true +} + +// HasSecurityGroupId returns a boolean if a field has been set. +func (o *RuleResponse) HasSecurityGroupId() bool { + if o != nil && !IsNil(o.SecurityGroupId) { + return true + } + + return false +} + +// SetSecurityGroupId gets a reference to the given string and assigns it to the SecurityGroupId field. +func (o *RuleResponse) SetSecurityGroupId(v string) { + o.SecurityGroupId = &v +} + +// GetSourceIP returns the SourceIP field value +func (o *RuleResponse) GetSourceIP() string { + if o == nil { + var ret string + return ret + } + + return o.SourceIP +} + +// GetSourceIPOk returns a tuple with the SourceIP field value +// and a boolean to check if the value has been set. +func (o *RuleResponse) GetSourceIPOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.SourceIP, true +} + +// SetSourceIP sets field value +func (o *RuleResponse) SetSourceIP(v string) { + o.SourceIP = v +} + +// GetStatus returns the Status field value if set, zero value otherwise. +func (o *RuleResponse) GetStatus() string { + if o == nil || IsNil(o.Status) { + var ret string + return ret + } + return *o.Status +} + +// GetStatusOk returns a tuple with the Status field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RuleResponse) GetStatusOk() (*string, bool) { + if o == nil || IsNil(o.Status) { + return nil, false + } + return o.Status, true +} + +// HasStatus returns a boolean if a field has been set. +func (o *RuleResponse) HasStatus() bool { + if o != nil && !IsNil(o.Status) { + return true + } + + return false +} + +// SetStatus gets a reference to the given string and assigns it to the Status field. +func (o *RuleResponse) SetStatus(v string) { + o.Status = &v +} + +// GetType returns the Type field value +func (o *RuleResponse) GetType() string { + if o == nil { + var ret string + return ret + } + + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *RuleResponse) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value +func (o *RuleResponse) SetType(v string) { + o.Type = v +} + +func (o RuleResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o RuleResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Description) { + toSerialize["description"] = o.Description + } + toSerialize["destination"] = o.Destination + if !IsNil(o.Direction) { + toSerialize["direction"] = o.Direction + } + if !IsNil(o.ErrorMessage) { + toSerialize["errorMessage"] = o.ErrorMessage + } + if !IsNil(o.EtherType) { + toSerialize["etherType"] = o.EtherType + } + toSerialize["instanceId"] = o.InstanceId + if !IsNil(o.InstanceName) { + toSerialize["instanceName"] = o.InstanceName + } + toSerialize["ipRange"] = o.IpRange + if !IsNil(o.Offset) { + toSerialize["offset"] = o.Offset + } + if !IsNil(o.PortRange) { + toSerialize["portRange"] = o.PortRange + } + toSerialize["product"] = o.Product + if !IsNil(o.Protocol) { + toSerialize["protocol"] = o.Protocol + } + if !IsNil(o.Region) { + toSerialize["region"] = o.Region + } + if !IsNil(o.RemoteSecurityGroupId) { + toSerialize["remoteSecurityGroupId"] = o.RemoteSecurityGroupId + } + if !IsNil(o.SecurityGroup) { + toSerialize["securityGroup"] = o.SecurityGroup + } + if !IsNil(o.SecurityGroupId) { + toSerialize["securityGroupId"] = o.SecurityGroupId + } + toSerialize["sourceIP"] = o.SourceIP + if !IsNil(o.Status) { + toSerialize["status"] = o.Status + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *RuleResponse) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "destination", + "instanceId", + "ipRange", + "product", + "sourceIP", + "type", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err + } + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varRuleResponse := _RuleResponse{} + + err = json.Unmarshal(data, &varRuleResponse) + + if err != nil { + return err + } + + *o = RuleResponse(varRuleResponse) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "description") + delete(additionalProperties, "destination") + delete(additionalProperties, "direction") + delete(additionalProperties, "errorMessage") + delete(additionalProperties, "etherType") + delete(additionalProperties, "instanceId") + delete(additionalProperties, "instanceName") + delete(additionalProperties, "ipRange") + delete(additionalProperties, "offset") + delete(additionalProperties, "portRange") + delete(additionalProperties, "product") + delete(additionalProperties, "protocol") + delete(additionalProperties, "region") + delete(additionalProperties, "remoteSecurityGroupId") + delete(additionalProperties, "securityGroup") + delete(additionalProperties, "securityGroupId") + delete(additionalProperties, "sourceIP") + delete(additionalProperties, "status") + delete(additionalProperties, "type") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableRuleResponse struct { + value *RuleResponse + isSet bool +} + +func (v NullableRuleResponse) Get() *RuleResponse { + return v.value +} + +func (v *NullableRuleResponse) Set(val *RuleResponse) { + v.value = val + v.isSet = true +} + +func (v NullableRuleResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableRuleResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRuleResponse(val *RuleResponse) *NullableRuleResponse { + return &NullableRuleResponse{value: val, isSet: true} +} + +func (v NullableRuleResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRuleResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/ufw/v1betaapi/model_security_rule_response.go b/services/ufw/v1betaapi/model_security_rule_response.go new file mode 100644 index 000000000..862c96d1f --- /dev/null +++ b/services/ufw/v1betaapi/model_security_rule_response.go @@ -0,0 +1,154 @@ +/* +STACKIT Unified Firewall API + +API for managing and controlling the STACKIT Unified Firewall. + +API version: 1beta.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1betaapi + +import ( + "encoding/json" +) + +// checks if the SecurityRuleResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &SecurityRuleResponse{} + +// SecurityRuleResponse struct for SecurityRuleResponse +type SecurityRuleResponse struct { + // Represents if the call was successfully made + Success *bool `json:"success,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _SecurityRuleResponse SecurityRuleResponse + +// NewSecurityRuleResponse instantiates a new SecurityRuleResponse 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 NewSecurityRuleResponse() *SecurityRuleResponse { + this := SecurityRuleResponse{} + return &this +} + +// NewSecurityRuleResponseWithDefaults instantiates a new SecurityRuleResponse 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 NewSecurityRuleResponseWithDefaults() *SecurityRuleResponse { + this := SecurityRuleResponse{} + return &this +} + +// GetSuccess returns the Success field value if set, zero value otherwise. +func (o *SecurityRuleResponse) GetSuccess() bool { + if o == nil || IsNil(o.Success) { + var ret bool + return ret + } + return *o.Success +} + +// GetSuccessOk returns a tuple with the Success field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SecurityRuleResponse) GetSuccessOk() (*bool, bool) { + if o == nil || IsNil(o.Success) { + return nil, false + } + return o.Success, true +} + +// HasSuccess returns a boolean if a field has been set. +func (o *SecurityRuleResponse) HasSuccess() bool { + if o != nil && !IsNil(o.Success) { + return true + } + + return false +} + +// SetSuccess gets a reference to the given bool and assigns it to the Success field. +func (o *SecurityRuleResponse) SetSuccess(v bool) { + o.Success = &v +} + +func (o SecurityRuleResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o SecurityRuleResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Success) { + toSerialize["success"] = o.Success + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *SecurityRuleResponse) UnmarshalJSON(data []byte) (err error) { + varSecurityRuleResponse := _SecurityRuleResponse{} + + err = json.Unmarshal(data, &varSecurityRuleResponse) + + if err != nil { + return err + } + + *o = SecurityRuleResponse(varSecurityRuleResponse) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "success") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableSecurityRuleResponse struct { + value *SecurityRuleResponse + isSet bool +} + +func (v NullableSecurityRuleResponse) Get() *SecurityRuleResponse { + return v.value +} + +func (v *NullableSecurityRuleResponse) Set(val *SecurityRuleResponse) { + v.value = val + v.isSet = true +} + +func (v NullableSecurityRuleResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableSecurityRuleResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableSecurityRuleResponse(val *SecurityRuleResponse) *NullableSecurityRuleResponse { + return &NullableSecurityRuleResponse{value: val, isSet: true} +} + +func (v NullableSecurityRuleResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableSecurityRuleResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/ufw/v1betaapi/model_security_rules_response.go b/services/ufw/v1betaapi/model_security_rules_response.go new file mode 100644 index 000000000..03beae5ae --- /dev/null +++ b/services/ufw/v1betaapi/model_security_rules_response.go @@ -0,0 +1,203 @@ +/* +STACKIT Unified Firewall API + +API for managing and controlling the STACKIT Unified Firewall. + +API version: 1beta.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1betaapi + +import ( + "encoding/json" + "fmt" +) + +// checks if the SecurityRulesResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &SecurityRulesResponse{} + +// SecurityRulesResponse struct for SecurityRulesResponse +type SecurityRulesResponse struct { + Errors []string `json:"errors,omitempty"` + Rules []RuleResponse `json:"rules"` + AdditionalProperties map[string]interface{} +} + +type _SecurityRulesResponse SecurityRulesResponse + +// NewSecurityRulesResponse instantiates a new SecurityRulesResponse 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 NewSecurityRulesResponse(rules []RuleResponse) *SecurityRulesResponse { + this := SecurityRulesResponse{} + this.Rules = rules + return &this +} + +// NewSecurityRulesResponseWithDefaults instantiates a new SecurityRulesResponse 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 NewSecurityRulesResponseWithDefaults() *SecurityRulesResponse { + this := SecurityRulesResponse{} + return &this +} + +// GetErrors returns the Errors field value if set, zero value otherwise. +func (o *SecurityRulesResponse) GetErrors() []string { + if o == nil || IsNil(o.Errors) { + var ret []string + return ret + } + return o.Errors +} + +// GetErrorsOk returns a tuple with the Errors field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SecurityRulesResponse) GetErrorsOk() ([]string, bool) { + if o == nil || IsNil(o.Errors) { + return nil, false + } + return o.Errors, true +} + +// HasErrors returns a boolean if a field has been set. +func (o *SecurityRulesResponse) HasErrors() bool { + if o != nil && !IsNil(o.Errors) { + return true + } + + return false +} + +// SetErrors gets a reference to the given []string and assigns it to the Errors field. +func (o *SecurityRulesResponse) SetErrors(v []string) { + o.Errors = v +} + +// GetRules returns the Rules field value +func (o *SecurityRulesResponse) GetRules() []RuleResponse { + if o == nil { + var ret []RuleResponse + return ret + } + + return o.Rules +} + +// GetRulesOk returns a tuple with the Rules field value +// and a boolean to check if the value has been set. +func (o *SecurityRulesResponse) GetRulesOk() ([]RuleResponse, bool) { + if o == nil { + return nil, false + } + return o.Rules, true +} + +// SetRules sets field value +func (o *SecurityRulesResponse) SetRules(v []RuleResponse) { + o.Rules = v +} + +func (o SecurityRulesResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o SecurityRulesResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Errors) { + toSerialize["errors"] = o.Errors + } + toSerialize["rules"] = o.Rules + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *SecurityRulesResponse) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "rules", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err + } + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varSecurityRulesResponse := _SecurityRulesResponse{} + + err = json.Unmarshal(data, &varSecurityRulesResponse) + + if err != nil { + return err + } + + *o = SecurityRulesResponse(varSecurityRulesResponse) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "errors") + delete(additionalProperties, "rules") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableSecurityRulesResponse struct { + value *SecurityRulesResponse + isSet bool +} + +func (v NullableSecurityRulesResponse) Get() *SecurityRulesResponse { + return v.value +} + +func (v *NullableSecurityRulesResponse) Set(val *SecurityRulesResponse) { + v.value = val + v.isSet = true +} + +func (v NullableSecurityRulesResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableSecurityRulesResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableSecurityRulesResponse(val *SecurityRulesResponse) *NullableSecurityRulesResponse { + return &NullableSecurityRulesResponse{value: val, isSet: true} +} + +func (v NullableSecurityRulesResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableSecurityRulesResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/ufw/v1betaapi/model_services_response.go b/services/ufw/v1betaapi/model_services_response.go new file mode 100644 index 000000000..e83a85a9a --- /dev/null +++ b/services/ufw/v1betaapi/model_services_response.go @@ -0,0 +1,409 @@ +/* +STACKIT Unified Firewall API + +API for managing and controlling the STACKIT Unified Firewall. + +API version: 1beta.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1betaapi + +import ( + "encoding/json" + "fmt" +) + +// checks if the ServicesResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ServicesResponse{} + +// ServicesResponse struct for ServicesResponse +type ServicesResponse struct { + Description *string `json:"description,omitempty"` + InstanceId string `json:"instanceId"` + InstanceName *string `json:"instanceName,omitempty"` + Product string `json:"product"` + RemoteSecurityGroupId *string `json:"remoteSecurityGroupId,omitempty"` + SecurityGroup *string `json:"securityGroup,omitempty"` + SecurityGroupId *string `json:"securityGroupId,omitempty"` + Type string `json:"type"` + AdditionalProperties map[string]interface{} +} + +type _ServicesResponse ServicesResponse + +// NewServicesResponse instantiates a new ServicesResponse 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 NewServicesResponse(instanceId string, product string, types string) *ServicesResponse { + this := ServicesResponse{} + this.InstanceId = instanceId + this.Product = product + this.Type = types + return &this +} + +// NewServicesResponseWithDefaults instantiates a new ServicesResponse 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 NewServicesResponseWithDefaults() *ServicesResponse { + this := ServicesResponse{} + return &this +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *ServicesResponse) GetDescription() string { + if o == nil || IsNil(o.Description) { + var ret string + return ret + } + return *o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ServicesResponse) GetDescriptionOk() (*string, bool) { + if o == nil || IsNil(o.Description) { + return nil, false + } + return o.Description, true +} + +// HasDescription returns a boolean if a field has been set. +func (o *ServicesResponse) HasDescription() bool { + if o != nil && !IsNil(o.Description) { + return true + } + + return false +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *ServicesResponse) SetDescription(v string) { + o.Description = &v +} + +// GetInstanceId returns the InstanceId field value +func (o *ServicesResponse) GetInstanceId() string { + if o == nil { + var ret string + return ret + } + + return o.InstanceId +} + +// GetInstanceIdOk returns a tuple with the InstanceId field value +// and a boolean to check if the value has been set. +func (o *ServicesResponse) GetInstanceIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.InstanceId, true +} + +// SetInstanceId sets field value +func (o *ServicesResponse) SetInstanceId(v string) { + o.InstanceId = v +} + +// GetInstanceName returns the InstanceName field value if set, zero value otherwise. +func (o *ServicesResponse) GetInstanceName() string { + if o == nil || IsNil(o.InstanceName) { + var ret string + return ret + } + return *o.InstanceName +} + +// GetInstanceNameOk returns a tuple with the InstanceName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ServicesResponse) GetInstanceNameOk() (*string, bool) { + if o == nil || IsNil(o.InstanceName) { + return nil, false + } + return o.InstanceName, true +} + +// HasInstanceName returns a boolean if a field has been set. +func (o *ServicesResponse) HasInstanceName() bool { + if o != nil && !IsNil(o.InstanceName) { + return true + } + + return false +} + +// SetInstanceName gets a reference to the given string and assigns it to the InstanceName field. +func (o *ServicesResponse) SetInstanceName(v string) { + o.InstanceName = &v +} + +// GetProduct returns the Product field value +func (o *ServicesResponse) GetProduct() string { + if o == nil { + var ret string + return ret + } + + return o.Product +} + +// GetProductOk returns a tuple with the Product field value +// and a boolean to check if the value has been set. +func (o *ServicesResponse) GetProductOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Product, true +} + +// SetProduct sets field value +func (o *ServicesResponse) SetProduct(v string) { + o.Product = v +} + +// GetRemoteSecurityGroupId returns the RemoteSecurityGroupId field value if set, zero value otherwise. +func (o *ServicesResponse) GetRemoteSecurityGroupId() string { + if o == nil || IsNil(o.RemoteSecurityGroupId) { + var ret string + return ret + } + return *o.RemoteSecurityGroupId +} + +// GetRemoteSecurityGroupIdOk returns a tuple with the RemoteSecurityGroupId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ServicesResponse) GetRemoteSecurityGroupIdOk() (*string, bool) { + if o == nil || IsNil(o.RemoteSecurityGroupId) { + return nil, false + } + return o.RemoteSecurityGroupId, true +} + +// HasRemoteSecurityGroupId returns a boolean if a field has been set. +func (o *ServicesResponse) HasRemoteSecurityGroupId() bool { + if o != nil && !IsNil(o.RemoteSecurityGroupId) { + return true + } + + return false +} + +// SetRemoteSecurityGroupId gets a reference to the given string and assigns it to the RemoteSecurityGroupId field. +func (o *ServicesResponse) SetRemoteSecurityGroupId(v string) { + o.RemoteSecurityGroupId = &v +} + +// GetSecurityGroup returns the SecurityGroup field value if set, zero value otherwise. +func (o *ServicesResponse) GetSecurityGroup() string { + if o == nil || IsNil(o.SecurityGroup) { + var ret string + return ret + } + return *o.SecurityGroup +} + +// GetSecurityGroupOk returns a tuple with the SecurityGroup field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ServicesResponse) GetSecurityGroupOk() (*string, bool) { + if o == nil || IsNil(o.SecurityGroup) { + return nil, false + } + return o.SecurityGroup, true +} + +// HasSecurityGroup returns a boolean if a field has been set. +func (o *ServicesResponse) HasSecurityGroup() bool { + if o != nil && !IsNil(o.SecurityGroup) { + return true + } + + return false +} + +// SetSecurityGroup gets a reference to the given string and assigns it to the SecurityGroup field. +func (o *ServicesResponse) SetSecurityGroup(v string) { + o.SecurityGroup = &v +} + +// GetSecurityGroupId returns the SecurityGroupId field value if set, zero value otherwise. +func (o *ServicesResponse) GetSecurityGroupId() string { + if o == nil || IsNil(o.SecurityGroupId) { + var ret string + return ret + } + return *o.SecurityGroupId +} + +// GetSecurityGroupIdOk returns a tuple with the SecurityGroupId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ServicesResponse) GetSecurityGroupIdOk() (*string, bool) { + if o == nil || IsNil(o.SecurityGroupId) { + return nil, false + } + return o.SecurityGroupId, true +} + +// HasSecurityGroupId returns a boolean if a field has been set. +func (o *ServicesResponse) HasSecurityGroupId() bool { + if o != nil && !IsNil(o.SecurityGroupId) { + return true + } + + return false +} + +// SetSecurityGroupId gets a reference to the given string and assigns it to the SecurityGroupId field. +func (o *ServicesResponse) SetSecurityGroupId(v string) { + o.SecurityGroupId = &v +} + +// GetType returns the Type field value +func (o *ServicesResponse) GetType() string { + if o == nil { + var ret string + return ret + } + + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *ServicesResponse) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value +func (o *ServicesResponse) SetType(v string) { + o.Type = v +} + +func (o ServicesResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ServicesResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Description) { + toSerialize["description"] = o.Description + } + toSerialize["instanceId"] = o.InstanceId + if !IsNil(o.InstanceName) { + toSerialize["instanceName"] = o.InstanceName + } + toSerialize["product"] = o.Product + if !IsNil(o.RemoteSecurityGroupId) { + toSerialize["remoteSecurityGroupId"] = o.RemoteSecurityGroupId + } + if !IsNil(o.SecurityGroup) { + toSerialize["securityGroup"] = o.SecurityGroup + } + if !IsNil(o.SecurityGroupId) { + toSerialize["securityGroupId"] = o.SecurityGroupId + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *ServicesResponse) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "instanceId", + "product", + "type", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err + } + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varServicesResponse := _ServicesResponse{} + + err = json.Unmarshal(data, &varServicesResponse) + + if err != nil { + return err + } + + *o = ServicesResponse(varServicesResponse) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "description") + delete(additionalProperties, "instanceId") + delete(additionalProperties, "instanceName") + delete(additionalProperties, "product") + delete(additionalProperties, "remoteSecurityGroupId") + delete(additionalProperties, "securityGroup") + delete(additionalProperties, "securityGroupId") + delete(additionalProperties, "type") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableServicesResponse struct { + value *ServicesResponse + isSet bool +} + +func (v NullableServicesResponse) Get() *ServicesResponse { + return v.value +} + +func (v *NullableServicesResponse) Set(val *ServicesResponse) { + v.value = val + v.isSet = true +} + +func (v NullableServicesResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableServicesResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableServicesResponse(val *ServicesResponse) *NullableServicesResponse { + return &NullableServicesResponse{value: val, isSet: true} +} + +func (v NullableServicesResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableServicesResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/ufw/v1betaapi/model_update_rule_payload.go b/services/ufw/v1betaapi/model_update_rule_payload.go new file mode 100644 index 000000000..bd68b5d84 --- /dev/null +++ b/services/ufw/v1betaapi/model_update_rule_payload.go @@ -0,0 +1,523 @@ +/* +STACKIT Unified Firewall API + +API for managing and controlling the STACKIT Unified Firewall. + +API version: 1beta.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1betaapi + +import ( + "encoding/json" + "fmt" +) + +// checks if the UpdateRulePayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &UpdateRulePayload{} + +// UpdateRulePayload The request body for creating a new security rule. +type UpdateRulePayload struct { + // A description for the rule. + Description *string `json:"description,omitempty"` + // The direction of the traffic, typically \"ingress\" or \"egress\". + Direction *string `json:"direction,omitempty"` + // Specifies the bound of the rule. + EtherType *string `json:"etherType,omitempty"` + // The ID of the product, similar to a project ID. + InstanceId string `json:"instanceId"` + // Position in the list. + Offset *int32 `json:"offset,omitempty"` + // The Port range to which the rule applies. + PortRange *string `json:"portRange,omitempty"` + // The source service (e.g., Load Balancer, Redis). + Product string `json:"product"` + // The network protocol (e.g., \"TCP\", \"UDP\", \"ICMP\"). + Protocol *string `json:"protocol,omitempty"` + // The ID of the Group. + SecurityGroupId *string `json:"securityGroupId,omitempty"` + // The IP (CIDR) to which the rule applies. + SourceIP string `json:"sourceIP"` + // The type of the rule (e.g., \"ACL\", \"PublicIP\", \"SecurityRule\"). + Type string `json:"type"` + AdditionalProperties map[string]interface{} +} + +type _UpdateRulePayload UpdateRulePayload + +// NewUpdateRulePayload instantiates a new UpdateRulePayload 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 NewUpdateRulePayload(instanceId string, product string, sourceIP string, types string) *UpdateRulePayload { + this := UpdateRulePayload{} + this.InstanceId = instanceId + this.Product = product + this.SourceIP = sourceIP + this.Type = types + return &this +} + +// NewUpdateRulePayloadWithDefaults instantiates a new UpdateRulePayload 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 NewUpdateRulePayloadWithDefaults() *UpdateRulePayload { + this := UpdateRulePayload{} + return &this +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *UpdateRulePayload) GetDescription() string { + if o == nil || IsNil(o.Description) { + var ret string + return ret + } + return *o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateRulePayload) GetDescriptionOk() (*string, bool) { + if o == nil || IsNil(o.Description) { + return nil, false + } + return o.Description, true +} + +// HasDescription returns a boolean if a field has been set. +func (o *UpdateRulePayload) HasDescription() bool { + if o != nil && !IsNil(o.Description) { + return true + } + + return false +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *UpdateRulePayload) SetDescription(v string) { + o.Description = &v +} + +// GetDirection returns the Direction field value if set, zero value otherwise. +func (o *UpdateRulePayload) GetDirection() string { + if o == nil || IsNil(o.Direction) { + var ret string + return ret + } + return *o.Direction +} + +// GetDirectionOk returns a tuple with the Direction field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateRulePayload) GetDirectionOk() (*string, bool) { + if o == nil || IsNil(o.Direction) { + return nil, false + } + return o.Direction, true +} + +// HasDirection returns a boolean if a field has been set. +func (o *UpdateRulePayload) HasDirection() bool { + if o != nil && !IsNil(o.Direction) { + return true + } + + return false +} + +// SetDirection gets a reference to the given string and assigns it to the Direction field. +func (o *UpdateRulePayload) SetDirection(v string) { + o.Direction = &v +} + +// GetEtherType returns the EtherType field value if set, zero value otherwise. +func (o *UpdateRulePayload) GetEtherType() string { + if o == nil || IsNil(o.EtherType) { + var ret string + return ret + } + return *o.EtherType +} + +// GetEtherTypeOk returns a tuple with the EtherType field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateRulePayload) GetEtherTypeOk() (*string, bool) { + if o == nil || IsNil(o.EtherType) { + return nil, false + } + return o.EtherType, true +} + +// HasEtherType returns a boolean if a field has been set. +func (o *UpdateRulePayload) HasEtherType() bool { + if o != nil && !IsNil(o.EtherType) { + return true + } + + return false +} + +// SetEtherType gets a reference to the given string and assigns it to the EtherType field. +func (o *UpdateRulePayload) SetEtherType(v string) { + o.EtherType = &v +} + +// GetInstanceId returns the InstanceId field value +func (o *UpdateRulePayload) GetInstanceId() string { + if o == nil { + var ret string + return ret + } + + return o.InstanceId +} + +// GetInstanceIdOk returns a tuple with the InstanceId field value +// and a boolean to check if the value has been set. +func (o *UpdateRulePayload) GetInstanceIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.InstanceId, true +} + +// SetInstanceId sets field value +func (o *UpdateRulePayload) SetInstanceId(v string) { + o.InstanceId = v +} + +// GetOffset returns the Offset field value if set, zero value otherwise. +func (o *UpdateRulePayload) GetOffset() int32 { + if o == nil || IsNil(o.Offset) { + var ret int32 + return ret + } + return *o.Offset +} + +// GetOffsetOk returns a tuple with the Offset field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateRulePayload) GetOffsetOk() (*int32, bool) { + if o == nil || IsNil(o.Offset) { + return nil, false + } + return o.Offset, true +} + +// HasOffset returns a boolean if a field has been set. +func (o *UpdateRulePayload) HasOffset() bool { + if o != nil && !IsNil(o.Offset) { + return true + } + + return false +} + +// SetOffset gets a reference to the given int32 and assigns it to the Offset field. +func (o *UpdateRulePayload) SetOffset(v int32) { + o.Offset = &v +} + +// GetPortRange returns the PortRange field value if set, zero value otherwise. +func (o *UpdateRulePayload) GetPortRange() string { + if o == nil || IsNil(o.PortRange) { + var ret string + return ret + } + return *o.PortRange +} + +// GetPortRangeOk returns a tuple with the PortRange field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateRulePayload) GetPortRangeOk() (*string, bool) { + if o == nil || IsNil(o.PortRange) { + return nil, false + } + return o.PortRange, true +} + +// HasPortRange returns a boolean if a field has been set. +func (o *UpdateRulePayload) HasPortRange() bool { + if o != nil && !IsNil(o.PortRange) { + return true + } + + return false +} + +// SetPortRange gets a reference to the given string and assigns it to the PortRange field. +func (o *UpdateRulePayload) SetPortRange(v string) { + o.PortRange = &v +} + +// GetProduct returns the Product field value +func (o *UpdateRulePayload) GetProduct() string { + if o == nil { + var ret string + return ret + } + + return o.Product +} + +// GetProductOk returns a tuple with the Product field value +// and a boolean to check if the value has been set. +func (o *UpdateRulePayload) GetProductOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Product, true +} + +// SetProduct sets field value +func (o *UpdateRulePayload) SetProduct(v string) { + o.Product = v +} + +// GetProtocol returns the Protocol field value if set, zero value otherwise. +func (o *UpdateRulePayload) GetProtocol() string { + if o == nil || IsNil(o.Protocol) { + var ret string + return ret + } + return *o.Protocol +} + +// GetProtocolOk returns a tuple with the Protocol field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateRulePayload) GetProtocolOk() (*string, bool) { + if o == nil || IsNil(o.Protocol) { + return nil, false + } + return o.Protocol, true +} + +// HasProtocol returns a boolean if a field has been set. +func (o *UpdateRulePayload) HasProtocol() bool { + if o != nil && !IsNil(o.Protocol) { + return true + } + + return false +} + +// SetProtocol gets a reference to the given string and assigns it to the Protocol field. +func (o *UpdateRulePayload) SetProtocol(v string) { + o.Protocol = &v +} + +// GetSecurityGroupId returns the SecurityGroupId field value if set, zero value otherwise. +func (o *UpdateRulePayload) GetSecurityGroupId() string { + if o == nil || IsNil(o.SecurityGroupId) { + var ret string + return ret + } + return *o.SecurityGroupId +} + +// GetSecurityGroupIdOk returns a tuple with the SecurityGroupId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateRulePayload) GetSecurityGroupIdOk() (*string, bool) { + if o == nil || IsNil(o.SecurityGroupId) { + return nil, false + } + return o.SecurityGroupId, true +} + +// HasSecurityGroupId returns a boolean if a field has been set. +func (o *UpdateRulePayload) HasSecurityGroupId() bool { + if o != nil && !IsNil(o.SecurityGroupId) { + return true + } + + return false +} + +// SetSecurityGroupId gets a reference to the given string and assigns it to the SecurityGroupId field. +func (o *UpdateRulePayload) SetSecurityGroupId(v string) { + o.SecurityGroupId = &v +} + +// GetSourceIP returns the SourceIP field value +func (o *UpdateRulePayload) GetSourceIP() string { + if o == nil { + var ret string + return ret + } + + return o.SourceIP +} + +// GetSourceIPOk returns a tuple with the SourceIP field value +// and a boolean to check if the value has been set. +func (o *UpdateRulePayload) GetSourceIPOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.SourceIP, true +} + +// SetSourceIP sets field value +func (o *UpdateRulePayload) SetSourceIP(v string) { + o.SourceIP = v +} + +// GetType returns the Type field value +func (o *UpdateRulePayload) GetType() string { + if o == nil { + var ret string + return ret + } + + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *UpdateRulePayload) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value +func (o *UpdateRulePayload) SetType(v string) { + o.Type = v +} + +func (o UpdateRulePayload) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o UpdateRulePayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Description) { + toSerialize["description"] = o.Description + } + if !IsNil(o.Direction) { + toSerialize["direction"] = o.Direction + } + if !IsNil(o.EtherType) { + toSerialize["etherType"] = o.EtherType + } + toSerialize["instanceId"] = o.InstanceId + if !IsNil(o.Offset) { + toSerialize["offset"] = o.Offset + } + if !IsNil(o.PortRange) { + toSerialize["portRange"] = o.PortRange + } + toSerialize["product"] = o.Product + if !IsNil(o.Protocol) { + toSerialize["protocol"] = o.Protocol + } + if !IsNil(o.SecurityGroupId) { + toSerialize["securityGroupId"] = o.SecurityGroupId + } + toSerialize["sourceIP"] = o.SourceIP + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *UpdateRulePayload) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "instanceId", + "product", + "sourceIP", + "type", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err + } + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varUpdateRulePayload := _UpdateRulePayload{} + + err = json.Unmarshal(data, &varUpdateRulePayload) + + if err != nil { + return err + } + + *o = UpdateRulePayload(varUpdateRulePayload) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "description") + delete(additionalProperties, "direction") + delete(additionalProperties, "etherType") + delete(additionalProperties, "instanceId") + delete(additionalProperties, "offset") + delete(additionalProperties, "portRange") + delete(additionalProperties, "product") + delete(additionalProperties, "protocol") + delete(additionalProperties, "securityGroupId") + delete(additionalProperties, "sourceIP") + delete(additionalProperties, "type") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableUpdateRulePayload struct { + value *UpdateRulePayload + isSet bool +} + +func (v NullableUpdateRulePayload) Get() *UpdateRulePayload { + return v.value +} + +func (v *NullableUpdateRulePayload) Set(val *UpdateRulePayload) { + v.value = val + v.isSet = true +} + +func (v NullableUpdateRulePayload) IsSet() bool { + return v.isSet +} + +func (v *NullableUpdateRulePayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableUpdateRulePayload(val *UpdateRulePayload) *NullableUpdateRulePayload { + return &NullableUpdateRulePayload{value: val, isSet: true} +} + +func (v NullableUpdateRulePayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableUpdateRulePayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/ufw/v1betaapi/model_update_ufw_request.go b/services/ufw/v1betaapi/model_update_ufw_request.go new file mode 100644 index 000000000..03a57a5cd --- /dev/null +++ b/services/ufw/v1betaapi/model_update_ufw_request.go @@ -0,0 +1,167 @@ +/* +STACKIT Unified Firewall API + +API for managing and controlling the STACKIT Unified Firewall. + +API version: 1beta.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1betaapi + +import ( + "encoding/json" + "fmt" +) + +// checks if the UpdateUfwRequest type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &UpdateUfwRequest{} + +// UpdateUfwRequest struct for UpdateUfwRequest +type UpdateUfwRequest struct { + // The list of CIDRs currently set on the instance. + Cidrs []string `json:"cidrs"` + AdditionalProperties map[string]interface{} +} + +type _UpdateUfwRequest UpdateUfwRequest + +// NewUpdateUfwRequest instantiates a new UpdateUfwRequest 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 NewUpdateUfwRequest(cidrs []string) *UpdateUfwRequest { + this := UpdateUfwRequest{} + this.Cidrs = cidrs + return &this +} + +// NewUpdateUfwRequestWithDefaults instantiates a new UpdateUfwRequest 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 NewUpdateUfwRequestWithDefaults() *UpdateUfwRequest { + this := UpdateUfwRequest{} + return &this +} + +// GetCidrs returns the Cidrs field value +func (o *UpdateUfwRequest) GetCidrs() []string { + if o == nil { + var ret []string + return ret + } + + return o.Cidrs +} + +// GetCidrsOk returns a tuple with the Cidrs field value +// and a boolean to check if the value has been set. +func (o *UpdateUfwRequest) GetCidrsOk() ([]string, bool) { + if o == nil { + return nil, false + } + return o.Cidrs, true +} + +// SetCidrs sets field value +func (o *UpdateUfwRequest) SetCidrs(v []string) { + o.Cidrs = v +} + +func (o UpdateUfwRequest) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o UpdateUfwRequest) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["cidrs"] = o.Cidrs + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *UpdateUfwRequest) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "cidrs", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err + } + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varUpdateUfwRequest := _UpdateUfwRequest{} + + err = json.Unmarshal(data, &varUpdateUfwRequest) + + if err != nil { + return err + } + + *o = UpdateUfwRequest(varUpdateUfwRequest) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "cidrs") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableUpdateUfwRequest struct { + value *UpdateUfwRequest + isSet bool +} + +func (v NullableUpdateUfwRequest) Get() *UpdateUfwRequest { + return v.value +} + +func (v *NullableUpdateUfwRequest) Set(val *UpdateUfwRequest) { + v.value = val + v.isSet = true +} + +func (v NullableUpdateUfwRequest) IsSet() bool { + return v.isSet +} + +func (v *NullableUpdateUfwRequest) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableUpdateUfwRequest(val *UpdateUfwRequest) *NullableUpdateUfwRequest { + return &NullableUpdateUfwRequest{value: val, isSet: true} +} + +func (v NullableUpdateUfwRequest) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableUpdateUfwRequest) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/ufw/v1betaapi/model_version_response.go b/services/ufw/v1betaapi/model_version_response.go new file mode 100644 index 000000000..662d57b58 --- /dev/null +++ b/services/ufw/v1betaapi/model_version_response.go @@ -0,0 +1,190 @@ +/* +STACKIT Unified Firewall API + +API for managing and controlling the STACKIT Unified Firewall. + +API version: 1beta.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1betaapi + +import ( + "encoding/json" +) + +// checks if the VersionResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &VersionResponse{} + +// VersionResponse struct for VersionResponse +type VersionResponse struct { + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _VersionResponse VersionResponse + +// NewVersionResponse instantiates a new VersionResponse 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 NewVersionResponse() *VersionResponse { + this := VersionResponse{} + return &this +} + +// NewVersionResponseWithDefaults instantiates a new VersionResponse 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 NewVersionResponseWithDefaults() *VersionResponse { + this := VersionResponse{} + return &this +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *VersionResponse) 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 *VersionResponse) 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 *VersionResponse) 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 *VersionResponse) SetName(v string) { + o.Name = &v +} + +// GetVersion returns the Version field value if set, zero value otherwise. +func (o *VersionResponse) GetVersion() string { + if o == nil || IsNil(o.Version) { + var ret string + return ret + } + return *o.Version +} + +// GetVersionOk returns a tuple with the Version field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *VersionResponse) GetVersionOk() (*string, bool) { + if o == nil || IsNil(o.Version) { + return nil, false + } + return o.Version, true +} + +// HasVersion returns a boolean if a field has been set. +func (o *VersionResponse) HasVersion() bool { + if o != nil && !IsNil(o.Version) { + return true + } + + return false +} + +// SetVersion gets a reference to the given string and assigns it to the Version field. +func (o *VersionResponse) SetVersion(v string) { + o.Version = &v +} + +func (o VersionResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o VersionResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.Version) { + toSerialize["version"] = o.Version + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *VersionResponse) UnmarshalJSON(data []byte) (err error) { + varVersionResponse := _VersionResponse{} + + err = json.Unmarshal(data, &varVersionResponse) + + if err != nil { + return err + } + + *o = VersionResponse(varVersionResponse) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "name") + delete(additionalProperties, "version") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableVersionResponse struct { + value *VersionResponse + isSet bool +} + +func (v NullableVersionResponse) Get() *VersionResponse { + return v.value +} + +func (v *NullableVersionResponse) Set(val *VersionResponse) { + v.value = val + v.isSet = true +} + +func (v NullableVersionResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableVersionResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableVersionResponse(val *VersionResponse) *NullableVersionResponse { + return &NullableVersionResponse{value: val, isSet: true} +} + +func (v NullableVersionResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableVersionResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/ufw/v1betaapi/response.go b/services/ufw/v1betaapi/response.go new file mode 100644 index 000000000..605728003 --- /dev/null +++ b/services/ufw/v1betaapi/response.go @@ -0,0 +1,47 @@ +/* +STACKIT Unified Firewall API + +API for managing and controlling the STACKIT Unified Firewall. + +API version: 1beta.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1betaapi + +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/ufw/v1betaapi/utils.go b/services/ufw/v1betaapi/utils.go new file mode 100644 index 000000000..cdfb82e71 --- /dev/null +++ b/services/ufw/v1betaapi/utils.go @@ -0,0 +1,361 @@ +/* +STACKIT Unified Firewall API + +API for managing and controlling the STACKIT Unified Firewall. + +API version: 1beta.0.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1betaapi + +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...) +}