diff --git a/go.work b/go.work index 86a8ffc3c..1751a00b0 100644 --- a/go.work +++ b/go.work @@ -58,6 +58,7 @@ use ( ./services/iaas ./services/intake ./services/kms + ./services/lbiplists ./services/loadbalancer ./services/logme ./services/logs diff --git a/services/lbiplists/LICENSE.md b/services/lbiplists/LICENSE.md new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/services/lbiplists/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/lbiplists/go.mod b/services/lbiplists/go.mod new file mode 100644 index 000000000..ebc366812 --- /dev/null +++ b/services/lbiplists/go.mod @@ -0,0 +1,10 @@ +module github.com/stackitcloud/stackit-sdk-go/services/lbiplists + +go 1.25 + +require github.com/stackitcloud/stackit-sdk-go/core v0.27.0 + +require ( + github.com/golang-jwt/jwt/v5 v5.3.1 // indirect + github.com/google/uuid v1.6.0 // indirect +) diff --git a/services/lbiplists/go.sum b/services/lbiplists/go.sum new file mode 100644 index 000000000..042f4a71a --- /dev/null +++ b/services/lbiplists/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.27.0 h1:7lc6qStcFDFf8zHP4ORPa9joybw+Sa2LtB6BVjKQ+ek= +github.com/stackitcloud/stackit-sdk-go/core v0.27.0/go.mod h1:WU1hhxnjXw2EV7CYa1nlEvNpMiRY6CvmIOaHuL3pOaA= diff --git a/services/lbiplists/oas_commit b/services/lbiplists/oas_commit new file mode 100644 index 000000000..d5d15003c --- /dev/null +++ b/services/lbiplists/oas_commit @@ -0,0 +1 @@ +f385f3b154cb566b3c9e5156c29b28150f2af4a2 diff --git a/services/lbiplists/package.go b/services/lbiplists/package.go new file mode 100644 index 000000000..704458a5a --- /dev/null +++ b/services/lbiplists/package.go @@ -0,0 +1 @@ +package lbiplists diff --git a/services/lbiplists/v1alphaapi/api_default.go b/services/lbiplists/v1alphaapi/api_default.go new file mode 100644 index 000000000..964cdc73f --- /dev/null +++ b/services/lbiplists/v1alphaapi/api_default.go @@ -0,0 +1,833 @@ +/* +STACKIT Load Balancer IP Lists API + +This API manages IP lists (sets of IPv4 CIDR ranges) scoped to a project and region. IP lists enable blacklisting: they can be referenced by Application and Network Load Balancer to deny traffic from matching source addresses. **Upload format** Lists are uploaded as a single raw payload in `file_content` (base64 in JSON transport). The server first tries to parse the payload as CSV (with a `cidr` column; any other columns are ignored) and falls back to a newline-separated `.txt` list of CIDR entries when CSV parsing fails. **Limits** - Maximum request payload size: 2 MB JSON (enforced before parsing). - Maximum number of CIDR entries per list: 50000 (enforced during streaming parse). - Maximum number of IP lists per project: 3. - Empty lists (0 CIDRs) are rejected. - Only IPv4 CIDR entries are supported for now; IPv6 entries are rejected. - No duplicate or overlap checks are performed. **Semantics** - `Upload` creates the list if it does not exist and replaces its content otherwise. Uploads with identical stored content are a no-op (no version bump, no reload). - `List` returns each stored IP list without its CIDR entries (name, labels, number of IPs, content hash, usage). The CIDR entries themselves are never returned by the API. - There is no single-item Get endpoint. Clients verify content by comparing the returned `content_hash`. - IP lists referenced by any load balancer cannot be deleted; the reference must be cleared or replaced with a different list first. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. +package v1alphaapi + +import ( + "bytes" + "context" + "io" + "net/http" + "net/url" + "strings" + + "github.com/stackitcloud/stackit-sdk-go/core/config" + "github.com/stackitcloud/stackit-sdk-go/core/oapierror" +) + +type DefaultAPI interface { + + /* + DeleteIPList Delete an IP List configuration + + Removes the IP list configuration from the project. If the IP list is referenced by load balancers, + clear or replace the reference first. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId + @param region + @param name + @return ApiDeleteIPListRequest + */ + DeleteIPList(ctx context.Context, projectId string, region string, name string) ApiDeleteIPListRequest + + // DeleteIPListExecute executes the request + // @return map[string]interface{} + DeleteIPListExecute(r ApiDeleteIPListRequest) (map[string]interface{}, error) + + /* + GetIPList Retrieve metadata of an existing IP list configuration in a project. + + GetIPList returns metadata of a single IP list by name, without CIDR entries. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId + @param region + @param name + @return ApiGetIPListRequest + */ + GetIPList(ctx context.Context, projectId string, region string, name string) ApiGetIPListRequest + + // GetIPListExecute executes the request + // @return GetIPListResponse + GetIPListExecute(r ApiGetIPListRequest) (*GetIPListResponse, error) + + /* + GetQuota Get the quota for IP lists in a project + + Retrieves the IP List resource quota for the project. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId + @param region + @return ApiGetQuotaRequest + */ + GetQuota(ctx context.Context, projectId string, region string) ApiGetQuotaRequest + + // GetQuotaExecute executes the request + // @return GetQuotaResponse + GetQuotaExecute(r ApiGetQuotaRequest) (*GetQuotaResponse, error) + + /* + ListIPLists List metadata of all IP lists in a project + + ListIPLists returns every IP list in the project without CIDR entries. + No pagination while the per-project limit is 3. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId + @param region + @return ApiListIPListsRequest + */ + ListIPLists(ctx context.Context, projectId string, region string) ApiListIPListsRequest + + // ListIPListsExecute executes the request + // @return ListIPListsResponse + ListIPListsExecute(r ApiListIPListsRequest) (*ListIPListsResponse, error) + + /* + UploadIPList Create/Replace an IP list + + UploadIPList creates the IP list or replaces its content. Raw upload + is in `file_content`. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId + @param region + @param name + @return ApiUploadIPListRequest + */ + UploadIPList(ctx context.Context, projectId string, region string, name string) ApiUploadIPListRequest + + // UploadIPListExecute executes the request + // @return GetIPListResponse + UploadIPListExecute(r ApiUploadIPListRequest) (*GetIPListResponse, error) +} + +// DefaultAPIService DefaultAPI service +type DefaultAPIService service + +type ApiDeleteIPListRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + region string + name string +} + +func (r ApiDeleteIPListRequest) Execute() (map[string]interface{}, error) { + return r.ApiService.DeleteIPListExecute(r) +} + +/* +DeleteIPList Delete an IP List configuration + +Removes the IP list configuration from the project. If the IP list is referenced by load balancers, + + clear or replace the reference first. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId + @param region + @param name + @return ApiDeleteIPListRequest +*/ +func (a *DefaultAPIService) DeleteIPList(ctx context.Context, projectId string, region string, name string) ApiDeleteIPListRequest { + return ApiDeleteIPListRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// Execute executes the request +// +// @return map[string]interface{} +func (a *DefaultAPIService) DeleteIPListExecute(r ApiDeleteIPListRequest) (map[string]interface{}, error) { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue map[string]interface{} + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.DeleteIPList") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{region}/ip-lists/{name}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(parameterValueToString(r.region, "region")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"name"+"}", url.PathEscape(parameterValueToString(r.name, "name")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json", "*/*"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiGetIPListRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + region string + name string +} + +func (r ApiGetIPListRequest) Execute() (*GetIPListResponse, error) { + return r.ApiService.GetIPListExecute(r) +} + +/* +GetIPList Retrieve metadata of an existing IP list configuration in a project. + +GetIPList returns metadata of a single IP list by name, without CIDR entries. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId + @param region + @param name + @return ApiGetIPListRequest +*/ +func (a *DefaultAPIService) GetIPList(ctx context.Context, projectId string, region string, name string) ApiGetIPListRequest { + return ApiGetIPListRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// Execute executes the request +// +// @return GetIPListResponse +func (a *DefaultAPIService) GetIPListExecute(r ApiGetIPListRequest) (*GetIPListResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *GetIPListResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.GetIPList") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{region}/ip-lists/{name}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(parameterValueToString(r.region, "region")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"name"+"}", url.PathEscape(parameterValueToString(r.name, "name")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json", "*/*"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiGetQuotaRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + region string +} + +func (r ApiGetQuotaRequest) Execute() (*GetQuotaResponse, error) { + return r.ApiService.GetQuotaExecute(r) +} + +/* +GetQuota Get the quota for IP lists in a project + +Retrieves the IP List resource quota for the project. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId + @param region + @return ApiGetQuotaRequest +*/ +func (a *DefaultAPIService) GetQuota(ctx context.Context, projectId string, region string) ApiGetQuotaRequest { + return ApiGetQuotaRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + } +} + +// Execute executes the request +// +// @return GetQuotaResponse +func (a *DefaultAPIService) GetQuotaExecute(r ApiGetQuotaRequest) (*GetQuotaResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *GetQuotaResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.GetQuota") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{region}/quotas" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(parameterValueToString(r.region, "region")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json", "text/plain"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + if localVarHTTPResponse.StatusCode == 401 { + var v string + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiListIPListsRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + region string +} + +func (r ApiListIPListsRequest) Execute() (*ListIPListsResponse, error) { + return r.ApiService.ListIPListsExecute(r) +} + +/* +ListIPLists List metadata of all IP lists in a project + +ListIPLists returns every IP list in the project without CIDR entries. + + No pagination while the per-project limit is 3. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId + @param region + @return ApiListIPListsRequest +*/ +func (a *DefaultAPIService) ListIPLists(ctx context.Context, projectId string, region string) ApiListIPListsRequest { + return ApiListIPListsRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + } +} + +// Execute executes the request +// +// @return ListIPListsResponse +func (a *DefaultAPIService) ListIPListsExecute(r ApiListIPListsRequest) (*ListIPListsResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ListIPListsResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ListIPLists") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{region}/ip-lists" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(parameterValueToString(r.region, "region")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json", "*/*"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiUploadIPListRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + region string + name string + uploadIPListPayload *UploadIPListPayload +} + +func (r ApiUploadIPListRequest) UploadIPListPayload(uploadIPListPayload UploadIPListPayload) ApiUploadIPListRequest { + r.uploadIPListPayload = &uploadIPListPayload + return r +} + +func (r ApiUploadIPListRequest) Execute() (*GetIPListResponse, error) { + return r.ApiService.UploadIPListExecute(r) +} + +/* +UploadIPList Create/Replace an IP list + +UploadIPList creates the IP list or replaces its content. Raw upload + + is in `file_content`. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId + @param region + @param name + @return ApiUploadIPListRequest +*/ +func (a *DefaultAPIService) UploadIPList(ctx context.Context, projectId string, region string, name string) ApiUploadIPListRequest { + return ApiUploadIPListRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// Execute executes the request +// +// @return GetIPListResponse +func (a *DefaultAPIService) UploadIPListExecute(r ApiUploadIPListRequest) (*GetIPListResponse, error) { + var ( + localVarHTTPMethod = http.MethodPut + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *GetIPListResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.UploadIPList") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{region}/ip-lists/{name}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(parameterValueToString(r.region, "region")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"name"+"}", url.PathEscape(parameterValueToString(r.name, "name")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.uploadIPListPayload == nil { + return localVarReturnValue, reportError("uploadIPListPayload is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json", "*/*"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.uploadIPListPayload + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + if localVarHTTPResponse.StatusCode == 401 { + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} diff --git a/services/lbiplists/v1alphaapi/api_default_mock.go b/services/lbiplists/v1alphaapi/api_default_mock.go new file mode 100644 index 000000000..23b884093 --- /dev/null +++ b/services/lbiplists/v1alphaapi/api_default_mock.go @@ -0,0 +1,131 @@ +/* +STACKIT Load Balancer IP Lists API + +This API manages IP lists (sets of IPv4 CIDR ranges) scoped to a project and region. IP lists enable blacklisting: they can be referenced by Application and Network Load Balancer to deny traffic from matching source addresses. **Upload format** Lists are uploaded as a single raw payload in `file_content` (base64 in JSON transport). The server first tries to parse the payload as CSV (with a `cidr` column; any other columns are ignored) and falls back to a newline-separated `.txt` list of CIDR entries when CSV parsing fails. **Limits** - Maximum request payload size: 2 MB JSON (enforced before parsing). - Maximum number of CIDR entries per list: 50000 (enforced during streaming parse). - Maximum number of IP lists per project: 3. - Empty lists (0 CIDRs) are rejected. - Only IPv4 CIDR entries are supported for now; IPv6 entries are rejected. - No duplicate or overlap checks are performed. **Semantics** - `Upload` creates the list if it does not exist and replaces its content otherwise. Uploads with identical stored content are a no-op (no version bump, no reload). - `List` returns each stored IP list without its CIDR entries (name, labels, number of IPs, content hash, usage). The CIDR entries themselves are never returned by the API. - There is no single-item Get endpoint. Clients verify content by comparing the returned `content_hash`. - IP lists referenced by any load balancer cannot be deleted; the reference must be cleared or replaced with a different list first. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "context" +) + +// assert the implementation matches the interface +var _ DefaultAPI = &DefaultAPIServiceMock{} + +// DefaultAPIServiceMock is meant to be used for testing only as a replacement for DefaultAPIService. +// By default all FooExecute() implementations are a no-op. Behavior of the mock can be customized by populating the callbacks in this struct. +type DefaultAPIServiceMock struct { + // DeleteIPListExecuteMock can be populated to implement the behavior of the DeleteIPListExecute function of this mock + DeleteIPListExecuteMock *func(r ApiDeleteIPListRequest) (map[string]interface{}, error) + // GetIPListExecuteMock can be populated to implement the behavior of the GetIPListExecute function of this mock + GetIPListExecuteMock *func(r ApiGetIPListRequest) (*GetIPListResponse, error) + // GetQuotaExecuteMock can be populated to implement the behavior of the GetQuotaExecute function of this mock + GetQuotaExecuteMock *func(r ApiGetQuotaRequest) (*GetQuotaResponse, error) + // ListIPListsExecuteMock can be populated to implement the behavior of the ListIPListsExecute function of this mock + ListIPListsExecuteMock *func(r ApiListIPListsRequest) (*ListIPListsResponse, error) + // UploadIPListExecuteMock can be populated to implement the behavior of the UploadIPListExecute function of this mock + UploadIPListExecuteMock *func(r ApiUploadIPListRequest) (*GetIPListResponse, error) +} + +func (a DefaultAPIServiceMock) DeleteIPList(ctx context.Context, projectId string, region string, name string) ApiDeleteIPListRequest { + return ApiDeleteIPListRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// DeleteIPListExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the DeleteIPListExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) DeleteIPListExecute(r ApiDeleteIPListRequest) (map[string]interface{}, error) { + if a.DeleteIPListExecuteMock == nil { + var localVarReturnValue map[string]interface{} + return localVarReturnValue, nil + } + + return (*a.DeleteIPListExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) GetIPList(ctx context.Context, projectId string, region string, name string) ApiGetIPListRequest { + return ApiGetIPListRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// GetIPListExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the GetIPListExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) GetIPListExecute(r ApiGetIPListRequest) (*GetIPListResponse, error) { + if a.GetIPListExecuteMock == nil { + var localVarReturnValue *GetIPListResponse + return localVarReturnValue, nil + } + + return (*a.GetIPListExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) GetQuota(ctx context.Context, projectId string, region string) ApiGetQuotaRequest { + return ApiGetQuotaRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + } +} + +// GetQuotaExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the GetQuotaExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) GetQuotaExecute(r ApiGetQuotaRequest) (*GetQuotaResponse, error) { + if a.GetQuotaExecuteMock == nil { + var localVarReturnValue *GetQuotaResponse + return localVarReturnValue, nil + } + + return (*a.GetQuotaExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) ListIPLists(ctx context.Context, projectId string, region string) ApiListIPListsRequest { + return ApiListIPListsRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + } +} + +// ListIPListsExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the ListIPListsExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) ListIPListsExecute(r ApiListIPListsRequest) (*ListIPListsResponse, error) { + if a.ListIPListsExecuteMock == nil { + var localVarReturnValue *ListIPListsResponse + return localVarReturnValue, nil + } + + return (*a.ListIPListsExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) UploadIPList(ctx context.Context, projectId string, region string, name string) ApiUploadIPListRequest { + return ApiUploadIPListRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + region: region, + name: name, + } +} + +// UploadIPListExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the UploadIPListExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) UploadIPListExecute(r ApiUploadIPListRequest) (*GetIPListResponse, error) { + if a.UploadIPListExecuteMock == nil { + var localVarReturnValue *GetIPListResponse + return localVarReturnValue, nil + } + + return (*a.UploadIPListExecuteMock)(r) +} diff --git a/services/lbiplists/v1alphaapi/client.go b/services/lbiplists/v1alphaapi/client.go new file mode 100644 index 000000000..391d22f71 --- /dev/null +++ b/services/lbiplists/v1alphaapi/client.go @@ -0,0 +1,667 @@ +/* +STACKIT Load Balancer IP Lists API + +This API manages IP lists (sets of IPv4 CIDR ranges) scoped to a project and region. IP lists enable blacklisting: they can be referenced by Application and Network Load Balancer to deny traffic from matching source addresses. **Upload format** Lists are uploaded as a single raw payload in `file_content` (base64 in JSON transport). The server first tries to parse the payload as CSV (with a `cidr` column; any other columns are ignored) and falls back to a newline-separated `.txt` list of CIDR entries when CSV parsing fails. **Limits** - Maximum request payload size: 2 MB JSON (enforced before parsing). - Maximum number of CIDR entries per list: 50000 (enforced during streaming parse). - Maximum number of IP lists per project: 3. - Empty lists (0 CIDRs) are rejected. - Only IPv4 CIDR entries are supported for now; IPv6 entries are rejected. - No duplicate or overlap checks are performed. **Semantics** - `Upload` creates the list if it does not exist and replaces its content otherwise. Uploads with identical stored content are a no-op (no version bump, no reload). - `List` returns each stored IP list without its CIDR entries (name, labels, number of IPs, content hash, usage). The CIDR entries themselves are never returned by the API. - There is no single-item Get endpoint. Clients verify content by comparing the returned `content_hash`. - IP lists referenced by any load balancer cannot be deleted; the reference must be cleared or replaced with a different list first. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. +package v1alphaapi + +import ( + "bytes" + "context" + "encoding/json" + "encoding/xml" + "errors" + "fmt" + "io" + "log" + "mime/multipart" + "net/http" + "net/http/httputil" + "net/url" + "os" + "path/filepath" + "reflect" + "regexp" + "strconv" + "strings" + "time" + "unicode/utf8" + + "github.com/stackitcloud/stackit-sdk-go/core/auth" + "github.com/stackitcloud/stackit-sdk-go/core/config" +) + +var ( + JsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?json)`) + XmlCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?xml)`) + queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`) + queryDescape = strings.NewReplacer("%5B", "[", "%5D", "]") +) + +// APIClient manages communication with the STACKIT Load Balancer IP Lists API API v1alpha.0.0 +// In most cases there should be only one, shared, APIClient. +type APIClient struct { + cfg *config.Configuration + common service // Reuse a single struct instead of allocating one for each service on the heap. + + // API Services + + DefaultAPI DefaultAPI +} + +type service struct { + client *APIClient +} + +// NewAPIClient creates a new API client. Requires a userAgent string describing your application. +// optionally a custom http.Client to allow for advanced features such as caching. +func NewAPIClient(opts ...config.ConfigurationOption) (*APIClient, error) { + cfg := NewConfiguration() + + for _, option := range opts { + err := option(cfg) + if err != nil { + return nil, fmt.Errorf("configuring the client: %w", err) + } + } + + err := config.ConfigureRegion(cfg) + if err != nil { + return nil, fmt.Errorf("configuring region: %w", err) + } + + if cfg.HTTPClient == nil { + cfg.HTTPClient = &http.Client{} + } + + authRoundTripper, err := auth.SetupAuth(cfg) + if err != nil { + return nil, fmt.Errorf("setting up authentication: %w", err) + } + + roundTripper := authRoundTripper + if cfg.Middleware != nil { + roundTripper = config.ChainMiddleware(roundTripper, cfg.Middleware...) + } + + cfg.HTTPClient.Transport = roundTripper + + c := &APIClient{} + c.cfg = cfg + c.common.client = c + + // API Services + c.DefaultAPI = (*DefaultAPIService)(&c.common) + + return c, nil +} + +func atoi(in string) (int, error) { + return strconv.Atoi(in) +} + +// selectHeaderContentType select a content type from the available list. +func selectHeaderContentType(contentTypes []string) string { + if len(contentTypes) == 0 { + return "" + } + if contains(contentTypes, "application/json") { + return "application/json" + } + return contentTypes[0] // use the first content type specified in 'consumes' +} + +// selectHeaderAccept join all accept types and return +func selectHeaderAccept(accepts []string) string { + if len(accepts) == 0 { + return "" + } + + if contains(accepts, "application/json") { + return "application/json" + } + + return strings.Join(accepts, ",") +} + +// contains is a case insensitive match, finding needle in a haystack +func contains(haystack []string, needle string) bool { + for _, a := range haystack { + if strings.EqualFold(a, needle) { + return true + } + } + return false +} + +// Verify optional parameters are of the correct type. +func typeCheckParameter(obj interface{}, expected string, name string) error { + // Make sure there is an object. + if obj == nil { + return nil + } + + // Check the type is as expected. + if reflect.TypeOf(obj).String() != expected { + return fmt.Errorf("expected %s to be of type %s but received %s", name, expected, reflect.TypeOf(obj).String()) + } + return nil +} + +func parameterValueToString(obj interface{}, key string) string { + if reflect.TypeOf(obj).Kind() != reflect.Ptr { + if actualObj, ok := obj.(interface{ GetActualInstanceValue() interface{} }); ok { + return fmt.Sprintf("%v", actualObj.GetActualInstanceValue()) + } + + return fmt.Sprintf("%v", obj) + } + var param, ok = obj.(MappedNullable) + if !ok { + return "" + } + dataMap, err := param.ToMap() + if err != nil { + return "" + } + return fmt.Sprintf("%v", dataMap[key]) +} + +// parameterAddToHeaderOrQuery adds the provided object to the request header or url query +// supporting deep object syntax +func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix string, obj interface{}, style string, collectionType string) { + var v = reflect.ValueOf(obj) + var value = "" + if v == reflect.ValueOf(nil) { + value = "null" + } else { + switch v.Kind() { + case reflect.Invalid: + value = "invalid" + + case reflect.Struct: + if t, ok := obj.(MappedNullable); ok { + dataMap, err := t.ToMap() + if err != nil { + return + } + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, dataMap, style, collectionType) + return + } + if t, ok := obj.(time.Time); ok { + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, t.Format(time.RFC3339Nano), style, collectionType) + return + } + value = v.Type().String() + " value" + case reflect.Slice: + var indValue = reflect.ValueOf(obj) + if indValue == reflect.ValueOf(nil) { + return + } + var lenIndValue = indValue.Len() + for i := 0; i < lenIndValue; i++ { + var arrayValue = indValue.Index(i) + var keyPrefixForCollectionType = keyPrefix + if style == "deepObject" { + keyPrefixForCollectionType = keyPrefix + "[" + strconv.Itoa(i) + "]" + } + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefixForCollectionType, arrayValue.Interface(), style, collectionType) + } + return + + case reflect.Map: + var indValue = reflect.ValueOf(obj) + if indValue == reflect.ValueOf(nil) { + return + } + iter := indValue.MapRange() + for iter.Next() { + k, v := iter.Key(), iter.Value() + parameterAddToHeaderOrQuery(headerOrQueryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface(), style, collectionType) + } + return + + case reflect.Interface: + fallthrough + case reflect.Ptr: + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, v.Elem().Interface(), style, collectionType) + return + + case reflect.Int, reflect.Int8, reflect.Int16, + reflect.Int32, reflect.Int64: + value = strconv.FormatInt(v.Int(), 10) + case reflect.Uint, reflect.Uint8, reflect.Uint16, + reflect.Uint32, reflect.Uint64, reflect.Uintptr: + value = strconv.FormatUint(v.Uint(), 10) + case reflect.Float32, reflect.Float64: + value = strconv.FormatFloat(v.Float(), 'g', -1, 32) + case reflect.Bool: + value = strconv.FormatBool(v.Bool()) + case reflect.String: + value = v.String() + default: + value = v.Type().String() + " value" + } + } + + switch valuesMap := headerOrQueryParams.(type) { + case url.Values: + if collectionType == "csv" && valuesMap.Get(keyPrefix) != "" { + valuesMap.Set(keyPrefix, valuesMap.Get(keyPrefix)+","+value) + } else { + valuesMap.Add(keyPrefix, value) + } + break + case map[string]string: + valuesMap[keyPrefix] = value + break + } +} + +// helper for converting interface{} parameters to json strings +func parameterToJson(obj interface{}) (string, error) { + jsonBuf, err := json.Marshal(obj) + if err != nil { + return "", err + } + return string(jsonBuf), err +} + +// callAPI do the request. +func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { + if c.cfg.Debug { + dump, err := httputil.DumpRequestOut(request, true) + if err != nil { + return nil, err + } + log.Printf("\n%s\n", string(dump)) + } + + resp, err := c.cfg.HTTPClient.Do(request) + if err != nil { + return resp, err + } + + if c.cfg.Debug { + dump, err := httputil.DumpResponse(resp, true) + if err != nil { + return resp, err + } + log.Printf("\n%s\n", string(dump)) + } + return resp, err +} + +// Allow modification of underlying config for alternate implementations and testing +// Caution: modifying the configuration while live can cause data races and potentially unwanted behavior +func (c *APIClient) GetConfig() *config.Configuration { + return c.cfg +} + +type formFile struct { + fileBytes []byte + fileName string + formFileName string +} + +// prepareRequest build the request +func (c *APIClient) prepareRequest( + ctx context.Context, + path string, method string, + postBody interface{}, + headerParams map[string]string, + queryParams url.Values, + formParams url.Values, + formFiles []formFile) (localVarRequest *http.Request, err error) { + + var body *bytes.Buffer + + // Detect postBody type and post. + if postBody != nil { + contentType := headerParams["Content-Type"] + if contentType == "" { + contentType = detectContentType(postBody) + headerParams["Content-Type"] = contentType + } + + body, err = setBody(postBody, contentType) + if err != nil { + return nil, err + } + } + + // add form parameters and file if available. + if strings.HasPrefix(headerParams["Content-Type"], "multipart/form-data") && len(formParams) > 0 || (len(formFiles) > 0) { + if body != nil { + return nil, errors.New("Cannot specify postBody and multipart form at the same time.") + } + body = &bytes.Buffer{} + w := multipart.NewWriter(body) + + for k, v := range formParams { + for _, iv := range v { + if strings.HasPrefix(k, "@") { // file + err = addFile(w, k[1:], iv) + if err != nil { + return nil, err + } + } else { // form value + w.WriteField(k, iv) + } + } + } + for _, formFile := range formFiles { + if len(formFile.fileBytes) > 0 && formFile.fileName != "" { + w.Boundary() + part, err := w.CreateFormFile(formFile.formFileName, filepath.Base(formFile.fileName)) + if err != nil { + return nil, err + } + _, err = part.Write(formFile.fileBytes) + if err != nil { + return nil, err + } + } + } + + // Set the Boundary in the Content-Type + headerParams["Content-Type"] = w.FormDataContentType() + + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + w.Close() + } + + if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 { + if body != nil { + return nil, errors.New("Cannot specify postBody and x-www-form-urlencoded form at the same time.") + } + body = &bytes.Buffer{} + body.WriteString(formParams.Encode()) + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + } + + // Setup path and query parameters + url, err := url.Parse(path) + if err != nil { + return nil, err + } + + // Override request host, if applicable + if c.cfg.Host != "" { + url.Host = c.cfg.Host + } + + // Override request scheme, if applicable + if c.cfg.Scheme != "" { + url.Scheme = c.cfg.Scheme + } + + // Adding Query Param + query := url.Query() + for k, v := range queryParams { + for _, iv := range v { + query.Add(k, iv) + } + } + + // Encode the parameters. + url.RawQuery = queryParamSplit.ReplaceAllStringFunc(query.Encode(), func(s string) string { + pieces := strings.Split(s, "=") + pieces[0] = queryDescape.Replace(pieces[0]) + return strings.Join(pieces, "=") + }) + + // Generate a new request + if body != nil { + localVarRequest, err = http.NewRequest(method, url.String(), body) + } else { + localVarRequest, err = http.NewRequest(method, url.String(), nil) + } + if err != nil { + return nil, err + } + + // add header parameters, if any + if len(headerParams) > 0 { + headers := http.Header{} + for h, v := range headerParams { + headers[h] = []string{v} + } + localVarRequest.Header = headers + } + + // Add the user agent to the request. + localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) + + if ctx != nil { + // add context to the request + localVarRequest = localVarRequest.WithContext(ctx) + + // Walk through any authentication. + + } + + for header, value := range c.cfg.DefaultHeader { + localVarRequest.Header.Add(header, value) + } + return localVarRequest, nil +} + +func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { + if len(b) == 0 { + return nil + } + if s, ok := v.(*string); ok { + *s = string(b) + return nil + } + if r, ok := v.(*io.Reader); ok { + *r = bytes.NewReader(b) + return nil + } + // Must stay before the JSON branch: json.Unmarshal would base64-decode into *[]byte. + if p, ok := v.(*[]byte); ok { + *p = 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/lbiplists/v1alphaapi/configuration.go b/services/lbiplists/v1alphaapi/configuration.go new file mode 100644 index 000000000..03fd23be9 --- /dev/null +++ b/services/lbiplists/v1alphaapi/configuration.go @@ -0,0 +1,41 @@ +/* +STACKIT Load Balancer IP Lists API + +This API manages IP lists (sets of IPv4 CIDR ranges) scoped to a project and region. IP lists enable blacklisting: they can be referenced by Application and Network Load Balancer to deny traffic from matching source addresses. **Upload format** Lists are uploaded as a single raw payload in `file_content` (base64 in JSON transport). The server first tries to parse the payload as CSV (with a `cidr` column; any other columns are ignored) and falls back to a newline-separated `.txt` list of CIDR entries when CSV parsing fails. **Limits** - Maximum request payload size: 2 MB JSON (enforced before parsing). - Maximum number of CIDR entries per list: 50000 (enforced during streaming parse). - Maximum number of IP lists per project: 3. - Empty lists (0 CIDRs) are rejected. - Only IPv4 CIDR entries are supported for now; IPv6 entries are rejected. - No duplicate or overlap checks are performed. **Semantics** - `Upload` creates the list if it does not exist and replaces its content otherwise. Uploads with identical stored content are a no-op (no version bump, no reload). - `List` returns each stored IP list without its CIDR entries (name, labels, number of IPs, content hash, usage). The CIDR entries themselves are never returned by the API. - There is no single-item Get endpoint. Clients verify content by comparing the returned `content_hash`. - IP lists referenced by any load balancer cannot be deleted; the reference must be cleared or replaced with a different list first. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. +package v1alphaapi + +import ( + "github.com/stackitcloud/stackit-sdk-go/core/config" +) + +// NewConfiguration returns a new Configuration object +func NewConfiguration() *config.Configuration { + cfg := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "stackit-sdk-go/lbiplists", + Debug: false, + Servers: config.ServerConfigurations{ + { + URL: "https://lb-ip-lists.api.{region}stackit.cloud", + Description: "No description provided", + Variables: map[string]config.ServerVariable{ + "region": { + Description: "No description provided", + DefaultValue: "eu01.", + EnumValues: []string{ + "eu01.", + "eu02.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + return cfg +} diff --git a/services/lbiplists/v1alphaapi/model_get_ip_list_response.go b/services/lbiplists/v1alphaapi/model_get_ip_list_response.go new file mode 100644 index 000000000..a345ce2b9 --- /dev/null +++ b/services/lbiplists/v1alphaapi/model_get_ip_list_response.go @@ -0,0 +1,319 @@ +/* +STACKIT Load Balancer IP Lists API + +This API manages IP lists (sets of IPv4 CIDR ranges) scoped to a project and region. IP lists enable blacklisting: they can be referenced by Application and Network Load Balancer to deny traffic from matching source addresses. **Upload format** Lists are uploaded as a single raw payload in `file_content` (base64 in JSON transport). The server first tries to parse the payload as CSV (with a `cidr` column; any other columns are ignored) and falls back to a newline-separated `.txt` list of CIDR entries when CSV parsing fails. **Limits** - Maximum request payload size: 2 MB JSON (enforced before parsing). - Maximum number of CIDR entries per list: 50000 (enforced during streaming parse). - Maximum number of IP lists per project: 3. - Empty lists (0 CIDRs) are rejected. - Only IPv4 CIDR entries are supported for now; IPv6 entries are rejected. - No duplicate or overlap checks are performed. **Semantics** - `Upload` creates the list if it does not exist and replaces its content otherwise. Uploads with identical stored content are a no-op (no version bump, no reload). - `List` returns each stored IP list without its CIDR entries (name, labels, number of IPs, content hash, usage). The CIDR entries themselves are never returned by the API. - There is no single-item Get endpoint. Clients verify content by comparing the returned `content_hash`. - IP lists referenced by any load balancer cannot be deleted; the reference must be cleared or replaced with a different list first. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" + "fmt" +) + +// checks if the GetIPListResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &GetIPListResponse{} + +// GetIPListResponse GetIPListResponse returns IP list configuration without CIDR entries. +type GetIPListResponse struct { + // Unique SHA-256 hex fingerprint used to verify the stored IP list content. + ContentHash *string `json:"contentHash,omitempty" validate:"regexp=^[a-f0-9]{64}$"` + // Labels represent user-defined metadata as key-value pairs. Label count should not exceed 64 per IP list. **Key Formatting Rules:** Length: 1-63 characters. Characters: Must begin and end with [a-zA-Z0-9]. May contain dashes (-), underscores (_), dots (.), and alphanumerics in between. Keys starting with 'stackit-' are system-reserved; users MUST NOT manage them. **Value Formatting Rules:** Length: 0-63 characters (empty string explicitly allowed). Characters (for non-empty values): Must begin and end with [a-zA-Z0-9]. May contain dashes (-), underscores (_), dots (.), and alphanumerics in between. + Labels *map[string]string `json:"labels,omitempty"` + // IP list name. + Name string `json:"name" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0\\,49}[0-9a-z])?$"` + // Number of IPv4 CIDR entries stored in the list. + NumberOfIps *string `json:"numberOfIps,omitempty"` + // Current use of this IP list in load balancers. + Usage *IPListUsage `json:"usage,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _GetIPListResponse GetIPListResponse + +// NewGetIPListResponse instantiates a new GetIPListResponse 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 NewGetIPListResponse(name string) *GetIPListResponse { + this := GetIPListResponse{} + this.Name = name + return &this +} + +// NewGetIPListResponseWithDefaults instantiates a new GetIPListResponse 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 NewGetIPListResponseWithDefaults() *GetIPListResponse { + this := GetIPListResponse{} + return &this +} + +// GetContentHash returns the ContentHash field value if set, zero value otherwise. +func (o *GetIPListResponse) GetContentHash() string { + if o == nil || IsNil(o.ContentHash) { + var ret string + return ret + } + return *o.ContentHash +} + +// GetContentHashOk returns a tuple with the ContentHash field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetIPListResponse) GetContentHashOk() (*string, bool) { + if o == nil || IsNil(o.ContentHash) { + return nil, false + } + return o.ContentHash, true +} + +// HasContentHash returns a boolean if a field has been set. +func (o *GetIPListResponse) HasContentHash() bool { + if o != nil && !IsNil(o.ContentHash) { + return true + } + + return false +} + +// SetContentHash gets a reference to the given string and assigns it to the ContentHash field. +func (o *GetIPListResponse) SetContentHash(v string) { + o.ContentHash = &v +} + +// GetLabels returns the Labels field value if set, zero value otherwise. +func (o *GetIPListResponse) GetLabels() map[string]string { + if o == nil || IsNil(o.Labels) { + var ret map[string]string + return ret + } + return *o.Labels +} + +// GetLabelsOk returns a tuple with the Labels field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetIPListResponse) GetLabelsOk() (*map[string]string, bool) { + if o == nil || IsNil(o.Labels) { + return nil, false + } + return o.Labels, true +} + +// HasLabels returns a boolean if a field has been set. +func (o *GetIPListResponse) HasLabels() bool { + if o != nil && !IsNil(o.Labels) { + return true + } + + return false +} + +// SetLabels gets a reference to the given map[string]string and assigns it to the Labels field. +func (o *GetIPListResponse) SetLabels(v map[string]string) { + o.Labels = &v +} + +// GetName returns the Name field value +func (o *GetIPListResponse) GetName() string { + if o == nil { + var ret string + return ret + } + + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *GetIPListResponse) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value +func (o *GetIPListResponse) SetName(v string) { + o.Name = v +} + +// GetNumberOfIps returns the NumberOfIps field value if set, zero value otherwise. +func (o *GetIPListResponse) GetNumberOfIps() string { + if o == nil || IsNil(o.NumberOfIps) { + var ret string + return ret + } + return *o.NumberOfIps +} + +// GetNumberOfIpsOk returns a tuple with the NumberOfIps field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetIPListResponse) GetNumberOfIpsOk() (*string, bool) { + if o == nil || IsNil(o.NumberOfIps) { + return nil, false + } + return o.NumberOfIps, true +} + +// HasNumberOfIps returns a boolean if a field has been set. +func (o *GetIPListResponse) HasNumberOfIps() bool { + if o != nil && !IsNil(o.NumberOfIps) { + return true + } + + return false +} + +// SetNumberOfIps gets a reference to the given string and assigns it to the NumberOfIps field. +func (o *GetIPListResponse) SetNumberOfIps(v string) { + o.NumberOfIps = &v +} + +// GetUsage returns the Usage field value if set, zero value otherwise. +func (o *GetIPListResponse) GetUsage() IPListUsage { + if o == nil || IsNil(o.Usage) { + var ret IPListUsage + return ret + } + return *o.Usage +} + +// GetUsageOk returns a tuple with the Usage field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetIPListResponse) GetUsageOk() (*IPListUsage, bool) { + if o == nil || IsNil(o.Usage) { + return nil, false + } + return o.Usage, true +} + +// HasUsage returns a boolean if a field has been set. +func (o *GetIPListResponse) HasUsage() bool { + if o != nil && !IsNil(o.Usage) { + return true + } + + return false +} + +// SetUsage gets a reference to the given IPListUsage and assigns it to the Usage field. +func (o *GetIPListResponse) SetUsage(v IPListUsage) { + o.Usage = &v +} + +func (o GetIPListResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o GetIPListResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.ContentHash) { + toSerialize["contentHash"] = o.ContentHash + } + if !IsNil(o.Labels) { + toSerialize["labels"] = o.Labels + } + toSerialize["name"] = o.Name + if !IsNil(o.NumberOfIps) { + toSerialize["numberOfIps"] = o.NumberOfIps + } + if !IsNil(o.Usage) { + toSerialize["usage"] = o.Usage + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *GetIPListResponse) 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{ + "name", + } + + 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) + } + } + + varGetIPListResponse := _GetIPListResponse{} + + err = json.Unmarshal(data, &varGetIPListResponse) + + if err != nil { + return err + } + + *o = GetIPListResponse(varGetIPListResponse) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "contentHash") + delete(additionalProperties, "labels") + delete(additionalProperties, "name") + delete(additionalProperties, "numberOfIps") + delete(additionalProperties, "usage") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableGetIPListResponse struct { + value *GetIPListResponse + isSet bool +} + +func (v NullableGetIPListResponse) Get() *GetIPListResponse { + return v.value +} + +func (v *NullableGetIPListResponse) Set(val *GetIPListResponse) { + v.value = val + v.isSet = true +} + +func (v NullableGetIPListResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableGetIPListResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableGetIPListResponse(val *GetIPListResponse) *NullableGetIPListResponse { + return &NullableGetIPListResponse{value: val, isSet: true} +} + +func (v NullableGetIPListResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableGetIPListResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/lbiplists/v1alphaapi/model_get_quota_response.go b/services/lbiplists/v1alphaapi/model_get_quota_response.go new file mode 100644 index 000000000..b740528e7 --- /dev/null +++ b/services/lbiplists/v1alphaapi/model_get_quota_response.go @@ -0,0 +1,229 @@ +/* +STACKIT Load Balancer IP Lists API + +This API manages IP lists (sets of IPv4 CIDR ranges) scoped to a project and region. IP lists enable blacklisting: they can be referenced by Application and Network Load Balancer to deny traffic from matching source addresses. **Upload format** Lists are uploaded as a single raw payload in `file_content` (base64 in JSON transport). The server first tries to parse the payload as CSV (with a `cidr` column; any other columns are ignored) and falls back to a newline-separated `.txt` list of CIDR entries when CSV parsing fails. **Limits** - Maximum request payload size: 2 MB JSON (enforced before parsing). - Maximum number of CIDR entries per list: 50000 (enforced during streaming parse). - Maximum number of IP lists per project: 3. - Empty lists (0 CIDRs) are rejected. - Only IPv4 CIDR entries are supported for now; IPv6 entries are rejected. - No duplicate or overlap checks are performed. **Semantics** - `Upload` creates the list if it does not exist and replaces its content otherwise. Uploads with identical stored content are a no-op (no version bump, no reload). - `List` returns each stored IP list without its CIDR entries (name, labels, number of IPs, content hash, usage). The CIDR entries themselves are never returned by the API. - There is no single-item Get endpoint. Clients verify content by comparing the returned `content_hash`. - IP lists referenced by any load balancer cannot be deleted; the reference must be cleared or replaced with a different list first. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the GetQuotaResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &GetQuotaResponse{} + +// GetQuotaResponse GetQuotaResponse returns the configured IP list quota for the project and region. +type GetQuotaResponse struct { + // Project identifier + ProjectId *string `json:"projectId,omitempty" validate:"regexp=^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"` + Quotas *Quotas `json:"quotas,omitempty"` + // Region + Region *string `json:"region,omitempty" validate:"regexp=^[a-z]{2\\,4}[0-9]{2}$"` + AdditionalProperties map[string]interface{} +} + +type _GetQuotaResponse GetQuotaResponse + +// NewGetQuotaResponse instantiates a new GetQuotaResponse object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewGetQuotaResponse() *GetQuotaResponse { + this := GetQuotaResponse{} + return &this +} + +// NewGetQuotaResponseWithDefaults instantiates a new GetQuotaResponse object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewGetQuotaResponseWithDefaults() *GetQuotaResponse { + this := GetQuotaResponse{} + return &this +} + +// GetProjectId returns the ProjectId field value if set, zero value otherwise. +func (o *GetQuotaResponse) GetProjectId() string { + if o == nil || IsNil(o.ProjectId) { + var ret string + return ret + } + return *o.ProjectId +} + +// GetProjectIdOk returns a tuple with the ProjectId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetQuotaResponse) GetProjectIdOk() (*string, bool) { + if o == nil || IsNil(o.ProjectId) { + return nil, false + } + return o.ProjectId, true +} + +// HasProjectId returns a boolean if a field has been set. +func (o *GetQuotaResponse) HasProjectId() bool { + if o != nil && !IsNil(o.ProjectId) { + return true + } + + return false +} + +// SetProjectId gets a reference to the given string and assigns it to the ProjectId field. +func (o *GetQuotaResponse) SetProjectId(v string) { + o.ProjectId = &v +} + +// GetQuotas returns the Quotas field value if set, zero value otherwise. +func (o *GetQuotaResponse) GetQuotas() Quotas { + if o == nil || IsNil(o.Quotas) { + var ret Quotas + return ret + } + return *o.Quotas +} + +// GetQuotasOk returns a tuple with the Quotas field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetQuotaResponse) GetQuotasOk() (*Quotas, bool) { + if o == nil || IsNil(o.Quotas) { + return nil, false + } + return o.Quotas, true +} + +// HasQuotas returns a boolean if a field has been set. +func (o *GetQuotaResponse) HasQuotas() bool { + if o != nil && !IsNil(o.Quotas) { + return true + } + + return false +} + +// SetQuotas gets a reference to the given Quotas and assigns it to the Quotas field. +func (o *GetQuotaResponse) SetQuotas(v Quotas) { + o.Quotas = &v +} + +// GetRegion returns the Region field value if set, zero value otherwise. +func (o *GetQuotaResponse) GetRegion() string { + if o == nil || IsNil(o.Region) { + var ret string + return ret + } + return *o.Region +} + +// GetRegionOk returns a tuple with the Region field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetQuotaResponse) GetRegionOk() (*string, bool) { + if o == nil || IsNil(o.Region) { + return nil, false + } + return o.Region, true +} + +// HasRegion returns a boolean if a field has been set. +func (o *GetQuotaResponse) HasRegion() bool { + if o != nil && !IsNil(o.Region) { + return true + } + + return false +} + +// SetRegion gets a reference to the given string and assigns it to the Region field. +func (o *GetQuotaResponse) SetRegion(v string) { + o.Region = &v +} + +func (o GetQuotaResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o GetQuotaResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.ProjectId) { + toSerialize["projectId"] = o.ProjectId + } + if !IsNil(o.Quotas) { + toSerialize["quotas"] = o.Quotas + } + if !IsNil(o.Region) { + toSerialize["region"] = o.Region + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *GetQuotaResponse) UnmarshalJSON(data []byte) (err error) { + varGetQuotaResponse := _GetQuotaResponse{} + + err = json.Unmarshal(data, &varGetQuotaResponse) + + if err != nil { + return err + } + + *o = GetQuotaResponse(varGetQuotaResponse) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "projectId") + delete(additionalProperties, "quotas") + delete(additionalProperties, "region") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableGetQuotaResponse struct { + value *GetQuotaResponse + isSet bool +} + +func (v NullableGetQuotaResponse) Get() *GetQuotaResponse { + return v.value +} + +func (v *NullableGetQuotaResponse) Set(val *GetQuotaResponse) { + v.value = val + v.isSet = true +} + +func (v NullableGetQuotaResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableGetQuotaResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableGetQuotaResponse(val *GetQuotaResponse) *NullableGetQuotaResponse { + return &NullableGetQuotaResponse{value: val, isSet: true} +} + +func (v NullableGetQuotaResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableGetQuotaResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/lbiplists/v1alphaapi/model_google_protobuf_any.go b/services/lbiplists/v1alphaapi/model_google_protobuf_any.go new file mode 100644 index 000000000..6d91f1d18 --- /dev/null +++ b/services/lbiplists/v1alphaapi/model_google_protobuf_any.go @@ -0,0 +1,154 @@ +/* +STACKIT Load Balancer IP Lists API + +This API manages IP lists (sets of IPv4 CIDR ranges) scoped to a project and region. IP lists enable blacklisting: they can be referenced by Application and Network Load Balancer to deny traffic from matching source addresses. **Upload format** Lists are uploaded as a single raw payload in `file_content` (base64 in JSON transport). The server first tries to parse the payload as CSV (with a `cidr` column; any other columns are ignored) and falls back to a newline-separated `.txt` list of CIDR entries when CSV parsing fails. **Limits** - Maximum request payload size: 2 MB JSON (enforced before parsing). - Maximum number of CIDR entries per list: 50000 (enforced during streaming parse). - Maximum number of IP lists per project: 3. - Empty lists (0 CIDRs) are rejected. - Only IPv4 CIDR entries are supported for now; IPv6 entries are rejected. - No duplicate or overlap checks are performed. **Semantics** - `Upload` creates the list if it does not exist and replaces its content otherwise. Uploads with identical stored content are a no-op (no version bump, no reload). - `List` returns each stored IP list without its CIDR entries (name, labels, number of IPs, content hash, usage). The CIDR entries themselves are never returned by the API. - There is no single-item Get endpoint. Clients verify content by comparing the returned `content_hash`. - IP lists referenced by any load balancer cannot be deleted; the reference must be cleared or replaced with a different list first. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the GoogleProtobufAny type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &GoogleProtobufAny{} + +// GoogleProtobufAny Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. +type GoogleProtobufAny struct { + // The type of the serialized message. + Type *string `json:"@type,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _GoogleProtobufAny GoogleProtobufAny + +// NewGoogleProtobufAny instantiates a new GoogleProtobufAny object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewGoogleProtobufAny() *GoogleProtobufAny { + this := GoogleProtobufAny{} + return &this +} + +// NewGoogleProtobufAnyWithDefaults instantiates a new GoogleProtobufAny object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewGoogleProtobufAnyWithDefaults() *GoogleProtobufAny { + this := GoogleProtobufAny{} + return &this +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *GoogleProtobufAny) GetType() string { + if o == nil || IsNil(o.Type) { + var ret string + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GoogleProtobufAny) GetTypeOk() (*string, bool) { + if o == nil || IsNil(o.Type) { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *GoogleProtobufAny) HasType() bool { + if o != nil && !IsNil(o.Type) { + return true + } + + return false +} + +// SetType gets a reference to the given string and assigns it to the Type field. +func (o *GoogleProtobufAny) SetType(v string) { + o.Type = &v +} + +func (o GoogleProtobufAny) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o GoogleProtobufAny) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Type) { + toSerialize["@type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *GoogleProtobufAny) UnmarshalJSON(data []byte) (err error) { + varGoogleProtobufAny := _GoogleProtobufAny{} + + err = json.Unmarshal(data, &varGoogleProtobufAny) + + if err != nil { + return err + } + + *o = GoogleProtobufAny(varGoogleProtobufAny) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "@type") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableGoogleProtobufAny struct { + value *GoogleProtobufAny + isSet bool +} + +func (v NullableGoogleProtobufAny) Get() *GoogleProtobufAny { + return v.value +} + +func (v *NullableGoogleProtobufAny) Set(val *GoogleProtobufAny) { + v.value = val + v.isSet = true +} + +func (v NullableGoogleProtobufAny) IsSet() bool { + return v.isSet +} + +func (v *NullableGoogleProtobufAny) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableGoogleProtobufAny(val *GoogleProtobufAny) *NullableGoogleProtobufAny { + return &NullableGoogleProtobufAny{value: val, isSet: true} +} + +func (v NullableGoogleProtobufAny) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableGoogleProtobufAny) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/lbiplists/v1alphaapi/model_ip_list_usage.go b/services/lbiplists/v1alphaapi/model_ip_list_usage.go new file mode 100644 index 000000000..697060168 --- /dev/null +++ b/services/lbiplists/v1alphaapi/model_ip_list_usage.go @@ -0,0 +1,192 @@ +/* +STACKIT Load Balancer IP Lists API + +This API manages IP lists (sets of IPv4 CIDR ranges) scoped to a project and region. IP lists enable blacklisting: they can be referenced by Application and Network Load Balancer to deny traffic from matching source addresses. **Upload format** Lists are uploaded as a single raw payload in `file_content` (base64 in JSON transport). The server first tries to parse the payload as CSV (with a `cidr` column; any other columns are ignored) and falls back to a newline-separated `.txt` list of CIDR entries when CSV parsing fails. **Limits** - Maximum request payload size: 2 MB JSON (enforced before parsing). - Maximum number of CIDR entries per list: 50000 (enforced during streaming parse). - Maximum number of IP lists per project: 3. - Empty lists (0 CIDRs) are rejected. - Only IPv4 CIDR entries are supported for now; IPv6 entries are rejected. - No duplicate or overlap checks are performed. **Semantics** - `Upload` creates the list if it does not exist and replaces its content otherwise. Uploads with identical stored content are a no-op (no version bump, no reload). - `List` returns each stored IP list without its CIDR entries (name, labels, number of IPs, content hash, usage). The CIDR entries themselves are never returned by the API. - There is no single-item Get endpoint. Clients verify content by comparing the returned `content_hash`. - IP lists referenced by any load balancer cannot be deleted; the reference must be cleared or replaced with a different list first. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the IPListUsage type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &IPListUsage{} + +// IPListUsage IPListUsage describes which NLB/ALB currently reference an IP list. +type IPListUsage struct { + // Number of load balancers currently using this IP list. + Count *int32 `json:"count,omitempty"` + // List of load balancers that reference this IP list. + Items []UsageItem `json:"items,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _IPListUsage IPListUsage + +// NewIPListUsage instantiates a new IPListUsage 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 NewIPListUsage() *IPListUsage { + this := IPListUsage{} + return &this +} + +// NewIPListUsageWithDefaults instantiates a new IPListUsage 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 NewIPListUsageWithDefaults() *IPListUsage { + this := IPListUsage{} + return &this +} + +// GetCount returns the Count field value if set, zero value otherwise. +func (o *IPListUsage) GetCount() int32 { + if o == nil || IsNil(o.Count) { + var ret int32 + return ret + } + return *o.Count +} + +// GetCountOk returns a tuple with the Count field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IPListUsage) GetCountOk() (*int32, bool) { + if o == nil || IsNil(o.Count) { + return nil, false + } + return o.Count, true +} + +// HasCount returns a boolean if a field has been set. +func (o *IPListUsage) HasCount() bool { + if o != nil && !IsNil(o.Count) { + return true + } + + return false +} + +// SetCount gets a reference to the given int32 and assigns it to the Count field. +func (o *IPListUsage) SetCount(v int32) { + o.Count = &v +} + +// GetItems returns the Items field value if set, zero value otherwise. +func (o *IPListUsage) GetItems() []UsageItem { + if o == nil || IsNil(o.Items) { + var ret []UsageItem + return ret + } + return o.Items +} + +// GetItemsOk returns a tuple with the Items field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IPListUsage) GetItemsOk() ([]UsageItem, bool) { + if o == nil || IsNil(o.Items) { + return nil, false + } + return o.Items, true +} + +// HasItems returns a boolean if a field has been set. +func (o *IPListUsage) HasItems() bool { + if o != nil && !IsNil(o.Items) { + return true + } + + return false +} + +// SetItems gets a reference to the given []UsageItem and assigns it to the Items field. +func (o *IPListUsage) SetItems(v []UsageItem) { + o.Items = v +} + +func (o IPListUsage) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o IPListUsage) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Count) { + toSerialize["count"] = o.Count + } + if !IsNil(o.Items) { + toSerialize["items"] = o.Items + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *IPListUsage) UnmarshalJSON(data []byte) (err error) { + varIPListUsage := _IPListUsage{} + + err = json.Unmarshal(data, &varIPListUsage) + + if err != nil { + return err + } + + *o = IPListUsage(varIPListUsage) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "count") + delete(additionalProperties, "items") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableIPListUsage struct { + value *IPListUsage + isSet bool +} + +func (v NullableIPListUsage) Get() *IPListUsage { + return v.value +} + +func (v *NullableIPListUsage) Set(val *IPListUsage) { + v.value = val + v.isSet = true +} + +func (v NullableIPListUsage) IsSet() bool { + return v.isSet +} + +func (v *NullableIPListUsage) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableIPListUsage(val *IPListUsage) *NullableIPListUsage { + return &NullableIPListUsage{value: val, isSet: true} +} + +func (v NullableIPListUsage) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableIPListUsage) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/lbiplists/v1alphaapi/model_ip_lists_quota.go b/services/lbiplists/v1alphaapi/model_ip_lists_quota.go new file mode 100644 index 000000000..c1dc7ada1 --- /dev/null +++ b/services/lbiplists/v1alphaapi/model_ip_lists_quota.go @@ -0,0 +1,230 @@ +/* +STACKIT Load Balancer IP Lists API + +This API manages IP lists (sets of IPv4 CIDR ranges) scoped to a project and region. IP lists enable blacklisting: they can be referenced by Application and Network Load Balancer to deny traffic from matching source addresses. **Upload format** Lists are uploaded as a single raw payload in `file_content` (base64 in JSON transport). The server first tries to parse the payload as CSV (with a `cidr` column; any other columns are ignored) and falls back to a newline-separated `.txt` list of CIDR entries when CSV parsing fails. **Limits** - Maximum request payload size: 2 MB JSON (enforced before parsing). - Maximum number of CIDR entries per list: 50000 (enforced during streaming parse). - Maximum number of IP lists per project: 3. - Empty lists (0 CIDRs) are rejected. - Only IPv4 CIDR entries are supported for now; IPv6 entries are rejected. - No duplicate or overlap checks are performed. **Semantics** - `Upload` creates the list if it does not exist and replaces its content otherwise. Uploads with identical stored content are a no-op (no version bump, no reload). - `List` returns each stored IP list without its CIDR entries (name, labels, number of IPs, content hash, usage). The CIDR entries themselves are never returned by the API. - There is no single-item Get endpoint. Clients verify content by comparing the returned `content_hash`. - IP lists referenced by any load balancer cannot be deleted; the reference must be cleared or replaced with a different list first. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the IPListsQuota type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &IPListsQuota{} + +// IPListsQuota IPListsQuota holds the limits and current usage for IP list resources. Defaults: limit=3 per project, max_entries_per_list=50000. +type IPListsQuota struct { + // The maximum number of IP lists allowed in this project. Defaults to 3. Use -1 to indicate unlimited. + Limit *int32 `json:"limit,omitempty"` + // The maximum number of IPv4 CIDR entries allowed in a single IP list. Defaults to 50000. + MaxEntriesPerList *int32 `json:"maxEntriesPerList,omitempty"` + // The number of IP lists that currently exist in this project. + Usage *int32 `json:"usage,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _IPListsQuota IPListsQuota + +// NewIPListsQuota instantiates a new IPListsQuota 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 NewIPListsQuota() *IPListsQuota { + this := IPListsQuota{} + return &this +} + +// NewIPListsQuotaWithDefaults instantiates a new IPListsQuota 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 NewIPListsQuotaWithDefaults() *IPListsQuota { + this := IPListsQuota{} + return &this +} + +// GetLimit returns the Limit field value if set, zero value otherwise. +func (o *IPListsQuota) GetLimit() int32 { + if o == nil || IsNil(o.Limit) { + var ret int32 + return ret + } + return *o.Limit +} + +// GetLimitOk returns a tuple with the Limit field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IPListsQuota) GetLimitOk() (*int32, bool) { + if o == nil || IsNil(o.Limit) { + return nil, false + } + return o.Limit, true +} + +// HasLimit returns a boolean if a field has been set. +func (o *IPListsQuota) HasLimit() bool { + if o != nil && !IsNil(o.Limit) { + return true + } + + return false +} + +// SetLimit gets a reference to the given int32 and assigns it to the Limit field. +func (o *IPListsQuota) SetLimit(v int32) { + o.Limit = &v +} + +// GetMaxEntriesPerList returns the MaxEntriesPerList field value if set, zero value otherwise. +func (o *IPListsQuota) GetMaxEntriesPerList() int32 { + if o == nil || IsNil(o.MaxEntriesPerList) { + var ret int32 + return ret + } + return *o.MaxEntriesPerList +} + +// GetMaxEntriesPerListOk returns a tuple with the MaxEntriesPerList field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IPListsQuota) GetMaxEntriesPerListOk() (*int32, bool) { + if o == nil || IsNil(o.MaxEntriesPerList) { + return nil, false + } + return o.MaxEntriesPerList, true +} + +// HasMaxEntriesPerList returns a boolean if a field has been set. +func (o *IPListsQuota) HasMaxEntriesPerList() bool { + if o != nil && !IsNil(o.MaxEntriesPerList) { + return true + } + + return false +} + +// SetMaxEntriesPerList gets a reference to the given int32 and assigns it to the MaxEntriesPerList field. +func (o *IPListsQuota) SetMaxEntriesPerList(v int32) { + o.MaxEntriesPerList = &v +} + +// GetUsage returns the Usage field value if set, zero value otherwise. +func (o *IPListsQuota) GetUsage() int32 { + if o == nil || IsNil(o.Usage) { + var ret int32 + return ret + } + return *o.Usage +} + +// GetUsageOk returns a tuple with the Usage field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IPListsQuota) GetUsageOk() (*int32, bool) { + if o == nil || IsNil(o.Usage) { + return nil, false + } + return o.Usage, true +} + +// HasUsage returns a boolean if a field has been set. +func (o *IPListsQuota) HasUsage() bool { + if o != nil && !IsNil(o.Usage) { + return true + } + + return false +} + +// SetUsage gets a reference to the given int32 and assigns it to the Usage field. +func (o *IPListsQuota) SetUsage(v int32) { + o.Usage = &v +} + +func (o IPListsQuota) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o IPListsQuota) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Limit) { + toSerialize["limit"] = o.Limit + } + if !IsNil(o.MaxEntriesPerList) { + toSerialize["maxEntriesPerList"] = o.MaxEntriesPerList + } + if !IsNil(o.Usage) { + toSerialize["usage"] = o.Usage + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *IPListsQuota) UnmarshalJSON(data []byte) (err error) { + varIPListsQuota := _IPListsQuota{} + + err = json.Unmarshal(data, &varIPListsQuota) + + if err != nil { + return err + } + + *o = IPListsQuota(varIPListsQuota) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "limit") + delete(additionalProperties, "maxEntriesPerList") + delete(additionalProperties, "usage") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableIPListsQuota struct { + value *IPListsQuota + isSet bool +} + +func (v NullableIPListsQuota) Get() *IPListsQuota { + return v.value +} + +func (v *NullableIPListsQuota) Set(val *IPListsQuota) { + v.value = val + v.isSet = true +} + +func (v NullableIPListsQuota) IsSet() bool { + return v.isSet +} + +func (v *NullableIPListsQuota) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableIPListsQuota(val *IPListsQuota) *NullableIPListsQuota { + return &NullableIPListsQuota{value: val, isSet: true} +} + +func (v NullableIPListsQuota) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableIPListsQuota) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/lbiplists/v1alphaapi/model_list_ip_lists_response.go b/services/lbiplists/v1alphaapi/model_list_ip_lists_response.go new file mode 100644 index 000000000..592ac0bf8 --- /dev/null +++ b/services/lbiplists/v1alphaapi/model_list_ip_lists_response.go @@ -0,0 +1,154 @@ +/* +STACKIT Load Balancer IP Lists API + +This API manages IP lists (sets of IPv4 CIDR ranges) scoped to a project and region. IP lists enable blacklisting: they can be referenced by Application and Network Load Balancer to deny traffic from matching source addresses. **Upload format** Lists are uploaded as a single raw payload in `file_content` (base64 in JSON transport). The server first tries to parse the payload as CSV (with a `cidr` column; any other columns are ignored) and falls back to a newline-separated `.txt` list of CIDR entries when CSV parsing fails. **Limits** - Maximum request payload size: 2 MB JSON (enforced before parsing). - Maximum number of CIDR entries per list: 50000 (enforced during streaming parse). - Maximum number of IP lists per project: 3. - Empty lists (0 CIDRs) are rejected. - Only IPv4 CIDR entries are supported for now; IPv6 entries are rejected. - No duplicate or overlap checks are performed. **Semantics** - `Upload` creates the list if it does not exist and replaces its content otherwise. Uploads with identical stored content are a no-op (no version bump, no reload). - `List` returns each stored IP list without its CIDR entries (name, labels, number of IPs, content hash, usage). The CIDR entries themselves are never returned by the API. - There is no single-item Get endpoint. Clients verify content by comparing the returned `content_hash`. - IP lists referenced by any load balancer cannot be deleted; the reference must be cleared or replaced with a different list first. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the ListIPListsResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ListIPListsResponse{} + +// ListIPListsResponse ListIPListsResponse returns metadata for all IP lists in a project and region. The CIDR entries themselves are never returned. +type ListIPListsResponse struct { + // Every IP list in the project and region. Never includes the CIDR entries themselves. + Items []GetIPListResponse `json:"items,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _ListIPListsResponse ListIPListsResponse + +// NewListIPListsResponse instantiates a new ListIPListsResponse 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 NewListIPListsResponse() *ListIPListsResponse { + this := ListIPListsResponse{} + return &this +} + +// NewListIPListsResponseWithDefaults instantiates a new ListIPListsResponse 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 NewListIPListsResponseWithDefaults() *ListIPListsResponse { + this := ListIPListsResponse{} + return &this +} + +// GetItems returns the Items field value if set, zero value otherwise. +func (o *ListIPListsResponse) GetItems() []GetIPListResponse { + if o == nil || IsNil(o.Items) { + var ret []GetIPListResponse + return ret + } + return o.Items +} + +// GetItemsOk returns a tuple with the Items field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ListIPListsResponse) GetItemsOk() ([]GetIPListResponse, bool) { + if o == nil || IsNil(o.Items) { + return nil, false + } + return o.Items, true +} + +// HasItems returns a boolean if a field has been set. +func (o *ListIPListsResponse) HasItems() bool { + if o != nil && !IsNil(o.Items) { + return true + } + + return false +} + +// SetItems gets a reference to the given []GetIPListResponse and assigns it to the Items field. +func (o *ListIPListsResponse) SetItems(v []GetIPListResponse) { + o.Items = v +} + +func (o ListIPListsResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ListIPListsResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Items) { + toSerialize["items"] = o.Items + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *ListIPListsResponse) UnmarshalJSON(data []byte) (err error) { + varListIPListsResponse := _ListIPListsResponse{} + + err = json.Unmarshal(data, &varListIPListsResponse) + + if err != nil { + return err + } + + *o = ListIPListsResponse(varListIPListsResponse) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "items") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableListIPListsResponse struct { + value *ListIPListsResponse + isSet bool +} + +func (v NullableListIPListsResponse) Get() *ListIPListsResponse { + return v.value +} + +func (v *NullableListIPListsResponse) Set(val *ListIPListsResponse) { + v.value = val + v.isSet = true +} + +func (v NullableListIPListsResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableListIPListsResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableListIPListsResponse(val *ListIPListsResponse) *NullableListIPListsResponse { + return &NullableListIPListsResponse{value: val, isSet: true} +} + +func (v NullableListIPListsResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableListIPListsResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/lbiplists/v1alphaapi/model_quotas.go b/services/lbiplists/v1alphaapi/model_quotas.go new file mode 100644 index 000000000..30ad233d6 --- /dev/null +++ b/services/lbiplists/v1alphaapi/model_quotas.go @@ -0,0 +1,153 @@ +/* +STACKIT Load Balancer IP Lists API + +This API manages IP lists (sets of IPv4 CIDR ranges) scoped to a project and region. IP lists enable blacklisting: they can be referenced by Application and Network Load Balancer to deny traffic from matching source addresses. **Upload format** Lists are uploaded as a single raw payload in `file_content` (base64 in JSON transport). The server first tries to parse the payload as CSV (with a `cidr` column; any other columns are ignored) and falls back to a newline-separated `.txt` list of CIDR entries when CSV parsing fails. **Limits** - Maximum request payload size: 2 MB JSON (enforced before parsing). - Maximum number of CIDR entries per list: 50000 (enforced during streaming parse). - Maximum number of IP lists per project: 3. - Empty lists (0 CIDRs) are rejected. - Only IPv4 CIDR entries are supported for now; IPv6 entries are rejected. - No duplicate or overlap checks are performed. **Semantics** - `Upload` creates the list if it does not exist and replaces its content otherwise. Uploads with identical stored content are a no-op (no version bump, no reload). - `List` returns each stored IP list without its CIDR entries (name, labels, number of IPs, content hash, usage). The CIDR entries themselves are never returned by the API. - There is no single-item Get endpoint. Clients verify content by comparing the returned `content_hash`. - IP lists referenced by any load balancer cannot be deleted; the reference must be cleared or replaced with a different list first. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the Quotas type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Quotas{} + +// Quotas Quotas holds the specific quota elements for resources managed by this API. +type Quotas struct { + IpLists *IPListsQuota `json:"ipLists,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _Quotas Quotas + +// NewQuotas instantiates a new Quotas object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewQuotas() *Quotas { + this := Quotas{} + return &this +} + +// NewQuotasWithDefaults instantiates a new Quotas object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewQuotasWithDefaults() *Quotas { + this := Quotas{} + return &this +} + +// GetIpLists returns the IpLists field value if set, zero value otherwise. +func (o *Quotas) GetIpLists() IPListsQuota { + if o == nil || IsNil(o.IpLists) { + var ret IPListsQuota + return ret + } + return *o.IpLists +} + +// GetIpListsOk returns a tuple with the IpLists field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Quotas) GetIpListsOk() (*IPListsQuota, bool) { + if o == nil || IsNil(o.IpLists) { + return nil, false + } + return o.IpLists, true +} + +// HasIpLists returns a boolean if a field has been set. +func (o *Quotas) HasIpLists() bool { + if o != nil && !IsNil(o.IpLists) { + return true + } + + return false +} + +// SetIpLists gets a reference to the given IPListsQuota and assigns it to the IpLists field. +func (o *Quotas) SetIpLists(v IPListsQuota) { + o.IpLists = &v +} + +func (o Quotas) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o Quotas) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.IpLists) { + toSerialize["ipLists"] = o.IpLists + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *Quotas) UnmarshalJSON(data []byte) (err error) { + varQuotas := _Quotas{} + + err = json.Unmarshal(data, &varQuotas) + + if err != nil { + return err + } + + *o = Quotas(varQuotas) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "ipLists") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableQuotas struct { + value *Quotas + isSet bool +} + +func (v NullableQuotas) Get() *Quotas { + return v.value +} + +func (v *NullableQuotas) Set(val *Quotas) { + v.value = val + v.isSet = true +} + +func (v NullableQuotas) IsSet() bool { + return v.isSet +} + +func (v *NullableQuotas) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableQuotas(val *Quotas) *NullableQuotas { + return &NullableQuotas{value: val, isSet: true} +} + +func (v NullableQuotas) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableQuotas) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/lbiplists/v1alphaapi/model_status.go b/services/lbiplists/v1alphaapi/model_status.go new file mode 100644 index 000000000..6bbc49572 --- /dev/null +++ b/services/lbiplists/v1alphaapi/model_status.go @@ -0,0 +1,230 @@ +/* +STACKIT Load Balancer IP Lists API + +This API manages IP lists (sets of IPv4 CIDR ranges) scoped to a project and region. IP lists enable blacklisting: they can be referenced by Application and Network Load Balancer to deny traffic from matching source addresses. **Upload format** Lists are uploaded as a single raw payload in `file_content` (base64 in JSON transport). The server first tries to parse the payload as CSV (with a `cidr` column; any other columns are ignored) and falls back to a newline-separated `.txt` list of CIDR entries when CSV parsing fails. **Limits** - Maximum request payload size: 2 MB JSON (enforced before parsing). - Maximum number of CIDR entries per list: 50000 (enforced during streaming parse). - Maximum number of IP lists per project: 3. - Empty lists (0 CIDRs) are rejected. - Only IPv4 CIDR entries are supported for now; IPv6 entries are rejected. - No duplicate or overlap checks are performed. **Semantics** - `Upload` creates the list if it does not exist and replaces its content otherwise. Uploads with identical stored content are a no-op (no version bump, no reload). - `List` returns each stored IP list without its CIDR entries (name, labels, number of IPs, content hash, usage). The CIDR entries themselves are never returned by the API. - There is no single-item Get endpoint. Clients verify content by comparing the returned `content_hash`. - IP lists referenced by any load balancer cannot be deleted; the reference must be cleared or replaced with a different list first. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" +) + +// checks if the Status type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Status{} + +// Status The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). +type Status struct { + // The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. + Code *int32 `json:"code,omitempty"` + // A list of messages that carry the error details. There is a common set of message types for APIs to use. + Details []GoogleProtobufAny `json:"details,omitempty"` + // A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. + Message *string `json:"message,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _Status Status + +// NewStatus instantiates a new Status object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewStatus() *Status { + this := Status{} + return &this +} + +// NewStatusWithDefaults instantiates a new Status object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewStatusWithDefaults() *Status { + this := Status{} + return &this +} + +// GetCode returns the Code field value if set, zero value otherwise. +func (o *Status) GetCode() int32 { + if o == nil || IsNil(o.Code) { + var ret int32 + return ret + } + return *o.Code +} + +// GetCodeOk returns a tuple with the Code field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Status) GetCodeOk() (*int32, bool) { + if o == nil || IsNil(o.Code) { + return nil, false + } + return o.Code, true +} + +// HasCode returns a boolean if a field has been set. +func (o *Status) HasCode() bool { + if o != nil && !IsNil(o.Code) { + return true + } + + return false +} + +// SetCode gets a reference to the given int32 and assigns it to the Code field. +func (o *Status) SetCode(v int32) { + o.Code = &v +} + +// GetDetails returns the Details field value if set, zero value otherwise. +func (o *Status) GetDetails() []GoogleProtobufAny { + if o == nil || IsNil(o.Details) { + var ret []GoogleProtobufAny + return ret + } + return o.Details +} + +// GetDetailsOk returns a tuple with the Details field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Status) GetDetailsOk() ([]GoogleProtobufAny, bool) { + if o == nil || IsNil(o.Details) { + return nil, false + } + return o.Details, true +} + +// HasDetails returns a boolean if a field has been set. +func (o *Status) HasDetails() bool { + if o != nil && !IsNil(o.Details) { + return true + } + + return false +} + +// SetDetails gets a reference to the given []GoogleProtobufAny and assigns it to the Details field. +func (o *Status) SetDetails(v []GoogleProtobufAny) { + o.Details = v +} + +// GetMessage returns the Message field value if set, zero value otherwise. +func (o *Status) GetMessage() string { + if o == nil || IsNil(o.Message) { + var ret string + return ret + } + return *o.Message +} + +// GetMessageOk returns a tuple with the Message field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Status) GetMessageOk() (*string, bool) { + if o == nil || IsNil(o.Message) { + return nil, false + } + return o.Message, true +} + +// HasMessage returns a boolean if a field has been set. +func (o *Status) HasMessage() bool { + if o != nil && !IsNil(o.Message) { + return true + } + + return false +} + +// SetMessage gets a reference to the given string and assigns it to the Message field. +func (o *Status) SetMessage(v string) { + o.Message = &v +} + +func (o Status) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o Status) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Code) { + toSerialize["code"] = o.Code + } + if !IsNil(o.Details) { + toSerialize["details"] = o.Details + } + if !IsNil(o.Message) { + toSerialize["message"] = o.Message + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *Status) UnmarshalJSON(data []byte) (err error) { + varStatus := _Status{} + + err = json.Unmarshal(data, &varStatus) + + if err != nil { + return err + } + + *o = Status(varStatus) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "code") + delete(additionalProperties, "details") + delete(additionalProperties, "message") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableStatus struct { + value *Status + isSet bool +} + +func (v NullableStatus) Get() *Status { + return v.value +} + +func (v *NullableStatus) Set(val *Status) { + v.value = val + v.isSet = true +} + +func (v NullableStatus) IsSet() bool { + return v.isSet +} + +func (v *NullableStatus) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableStatus(val *Status) *NullableStatus { + return &NullableStatus{value: val, isSet: true} +} + +func (v NullableStatus) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableStatus) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/lbiplists/v1alphaapi/model_upload_ip_list_payload.go b/services/lbiplists/v1alphaapi/model_upload_ip_list_payload.go new file mode 100644 index 000000000..6de955aae --- /dev/null +++ b/services/lbiplists/v1alphaapi/model_upload_ip_list_payload.go @@ -0,0 +1,311 @@ +/* +STACKIT Load Balancer IP Lists API + +This API manages IP lists (sets of IPv4 CIDR ranges) scoped to a project and region. IP lists enable blacklisting: they can be referenced by Application and Network Load Balancer to deny traffic from matching source addresses. **Upload format** Lists are uploaded as a single raw payload in `file_content` (base64 in JSON transport). The server first tries to parse the payload as CSV (with a `cidr` column; any other columns are ignored) and falls back to a newline-separated `.txt` list of CIDR entries when CSV parsing fails. **Limits** - Maximum request payload size: 2 MB JSON (enforced before parsing). - Maximum number of CIDR entries per list: 50000 (enforced during streaming parse). - Maximum number of IP lists per project: 3. - Empty lists (0 CIDRs) are rejected. - Only IPv4 CIDR entries are supported for now; IPv6 entries are rejected. - No duplicate or overlap checks are performed. **Semantics** - `Upload` creates the list if it does not exist and replaces its content otherwise. Uploads with identical stored content are a no-op (no version bump, no reload). - `List` returns each stored IP list without its CIDR entries (name, labels, number of IPs, content hash, usage). The CIDR entries themselves are never returned by the API. - There is no single-item Get endpoint. Clients verify content by comparing the returned `content_hash`. - IP lists referenced by any load balancer cannot be deleted; the reference must be cleared or replaced with a different list first. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" + "fmt" +) + +// checks if the UploadIPListPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &UploadIPListPayload{} + +// UploadIPListPayload Request payload for creating or replacing an IP list. **Limits & Restrictions:** - **Project Quota:** Maximum of 3 IP lists allowed per project. - **Payload Size:** The entire HTTP request body JSON payload is restricted to a maximum size of 2 MB. This limit applies to the full JSON structure, including all fields (`name`, `projectId`, `region`, `fileContent`) and all `labels` keys and values. - **Rate Limit:** 1 request per minute. +type UploadIPListPayload struct { + // Raw upload payload. Base64-encoded over JSON. Newline-separated `.txt` list of IPv4 CIDR entries, or CSV with `cidr,labels` columns (any other columns are ignored). + FileContent string `json:"fileContent"` + // Labels represent user-defined metadata as key-value pairs. Label count should not exceed 64 per IP list. **Key Formatting Rules:** Length: 1-63 characters. Characters: Must begin and end with [a-zA-Z0-9]. May contain dashes (-), underscores (_), dots (.), and alphanumerics in between. Keys starting with 'stackit-' are system-reserved; users MUST NOT manage them. **Value Formatting Rules:** Length: 0-63 characters (empty string explicitly allowed). Characters (for non-empty values): Must begin and end with [a-zA-Z0-9]. May contain dashes (-), underscores (_), dots (.), and alphanumerics in between. + Labels *map[string]string `json:"labels,omitempty"` + // IP list name + Name string `json:"name" validate:"regexp=^[0-9a-z](?:(?:[0-9a-z]|-){0\\,49}[0-9a-z])?$"` + // Project identifier + ProjectId *string `json:"projectId,omitempty" validate:"regexp=^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"` + // Region + Region *string `json:"region,omitempty" validate:"regexp=^[a-z]{2\\,4}[0-9]{2}$"` + AdditionalProperties map[string]interface{} +} + +type _UploadIPListPayload UploadIPListPayload + +// NewUploadIPListPayload instantiates a new UploadIPListPayload 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 NewUploadIPListPayload(fileContent string, name string) *UploadIPListPayload { + this := UploadIPListPayload{} + this.FileContent = fileContent + this.Name = name + return &this +} + +// NewUploadIPListPayloadWithDefaults instantiates a new UploadIPListPayload 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 NewUploadIPListPayloadWithDefaults() *UploadIPListPayload { + this := UploadIPListPayload{} + return &this +} + +// GetFileContent returns the FileContent field value +func (o *UploadIPListPayload) GetFileContent() string { + if o == nil { + var ret string + return ret + } + + return o.FileContent +} + +// GetFileContentOk returns a tuple with the FileContent field value +// and a boolean to check if the value has been set. +func (o *UploadIPListPayload) GetFileContentOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.FileContent, true +} + +// SetFileContent sets field value +func (o *UploadIPListPayload) SetFileContent(v string) { + o.FileContent = v +} + +// GetLabels returns the Labels field value if set, zero value otherwise. +func (o *UploadIPListPayload) GetLabels() map[string]string { + if o == nil || IsNil(o.Labels) { + var ret map[string]string + return ret + } + return *o.Labels +} + +// GetLabelsOk returns a tuple with the Labels field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UploadIPListPayload) GetLabelsOk() (*map[string]string, bool) { + if o == nil || IsNil(o.Labels) { + return nil, false + } + return o.Labels, true +} + +// HasLabels returns a boolean if a field has been set. +func (o *UploadIPListPayload) HasLabels() bool { + if o != nil && !IsNil(o.Labels) { + return true + } + + return false +} + +// SetLabels gets a reference to the given map[string]string and assigns it to the Labels field. +func (o *UploadIPListPayload) SetLabels(v map[string]string) { + o.Labels = &v +} + +// GetName returns the Name field value +func (o *UploadIPListPayload) GetName() string { + if o == nil { + var ret string + return ret + } + + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *UploadIPListPayload) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value +func (o *UploadIPListPayload) SetName(v string) { + o.Name = v +} + +// GetProjectId returns the ProjectId field value if set, zero value otherwise. +func (o *UploadIPListPayload) GetProjectId() string { + if o == nil || IsNil(o.ProjectId) { + var ret string + return ret + } + return *o.ProjectId +} + +// GetProjectIdOk returns a tuple with the ProjectId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UploadIPListPayload) GetProjectIdOk() (*string, bool) { + if o == nil || IsNil(o.ProjectId) { + return nil, false + } + return o.ProjectId, true +} + +// HasProjectId returns a boolean if a field has been set. +func (o *UploadIPListPayload) HasProjectId() bool { + if o != nil && !IsNil(o.ProjectId) { + return true + } + + return false +} + +// SetProjectId gets a reference to the given string and assigns it to the ProjectId field. +func (o *UploadIPListPayload) SetProjectId(v string) { + o.ProjectId = &v +} + +// GetRegion returns the Region field value if set, zero value otherwise. +func (o *UploadIPListPayload) 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 *UploadIPListPayload) 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 *UploadIPListPayload) 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 *UploadIPListPayload) SetRegion(v string) { + o.Region = &v +} + +func (o UploadIPListPayload) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o UploadIPListPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["fileContent"] = o.FileContent + if !IsNil(o.Labels) { + toSerialize["labels"] = o.Labels + } + toSerialize["name"] = o.Name + if !IsNil(o.ProjectId) { + toSerialize["projectId"] = o.ProjectId + } + if !IsNil(o.Region) { + toSerialize["region"] = o.Region + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *UploadIPListPayload) 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{ + "fileContent", + "name", + } + + 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) + } + } + + varUploadIPListPayload := _UploadIPListPayload{} + + err = json.Unmarshal(data, &varUploadIPListPayload) + + if err != nil { + return err + } + + *o = UploadIPListPayload(varUploadIPListPayload) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "fileContent") + delete(additionalProperties, "labels") + delete(additionalProperties, "name") + delete(additionalProperties, "projectId") + delete(additionalProperties, "region") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableUploadIPListPayload struct { + value *UploadIPListPayload + isSet bool +} + +func (v NullableUploadIPListPayload) Get() *UploadIPListPayload { + return v.value +} + +func (v *NullableUploadIPListPayload) Set(val *UploadIPListPayload) { + v.value = val + v.isSet = true +} + +func (v NullableUploadIPListPayload) IsSet() bool { + return v.isSet +} + +func (v *NullableUploadIPListPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableUploadIPListPayload(val *UploadIPListPayload) *NullableUploadIPListPayload { + return &NullableUploadIPListPayload{value: val, isSet: true} +} + +func (v NullableUploadIPListPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableUploadIPListPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/lbiplists/v1alphaapi/model_usage_item.go b/services/lbiplists/v1alphaapi/model_usage_item.go new file mode 100644 index 000000000..c933374e4 --- /dev/null +++ b/services/lbiplists/v1alphaapi/model_usage_item.go @@ -0,0 +1,167 @@ +/* +STACKIT Load Balancer IP Lists API + +This API manages IP lists (sets of IPv4 CIDR ranges) scoped to a project and region. IP lists enable blacklisting: they can be referenced by Application and Network Load Balancer to deny traffic from matching source addresses. **Upload format** Lists are uploaded as a single raw payload in `file_content` (base64 in JSON transport). The server first tries to parse the payload as CSV (with a `cidr` column; any other columns are ignored) and falls back to a newline-separated `.txt` list of CIDR entries when CSV parsing fails. **Limits** - Maximum request payload size: 2 MB JSON (enforced before parsing). - Maximum number of CIDR entries per list: 50000 (enforced during streaming parse). - Maximum number of IP lists per project: 3. - Empty lists (0 CIDRs) are rejected. - Only IPv4 CIDR entries are supported for now; IPv6 entries are rejected. - No duplicate or overlap checks are performed. **Semantics** - `Upload` creates the list if it does not exist and replaces its content otherwise. Uploads with identical stored content are a no-op (no version bump, no reload). - `List` returns each stored IP list without its CIDR entries (name, labels, number of IPs, content hash, usage). The CIDR entries themselves are never returned by the API. - There is no single-item Get endpoint. Clients verify content by comparing the returned `content_hash`. - IP lists referenced by any load balancer cannot be deleted; the reference must be cleared or replaced with a different list first. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" + "fmt" +) + +// checks if the UsageItem type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &UsageItem{} + +// UsageItem IPListUsageItem names the LB referencing the IP list. +type UsageItem struct { + // The display name of the load balancer. + LoadBalancerName string `json:"loadBalancerName"` + AdditionalProperties map[string]interface{} +} + +type _UsageItem UsageItem + +// NewUsageItem instantiates a new UsageItem 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 NewUsageItem(loadBalancerName string) *UsageItem { + this := UsageItem{} + this.LoadBalancerName = loadBalancerName + return &this +} + +// NewUsageItemWithDefaults instantiates a new UsageItem 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 NewUsageItemWithDefaults() *UsageItem { + this := UsageItem{} + return &this +} + +// GetLoadBalancerName returns the LoadBalancerName field value +func (o *UsageItem) GetLoadBalancerName() string { + if o == nil { + var ret string + return ret + } + + return o.LoadBalancerName +} + +// GetLoadBalancerNameOk returns a tuple with the LoadBalancerName field value +// and a boolean to check if the value has been set. +func (o *UsageItem) GetLoadBalancerNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.LoadBalancerName, true +} + +// SetLoadBalancerName sets field value +func (o *UsageItem) SetLoadBalancerName(v string) { + o.LoadBalancerName = v +} + +func (o UsageItem) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o UsageItem) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["loadBalancerName"] = o.LoadBalancerName + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *UsageItem) 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{ + "loadBalancerName", + } + + 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) + } + } + + varUsageItem := _UsageItem{} + + err = json.Unmarshal(data, &varUsageItem) + + if err != nil { + return err + } + + *o = UsageItem(varUsageItem) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "loadBalancerName") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableUsageItem struct { + value *UsageItem + isSet bool +} + +func (v NullableUsageItem) Get() *UsageItem { + return v.value +} + +func (v *NullableUsageItem) Set(val *UsageItem) { + v.value = val + v.isSet = true +} + +func (v NullableUsageItem) IsSet() bool { + return v.isSet +} + +func (v *NullableUsageItem) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableUsageItem(val *UsageItem) *NullableUsageItem { + return &NullableUsageItem{value: val, isSet: true} +} + +func (v NullableUsageItem) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableUsageItem) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/lbiplists/v1alphaapi/response.go b/services/lbiplists/v1alphaapi/response.go new file mode 100644 index 000000000..41e794b5b --- /dev/null +++ b/services/lbiplists/v1alphaapi/response.go @@ -0,0 +1,47 @@ +/* +STACKIT Load Balancer IP Lists API + +This API manages IP lists (sets of IPv4 CIDR ranges) scoped to a project and region. IP lists enable blacklisting: they can be referenced by Application and Network Load Balancer to deny traffic from matching source addresses. **Upload format** Lists are uploaded as a single raw payload in `file_content` (base64 in JSON transport). The server first tries to parse the payload as CSV (with a `cidr` column; any other columns are ignored) and falls back to a newline-separated `.txt` list of CIDR entries when CSV parsing fails. **Limits** - Maximum request payload size: 2 MB JSON (enforced before parsing). - Maximum number of CIDR entries per list: 50000 (enforced during streaming parse). - Maximum number of IP lists per project: 3. - Empty lists (0 CIDRs) are rejected. - Only IPv4 CIDR entries are supported for now; IPv6 entries are rejected. - No duplicate or overlap checks are performed. **Semantics** - `Upload` creates the list if it does not exist and replaces its content otherwise. Uploads with identical stored content are a no-op (no version bump, no reload). - `List` returns each stored IP list without its CIDR entries (name, labels, number of IPs, content hash, usage). The CIDR entries themselves are never returned by the API. - There is no single-item Get endpoint. Clients verify content by comparing the returned `content_hash`. - IP lists referenced by any load balancer cannot be deleted; the reference must be cleared or replaced with a different list first. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "net/http" +) + +// APIResponse stores the API response returned by the server. +type APIResponse struct { + *http.Response `json:"-"` + Message string `json:"message,omitempty"` + // Operation is the name of the OpenAPI operation. + Operation string `json:"operation,omitempty"` + // RequestURL is the request URL. This value is always available, even if the + // embedded *http.Response is nil. + RequestURL string `json:"url,omitempty"` + // Method is the HTTP method used for the request. This value is always + // available, even if the embedded *http.Response is nil. + Method string `json:"method,omitempty"` + // Payload holds the contents of the response body (which may be nil or empty). + // This is provided here as the raw response.Body() reader will have already + // been drained. + Payload []byte `json:"-"` +} + +// NewAPIResponse returns a new APIResponse object. +func NewAPIResponse(r *http.Response) *APIResponse { + + response := &APIResponse{Response: r} + return response +} + +// NewAPIResponseWithError returns a new APIResponse object with the provided error message. +func NewAPIResponseWithError(errorMessage string) *APIResponse { + + response := &APIResponse{Message: errorMessage} + return response +} diff --git a/services/lbiplists/v1alphaapi/utils.go b/services/lbiplists/v1alphaapi/utils.go new file mode 100644 index 000000000..018d5decd --- /dev/null +++ b/services/lbiplists/v1alphaapi/utils.go @@ -0,0 +1,361 @@ +/* +STACKIT Load Balancer IP Lists API + +This API manages IP lists (sets of IPv4 CIDR ranges) scoped to a project and region. IP lists enable blacklisting: they can be referenced by Application and Network Load Balancer to deny traffic from matching source addresses. **Upload format** Lists are uploaded as a single raw payload in `file_content` (base64 in JSON transport). The server first tries to parse the payload as CSV (with a `cidr` column; any other columns are ignored) and falls back to a newline-separated `.txt` list of CIDR entries when CSV parsing fails. **Limits** - Maximum request payload size: 2 MB JSON (enforced before parsing). - Maximum number of CIDR entries per list: 50000 (enforced during streaming parse). - Maximum number of IP lists per project: 3. - Empty lists (0 CIDRs) are rejected. - Only IPv4 CIDR entries are supported for now; IPv6 entries are rejected. - No duplicate or overlap checks are performed. **Semantics** - `Upload` creates the list if it does not exist and replaces its content otherwise. Uploads with identical stored content are a no-op (no version bump, no reload). - `List` returns each stored IP list without its CIDR entries (name, labels, number of IPs, content hash, usage). The CIDR entries themselves are never returned by the API. - There is no single-item Get endpoint. Clients verify content by comparing the returned `content_hash`. - IP lists referenced by any load balancer cannot be deleted; the reference must be cleared or replaced with a different list first. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "bytes" + "encoding/json" + "fmt" + "reflect" + "time" +) + +// PtrBool is a helper routine that returns a pointer to given boolean value. +func PtrBool(v bool) *bool { return &v } + +// PtrInt is a helper routine that returns a pointer to given integer value. +func PtrInt(v int) *int { return &v } + +// PtrInt32 is a helper routine that returns a pointer to given integer value. +func PtrInt32(v int32) *int32 { return &v } + +// PtrInt64 is a helper routine that returns a pointer to given integer value. +func PtrInt64(v int64) *int64 { return &v } + +// PtrFloat32 is a helper routine that returns a pointer to given float value. +func PtrFloat32(v float32) *float32 { return &v } + +// PtrFloat64 is a helper routine that returns a pointer to given float value. +func PtrFloat64(v float64) *float64 { return &v } + +// PtrString is a helper routine that returns a pointer to given string value. +func PtrString(v string) *string { return &v } + +// PtrTime is helper routine that returns a pointer to given Time value. +func PtrTime(v time.Time) *time.Time { return &v } + +type NullableBool struct { + value *bool + isSet bool +} + +func (v NullableBool) Get() *bool { + return v.value +} + +func (v *NullableBool) Set(val *bool) { + v.value = val + v.isSet = true +} + +func (v NullableBool) IsSet() bool { + return v.isSet +} + +func (v *NullableBool) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableBool(val *bool) *NullableBool { + return &NullableBool{value: val, isSet: true} +} + +func (v NullableBool) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableBool) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableInt struct { + value *int + isSet bool +} + +func (v NullableInt) Get() *int { + return v.value +} + +func (v *NullableInt) Set(val *int) { + v.value = val + v.isSet = true +} + +func (v NullableInt) IsSet() bool { + return v.isSet +} + +func (v *NullableInt) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInt(val *int) *NullableInt { + return &NullableInt{value: val, isSet: true} +} + +func (v NullableInt) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInt) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableInt32 struct { + value *int32 + isSet bool +} + +func (v NullableInt32) Get() *int32 { + return v.value +} + +func (v *NullableInt32) Set(val *int32) { + v.value = val + v.isSet = true +} + +func (v NullableInt32) IsSet() bool { + return v.isSet +} + +func (v *NullableInt32) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInt32(val *int32) *NullableInt32 { + return &NullableInt32{value: val, isSet: true} +} + +func (v NullableInt32) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInt32) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableInt64 struct { + value *int64 + isSet bool +} + +func (v NullableInt64) Get() *int64 { + return v.value +} + +func (v *NullableInt64) Set(val *int64) { + v.value = val + v.isSet = true +} + +func (v NullableInt64) IsSet() bool { + return v.isSet +} + +func (v *NullableInt64) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInt64(val *int64) *NullableInt64 { + return &NullableInt64{value: val, isSet: true} +} + +func (v NullableInt64) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInt64) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableFloat32 struct { + value *float32 + isSet bool +} + +func (v NullableFloat32) Get() *float32 { + return v.value +} + +func (v *NullableFloat32) Set(val *float32) { + v.value = val + v.isSet = true +} + +func (v NullableFloat32) IsSet() bool { + return v.isSet +} + +func (v *NullableFloat32) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableFloat32(val *float32) *NullableFloat32 { + return &NullableFloat32{value: val, isSet: true} +} + +func (v NullableFloat32) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableFloat32) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableFloat64 struct { + value *float64 + isSet bool +} + +func (v NullableFloat64) Get() *float64 { + return v.value +} + +func (v *NullableFloat64) Set(val *float64) { + v.value = val + v.isSet = true +} + +func (v NullableFloat64) IsSet() bool { + return v.isSet +} + +func (v *NullableFloat64) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableFloat64(val *float64) *NullableFloat64 { + return &NullableFloat64{value: val, isSet: true} +} + +func (v NullableFloat64) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableFloat64) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableString struct { + value *string + isSet bool +} + +func (v NullableString) Get() *string { + return v.value +} + +func (v *NullableString) Set(val *string) { + v.value = val + v.isSet = true +} + +func (v NullableString) IsSet() bool { + return v.isSet +} + +func (v *NullableString) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableString(val *string) *NullableString { + return &NullableString{value: val, isSet: true} +} + +func (v NullableString) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableString) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableTime struct { + value *time.Time + isSet bool +} + +func (v NullableTime) Get() *time.Time { + return v.value +} + +func (v *NullableTime) Set(val *time.Time) { + v.value = val + v.isSet = true +} + +func (v NullableTime) IsSet() bool { + return v.isSet +} + +func (v *NullableTime) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableTime(val *time.Time) *NullableTime { + return &NullableTime{value: val, isSet: true} +} + +func (v NullableTime) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableTime) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +// IsNil checks if an input is nil +func IsNil(i interface{}) bool { + if i == nil { + return true + } + switch reflect.TypeOf(i).Kind() { + case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.UnsafePointer, reflect.Interface, reflect.Slice: + return reflect.ValueOf(i).IsNil() + case reflect.Array: + return reflect.ValueOf(i).IsZero() + } + return false +} + +type MappedNullable interface { + ToMap() (map[string]interface{}, error) +} + +// A wrapper for strict JSON decoding +func newStrictDecoder(data []byte) *json.Decoder { + dec := json.NewDecoder(bytes.NewBuffer(data)) + dec.DisallowUnknownFields() + return dec +} + +// Prevent trying to import "fmt" +func reportError(format string, a ...interface{}) error { + return fmt.Errorf(format, a...) +}