diff --git a/go.work b/go.work index 7c0013e6d..1f720e65d 100644 --- a/go.work +++ b/go.work @@ -68,6 +68,7 @@ use ( ./services/observability ./services/opensearch ./services/postgresflex + ./services/pubsub ./services/rabbitmq ./services/redis ./services/resourcemanager diff --git a/services/pubsub/LICENSE.md b/services/pubsub/LICENSE.md new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/services/pubsub/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/pubsub/go.mod b/services/pubsub/go.mod new file mode 100644 index 000000000..07e2dda86 --- /dev/null +++ b/services/pubsub/go.mod @@ -0,0 +1,10 @@ +module github.com/stackitcloud/stackit-sdk-go/services/pubsub + +go 1.25 + +require github.com/stackitcloud/stackit-sdk-go/core v0.26.0 + +require ( + github.com/golang-jwt/jwt/v5 v5.3.1 // indirect + github.com/google/uuid v1.6.0 // indirect +) diff --git a/services/pubsub/go.sum b/services/pubsub/go.sum new file mode 100644 index 000000000..3712a0c87 --- /dev/null +++ b/services/pubsub/go.sum @@ -0,0 +1,8 @@ +github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY= +github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/stackitcloud/stackit-sdk-go/core v0.26.0 h1:jQEb9gkehfp6VCP6TcYk7BI10cz4l0KM2L6hqYBH2QA= +github.com/stackitcloud/stackit-sdk-go/core v0.26.0/go.mod h1:WU1hhxnjXw2EV7CYa1nlEvNpMiRY6CvmIOaHuL3pOaA= diff --git a/services/pubsub/oas_commit b/services/pubsub/oas_commit new file mode 100644 index 000000000..f01ce2f47 --- /dev/null +++ b/services/pubsub/oas_commit @@ -0,0 +1 @@ +9e58981af825e8fde178fa1aa6a93b47216e5470 diff --git a/services/pubsub/package.go b/services/pubsub/package.go new file mode 100644 index 000000000..bdd8147f5 --- /dev/null +++ b/services/pubsub/package.go @@ -0,0 +1 @@ +package pubsub diff --git a/services/pubsub/v1alphaapi/api_default.go b/services/pubsub/v1alphaapi/api_default.go new file mode 100644 index 000000000..2defb75cf --- /dev/null +++ b/services/pubsub/v1alphaapi/api_default.go @@ -0,0 +1,2564 @@ +/* +[ALPHA] STACKIT PubSub API + +This API provides endpoints for managing PubSubs. + +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 { + + /* + CreateSubscription Method for CreateSubscription + + Creates a new subscription for a topic within the PubSub project. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @return ApiCreateSubscriptionRequest + */ + CreateSubscription(ctx context.Context, projectId string, regionId string, topicId string) ApiCreateSubscriptionRequest + + // CreateSubscriptionExecute executes the request + // @return SubscriptionResponse + CreateSubscriptionExecute(r ApiCreateSubscriptionRequest) (*SubscriptionResponse, error) + + /* + CreateTopic Method for CreateTopic + + Creates a new topic within the PubSub project. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @return ApiCreateTopicRequest + */ + CreateTopic(ctx context.Context, projectId string, regionId string) ApiCreateTopicRequest + + // CreateTopicExecute executes the request + // @return TopicResponse + CreateTopicExecute(r ApiCreateTopicRequest) (*TopicResponse, error) + + /* + DeleteSubscription Method for DeleteSubscription + + Deletes the given subscription. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @param subscriptionId The subscription UUID. + @return ApiDeleteSubscriptionRequest + */ + DeleteSubscription(ctx context.Context, projectId string, regionId string, topicId string, subscriptionId string) ApiDeleteSubscriptionRequest + + // DeleteSubscriptionExecute executes the request + DeleteSubscriptionExecute(r ApiDeleteSubscriptionRequest) error + + /* + DeleteTopic Method for DeleteTopic + + Deletes the given topic. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @return ApiDeleteTopicRequest + */ + DeleteTopic(ctx context.Context, projectId string, regionId string, topicId string) ApiDeleteTopicRequest + + // DeleteTopicExecute executes the request + DeleteTopicExecute(r ApiDeleteTopicRequest) error + + /* + GetSubscription Method for GetSubscription + + Returns the details for the given subscription. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @param subscriptionId The subscription UUID. + @return ApiGetSubscriptionRequest + */ + GetSubscription(ctx context.Context, projectId string, regionId string, topicId string, subscriptionId string) ApiGetSubscriptionRequest + + // GetSubscriptionExecute executes the request + // @return SubscriptionResponse + GetSubscriptionExecute(r ApiGetSubscriptionRequest) (*SubscriptionResponse, error) + + /* + GetTopic Method for GetTopic + + Returns the details for the given topic. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @return ApiGetTopicRequest + */ + GetTopic(ctx context.Context, projectId string, regionId string, topicId string) ApiGetTopicRequest + + // GetTopicExecute executes the request + // @return TopicResponse + GetTopicExecute(r ApiGetTopicRequest) (*TopicResponse, error) + + /* + GrantSubscriptionSubscriberAccess Method for GrantSubscriptionSubscriberAccess + + Grants an emailAddress access to pull from the given subscription. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @param subscriptionId The subscription UUID. + @param emailAddress Unique identifier of a user or service account. + @return ApiGrantSubscriptionSubscriberAccessRequest + */ + GrantSubscriptionSubscriberAccess(ctx context.Context, projectId string, regionId string, topicId string, subscriptionId string, emailAddress string) ApiGrantSubscriptionSubscriberAccessRequest + + // GrantSubscriptionSubscriberAccessExecute executes the request + GrantSubscriptionSubscriberAccessExecute(r ApiGrantSubscriptionSubscriberAccessRequest) error + + /* + GrantTopicPublisherAccess Method for GrantTopicPublisherAccess + + Grants an emailAddress access to publish to the given topic. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @param emailAddress Unique identifier of a user or service account. + @return ApiGrantTopicPublisherAccessRequest + */ + GrantTopicPublisherAccess(ctx context.Context, projectId string, regionId string, topicId string, emailAddress string) ApiGrantTopicPublisherAccessRequest + + // GrantTopicPublisherAccessExecute executes the request + GrantTopicPublisherAccessExecute(r ApiGrantTopicPublisherAccessRequest) error + + /* + ListSubscriptionSubscribers Method for ListSubscriptionSubscribers + + Returns a list of emailAddresses that are allowed to pull from the given subscription. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @param subscriptionId The subscription UUID. + @return ApiListSubscriptionSubscribersRequest + */ + ListSubscriptionSubscribers(ctx context.Context, projectId string, regionId string, topicId string, subscriptionId string) ApiListSubscriptionSubscribersRequest + + // ListSubscriptionSubscribersExecute executes the request + // @return ListEmailAdressesResponse + ListSubscriptionSubscribersExecute(r ApiListSubscriptionSubscribersRequest) (*ListEmailAdressesResponse, error) + + /* + ListSubscriptions Method for ListSubscriptions + + Returns a list of all topic subscriptions. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @return ApiListSubscriptionsRequest + */ + ListSubscriptions(ctx context.Context, projectId string, regionId string, topicId string) ApiListSubscriptionsRequest + + // ListSubscriptionsExecute executes the request + // @return ListSubscriptionsResponse + ListSubscriptionsExecute(r ApiListSubscriptionsRequest) (*ListSubscriptionsResponse, error) + + /* + ListTopicPublishers Method for ListTopicPublishers + + Returns a list of emailAddresses that are allowed to publish to the given topic. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @return ApiListTopicPublishersRequest + */ + ListTopicPublishers(ctx context.Context, projectId string, regionId string, topicId string) ApiListTopicPublishersRequest + + // ListTopicPublishersExecute executes the request + // @return ListEmailAdressesResponse + ListTopicPublishersExecute(r ApiListTopicPublishersRequest) (*ListEmailAdressesResponse, error) + + /* + ListTopics Method for ListTopics + + Returns a list of all topics within the PubSub project. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @return ApiListTopicsRequest + */ + ListTopics(ctx context.Context, projectId string, regionId string) ApiListTopicsRequest + + // ListTopicsExecute executes the request + // @return ListTopicsResponse + ListTopicsExecute(r ApiListTopicsRequest) (*ListTopicsResponse, error) + + /* + RevokeSubscriptionSubscriberAccess Method for RevokeSubscriptionSubscriberAccess + + Revokes an emailAddress access to pull from the given subscription. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @param subscriptionId The subscription UUID. + @param emailAddress Unique identifier of a user or service account. + @return ApiRevokeSubscriptionSubscriberAccessRequest + */ + RevokeSubscriptionSubscriberAccess(ctx context.Context, projectId string, regionId string, topicId string, subscriptionId string, emailAddress string) ApiRevokeSubscriptionSubscriberAccessRequest + + // RevokeSubscriptionSubscriberAccessExecute executes the request + RevokeSubscriptionSubscriberAccessExecute(r ApiRevokeSubscriptionSubscriberAccessRequest) error + + /* + RevokeTopicPublisherAccess Method for RevokeTopicPublisherAccess + + Revokes an emailAddress access to publish to the given topic. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @param emailAddress Unique identifier of a user or service account. + @return ApiRevokeTopicPublisherAccessRequest + */ + RevokeTopicPublisherAccess(ctx context.Context, projectId string, regionId string, topicId string, emailAddress string) ApiRevokeTopicPublisherAccessRequest + + // RevokeTopicPublisherAccessExecute executes the request + RevokeTopicPublisherAccessExecute(r ApiRevokeTopicPublisherAccessRequest) error + + /* + UpdateSubscription Method for UpdateSubscription + + Will update the given subscription. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @param subscriptionId The subscription UUID. + @return ApiUpdateSubscriptionRequest + */ + UpdateSubscription(ctx context.Context, projectId string, regionId string, topicId string, subscriptionId string) ApiUpdateSubscriptionRequest + + // UpdateSubscriptionExecute executes the request + UpdateSubscriptionExecute(r ApiUpdateSubscriptionRequest) error + + /* + UpdateTopic Method for UpdateTopic + + Will update the given topic. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @return ApiUpdateTopicRequest + */ + UpdateTopic(ctx context.Context, projectId string, regionId string, topicId string) ApiUpdateTopicRequest + + // UpdateTopicExecute executes the request + UpdateTopicExecute(r ApiUpdateTopicRequest) error +} + +// DefaultAPIService DefaultAPI service +type DefaultAPIService service + +type ApiCreateSubscriptionRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + regionId string + topicId string + createSubscriptionPayload *CreateSubscriptionPayload +} + +func (r ApiCreateSubscriptionRequest) CreateSubscriptionPayload(createSubscriptionPayload CreateSubscriptionPayload) ApiCreateSubscriptionRequest { + r.createSubscriptionPayload = &createSubscriptionPayload + return r +} + +func (r ApiCreateSubscriptionRequest) Execute() (*SubscriptionResponse, error) { + return r.ApiService.CreateSubscriptionExecute(r) +} + +/* +CreateSubscription Method for CreateSubscription + +Creates a new subscription for a topic within the PubSub project. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @return ApiCreateSubscriptionRequest +*/ +func (a *DefaultAPIService) CreateSubscription(ctx context.Context, projectId string, regionId string, topicId string) ApiCreateSubscriptionRequest { + return ApiCreateSubscriptionRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + } +} + +// Execute executes the request +// +// @return SubscriptionResponse +func (a *DefaultAPIService) CreateSubscriptionExecute(r ApiCreateSubscriptionRequest) (*SubscriptionResponse, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *SubscriptionResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.CreateSubscription") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{regionId}/topics/{topicId}/subscriptions" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(parameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"topicId"+"}", url.PathEscape(parameterValueToString(r.topicId, "topicId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.projectId) < 36 { + return localVarReturnValue, reportError("projectId must have at least 36 elements") + } + if strlen(r.projectId) > 36 { + return localVarReturnValue, reportError("projectId must have less than 36 elements") + } + if strlen(r.topicId) < 36 { + return localVarReturnValue, reportError("topicId must have at least 36 elements") + } + if strlen(r.topicId) > 36 { + return localVarReturnValue, reportError("topicId must have less than 36 elements") + } + if r.createSubscriptionPayload == nil { + return localVarReturnValue, reportError("createSubscriptionPayload 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.createSubscriptionPayload + 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, + } + 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 ApiCreateTopicRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + regionId string + createTopicPayload *CreateTopicPayload +} + +func (r ApiCreateTopicRequest) CreateTopicPayload(createTopicPayload CreateTopicPayload) ApiCreateTopicRequest { + r.createTopicPayload = &createTopicPayload + return r +} + +func (r ApiCreateTopicRequest) Execute() (*TopicResponse, error) { + return r.ApiService.CreateTopicExecute(r) +} + +/* +CreateTopic Method for CreateTopic + +Creates a new topic within the PubSub project. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @return ApiCreateTopicRequest +*/ +func (a *DefaultAPIService) CreateTopic(ctx context.Context, projectId string, regionId string) ApiCreateTopicRequest { + return ApiCreateTopicRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + } +} + +// Execute executes the request +// +// @return TopicResponse +func (a *DefaultAPIService) CreateTopicExecute(r ApiCreateTopicRequest) (*TopicResponse, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *TopicResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.CreateTopic") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{regionId}/topics" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(parameterValueToString(r.regionId, "regionId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.projectId) < 36 { + return localVarReturnValue, reportError("projectId must have at least 36 elements") + } + if strlen(r.projectId) > 36 { + return localVarReturnValue, reportError("projectId must have less than 36 elements") + } + if r.createTopicPayload == nil { + return localVarReturnValue, reportError("createTopicPayload 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.createTopicPayload + 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, + } + 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 ApiDeleteSubscriptionRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + regionId string + topicId string + subscriptionId string + force *bool +} + +// If true, deletes the topic and all its active subscriptions (cascading delete). If false (default), the operation returns a 409 conflict if active subscriptions exist. +func (r ApiDeleteSubscriptionRequest) Force(force bool) ApiDeleteSubscriptionRequest { + r.force = &force + return r +} + +func (r ApiDeleteSubscriptionRequest) Execute() error { + return r.ApiService.DeleteSubscriptionExecute(r) +} + +/* +DeleteSubscription Method for DeleteSubscription + +Deletes the given subscription. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @param subscriptionId The subscription UUID. + @return ApiDeleteSubscriptionRequest +*/ +func (a *DefaultAPIService) DeleteSubscription(ctx context.Context, projectId string, regionId string, topicId string, subscriptionId string) ApiDeleteSubscriptionRequest { + return ApiDeleteSubscriptionRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + subscriptionId: subscriptionId, + } +} + +// Execute executes the request +func (a *DefaultAPIService) DeleteSubscriptionExecute(r ApiDeleteSubscriptionRequest) error { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.DeleteSubscription") + if err != nil { + return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{regionId}/topics/{topicId}/subscriptions/{subscriptionId}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(parameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"topicId"+"}", url.PathEscape(parameterValueToString(r.topicId, "topicId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"subscriptionId"+"}", url.PathEscape(parameterValueToString(r.subscriptionId, "subscriptionId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.projectId) < 36 { + return reportError("projectId must have at least 36 elements") + } + if strlen(r.projectId) > 36 { + return reportError("projectId must have less than 36 elements") + } + if strlen(r.topicId) < 36 { + return reportError("topicId must have at least 36 elements") + } + if strlen(r.topicId) > 36 { + return reportError("topicId must have less than 36 elements") + } + if strlen(r.subscriptionId) < 36 { + return reportError("subscriptionId must have at least 36 elements") + } + if strlen(r.subscriptionId) > 36 { + return reportError("subscriptionId must have less than 36 elements") + } + + if r.force != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "force", r.force, "form", "") + } else { + var defaultValue bool = false + parameterAddToHeaderOrQuery(localVarQueryParams, "force", defaultValue, "form", "") + r.force = &defaultValue + } + // 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{} + + // 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 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 err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + return newErr + } + + return nil +} + +type ApiDeleteTopicRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + regionId string + topicId string + force *bool +} + +// If true, deletes the topic and all its active subscriptions (cascading delete). If false (default), the operation returns a 409 conflict if active subscriptions exist. +func (r ApiDeleteTopicRequest) Force(force bool) ApiDeleteTopicRequest { + r.force = &force + return r +} + +func (r ApiDeleteTopicRequest) Execute() error { + return r.ApiService.DeleteTopicExecute(r) +} + +/* +DeleteTopic Method for DeleteTopic + +Deletes the given topic. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @return ApiDeleteTopicRequest +*/ +func (a *DefaultAPIService) DeleteTopic(ctx context.Context, projectId string, regionId string, topicId string) ApiDeleteTopicRequest { + return ApiDeleteTopicRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + } +} + +// Execute executes the request +func (a *DefaultAPIService) DeleteTopicExecute(r ApiDeleteTopicRequest) error { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.DeleteTopic") + if err != nil { + return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{regionId}/topics/{topicId}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(parameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"topicId"+"}", url.PathEscape(parameterValueToString(r.topicId, "topicId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.projectId) < 36 { + return reportError("projectId must have at least 36 elements") + } + if strlen(r.projectId) > 36 { + return reportError("projectId must have less than 36 elements") + } + if strlen(r.topicId) < 36 { + return reportError("topicId must have at least 36 elements") + } + if strlen(r.topicId) > 36 { + return reportError("topicId must have less than 36 elements") + } + + if r.force != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "force", r.force, "form", "") + } else { + var defaultValue bool = false + parameterAddToHeaderOrQuery(localVarQueryParams, "force", defaultValue, "form", "") + r.force = &defaultValue + } + // 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{} + + // 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 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 err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + return newErr + } + + return nil +} + +type ApiGetSubscriptionRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + regionId string + topicId string + subscriptionId string +} + +func (r ApiGetSubscriptionRequest) Execute() (*SubscriptionResponse, error) { + return r.ApiService.GetSubscriptionExecute(r) +} + +/* +GetSubscription Method for GetSubscription + +Returns the details for the given subscription. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @param subscriptionId The subscription UUID. + @return ApiGetSubscriptionRequest +*/ +func (a *DefaultAPIService) GetSubscription(ctx context.Context, projectId string, regionId string, topicId string, subscriptionId string) ApiGetSubscriptionRequest { + return ApiGetSubscriptionRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + subscriptionId: subscriptionId, + } +} + +// Execute executes the request +// +// @return SubscriptionResponse +func (a *DefaultAPIService) GetSubscriptionExecute(r ApiGetSubscriptionRequest) (*SubscriptionResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *SubscriptionResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.GetSubscription") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{regionId}/topics/{topicId}/subscriptions/{subscriptionId}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(parameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"topicId"+"}", url.PathEscape(parameterValueToString(r.topicId, "topicId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"subscriptionId"+"}", url.PathEscape(parameterValueToString(r.subscriptionId, "subscriptionId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.projectId) < 36 { + return localVarReturnValue, reportError("projectId must have at least 36 elements") + } + if strlen(r.projectId) > 36 { + return localVarReturnValue, reportError("projectId must have less than 36 elements") + } + if strlen(r.topicId) < 36 { + return localVarReturnValue, reportError("topicId must have at least 36 elements") + } + if strlen(r.topicId) > 36 { + return localVarReturnValue, reportError("topicId must have less than 36 elements") + } + if strlen(r.subscriptionId) < 36 { + return localVarReturnValue, reportError("subscriptionId must have at least 36 elements") + } + if strlen(r.subscriptionId) > 36 { + return localVarReturnValue, reportError("subscriptionId must have less than 36 elements") + } + + // 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, + } + 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 ApiGetTopicRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + regionId string + topicId string +} + +func (r ApiGetTopicRequest) Execute() (*TopicResponse, error) { + return r.ApiService.GetTopicExecute(r) +} + +/* +GetTopic Method for GetTopic + +Returns the details for the given topic. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @return ApiGetTopicRequest +*/ +func (a *DefaultAPIService) GetTopic(ctx context.Context, projectId string, regionId string, topicId string) ApiGetTopicRequest { + return ApiGetTopicRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + } +} + +// Execute executes the request +// +// @return TopicResponse +func (a *DefaultAPIService) GetTopicExecute(r ApiGetTopicRequest) (*TopicResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *TopicResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.GetTopic") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{regionId}/topics/{topicId}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(parameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"topicId"+"}", url.PathEscape(parameterValueToString(r.topicId, "topicId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.projectId) < 36 { + return localVarReturnValue, reportError("projectId must have at least 36 elements") + } + if strlen(r.projectId) > 36 { + return localVarReturnValue, reportError("projectId must have less than 36 elements") + } + if strlen(r.topicId) < 36 { + return localVarReturnValue, reportError("topicId must have at least 36 elements") + } + if strlen(r.topicId) > 36 { + return localVarReturnValue, reportError("topicId must have less than 36 elements") + } + + // 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, + } + 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 ApiGrantSubscriptionSubscriberAccessRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + regionId string + topicId string + subscriptionId string + emailAddress string +} + +func (r ApiGrantSubscriptionSubscriberAccessRequest) Execute() error { + return r.ApiService.GrantSubscriptionSubscriberAccessExecute(r) +} + +/* +GrantSubscriptionSubscriberAccess Method for GrantSubscriptionSubscriberAccess + +Grants an emailAddress access to pull from the given subscription. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @param subscriptionId The subscription UUID. + @param emailAddress Unique identifier of a user or service account. + @return ApiGrantSubscriptionSubscriberAccessRequest +*/ +func (a *DefaultAPIService) GrantSubscriptionSubscriberAccess(ctx context.Context, projectId string, regionId string, topicId string, subscriptionId string, emailAddress string) ApiGrantSubscriptionSubscriberAccessRequest { + return ApiGrantSubscriptionSubscriberAccessRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + subscriptionId: subscriptionId, + emailAddress: emailAddress, + } +} + +// Execute executes the request +func (a *DefaultAPIService) GrantSubscriptionSubscriberAccessExecute(r ApiGrantSubscriptionSubscriberAccessRequest) error { + var ( + localVarHTTPMethod = http.MethodPut + localVarPostBody interface{} + formFiles []formFile + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.GrantSubscriptionSubscriberAccess") + if err != nil { + return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{regionId}/topics/{topicId}/subscriptions/{subscriptionId}/subscribers/{emailAddress}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(parameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"topicId"+"}", url.PathEscape(parameterValueToString(r.topicId, "topicId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"subscriptionId"+"}", url.PathEscape(parameterValueToString(r.subscriptionId, "subscriptionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"emailAddress"+"}", url.PathEscape(parameterValueToString(r.emailAddress, "emailAddress")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.projectId) < 36 { + return reportError("projectId must have at least 36 elements") + } + if strlen(r.projectId) > 36 { + return reportError("projectId must have less than 36 elements") + } + if strlen(r.topicId) < 36 { + return reportError("topicId must have at least 36 elements") + } + if strlen(r.topicId) > 36 { + return reportError("topicId must have less than 36 elements") + } + if strlen(r.subscriptionId) < 36 { + return reportError("subscriptionId must have at least 36 elements") + } + if strlen(r.subscriptionId) > 36 { + return reportError("subscriptionId must have less than 36 elements") + } + if strlen(r.emailAddress) > 254 { + return reportError("emailAddress must have less than 254 elements") + } + + // 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{} + + // 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 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 err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + return newErr + } + + return nil +} + +type ApiGrantTopicPublisherAccessRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + regionId string + topicId string + emailAddress string +} + +func (r ApiGrantTopicPublisherAccessRequest) Execute() error { + return r.ApiService.GrantTopicPublisherAccessExecute(r) +} + +/* +GrantTopicPublisherAccess Method for GrantTopicPublisherAccess + +Grants an emailAddress access to publish to the given topic. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @param emailAddress Unique identifier of a user or service account. + @return ApiGrantTopicPublisherAccessRequest +*/ +func (a *DefaultAPIService) GrantTopicPublisherAccess(ctx context.Context, projectId string, regionId string, topicId string, emailAddress string) ApiGrantTopicPublisherAccessRequest { + return ApiGrantTopicPublisherAccessRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + emailAddress: emailAddress, + } +} + +// Execute executes the request +func (a *DefaultAPIService) GrantTopicPublisherAccessExecute(r ApiGrantTopicPublisherAccessRequest) error { + var ( + localVarHTTPMethod = http.MethodPut + localVarPostBody interface{} + formFiles []formFile + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.GrantTopicPublisherAccess") + if err != nil { + return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{regionId}/topics/{topicId}/publishers/{emailAddress}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(parameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"topicId"+"}", url.PathEscape(parameterValueToString(r.topicId, "topicId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"emailAddress"+"}", url.PathEscape(parameterValueToString(r.emailAddress, "emailAddress")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.projectId) < 36 { + return reportError("projectId must have at least 36 elements") + } + if strlen(r.projectId) > 36 { + return reportError("projectId must have less than 36 elements") + } + if strlen(r.topicId) < 36 { + return reportError("topicId must have at least 36 elements") + } + if strlen(r.topicId) > 36 { + return reportError("topicId must have less than 36 elements") + } + if strlen(r.emailAddress) > 254 { + return reportError("emailAddress must have less than 254 elements") + } + + // 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{} + + // 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 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 err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + return newErr + } + + return nil +} + +type ApiListSubscriptionSubscribersRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + regionId string + topicId string + subscriptionId string +} + +func (r ApiListSubscriptionSubscribersRequest) Execute() (*ListEmailAdressesResponse, error) { + return r.ApiService.ListSubscriptionSubscribersExecute(r) +} + +/* +ListSubscriptionSubscribers Method for ListSubscriptionSubscribers + +Returns a list of emailAddresses that are allowed to pull from the given subscription. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @param subscriptionId The subscription UUID. + @return ApiListSubscriptionSubscribersRequest +*/ +func (a *DefaultAPIService) ListSubscriptionSubscribers(ctx context.Context, projectId string, regionId string, topicId string, subscriptionId string) ApiListSubscriptionSubscribersRequest { + return ApiListSubscriptionSubscribersRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + subscriptionId: subscriptionId, + } +} + +// Execute executes the request +// +// @return ListEmailAdressesResponse +func (a *DefaultAPIService) ListSubscriptionSubscribersExecute(r ApiListSubscriptionSubscribersRequest) (*ListEmailAdressesResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ListEmailAdressesResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ListSubscriptionSubscribers") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{regionId}/topics/{topicId}/subscriptions/{subscriptionId}/subscribers" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(parameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"topicId"+"}", url.PathEscape(parameterValueToString(r.topicId, "topicId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"subscriptionId"+"}", url.PathEscape(parameterValueToString(r.subscriptionId, "subscriptionId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.projectId) < 36 { + return localVarReturnValue, reportError("projectId must have at least 36 elements") + } + if strlen(r.projectId) > 36 { + return localVarReturnValue, reportError("projectId must have less than 36 elements") + } + if strlen(r.topicId) < 36 { + return localVarReturnValue, reportError("topicId must have at least 36 elements") + } + if strlen(r.topicId) > 36 { + return localVarReturnValue, reportError("topicId must have less than 36 elements") + } + if strlen(r.subscriptionId) < 36 { + return localVarReturnValue, reportError("subscriptionId must have at least 36 elements") + } + if strlen(r.subscriptionId) > 36 { + return localVarReturnValue, reportError("subscriptionId must have less than 36 elements") + } + + // 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, + } + 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 ApiListSubscriptionsRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + regionId string + topicId string + pageToken *string + pageSize *int32 + query *string +} + +// A token to retrieve the next page of results. +func (r ApiListSubscriptionsRequest) PageToken(pageToken string) ApiListSubscriptionsRequest { + r.pageToken = &pageToken + return r +} + +// Maximum number of items to return +func (r ApiListSubscriptionsRequest) PageSize(pageSize int32) ApiListSubscriptionsRequest { + r.pageSize = &pageSize + return r +} + +// Supply a query string to filter the results. +func (r ApiListSubscriptionsRequest) Query(query string) ApiListSubscriptionsRequest { + r.query = &query + return r +} + +func (r ApiListSubscriptionsRequest) Execute() (*ListSubscriptionsResponse, error) { + return r.ApiService.ListSubscriptionsExecute(r) +} + +/* +ListSubscriptions Method for ListSubscriptions + +Returns a list of all topic subscriptions. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @return ApiListSubscriptionsRequest +*/ +func (a *DefaultAPIService) ListSubscriptions(ctx context.Context, projectId string, regionId string, topicId string) ApiListSubscriptionsRequest { + return ApiListSubscriptionsRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + } +} + +// Execute executes the request +// +// @return ListSubscriptionsResponse +func (a *DefaultAPIService) ListSubscriptionsExecute(r ApiListSubscriptionsRequest) (*ListSubscriptionsResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ListSubscriptionsResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ListSubscriptions") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{regionId}/topics/{topicId}/subscriptions" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(parameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"topicId"+"}", url.PathEscape(parameterValueToString(r.topicId, "topicId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.projectId) < 36 { + return localVarReturnValue, reportError("projectId must have at least 36 elements") + } + if strlen(r.projectId) > 36 { + return localVarReturnValue, reportError("projectId must have less than 36 elements") + } + if strlen(r.topicId) < 36 { + return localVarReturnValue, reportError("topicId must have at least 36 elements") + } + if strlen(r.topicId) > 36 { + return localVarReturnValue, reportError("topicId must have less than 36 elements") + } + + if r.pageToken != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "pageToken", r.pageToken, "form", "") + } + if r.pageSize != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "pageSize", r.pageSize, "form", "") + } else { + var defaultValue int32 = 10 + parameterAddToHeaderOrQuery(localVarQueryParams, "pageSize", defaultValue, "form", "") + r.pageSize = &defaultValue + } + if r.query != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "query", r.query, "form", "") + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + 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 ApiListTopicPublishersRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + regionId string + topicId string +} + +func (r ApiListTopicPublishersRequest) Execute() (*ListEmailAdressesResponse, error) { + return r.ApiService.ListTopicPublishersExecute(r) +} + +/* +ListTopicPublishers Method for ListTopicPublishers + +Returns a list of emailAddresses that are allowed to publish to the given topic. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @return ApiListTopicPublishersRequest +*/ +func (a *DefaultAPIService) ListTopicPublishers(ctx context.Context, projectId string, regionId string, topicId string) ApiListTopicPublishersRequest { + return ApiListTopicPublishersRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + } +} + +// Execute executes the request +// +// @return ListEmailAdressesResponse +func (a *DefaultAPIService) ListTopicPublishersExecute(r ApiListTopicPublishersRequest) (*ListEmailAdressesResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ListEmailAdressesResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ListTopicPublishers") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{regionId}/topics/{topicId}/publishers" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(parameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"topicId"+"}", url.PathEscape(parameterValueToString(r.topicId, "topicId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.projectId) < 36 { + return localVarReturnValue, reportError("projectId must have at least 36 elements") + } + if strlen(r.projectId) > 36 { + return localVarReturnValue, reportError("projectId must have less than 36 elements") + } + if strlen(r.topicId) < 36 { + return localVarReturnValue, reportError("topicId must have at least 36 elements") + } + if strlen(r.topicId) > 36 { + return localVarReturnValue, reportError("topicId must have less than 36 elements") + } + + // 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, + } + 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 ApiListTopicsRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + regionId string + pageToken *string + pageSize *int32 + query *string +} + +// A token to retrieve the next page of results. +func (r ApiListTopicsRequest) PageToken(pageToken string) ApiListTopicsRequest { + r.pageToken = &pageToken + return r +} + +// Maximum number of items to return +func (r ApiListTopicsRequest) PageSize(pageSize int32) ApiListTopicsRequest { + r.pageSize = &pageSize + return r +} + +// Supply a query string to filter the results. +func (r ApiListTopicsRequest) Query(query string) ApiListTopicsRequest { + r.query = &query + return r +} + +func (r ApiListTopicsRequest) Execute() (*ListTopicsResponse, error) { + return r.ApiService.ListTopicsExecute(r) +} + +/* +ListTopics Method for ListTopics + +Returns a list of all topics within the PubSub project. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @return ApiListTopicsRequest +*/ +func (a *DefaultAPIService) ListTopics(ctx context.Context, projectId string, regionId string) ApiListTopicsRequest { + return ApiListTopicsRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + } +} + +// Execute executes the request +// +// @return ListTopicsResponse +func (a *DefaultAPIService) ListTopicsExecute(r ApiListTopicsRequest) (*ListTopicsResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ListTopicsResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ListTopics") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{regionId}/topics" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(parameterValueToString(r.regionId, "regionId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.projectId) < 36 { + return localVarReturnValue, reportError("projectId must have at least 36 elements") + } + if strlen(r.projectId) > 36 { + return localVarReturnValue, reportError("projectId must have less than 36 elements") + } + + if r.pageToken != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "pageToken", r.pageToken, "form", "") + } + if r.pageSize != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "pageSize", r.pageSize, "form", "") + } else { + var defaultValue int32 = 10 + parameterAddToHeaderOrQuery(localVarQueryParams, "pageSize", defaultValue, "form", "") + r.pageSize = &defaultValue + } + if r.query != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "query", r.query, "form", "") + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + 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 ApiRevokeSubscriptionSubscriberAccessRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + regionId string + topicId string + subscriptionId string + emailAddress string +} + +func (r ApiRevokeSubscriptionSubscriberAccessRequest) Execute() error { + return r.ApiService.RevokeSubscriptionSubscriberAccessExecute(r) +} + +/* +RevokeSubscriptionSubscriberAccess Method for RevokeSubscriptionSubscriberAccess + +Revokes an emailAddress access to pull from the given subscription. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @param subscriptionId The subscription UUID. + @param emailAddress Unique identifier of a user or service account. + @return ApiRevokeSubscriptionSubscriberAccessRequest +*/ +func (a *DefaultAPIService) RevokeSubscriptionSubscriberAccess(ctx context.Context, projectId string, regionId string, topicId string, subscriptionId string, emailAddress string) ApiRevokeSubscriptionSubscriberAccessRequest { + return ApiRevokeSubscriptionSubscriberAccessRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + subscriptionId: subscriptionId, + emailAddress: emailAddress, + } +} + +// Execute executes the request +func (a *DefaultAPIService) RevokeSubscriptionSubscriberAccessExecute(r ApiRevokeSubscriptionSubscriberAccessRequest) error { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.RevokeSubscriptionSubscriberAccess") + if err != nil { + return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{regionId}/topics/{topicId}/subscriptions/{subscriptionId}/subscribers/{emailAddress}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(parameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"topicId"+"}", url.PathEscape(parameterValueToString(r.topicId, "topicId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"subscriptionId"+"}", url.PathEscape(parameterValueToString(r.subscriptionId, "subscriptionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"emailAddress"+"}", url.PathEscape(parameterValueToString(r.emailAddress, "emailAddress")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.projectId) < 36 { + return reportError("projectId must have at least 36 elements") + } + if strlen(r.projectId) > 36 { + return reportError("projectId must have less than 36 elements") + } + if strlen(r.topicId) < 36 { + return reportError("topicId must have at least 36 elements") + } + if strlen(r.topicId) > 36 { + return reportError("topicId must have less than 36 elements") + } + if strlen(r.subscriptionId) < 36 { + return reportError("subscriptionId must have at least 36 elements") + } + if strlen(r.subscriptionId) > 36 { + return reportError("subscriptionId must have less than 36 elements") + } + if strlen(r.emailAddress) > 254 { + return reportError("emailAddress must have less than 254 elements") + } + + // 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{} + + // 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 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 err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + return newErr + } + + return nil +} + +type ApiRevokeTopicPublisherAccessRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + regionId string + topicId string + emailAddress string +} + +func (r ApiRevokeTopicPublisherAccessRequest) Execute() error { + return r.ApiService.RevokeTopicPublisherAccessExecute(r) +} + +/* +RevokeTopicPublisherAccess Method for RevokeTopicPublisherAccess + +Revokes an emailAddress access to publish to the given topic. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @param emailAddress Unique identifier of a user or service account. + @return ApiRevokeTopicPublisherAccessRequest +*/ +func (a *DefaultAPIService) RevokeTopicPublisherAccess(ctx context.Context, projectId string, regionId string, topicId string, emailAddress string) ApiRevokeTopicPublisherAccessRequest { + return ApiRevokeTopicPublisherAccessRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + emailAddress: emailAddress, + } +} + +// Execute executes the request +func (a *DefaultAPIService) RevokeTopicPublisherAccessExecute(r ApiRevokeTopicPublisherAccessRequest) error { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.RevokeTopicPublisherAccess") + if err != nil { + return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{regionId}/topics/{topicId}/publishers/{emailAddress}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(parameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"topicId"+"}", url.PathEscape(parameterValueToString(r.topicId, "topicId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"emailAddress"+"}", url.PathEscape(parameterValueToString(r.emailAddress, "emailAddress")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.projectId) < 36 { + return reportError("projectId must have at least 36 elements") + } + if strlen(r.projectId) > 36 { + return reportError("projectId must have less than 36 elements") + } + if strlen(r.topicId) < 36 { + return reportError("topicId must have at least 36 elements") + } + if strlen(r.topicId) > 36 { + return reportError("topicId must have less than 36 elements") + } + if strlen(r.emailAddress) > 254 { + return reportError("emailAddress must have less than 254 elements") + } + + // 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{} + + // 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 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 err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + return newErr + } + + return nil +} + +type ApiUpdateSubscriptionRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + regionId string + topicId string + subscriptionId string + updateSubscriptionPayload *UpdateSubscriptionPayload +} + +func (r ApiUpdateSubscriptionRequest) UpdateSubscriptionPayload(updateSubscriptionPayload UpdateSubscriptionPayload) ApiUpdateSubscriptionRequest { + r.updateSubscriptionPayload = &updateSubscriptionPayload + return r +} + +func (r ApiUpdateSubscriptionRequest) Execute() error { + return r.ApiService.UpdateSubscriptionExecute(r) +} + +/* +UpdateSubscription Method for UpdateSubscription + +Will update the given subscription. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @param subscriptionId The subscription UUID. + @return ApiUpdateSubscriptionRequest +*/ +func (a *DefaultAPIService) UpdateSubscription(ctx context.Context, projectId string, regionId string, topicId string, subscriptionId string) ApiUpdateSubscriptionRequest { + return ApiUpdateSubscriptionRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + subscriptionId: subscriptionId, + } +} + +// Execute executes the request +func (a *DefaultAPIService) UpdateSubscriptionExecute(r ApiUpdateSubscriptionRequest) error { + var ( + localVarHTTPMethod = http.MethodPatch + localVarPostBody interface{} + formFiles []formFile + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.UpdateSubscription") + if err != nil { + return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{regionId}/topics/{topicId}/subscriptions/{subscriptionId}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(parameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"topicId"+"}", url.PathEscape(parameterValueToString(r.topicId, "topicId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"subscriptionId"+"}", url.PathEscape(parameterValueToString(r.subscriptionId, "subscriptionId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.projectId) < 36 { + return reportError("projectId must have at least 36 elements") + } + if strlen(r.projectId) > 36 { + return reportError("projectId must have less than 36 elements") + } + if strlen(r.topicId) < 36 { + return reportError("topicId must have at least 36 elements") + } + if strlen(r.topicId) > 36 { + return reportError("topicId must have less than 36 elements") + } + if strlen(r.subscriptionId) < 36 { + return reportError("subscriptionId must have at least 36 elements") + } + if strlen(r.subscriptionId) > 36 { + return reportError("subscriptionId must have less than 36 elements") + } + if r.updateSubscriptionPayload == nil { + return reportError("updateSubscriptionPayload 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{} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.updateSubscriptionPayload + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return 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 err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + return newErr + } + + return nil +} + +type ApiUpdateTopicRequest struct { + ctx context.Context + ApiService DefaultAPI + projectId string + regionId string + topicId string + updateTopicPayload *UpdateTopicPayload +} + +func (r ApiUpdateTopicRequest) UpdateTopicPayload(updateTopicPayload UpdateTopicPayload) ApiUpdateTopicRequest { + r.updateTopicPayload = &updateTopicPayload + return r +} + +func (r ApiUpdateTopicRequest) Execute() error { + return r.ApiService.UpdateTopicExecute(r) +} + +/* +UpdateTopic Method for UpdateTopic + +Will update the given topic. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The STACKIT portal project UUID the resource is located in. + @param regionId The STACKIT region name the resource is located in. + @param topicId The topic UUID. + @return ApiUpdateTopicRequest +*/ +func (a *DefaultAPIService) UpdateTopic(ctx context.Context, projectId string, regionId string, topicId string) ApiUpdateTopicRequest { + return ApiUpdateTopicRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + } +} + +// Execute executes the request +func (a *DefaultAPIService) UpdateTopicExecute(r ApiUpdateTopicRequest) error { + var ( + localVarHTTPMethod = http.MethodPatch + localVarPostBody interface{} + formFiles []formFile + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.UpdateTopic") + if err != nil { + return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1alpha/projects/{projectId}/regions/{regionId}/topics/{topicId}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"regionId"+"}", url.PathEscape(parameterValueToString(r.regionId, "regionId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"topicId"+"}", url.PathEscape(parameterValueToString(r.topicId, "topicId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.projectId) < 36 { + return reportError("projectId must have at least 36 elements") + } + if strlen(r.projectId) > 36 { + return reportError("projectId must have less than 36 elements") + } + if strlen(r.topicId) < 36 { + return reportError("topicId must have at least 36 elements") + } + if strlen(r.topicId) > 36 { + return reportError("topicId must have less than 36 elements") + } + if r.updateTopicPayload == nil { + return reportError("updateTopicPayload 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{} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.updateTopicPayload + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return 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 err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + StatusCode: localVarHTTPResponse.StatusCode, + } + return newErr + } + + return nil +} diff --git a/services/pubsub/v1alphaapi/api_default_mock.go b/services/pubsub/v1alphaapi/api_default_mock.go new file mode 100644 index 000000000..52ec047b8 --- /dev/null +++ b/services/pubsub/v1alphaapi/api_default_mock.go @@ -0,0 +1,375 @@ +/* +[ALPHA] STACKIT PubSub API + +This API provides endpoints for managing PubSubs. + +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 { + // CreateSubscriptionExecuteMock can be populated to implement the behavior of the CreateSubscriptionExecute function of this mock + CreateSubscriptionExecuteMock *func(r ApiCreateSubscriptionRequest) (*SubscriptionResponse, error) + // CreateTopicExecuteMock can be populated to implement the behavior of the CreateTopicExecute function of this mock + CreateTopicExecuteMock *func(r ApiCreateTopicRequest) (*TopicResponse, error) + // DeleteSubscriptionExecuteMock can be populated to implement the behavior of the DeleteSubscriptionExecute function of this mock + DeleteSubscriptionExecuteMock *func(r ApiDeleteSubscriptionRequest) error + // DeleteTopicExecuteMock can be populated to implement the behavior of the DeleteTopicExecute function of this mock + DeleteTopicExecuteMock *func(r ApiDeleteTopicRequest) error + // GetSubscriptionExecuteMock can be populated to implement the behavior of the GetSubscriptionExecute function of this mock + GetSubscriptionExecuteMock *func(r ApiGetSubscriptionRequest) (*SubscriptionResponse, error) + // GetTopicExecuteMock can be populated to implement the behavior of the GetTopicExecute function of this mock + GetTopicExecuteMock *func(r ApiGetTopicRequest) (*TopicResponse, error) + // GrantSubscriptionSubscriberAccessExecuteMock can be populated to implement the behavior of the GrantSubscriptionSubscriberAccessExecute function of this mock + GrantSubscriptionSubscriberAccessExecuteMock *func(r ApiGrantSubscriptionSubscriberAccessRequest) error + // GrantTopicPublisherAccessExecuteMock can be populated to implement the behavior of the GrantTopicPublisherAccessExecute function of this mock + GrantTopicPublisherAccessExecuteMock *func(r ApiGrantTopicPublisherAccessRequest) error + // ListSubscriptionSubscribersExecuteMock can be populated to implement the behavior of the ListSubscriptionSubscribersExecute function of this mock + ListSubscriptionSubscribersExecuteMock *func(r ApiListSubscriptionSubscribersRequest) (*ListEmailAdressesResponse, error) + // ListSubscriptionsExecuteMock can be populated to implement the behavior of the ListSubscriptionsExecute function of this mock + ListSubscriptionsExecuteMock *func(r ApiListSubscriptionsRequest) (*ListSubscriptionsResponse, error) + // ListTopicPublishersExecuteMock can be populated to implement the behavior of the ListTopicPublishersExecute function of this mock + ListTopicPublishersExecuteMock *func(r ApiListTopicPublishersRequest) (*ListEmailAdressesResponse, error) + // ListTopicsExecuteMock can be populated to implement the behavior of the ListTopicsExecute function of this mock + ListTopicsExecuteMock *func(r ApiListTopicsRequest) (*ListTopicsResponse, error) + // RevokeSubscriptionSubscriberAccessExecuteMock can be populated to implement the behavior of the RevokeSubscriptionSubscriberAccessExecute function of this mock + RevokeSubscriptionSubscriberAccessExecuteMock *func(r ApiRevokeSubscriptionSubscriberAccessRequest) error + // RevokeTopicPublisherAccessExecuteMock can be populated to implement the behavior of the RevokeTopicPublisherAccessExecute function of this mock + RevokeTopicPublisherAccessExecuteMock *func(r ApiRevokeTopicPublisherAccessRequest) error + // UpdateSubscriptionExecuteMock can be populated to implement the behavior of the UpdateSubscriptionExecute function of this mock + UpdateSubscriptionExecuteMock *func(r ApiUpdateSubscriptionRequest) error + // UpdateTopicExecuteMock can be populated to implement the behavior of the UpdateTopicExecute function of this mock + UpdateTopicExecuteMock *func(r ApiUpdateTopicRequest) error +} + +func (a DefaultAPIServiceMock) CreateSubscription(ctx context.Context, projectId string, regionId string, topicId string) ApiCreateSubscriptionRequest { + return ApiCreateSubscriptionRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + } +} + +// CreateSubscriptionExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the CreateSubscriptionExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) CreateSubscriptionExecute(r ApiCreateSubscriptionRequest) (*SubscriptionResponse, error) { + if a.CreateSubscriptionExecuteMock == nil { + var localVarReturnValue *SubscriptionResponse + return localVarReturnValue, nil + } + + return (*a.CreateSubscriptionExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) CreateTopic(ctx context.Context, projectId string, regionId string) ApiCreateTopicRequest { + return ApiCreateTopicRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + } +} + +// CreateTopicExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the CreateTopicExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) CreateTopicExecute(r ApiCreateTopicRequest) (*TopicResponse, error) { + if a.CreateTopicExecuteMock == nil { + var localVarReturnValue *TopicResponse + return localVarReturnValue, nil + } + + return (*a.CreateTopicExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) DeleteSubscription(ctx context.Context, projectId string, regionId string, topicId string, subscriptionId string) ApiDeleteSubscriptionRequest { + return ApiDeleteSubscriptionRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + subscriptionId: subscriptionId, + } +} + +// DeleteSubscriptionExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the DeleteSubscriptionExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) DeleteSubscriptionExecute(r ApiDeleteSubscriptionRequest) error { + if a.DeleteSubscriptionExecuteMock == nil { + return nil + } + + return (*a.DeleteSubscriptionExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) DeleteTopic(ctx context.Context, projectId string, regionId string, topicId string) ApiDeleteTopicRequest { + return ApiDeleteTopicRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + } +} + +// DeleteTopicExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the DeleteTopicExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) DeleteTopicExecute(r ApiDeleteTopicRequest) error { + if a.DeleteTopicExecuteMock == nil { + return nil + } + + return (*a.DeleteTopicExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) GetSubscription(ctx context.Context, projectId string, regionId string, topicId string, subscriptionId string) ApiGetSubscriptionRequest { + return ApiGetSubscriptionRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + subscriptionId: subscriptionId, + } +} + +// GetSubscriptionExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the GetSubscriptionExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) GetSubscriptionExecute(r ApiGetSubscriptionRequest) (*SubscriptionResponse, error) { + if a.GetSubscriptionExecuteMock == nil { + var localVarReturnValue *SubscriptionResponse + return localVarReturnValue, nil + } + + return (*a.GetSubscriptionExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) GetTopic(ctx context.Context, projectId string, regionId string, topicId string) ApiGetTopicRequest { + return ApiGetTopicRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + } +} + +// GetTopicExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the GetTopicExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) GetTopicExecute(r ApiGetTopicRequest) (*TopicResponse, error) { + if a.GetTopicExecuteMock == nil { + var localVarReturnValue *TopicResponse + return localVarReturnValue, nil + } + + return (*a.GetTopicExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) GrantSubscriptionSubscriberAccess(ctx context.Context, projectId string, regionId string, topicId string, subscriptionId string, emailAddress string) ApiGrantSubscriptionSubscriberAccessRequest { + return ApiGrantSubscriptionSubscriberAccessRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + subscriptionId: subscriptionId, + emailAddress: emailAddress, + } +} + +// GrantSubscriptionSubscriberAccessExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the GrantSubscriptionSubscriberAccessExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) GrantSubscriptionSubscriberAccessExecute(r ApiGrantSubscriptionSubscriberAccessRequest) error { + if a.GrantSubscriptionSubscriberAccessExecuteMock == nil { + return nil + } + + return (*a.GrantSubscriptionSubscriberAccessExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) GrantTopicPublisherAccess(ctx context.Context, projectId string, regionId string, topicId string, emailAddress string) ApiGrantTopicPublisherAccessRequest { + return ApiGrantTopicPublisherAccessRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + emailAddress: emailAddress, + } +} + +// GrantTopicPublisherAccessExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the GrantTopicPublisherAccessExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) GrantTopicPublisherAccessExecute(r ApiGrantTopicPublisherAccessRequest) error { + if a.GrantTopicPublisherAccessExecuteMock == nil { + return nil + } + + return (*a.GrantTopicPublisherAccessExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) ListSubscriptionSubscribers(ctx context.Context, projectId string, regionId string, topicId string, subscriptionId string) ApiListSubscriptionSubscribersRequest { + return ApiListSubscriptionSubscribersRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + subscriptionId: subscriptionId, + } +} + +// ListSubscriptionSubscribersExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the ListSubscriptionSubscribersExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) ListSubscriptionSubscribersExecute(r ApiListSubscriptionSubscribersRequest) (*ListEmailAdressesResponse, error) { + if a.ListSubscriptionSubscribersExecuteMock == nil { + var localVarReturnValue *ListEmailAdressesResponse + return localVarReturnValue, nil + } + + return (*a.ListSubscriptionSubscribersExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) ListSubscriptions(ctx context.Context, projectId string, regionId string, topicId string) ApiListSubscriptionsRequest { + return ApiListSubscriptionsRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + } +} + +// ListSubscriptionsExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the ListSubscriptionsExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) ListSubscriptionsExecute(r ApiListSubscriptionsRequest) (*ListSubscriptionsResponse, error) { + if a.ListSubscriptionsExecuteMock == nil { + var localVarReturnValue *ListSubscriptionsResponse + return localVarReturnValue, nil + } + + return (*a.ListSubscriptionsExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) ListTopicPublishers(ctx context.Context, projectId string, regionId string, topicId string) ApiListTopicPublishersRequest { + return ApiListTopicPublishersRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + } +} + +// ListTopicPublishersExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the ListTopicPublishersExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) ListTopicPublishersExecute(r ApiListTopicPublishersRequest) (*ListEmailAdressesResponse, error) { + if a.ListTopicPublishersExecuteMock == nil { + var localVarReturnValue *ListEmailAdressesResponse + return localVarReturnValue, nil + } + + return (*a.ListTopicPublishersExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) ListTopics(ctx context.Context, projectId string, regionId string) ApiListTopicsRequest { + return ApiListTopicsRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + } +} + +// ListTopicsExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the ListTopicsExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) ListTopicsExecute(r ApiListTopicsRequest) (*ListTopicsResponse, error) { + if a.ListTopicsExecuteMock == nil { + var localVarReturnValue *ListTopicsResponse + return localVarReturnValue, nil + } + + return (*a.ListTopicsExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) RevokeSubscriptionSubscriberAccess(ctx context.Context, projectId string, regionId string, topicId string, subscriptionId string, emailAddress string) ApiRevokeSubscriptionSubscriberAccessRequest { + return ApiRevokeSubscriptionSubscriberAccessRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + subscriptionId: subscriptionId, + emailAddress: emailAddress, + } +} + +// RevokeSubscriptionSubscriberAccessExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the RevokeSubscriptionSubscriberAccessExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) RevokeSubscriptionSubscriberAccessExecute(r ApiRevokeSubscriptionSubscriberAccessRequest) error { + if a.RevokeSubscriptionSubscriberAccessExecuteMock == nil { + return nil + } + + return (*a.RevokeSubscriptionSubscriberAccessExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) RevokeTopicPublisherAccess(ctx context.Context, projectId string, regionId string, topicId string, emailAddress string) ApiRevokeTopicPublisherAccessRequest { + return ApiRevokeTopicPublisherAccessRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + emailAddress: emailAddress, + } +} + +// RevokeTopicPublisherAccessExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the RevokeTopicPublisherAccessExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) RevokeTopicPublisherAccessExecute(r ApiRevokeTopicPublisherAccessRequest) error { + if a.RevokeTopicPublisherAccessExecuteMock == nil { + return nil + } + + return (*a.RevokeTopicPublisherAccessExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) UpdateSubscription(ctx context.Context, projectId string, regionId string, topicId string, subscriptionId string) ApiUpdateSubscriptionRequest { + return ApiUpdateSubscriptionRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + subscriptionId: subscriptionId, + } +} + +// UpdateSubscriptionExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the UpdateSubscriptionExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) UpdateSubscriptionExecute(r ApiUpdateSubscriptionRequest) error { + if a.UpdateSubscriptionExecuteMock == nil { + return nil + } + + return (*a.UpdateSubscriptionExecuteMock)(r) +} + +func (a DefaultAPIServiceMock) UpdateTopic(ctx context.Context, projectId string, regionId string, topicId string) ApiUpdateTopicRequest { + return ApiUpdateTopicRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + regionId: regionId, + topicId: topicId, + } +} + +// UpdateTopicExecute is a no-op by default and will return only return nil values. Behavior can be controlled by populating the UpdateTopicExecuteMock field in the DefaultAPIServiceMock struct. +func (a DefaultAPIServiceMock) UpdateTopicExecute(r ApiUpdateTopicRequest) error { + if a.UpdateTopicExecuteMock == nil { + return nil + } + + return (*a.UpdateTopicExecuteMock)(r) +} diff --git a/services/pubsub/v1alphaapi/client.go b/services/pubsub/v1alphaapi/client.go new file mode 100644 index 000000000..249394c04 --- /dev/null +++ b/services/pubsub/v1alphaapi/client.go @@ -0,0 +1,658 @@ +/* +[ALPHA] STACKIT PubSub API + +This API provides endpoints for managing PubSubs. + +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 [ALPHA] STACKIT PubSub API API v1alpha.0.0 +// In most cases there should be only one, shared, APIClient. +type APIClient struct { + cfg *config.Configuration + common service // Reuse a single struct instead of allocating one for each service on the heap. + + // API Services + + DefaultAPI DefaultAPI +} + +type service struct { + client *APIClient +} + +// NewAPIClient creates a new API client. Requires a userAgent string describing your application. +// optionally a custom http.Client to allow for advanced features such as caching. +func NewAPIClient(opts ...config.ConfigurationOption) (*APIClient, error) { + cfg := NewConfiguration() + + for _, option := range opts { + err := option(cfg) + if err != nil { + return nil, fmt.Errorf("configuring the client: %w", err) + } + } + + err := config.ConfigureRegion(cfg) + if err != nil { + return nil, fmt.Errorf("configuring region: %w", err) + } + + if cfg.HTTPClient == nil { + cfg.HTTPClient = &http.Client{} + } + + authRoundTripper, err := auth.SetupAuth(cfg) + if err != nil { + return nil, fmt.Errorf("setting up authentication: %w", err) + } + + roundTripper := authRoundTripper + if cfg.Middleware != nil { + roundTripper = config.ChainMiddleware(roundTripper, cfg.Middleware...) + } + + cfg.HTTPClient.Transport = roundTripper + + c := &APIClient{} + c.cfg = cfg + c.common.client = c + + // API Services + c.DefaultAPI = (*DefaultAPIService)(&c.common) + + return c, nil +} + +func atoi(in string) (int, error) { + return strconv.Atoi(in) +} + +// selectHeaderContentType select a content type from the available list. +func selectHeaderContentType(contentTypes []string) string { + if len(contentTypes) == 0 { + return "" + } + if contains(contentTypes, "application/json") { + return "application/json" + } + return contentTypes[0] // use the first content type specified in 'consumes' +} + +// selectHeaderAccept join all accept types and return +func selectHeaderAccept(accepts []string) string { + if len(accepts) == 0 { + return "" + } + + if contains(accepts, "application/json") { + return "application/json" + } + + return strings.Join(accepts, ",") +} + +// contains is a case insensitive match, finding needle in a haystack +func contains(haystack []string, needle string) bool { + for _, a := range haystack { + if strings.EqualFold(a, needle) { + return true + } + } + return false +} + +// Verify optional parameters are of the correct type. +func typeCheckParameter(obj interface{}, expected string, name string) error { + // Make sure there is an object. + if obj == nil { + return nil + } + + // Check the type is as expected. + if reflect.TypeOf(obj).String() != expected { + return fmt.Errorf("expected %s to be of type %s but received %s", name, expected, reflect.TypeOf(obj).String()) + } + return nil +} + +func parameterValueToString(obj interface{}, key string) string { + if reflect.TypeOf(obj).Kind() != reflect.Ptr { + if actualObj, ok := obj.(interface{ GetActualInstanceValue() interface{} }); ok { + return fmt.Sprintf("%v", actualObj.GetActualInstanceValue()) + } + + return fmt.Sprintf("%v", obj) + } + var param, ok = obj.(MappedNullable) + if !ok { + return "" + } + dataMap, err := param.ToMap() + if err != nil { + return "" + } + return fmt.Sprintf("%v", dataMap[key]) +} + +// parameterAddToHeaderOrQuery adds the provided object to the request header or url query +// supporting deep object syntax +func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix string, obj interface{}, style string, collectionType string) { + var v = reflect.ValueOf(obj) + var value = "" + if v == reflect.ValueOf(nil) { + value = "null" + } else { + switch v.Kind() { + case reflect.Invalid: + value = "invalid" + + case reflect.Struct: + if t, ok := obj.(MappedNullable); ok { + dataMap, err := t.ToMap() + if err != nil { + return + } + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, dataMap, style, collectionType) + return + } + if t, ok := obj.(time.Time); ok { + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, t.Format(time.RFC3339Nano), style, collectionType) + return + } + value = v.Type().String() + " value" + case reflect.Slice: + var indValue = reflect.ValueOf(obj) + if indValue == reflect.ValueOf(nil) { + return + } + var lenIndValue = indValue.Len() + for i := 0; i < lenIndValue; i++ { + var arrayValue = indValue.Index(i) + var keyPrefixForCollectionType = keyPrefix + if style == "deepObject" { + keyPrefixForCollectionType = keyPrefix + "[" + strconv.Itoa(i) + "]" + } + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefixForCollectionType, arrayValue.Interface(), style, collectionType) + } + return + + case reflect.Map: + var indValue = reflect.ValueOf(obj) + if indValue == reflect.ValueOf(nil) { + return + } + iter := indValue.MapRange() + for iter.Next() { + k, v := iter.Key(), iter.Value() + parameterAddToHeaderOrQuery(headerOrQueryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface(), style, collectionType) + } + return + + case reflect.Interface: + fallthrough + case reflect.Ptr: + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, v.Elem().Interface(), style, collectionType) + return + + case reflect.Int, reflect.Int8, reflect.Int16, + reflect.Int32, reflect.Int64: + value = strconv.FormatInt(v.Int(), 10) + case reflect.Uint, reflect.Uint8, reflect.Uint16, + reflect.Uint32, reflect.Uint64, reflect.Uintptr: + value = strconv.FormatUint(v.Uint(), 10) + case reflect.Float32, reflect.Float64: + value = strconv.FormatFloat(v.Float(), 'g', -1, 32) + case reflect.Bool: + value = strconv.FormatBool(v.Bool()) + case reflect.String: + value = v.String() + default: + value = v.Type().String() + " value" + } + } + + switch valuesMap := headerOrQueryParams.(type) { + case url.Values: + if collectionType == "csv" && valuesMap.Get(keyPrefix) != "" { + valuesMap.Set(keyPrefix, valuesMap.Get(keyPrefix)+","+value) + } else { + valuesMap.Add(keyPrefix, value) + } + break + case map[string]string: + valuesMap[keyPrefix] = value + break + } +} + +// helper for converting interface{} parameters to json strings +func parameterToJson(obj interface{}) (string, error) { + jsonBuf, err := json.Marshal(obj) + if err != nil { + return "", err + } + return string(jsonBuf), err +} + +// callAPI do the request. +func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { + if c.cfg.Debug { + dump, err := httputil.DumpRequestOut(request, true) + if err != nil { + return nil, err + } + log.Printf("\n%s\n", string(dump)) + } + + resp, err := c.cfg.HTTPClient.Do(request) + if err != nil { + return resp, err + } + + if c.cfg.Debug { + dump, err := httputil.DumpResponse(resp, true) + if err != nil { + return resp, err + } + log.Printf("\n%s\n", string(dump)) + } + return resp, err +} + +// Allow modification of underlying config for alternate implementations and testing +// Caution: modifying the configuration while live can cause data races and potentially unwanted behavior +func (c *APIClient) GetConfig() *config.Configuration { + return c.cfg +} + +type formFile struct { + fileBytes []byte + fileName string + formFileName string +} + +// prepareRequest build the request +func (c *APIClient) prepareRequest( + ctx context.Context, + path string, method string, + postBody interface{}, + headerParams map[string]string, + queryParams url.Values, + formParams url.Values, + formFiles []formFile) (localVarRequest *http.Request, err error) { + + var body *bytes.Buffer + + // Detect postBody type and post. + if postBody != nil { + contentType := headerParams["Content-Type"] + if contentType == "" { + contentType = detectContentType(postBody) + headerParams["Content-Type"] = contentType + } + + body, err = setBody(postBody, contentType) + if err != nil { + return nil, err + } + } + + // add form parameters and file if available. + if strings.HasPrefix(headerParams["Content-Type"], "multipart/form-data") && len(formParams) > 0 || (len(formFiles) > 0) { + if body != nil { + return nil, errors.New("Cannot specify postBody and multipart form at the same time.") + } + body = &bytes.Buffer{} + w := multipart.NewWriter(body) + + for k, v := range formParams { + for _, iv := range v { + if strings.HasPrefix(k, "@") { // file + err = addFile(w, k[1:], iv) + if err != nil { + return nil, err + } + } else { // form value + w.WriteField(k, iv) + } + } + } + for _, formFile := range formFiles { + if len(formFile.fileBytes) > 0 && formFile.fileName != "" { + w.Boundary() + part, err := w.CreateFormFile(formFile.formFileName, filepath.Base(formFile.fileName)) + if err != nil { + return nil, err + } + _, err = part.Write(formFile.fileBytes) + if err != nil { + return nil, err + } + } + } + + // Set the Boundary in the Content-Type + headerParams["Content-Type"] = w.FormDataContentType() + + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + w.Close() + } + + if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 { + if body != nil { + return nil, errors.New("Cannot specify postBody and x-www-form-urlencoded form at the same time.") + } + body = &bytes.Buffer{} + body.WriteString(formParams.Encode()) + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + } + + // Setup path and query parameters + url, err := url.Parse(path) + if err != nil { + return nil, err + } + + // Override request host, if applicable + if c.cfg.Host != "" { + url.Host = c.cfg.Host + } + + // Override request scheme, if applicable + if c.cfg.Scheme != "" { + url.Scheme = c.cfg.Scheme + } + + // Adding Query Param + query := url.Query() + for k, v := range queryParams { + for _, iv := range v { + query.Add(k, iv) + } + } + + // Encode the parameters. + url.RawQuery = queryParamSplit.ReplaceAllStringFunc(query.Encode(), func(s string) string { + pieces := strings.Split(s, "=") + pieces[0] = queryDescape.Replace(pieces[0]) + return strings.Join(pieces, "=") + }) + + // Generate a new request + if body != nil { + localVarRequest, err = http.NewRequest(method, url.String(), body) + } else { + localVarRequest, err = http.NewRequest(method, url.String(), nil) + } + if err != nil { + return nil, err + } + + // add header parameters, if any + if len(headerParams) > 0 { + headers := http.Header{} + for h, v := range headerParams { + headers[h] = []string{v} + } + localVarRequest.Header = headers + } + + // Add the user agent to the request. + localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) + + if ctx != nil { + // add context to the request + localVarRequest = localVarRequest.WithContext(ctx) + + // Walk through any authentication. + + } + + for header, value := range c.cfg.DefaultHeader { + localVarRequest.Header.Add(header, value) + } + return localVarRequest, nil +} + +func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { + if len(b) == 0 { + return nil + } + if s, ok := v.(*string); ok { + *s = string(b) + return nil + } + if f, ok := v.(*os.File); ok { + f, err = os.CreateTemp("", "HttpClientFile") + if err != nil { + return + } + _, err = f.Write(b) + if err != nil { + return + } + _, err = f.Seek(0, io.SeekStart) + return + } + if f, ok := v.(**os.File); ok { + *f, err = os.CreateTemp("", "HttpClientFile") + if err != nil { + return + } + _, err = (*f).Write(b) + if err != nil { + return + } + _, err = (*f).Seek(0, io.SeekStart) + return + } + if XmlCheck.MatchString(contentType) { + if err = xml.Unmarshal(b, v); err != nil { + return err + } + return nil + } + if JsonCheck.MatchString(contentType) { + if actualObj, ok := v.(interface{ GetActualInstance() interface{} }); ok { // oneOf, anyOf schemas + if unmarshalObj, ok := actualObj.(interface{ UnmarshalJSON([]byte) error }); ok { // make sure it has UnmarshalJSON defined + if err = unmarshalObj.UnmarshalJSON(b); err != nil { + return err + } + } else { + return errors.New("Unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined") + } + } else if err = json.Unmarshal(b, v); err != nil { // simple model + return err + } + return nil + } + return errors.New("undefined response type") +} + +// Add a file to the multipart request +func addFile(w *multipart.Writer, fieldName, path string) error { + file, err := os.Open(filepath.Clean(path)) + if err != nil { + return err + } + defer file.Close() + + part, err := w.CreateFormFile(fieldName, filepath.Base(path)) + if err != nil { + return err + } + _, err = io.Copy(part, file) + + return err +} + +// Set request body from an interface{} +func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { + if bodyBuf == nil { + bodyBuf = &bytes.Buffer{} + } + + if reader, ok := body.(io.Reader); ok { + _, err = bodyBuf.ReadFrom(reader) + } else if fp, ok := body.(*os.File); ok { + _, err = bodyBuf.ReadFrom(fp) + } else if b, ok := body.([]byte); ok { + _, err = bodyBuf.Write(b) + } else if s, ok := body.(string); ok { + _, err = bodyBuf.WriteString(s) + } else if s, ok := body.(*string); ok { + _, err = bodyBuf.WriteString(*s) + } else if JsonCheck.MatchString(contentType) { + err = json.NewEncoder(bodyBuf).Encode(body) + } else if XmlCheck.MatchString(contentType) { + var bs []byte + bs, err = xml.Marshal(body) + if err == nil { + bodyBuf.Write(bs) + } + } + + if err != nil { + return nil, err + } + + if bodyBuf.Len() == 0 { + err = fmt.Errorf("invalid body type %s\n", contentType) + return nil, err + } + return bodyBuf, nil +} + +// detectContentType method is used to figure out `Request.Body` content type for request header +func detectContentType(body interface{}) string { + contentType := "text/plain; charset=utf-8" + kind := reflect.TypeOf(body).Kind() + + switch kind { + case reflect.Struct, reflect.Map, reflect.Ptr: + contentType = "application/json; charset=utf-8" + case reflect.String: + contentType = "text/plain; charset=utf-8" + default: + if b, ok := body.([]byte); ok { + contentType = http.DetectContentType(b) + } else if kind == reflect.Slice { + contentType = "application/json; charset=utf-8" + } + } + + return contentType +} + +// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go +type cacheControl map[string]string + +func parseCacheControl(headers http.Header) cacheControl { + cc := cacheControl{} + ccHeader := headers.Get("Cache-Control") + for _, part := range strings.Split(ccHeader, ",") { + part = strings.Trim(part, " ") + if part == "" { + continue + } + if strings.ContainsRune(part, '=') { + keyval := strings.Split(part, "=") + cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") + } else { + cc[part] = "" + } + } + return cc +} + +// CacheExpires helper function to determine remaining time before repeating a request. +func CacheExpires(r *http.Response) time.Time { + // Figure out when the cache expires. + var expires time.Time + now, err := time.Parse(time.RFC1123, r.Header.Get("date")) + if err != nil { + return time.Now() + } + respCacheControl := parseCacheControl(r.Header) + + if maxAge, ok := respCacheControl["max-age"]; ok { + lifetime, err := time.ParseDuration(maxAge + "s") + if err != nil { + expires = now + } else { + expires = now.Add(lifetime) + } + } else { + expiresHeader := r.Header.Get("Expires") + if expiresHeader != "" { + expires, err = time.Parse(time.RFC1123, expiresHeader) + if err != nil { + expires = now + } + } + } + return expires +} + +func strlen(s string) int { + return utf8.RuneCountInString(s) +} + +// format error message using title and detail when model implements rfc7807 +func formatErrorMessage(status string, v interface{}) string { + str := "" + metaValue := reflect.ValueOf(v).Elem() + + if metaValue.Kind() == reflect.Struct { + field := metaValue.FieldByName("Title") + if field != (reflect.Value{}) { + str = fmt.Sprintf("%s", field.Interface()) + } + + field = metaValue.FieldByName("Detail") + if field != (reflect.Value{}) { + str = fmt.Sprintf("%s (%s)", str, field.Interface()) + } + } + + return strings.TrimSpace(fmt.Sprintf("%s %s", status, str)) +} diff --git a/services/pubsub/v1alphaapi/configuration.go b/services/pubsub/v1alphaapi/configuration.go new file mode 100644 index 000000000..3e0012504 --- /dev/null +++ b/services/pubsub/v1alphaapi/configuration.go @@ -0,0 +1,40 @@ +/* +[ALPHA] STACKIT PubSub API + +This API provides endpoints for managing PubSubs. + +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/pubsub", + Debug: false, + Servers: config.ServerConfigurations{ + { + URL: "https://pubsub.api.{region}stackit.cloud", + Description: "No description provided", + Variables: map[string]config.ServerVariable{ + "region": { + Description: "No description provided", + DefaultValue: "eu01.", + EnumValues: []string{ + "eu01.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + return cfg +} diff --git a/services/pubsub/v1alphaapi/model_create_subscription_payload.go b/services/pubsub/v1alphaapi/model_create_subscription_payload.go new file mode 100644 index 000000000..0c5091475 --- /dev/null +++ b/services/pubsub/v1alphaapi/model_create_subscription_payload.go @@ -0,0 +1,242 @@ +/* +[ALPHA] STACKIT PubSub API + +This API provides endpoints for managing PubSubs. + +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 CreateSubscriptionPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &CreateSubscriptionPayload{} + +// CreateSubscriptionPayload struct for CreateSubscriptionPayload +type CreateSubscriptionPayload struct { + // The description is a longer text chosen by the user to provide more context for the resource. + Description *string `json:"description,omitempty"` + // The display name is a short name chosen by the user to identify the resource. + DisplayName string `json:"displayName" validate:"regexp=^[a-zA-Z0-9 -]*$"` + Settings *SubscriptionSettings `json:"settings,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _CreateSubscriptionPayload CreateSubscriptionPayload + +// NewCreateSubscriptionPayload instantiates a new CreateSubscriptionPayload 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 NewCreateSubscriptionPayload(displayName string) *CreateSubscriptionPayload { + this := CreateSubscriptionPayload{} + this.DisplayName = displayName + return &this +} + +// NewCreateSubscriptionPayloadWithDefaults instantiates a new CreateSubscriptionPayload 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 NewCreateSubscriptionPayloadWithDefaults() *CreateSubscriptionPayload { + this := CreateSubscriptionPayload{} + return &this +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *CreateSubscriptionPayload) GetDescription() string { + if o == nil || IsNil(o.Description) { + var ret string + return ret + } + return *o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateSubscriptionPayload) GetDescriptionOk() (*string, bool) { + if o == nil || IsNil(o.Description) { + return nil, false + } + return o.Description, true +} + +// HasDescription returns a boolean if a field has been set. +func (o *CreateSubscriptionPayload) HasDescription() bool { + if o != nil && !IsNil(o.Description) { + return true + } + + return false +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *CreateSubscriptionPayload) SetDescription(v string) { + o.Description = &v +} + +// GetDisplayName returns the DisplayName field value +func (o *CreateSubscriptionPayload) GetDisplayName() string { + if o == nil { + var ret string + return ret + } + + return o.DisplayName +} + +// GetDisplayNameOk returns a tuple with the DisplayName field value +// and a boolean to check if the value has been set. +func (o *CreateSubscriptionPayload) GetDisplayNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.DisplayName, true +} + +// SetDisplayName sets field value +func (o *CreateSubscriptionPayload) SetDisplayName(v string) { + o.DisplayName = v +} + +// GetSettings returns the Settings field value if set, zero value otherwise. +func (o *CreateSubscriptionPayload) GetSettings() SubscriptionSettings { + if o == nil || IsNil(o.Settings) { + var ret SubscriptionSettings + return ret + } + return *o.Settings +} + +// GetSettingsOk returns a tuple with the Settings field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateSubscriptionPayload) GetSettingsOk() (*SubscriptionSettings, bool) { + if o == nil || IsNil(o.Settings) { + return nil, false + } + return o.Settings, true +} + +// HasSettings returns a boolean if a field has been set. +func (o *CreateSubscriptionPayload) HasSettings() bool { + if o != nil && !IsNil(o.Settings) { + return true + } + + return false +} + +// SetSettings gets a reference to the given SubscriptionSettings and assigns it to the Settings field. +func (o *CreateSubscriptionPayload) SetSettings(v SubscriptionSettings) { + o.Settings = &v +} + +func (o CreateSubscriptionPayload) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o CreateSubscriptionPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Description) { + toSerialize["description"] = o.Description + } + toSerialize["displayName"] = o.DisplayName + if !IsNil(o.Settings) { + toSerialize["settings"] = o.Settings + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *CreateSubscriptionPayload) 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{ + "displayName", + } + + 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) + } + } + + varCreateSubscriptionPayload := _CreateSubscriptionPayload{} + + err = json.Unmarshal(data, &varCreateSubscriptionPayload) + + if err != nil { + return err + } + + *o = CreateSubscriptionPayload(varCreateSubscriptionPayload) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "description") + delete(additionalProperties, "displayName") + delete(additionalProperties, "settings") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableCreateSubscriptionPayload struct { + value *CreateSubscriptionPayload + isSet bool +} + +func (v NullableCreateSubscriptionPayload) Get() *CreateSubscriptionPayload { + return v.value +} + +func (v *NullableCreateSubscriptionPayload) Set(val *CreateSubscriptionPayload) { + v.value = val + v.isSet = true +} + +func (v NullableCreateSubscriptionPayload) IsSet() bool { + return v.isSet +} + +func (v *NullableCreateSubscriptionPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCreateSubscriptionPayload(val *CreateSubscriptionPayload) *NullableCreateSubscriptionPayload { + return &NullableCreateSubscriptionPayload{value: val, isSet: true} +} + +func (v NullableCreateSubscriptionPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCreateSubscriptionPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/pubsub/v1alphaapi/model_create_topic_payload.go b/services/pubsub/v1alphaapi/model_create_topic_payload.go new file mode 100644 index 000000000..ea8996078 --- /dev/null +++ b/services/pubsub/v1alphaapi/model_create_topic_payload.go @@ -0,0 +1,242 @@ +/* +[ALPHA] STACKIT PubSub API + +This API provides endpoints for managing PubSubs. + +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 CreateTopicPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &CreateTopicPayload{} + +// CreateTopicPayload struct for CreateTopicPayload +type CreateTopicPayload struct { + // The description is a longer text chosen by the user to provide more context for the resource. + Description *string `json:"description,omitempty"` + // The display name is a short name chosen by the user to identify the resource. + DisplayName string `json:"displayName" validate:"regexp=^[a-zA-Z0-9 -]*$"` + Settings *TopicSettings `json:"settings,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _CreateTopicPayload CreateTopicPayload + +// NewCreateTopicPayload instantiates a new CreateTopicPayload 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 NewCreateTopicPayload(displayName string) *CreateTopicPayload { + this := CreateTopicPayload{} + this.DisplayName = displayName + return &this +} + +// NewCreateTopicPayloadWithDefaults instantiates a new CreateTopicPayload 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 NewCreateTopicPayloadWithDefaults() *CreateTopicPayload { + this := CreateTopicPayload{} + return &this +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *CreateTopicPayload) GetDescription() string { + if o == nil || IsNil(o.Description) { + var ret string + return ret + } + return *o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateTopicPayload) GetDescriptionOk() (*string, bool) { + if o == nil || IsNil(o.Description) { + return nil, false + } + return o.Description, true +} + +// HasDescription returns a boolean if a field has been set. +func (o *CreateTopicPayload) HasDescription() bool { + if o != nil && !IsNil(o.Description) { + return true + } + + return false +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *CreateTopicPayload) SetDescription(v string) { + o.Description = &v +} + +// GetDisplayName returns the DisplayName field value +func (o *CreateTopicPayload) GetDisplayName() string { + if o == nil { + var ret string + return ret + } + + return o.DisplayName +} + +// GetDisplayNameOk returns a tuple with the DisplayName field value +// and a boolean to check if the value has been set. +func (o *CreateTopicPayload) GetDisplayNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.DisplayName, true +} + +// SetDisplayName sets field value +func (o *CreateTopicPayload) SetDisplayName(v string) { + o.DisplayName = v +} + +// GetSettings returns the Settings field value if set, zero value otherwise. +func (o *CreateTopicPayload) GetSettings() TopicSettings { + if o == nil || IsNil(o.Settings) { + var ret TopicSettings + return ret + } + return *o.Settings +} + +// GetSettingsOk returns a tuple with the Settings field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateTopicPayload) GetSettingsOk() (*TopicSettings, bool) { + if o == nil || IsNil(o.Settings) { + return nil, false + } + return o.Settings, true +} + +// HasSettings returns a boolean if a field has been set. +func (o *CreateTopicPayload) HasSettings() bool { + if o != nil && !IsNil(o.Settings) { + return true + } + + return false +} + +// SetSettings gets a reference to the given TopicSettings and assigns it to the Settings field. +func (o *CreateTopicPayload) SetSettings(v TopicSettings) { + o.Settings = &v +} + +func (o CreateTopicPayload) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o CreateTopicPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Description) { + toSerialize["description"] = o.Description + } + toSerialize["displayName"] = o.DisplayName + if !IsNil(o.Settings) { + toSerialize["settings"] = o.Settings + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *CreateTopicPayload) 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{ + "displayName", + } + + 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) + } + } + + varCreateTopicPayload := _CreateTopicPayload{} + + err = json.Unmarshal(data, &varCreateTopicPayload) + + if err != nil { + return err + } + + *o = CreateTopicPayload(varCreateTopicPayload) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "description") + delete(additionalProperties, "displayName") + delete(additionalProperties, "settings") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableCreateTopicPayload struct { + value *CreateTopicPayload + isSet bool +} + +func (v NullableCreateTopicPayload) Get() *CreateTopicPayload { + return v.value +} + +func (v *NullableCreateTopicPayload) Set(val *CreateTopicPayload) { + v.value = val + v.isSet = true +} + +func (v NullableCreateTopicPayload) IsSet() bool { + return v.isSet +} + +func (v *NullableCreateTopicPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCreateTopicPayload(val *CreateTopicPayload) *NullableCreateTopicPayload { + return &NullableCreateTopicPayload{value: val, isSet: true} +} + +func (v NullableCreateTopicPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCreateTopicPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/pubsub/v1alphaapi/model_list_email_adresses_response.go b/services/pubsub/v1alphaapi/model_list_email_adresses_response.go new file mode 100644 index 000000000..73de4df15 --- /dev/null +++ b/services/pubsub/v1alphaapi/model_list_email_adresses_response.go @@ -0,0 +1,166 @@ +/* +[ALPHA] STACKIT PubSub API + +This API provides endpoints for managing PubSubs. + +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 ListEmailAdressesResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ListEmailAdressesResponse{} + +// ListEmailAdressesResponse struct for ListEmailAdressesResponse +type ListEmailAdressesResponse struct { + EmailAddresses []string `json:"emailAddresses"` + AdditionalProperties map[string]interface{} +} + +type _ListEmailAdressesResponse ListEmailAdressesResponse + +// NewListEmailAdressesResponse instantiates a new ListEmailAdressesResponse 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 NewListEmailAdressesResponse(emailAddresses []string) *ListEmailAdressesResponse { + this := ListEmailAdressesResponse{} + this.EmailAddresses = emailAddresses + return &this +} + +// NewListEmailAdressesResponseWithDefaults instantiates a new ListEmailAdressesResponse 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 NewListEmailAdressesResponseWithDefaults() *ListEmailAdressesResponse { + this := ListEmailAdressesResponse{} + return &this +} + +// GetEmailAddresses returns the EmailAddresses field value +func (o *ListEmailAdressesResponse) GetEmailAddresses() []string { + if o == nil { + var ret []string + return ret + } + + return o.EmailAddresses +} + +// GetEmailAddressesOk returns a tuple with the EmailAddresses field value +// and a boolean to check if the value has been set. +func (o *ListEmailAdressesResponse) GetEmailAddressesOk() ([]string, bool) { + if o == nil { + return nil, false + } + return o.EmailAddresses, true +} + +// SetEmailAddresses sets field value +func (o *ListEmailAdressesResponse) SetEmailAddresses(v []string) { + o.EmailAddresses = v +} + +func (o ListEmailAdressesResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ListEmailAdressesResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["emailAddresses"] = o.EmailAddresses + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *ListEmailAdressesResponse) 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{ + "emailAddresses", + } + + 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) + } + } + + varListEmailAdressesResponse := _ListEmailAdressesResponse{} + + err = json.Unmarshal(data, &varListEmailAdressesResponse) + + if err != nil { + return err + } + + *o = ListEmailAdressesResponse(varListEmailAdressesResponse) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "emailAddresses") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableListEmailAdressesResponse struct { + value *ListEmailAdressesResponse + isSet bool +} + +func (v NullableListEmailAdressesResponse) Get() *ListEmailAdressesResponse { + return v.value +} + +func (v *NullableListEmailAdressesResponse) Set(val *ListEmailAdressesResponse) { + v.value = val + v.isSet = true +} + +func (v NullableListEmailAdressesResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableListEmailAdressesResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableListEmailAdressesResponse(val *ListEmailAdressesResponse) *NullableListEmailAdressesResponse { + return &NullableListEmailAdressesResponse{value: val, isSet: true} +} + +func (v NullableListEmailAdressesResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableListEmailAdressesResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/pubsub/v1alphaapi/model_list_subscriptions_response.go b/services/pubsub/v1alphaapi/model_list_subscriptions_response.go new file mode 100644 index 000000000..33b9a54f1 --- /dev/null +++ b/services/pubsub/v1alphaapi/model_list_subscriptions_response.go @@ -0,0 +1,204 @@ +/* +[ALPHA] STACKIT PubSub API + +This API provides endpoints for managing PubSubs. + +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 ListSubscriptionsResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ListSubscriptionsResponse{} + +// ListSubscriptionsResponse struct for ListSubscriptionsResponse +type ListSubscriptionsResponse struct { + // A token to retrieve the next page of results. + NextPageToken *string `json:"nextPageToken,omitempty"` + Subscriptions []SubscriptionResponse `json:"subscriptions"` + AdditionalProperties map[string]interface{} +} + +type _ListSubscriptionsResponse ListSubscriptionsResponse + +// NewListSubscriptionsResponse instantiates a new ListSubscriptionsResponse 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 NewListSubscriptionsResponse(subscriptions []SubscriptionResponse) *ListSubscriptionsResponse { + this := ListSubscriptionsResponse{} + this.Subscriptions = subscriptions + return &this +} + +// NewListSubscriptionsResponseWithDefaults instantiates a new ListSubscriptionsResponse 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 NewListSubscriptionsResponseWithDefaults() *ListSubscriptionsResponse { + this := ListSubscriptionsResponse{} + return &this +} + +// GetNextPageToken returns the NextPageToken field value if set, zero value otherwise. +func (o *ListSubscriptionsResponse) GetNextPageToken() string { + if o == nil || IsNil(o.NextPageToken) { + var ret string + return ret + } + return *o.NextPageToken +} + +// GetNextPageTokenOk returns a tuple with the NextPageToken field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ListSubscriptionsResponse) GetNextPageTokenOk() (*string, bool) { + if o == nil || IsNil(o.NextPageToken) { + return nil, false + } + return o.NextPageToken, true +} + +// HasNextPageToken returns a boolean if a field has been set. +func (o *ListSubscriptionsResponse) HasNextPageToken() bool { + if o != nil && !IsNil(o.NextPageToken) { + return true + } + + return false +} + +// SetNextPageToken gets a reference to the given string and assigns it to the NextPageToken field. +func (o *ListSubscriptionsResponse) SetNextPageToken(v string) { + o.NextPageToken = &v +} + +// GetSubscriptions returns the Subscriptions field value +func (o *ListSubscriptionsResponse) GetSubscriptions() []SubscriptionResponse { + if o == nil { + var ret []SubscriptionResponse + return ret + } + + return o.Subscriptions +} + +// GetSubscriptionsOk returns a tuple with the Subscriptions field value +// and a boolean to check if the value has been set. +func (o *ListSubscriptionsResponse) GetSubscriptionsOk() ([]SubscriptionResponse, bool) { + if o == nil { + return nil, false + } + return o.Subscriptions, true +} + +// SetSubscriptions sets field value +func (o *ListSubscriptionsResponse) SetSubscriptions(v []SubscriptionResponse) { + o.Subscriptions = v +} + +func (o ListSubscriptionsResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ListSubscriptionsResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.NextPageToken) { + toSerialize["nextPageToken"] = o.NextPageToken + } + toSerialize["subscriptions"] = o.Subscriptions + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *ListSubscriptionsResponse) 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{ + "subscriptions", + } + + 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) + } + } + + varListSubscriptionsResponse := _ListSubscriptionsResponse{} + + err = json.Unmarshal(data, &varListSubscriptionsResponse) + + if err != nil { + return err + } + + *o = ListSubscriptionsResponse(varListSubscriptionsResponse) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "nextPageToken") + delete(additionalProperties, "subscriptions") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableListSubscriptionsResponse struct { + value *ListSubscriptionsResponse + isSet bool +} + +func (v NullableListSubscriptionsResponse) Get() *ListSubscriptionsResponse { + return v.value +} + +func (v *NullableListSubscriptionsResponse) Set(val *ListSubscriptionsResponse) { + v.value = val + v.isSet = true +} + +func (v NullableListSubscriptionsResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableListSubscriptionsResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableListSubscriptionsResponse(val *ListSubscriptionsResponse) *NullableListSubscriptionsResponse { + return &NullableListSubscriptionsResponse{value: val, isSet: true} +} + +func (v NullableListSubscriptionsResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableListSubscriptionsResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/pubsub/v1alphaapi/model_list_topics_response.go b/services/pubsub/v1alphaapi/model_list_topics_response.go new file mode 100644 index 000000000..02c95e172 --- /dev/null +++ b/services/pubsub/v1alphaapi/model_list_topics_response.go @@ -0,0 +1,204 @@ +/* +[ALPHA] STACKIT PubSub API + +This API provides endpoints for managing PubSubs. + +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 ListTopicsResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ListTopicsResponse{} + +// ListTopicsResponse struct for ListTopicsResponse +type ListTopicsResponse struct { + // A token to retrieve the next page of results. + NextPageToken *string `json:"nextPageToken,omitempty"` + Topics []TopicResponse `json:"topics"` + AdditionalProperties map[string]interface{} +} + +type _ListTopicsResponse ListTopicsResponse + +// NewListTopicsResponse instantiates a new ListTopicsResponse 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 NewListTopicsResponse(topics []TopicResponse) *ListTopicsResponse { + this := ListTopicsResponse{} + this.Topics = topics + return &this +} + +// NewListTopicsResponseWithDefaults instantiates a new ListTopicsResponse 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 NewListTopicsResponseWithDefaults() *ListTopicsResponse { + this := ListTopicsResponse{} + return &this +} + +// GetNextPageToken returns the NextPageToken field value if set, zero value otherwise. +func (o *ListTopicsResponse) GetNextPageToken() string { + if o == nil || IsNil(o.NextPageToken) { + var ret string + return ret + } + return *o.NextPageToken +} + +// GetNextPageTokenOk returns a tuple with the NextPageToken field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ListTopicsResponse) GetNextPageTokenOk() (*string, bool) { + if o == nil || IsNil(o.NextPageToken) { + return nil, false + } + return o.NextPageToken, true +} + +// HasNextPageToken returns a boolean if a field has been set. +func (o *ListTopicsResponse) HasNextPageToken() bool { + if o != nil && !IsNil(o.NextPageToken) { + return true + } + + return false +} + +// SetNextPageToken gets a reference to the given string and assigns it to the NextPageToken field. +func (o *ListTopicsResponse) SetNextPageToken(v string) { + o.NextPageToken = &v +} + +// GetTopics returns the Topics field value +func (o *ListTopicsResponse) GetTopics() []TopicResponse { + if o == nil { + var ret []TopicResponse + return ret + } + + return o.Topics +} + +// GetTopicsOk returns a tuple with the Topics field value +// and a boolean to check if the value has been set. +func (o *ListTopicsResponse) GetTopicsOk() ([]TopicResponse, bool) { + if o == nil { + return nil, false + } + return o.Topics, true +} + +// SetTopics sets field value +func (o *ListTopicsResponse) SetTopics(v []TopicResponse) { + o.Topics = v +} + +func (o ListTopicsResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ListTopicsResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.NextPageToken) { + toSerialize["nextPageToken"] = o.NextPageToken + } + toSerialize["topics"] = o.Topics + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *ListTopicsResponse) 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{ + "topics", + } + + 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) + } + } + + varListTopicsResponse := _ListTopicsResponse{} + + err = json.Unmarshal(data, &varListTopicsResponse) + + if err != nil { + return err + } + + *o = ListTopicsResponse(varListTopicsResponse) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "nextPageToken") + delete(additionalProperties, "topics") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableListTopicsResponse struct { + value *ListTopicsResponse + isSet bool +} + +func (v NullableListTopicsResponse) Get() *ListTopicsResponse { + return v.value +} + +func (v *NullableListTopicsResponse) Set(val *ListTopicsResponse) { + v.value = val + v.isSet = true +} + +func (v NullableListTopicsResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableListTopicsResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableListTopicsResponse(val *ListTopicsResponse) *NullableListTopicsResponse { + return &NullableListTopicsResponse{value: val, isSet: true} +} + +func (v NullableListTopicsResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableListTopicsResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/pubsub/v1alphaapi/model_subscription_response.go b/services/pubsub/v1alphaapi/model_subscription_response.go new file mode 100644 index 000000000..fa288a1f3 --- /dev/null +++ b/services/pubsub/v1alphaapi/model_subscription_response.go @@ -0,0 +1,362 @@ +/* +[ALPHA] STACKIT PubSub API + +This API provides endpoints for managing PubSubs. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" + "fmt" + "time" +) + +// checks if the SubscriptionResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &SubscriptionResponse{} + +// SubscriptionResponse struct for SubscriptionResponse +type SubscriptionResponse struct { + // The point in time the resource was created. + CreateTime time.Time `json:"createTime"` + // The description is a longer text chosen by the user to provide more context for the resource. + Description *string `json:"description,omitempty"` + // The display name is a short name chosen by the user to identify the resource. + DisplayName string `json:"displayName" validate:"regexp=^[a-zA-Z0-9 -]*$"` + // An auto generated unique id which identifies the resource. + Id string `json:"id"` + Settings *SubscriptionSettings `json:"settings,omitempty"` + State SubscriptionResponseState `json:"state"` + // The id of the topic to which the subscription belongs. + TopicId string `json:"topicId"` + AdditionalProperties map[string]interface{} +} + +type _SubscriptionResponse SubscriptionResponse + +// NewSubscriptionResponse instantiates a new SubscriptionResponse 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 NewSubscriptionResponse(createTime time.Time, displayName string, id string, state SubscriptionResponseState, topicId string) *SubscriptionResponse { + this := SubscriptionResponse{} + this.CreateTime = createTime + this.DisplayName = displayName + this.Id = id + this.State = state + this.TopicId = topicId + return &this +} + +// NewSubscriptionResponseWithDefaults instantiates a new SubscriptionResponse 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 NewSubscriptionResponseWithDefaults() *SubscriptionResponse { + this := SubscriptionResponse{} + return &this +} + +// GetCreateTime returns the CreateTime field value +func (o *SubscriptionResponse) GetCreateTime() time.Time { + if o == nil { + var ret time.Time + return ret + } + + return o.CreateTime +} + +// GetCreateTimeOk returns a tuple with the CreateTime field value +// and a boolean to check if the value has been set. +func (o *SubscriptionResponse) GetCreateTimeOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.CreateTime, true +} + +// SetCreateTime sets field value +func (o *SubscriptionResponse) SetCreateTime(v time.Time) { + o.CreateTime = v +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *SubscriptionResponse) GetDescription() string { + if o == nil || IsNil(o.Description) { + var ret string + return ret + } + return *o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SubscriptionResponse) GetDescriptionOk() (*string, bool) { + if o == nil || IsNil(o.Description) { + return nil, false + } + return o.Description, true +} + +// HasDescription returns a boolean if a field has been set. +func (o *SubscriptionResponse) HasDescription() bool { + if o != nil && !IsNil(o.Description) { + return true + } + + return false +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *SubscriptionResponse) SetDescription(v string) { + o.Description = &v +} + +// GetDisplayName returns the DisplayName field value +func (o *SubscriptionResponse) GetDisplayName() string { + if o == nil { + var ret string + return ret + } + + return o.DisplayName +} + +// GetDisplayNameOk returns a tuple with the DisplayName field value +// and a boolean to check if the value has been set. +func (o *SubscriptionResponse) GetDisplayNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.DisplayName, true +} + +// SetDisplayName sets field value +func (o *SubscriptionResponse) SetDisplayName(v string) { + o.DisplayName = v +} + +// GetId returns the Id field value +func (o *SubscriptionResponse) GetId() string { + if o == nil { + var ret string + return ret + } + + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *SubscriptionResponse) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value +func (o *SubscriptionResponse) SetId(v string) { + o.Id = v +} + +// GetSettings returns the Settings field value if set, zero value otherwise. +func (o *SubscriptionResponse) GetSettings() SubscriptionSettings { + if o == nil || IsNil(o.Settings) { + var ret SubscriptionSettings + return ret + } + return *o.Settings +} + +// GetSettingsOk returns a tuple with the Settings field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SubscriptionResponse) GetSettingsOk() (*SubscriptionSettings, bool) { + if o == nil || IsNil(o.Settings) { + return nil, false + } + return o.Settings, true +} + +// HasSettings returns a boolean if a field has been set. +func (o *SubscriptionResponse) HasSettings() bool { + if o != nil && !IsNil(o.Settings) { + return true + } + + return false +} + +// SetSettings gets a reference to the given SubscriptionSettings and assigns it to the Settings field. +func (o *SubscriptionResponse) SetSettings(v SubscriptionSettings) { + o.Settings = &v +} + +// GetState returns the State field value +func (o *SubscriptionResponse) GetState() SubscriptionResponseState { + if o == nil { + var ret SubscriptionResponseState + return ret + } + + return o.State +} + +// GetStateOk returns a tuple with the State field value +// and a boolean to check if the value has been set. +func (o *SubscriptionResponse) GetStateOk() (*SubscriptionResponseState, bool) { + if o == nil { + return nil, false + } + return &o.State, true +} + +// SetState sets field value +func (o *SubscriptionResponse) SetState(v SubscriptionResponseState) { + o.State = v +} + +// GetTopicId returns the TopicId field value +func (o *SubscriptionResponse) GetTopicId() string { + if o == nil { + var ret string + return ret + } + + return o.TopicId +} + +// GetTopicIdOk returns a tuple with the TopicId field value +// and a boolean to check if the value has been set. +func (o *SubscriptionResponse) GetTopicIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.TopicId, true +} + +// SetTopicId sets field value +func (o *SubscriptionResponse) SetTopicId(v string) { + o.TopicId = v +} + +func (o SubscriptionResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o SubscriptionResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["createTime"] = o.CreateTime + if !IsNil(o.Description) { + toSerialize["description"] = o.Description + } + toSerialize["displayName"] = o.DisplayName + toSerialize["id"] = o.Id + if !IsNil(o.Settings) { + toSerialize["settings"] = o.Settings + } + toSerialize["state"] = o.State + toSerialize["topicId"] = o.TopicId + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *SubscriptionResponse) 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{ + "createTime", + "displayName", + "id", + "state", + "topicId", + } + + 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) + } + } + + varSubscriptionResponse := _SubscriptionResponse{} + + err = json.Unmarshal(data, &varSubscriptionResponse) + + if err != nil { + return err + } + + *o = SubscriptionResponse(varSubscriptionResponse) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "createTime") + delete(additionalProperties, "description") + delete(additionalProperties, "displayName") + delete(additionalProperties, "id") + delete(additionalProperties, "settings") + delete(additionalProperties, "state") + delete(additionalProperties, "topicId") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableSubscriptionResponse struct { + value *SubscriptionResponse + isSet bool +} + +func (v NullableSubscriptionResponse) Get() *SubscriptionResponse { + return v.value +} + +func (v *NullableSubscriptionResponse) Set(val *SubscriptionResponse) { + v.value = val + v.isSet = true +} + +func (v NullableSubscriptionResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableSubscriptionResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableSubscriptionResponse(val *SubscriptionResponse) *NullableSubscriptionResponse { + return &NullableSubscriptionResponse{value: val, isSet: true} +} + +func (v NullableSubscriptionResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableSubscriptionResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/pubsub/v1alphaapi/model_subscription_response_state.go b/services/pubsub/v1alphaapi/model_subscription_response_state.go new file mode 100644 index 000000000..f66c5ab22 --- /dev/null +++ b/services/pubsub/v1alphaapi/model_subscription_response_state.go @@ -0,0 +1,115 @@ +/* +[ALPHA] STACKIT PubSub API + +This API provides endpoints for managing PubSubs. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" + "fmt" +) + +// SubscriptionResponseState The current state of the resource. +type SubscriptionResponseState string + +// List of subscriptionResponse_state +const ( + SUBSCRIPTIONRESPONSESTATE_RECONCILING SubscriptionResponseState = "reconciling" + SUBSCRIPTIONRESPONSESTATE_ACTIVE SubscriptionResponseState = "active" + SUBSCRIPTIONRESPONSESTATE_DELETING SubscriptionResponseState = "deleting" + SUBSCRIPTIONRESPONSESTATE_UNKNOWN_DEFAULT_OPEN_API SubscriptionResponseState = "unknown_default_open_api" +) + +// All allowed values of SubscriptionResponseState enum +var AllowedSubscriptionResponseStateEnumValues = []SubscriptionResponseState{ + "reconciling", + "active", + "deleting", + "unknown_default_open_api", +} + +func (v *SubscriptionResponseState) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + enumTypeValue := SubscriptionResponseState(value) + for _, existing := range AllowedSubscriptionResponseStateEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + *v = SUBSCRIPTIONRESPONSESTATE_UNKNOWN_DEFAULT_OPEN_API + return nil +} + +// NewSubscriptionResponseStateFromValue returns a pointer to a valid SubscriptionResponseState +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewSubscriptionResponseStateFromValue(v string) (*SubscriptionResponseState, error) { + ev := SubscriptionResponseState(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for SubscriptionResponseState: valid values are %v", v, AllowedSubscriptionResponseStateEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v SubscriptionResponseState) IsValid() bool { + for _, existing := range AllowedSubscriptionResponseStateEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to subscriptionResponse_state value +func (v SubscriptionResponseState) Ptr() *SubscriptionResponseState { + return &v +} + +type NullableSubscriptionResponseState struct { + value *SubscriptionResponseState + isSet bool +} + +func (v NullableSubscriptionResponseState) Get() *SubscriptionResponseState { + return v.value +} + +func (v *NullableSubscriptionResponseState) Set(val *SubscriptionResponseState) { + v.value = val + v.isSet = true +} + +func (v NullableSubscriptionResponseState) IsSet() bool { + return v.isSet +} + +func (v *NullableSubscriptionResponseState) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableSubscriptionResponseState(val *SubscriptionResponseState) *NullableSubscriptionResponseState { + return &NullableSubscriptionResponseState{value: val, isSet: true} +} + +func (v NullableSubscriptionResponseState) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableSubscriptionResponseState) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/pubsub/v1alphaapi/model_subscription_settings.go b/services/pubsub/v1alphaapi/model_subscription_settings.go new file mode 100644 index 000000000..8de607bcb --- /dev/null +++ b/services/pubsub/v1alphaapi/model_subscription_settings.go @@ -0,0 +1,158 @@ +/* +[ALPHA] STACKIT PubSub API + +This API provides endpoints for managing PubSubs. + +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 SubscriptionSettings type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &SubscriptionSettings{} + +// SubscriptionSettings Configuration settings for the subscription. +type SubscriptionSettings struct { + // The maximum amount of time the system waits for a message acknowledgment. If a message is not acknowledged within this window, it will be redelivered. **Format:** Must be a duration string consisting of a number (integer or decimal) followed by a unit ('s', 'm', or 'h'). **Constraints:** - **Minimum:** \"1s\" - **Maximum:** \"168h\" (7 days) + AckDeadline *string `json:"ackDeadline,omitempty" validate:"regexp=^[0-9]+(\\\\.[0-9]+)?(s|m|h)$"` + AdditionalProperties map[string]interface{} +} + +type _SubscriptionSettings SubscriptionSettings + +// NewSubscriptionSettings instantiates a new SubscriptionSettings 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 NewSubscriptionSettings() *SubscriptionSettings { + this := SubscriptionSettings{} + var ackDeadline string = "2m" + this.AckDeadline = &ackDeadline + return &this +} + +// NewSubscriptionSettingsWithDefaults instantiates a new SubscriptionSettings 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 NewSubscriptionSettingsWithDefaults() *SubscriptionSettings { + this := SubscriptionSettings{} + var ackDeadline string = "2m" + this.AckDeadline = &ackDeadline + return &this +} + +// GetAckDeadline returns the AckDeadline field value if set, zero value otherwise. +func (o *SubscriptionSettings) GetAckDeadline() string { + if o == nil || IsNil(o.AckDeadline) { + var ret string + return ret + } + return *o.AckDeadline +} + +// GetAckDeadlineOk returns a tuple with the AckDeadline field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SubscriptionSettings) GetAckDeadlineOk() (*string, bool) { + if o == nil || IsNil(o.AckDeadline) { + return nil, false + } + return o.AckDeadline, true +} + +// HasAckDeadline returns a boolean if a field has been set. +func (o *SubscriptionSettings) HasAckDeadline() bool { + if o != nil && !IsNil(o.AckDeadline) { + return true + } + + return false +} + +// SetAckDeadline gets a reference to the given string and assigns it to the AckDeadline field. +func (o *SubscriptionSettings) SetAckDeadline(v string) { + o.AckDeadline = &v +} + +func (o SubscriptionSettings) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o SubscriptionSettings) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.AckDeadline) { + toSerialize["ackDeadline"] = o.AckDeadline + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *SubscriptionSettings) UnmarshalJSON(data []byte) (err error) { + varSubscriptionSettings := _SubscriptionSettings{} + + err = json.Unmarshal(data, &varSubscriptionSettings) + + if err != nil { + return err + } + + *o = SubscriptionSettings(varSubscriptionSettings) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "ackDeadline") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableSubscriptionSettings struct { + value *SubscriptionSettings + isSet bool +} + +func (v NullableSubscriptionSettings) Get() *SubscriptionSettings { + return v.value +} + +func (v *NullableSubscriptionSettings) Set(val *SubscriptionSettings) { + v.value = val + v.isSet = true +} + +func (v NullableSubscriptionSettings) IsSet() bool { + return v.isSet +} + +func (v *NullableSubscriptionSettings) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableSubscriptionSettings(val *SubscriptionSettings) *NullableSubscriptionSettings { + return &NullableSubscriptionSettings{value: val, isSet: true} +} + +func (v NullableSubscriptionSettings) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableSubscriptionSettings) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/pubsub/v1alphaapi/model_topic_response.go b/services/pubsub/v1alphaapi/model_topic_response.go new file mode 100644 index 000000000..9902a3bb5 --- /dev/null +++ b/services/pubsub/v1alphaapi/model_topic_response.go @@ -0,0 +1,370 @@ +/* +[ALPHA] STACKIT PubSub API + +This API provides endpoints for managing PubSubs. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" + "fmt" + "time" +) + +// checks if the TopicResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &TopicResponse{} + +// TopicResponse struct for TopicResponse +type TopicResponse struct { + // The point in time the resource was created. + CreateTime time.Time `json:"createTime"` + // The description is a longer text chosen by the user to provide more context for the resource. + Description *string `json:"description,omitempty"` + // The display name is a short name chosen by the user to identify the resource. + DisplayName string `json:"displayName" validate:"regexp=^[a-zA-Z0-9 -]*$"` + // An auto generated unique id which identifies the resource. + Id string `json:"id"` + Settings *TopicSettings `json:"settings,omitempty"` + State TopicResponseState `json:"state"` + // The URI for reaching the resource. + Uri *string `json:"uri,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _TopicResponse TopicResponse + +// NewTopicResponse instantiates a new TopicResponse 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 NewTopicResponse(createTime time.Time, displayName string, id string, state TopicResponseState) *TopicResponse { + this := TopicResponse{} + this.CreateTime = createTime + this.DisplayName = displayName + this.Id = id + this.State = state + return &this +} + +// NewTopicResponseWithDefaults instantiates a new TopicResponse 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 NewTopicResponseWithDefaults() *TopicResponse { + this := TopicResponse{} + return &this +} + +// GetCreateTime returns the CreateTime field value +func (o *TopicResponse) GetCreateTime() time.Time { + if o == nil { + var ret time.Time + return ret + } + + return o.CreateTime +} + +// GetCreateTimeOk returns a tuple with the CreateTime field value +// and a boolean to check if the value has been set. +func (o *TopicResponse) GetCreateTimeOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.CreateTime, true +} + +// SetCreateTime sets field value +func (o *TopicResponse) SetCreateTime(v time.Time) { + o.CreateTime = v +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *TopicResponse) GetDescription() string { + if o == nil || IsNil(o.Description) { + var ret string + return ret + } + return *o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TopicResponse) GetDescriptionOk() (*string, bool) { + if o == nil || IsNil(o.Description) { + return nil, false + } + return o.Description, true +} + +// HasDescription returns a boolean if a field has been set. +func (o *TopicResponse) HasDescription() bool { + if o != nil && !IsNil(o.Description) { + return true + } + + return false +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *TopicResponse) SetDescription(v string) { + o.Description = &v +} + +// GetDisplayName returns the DisplayName field value +func (o *TopicResponse) GetDisplayName() string { + if o == nil { + var ret string + return ret + } + + return o.DisplayName +} + +// GetDisplayNameOk returns a tuple with the DisplayName field value +// and a boolean to check if the value has been set. +func (o *TopicResponse) GetDisplayNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.DisplayName, true +} + +// SetDisplayName sets field value +func (o *TopicResponse) SetDisplayName(v string) { + o.DisplayName = v +} + +// GetId returns the Id field value +func (o *TopicResponse) GetId() string { + if o == nil { + var ret string + return ret + } + + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *TopicResponse) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value +func (o *TopicResponse) SetId(v string) { + o.Id = v +} + +// GetSettings returns the Settings field value if set, zero value otherwise. +func (o *TopicResponse) GetSettings() TopicSettings { + if o == nil || IsNil(o.Settings) { + var ret TopicSettings + return ret + } + return *o.Settings +} + +// GetSettingsOk returns a tuple with the Settings field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TopicResponse) GetSettingsOk() (*TopicSettings, bool) { + if o == nil || IsNil(o.Settings) { + return nil, false + } + return o.Settings, true +} + +// HasSettings returns a boolean if a field has been set. +func (o *TopicResponse) HasSettings() bool { + if o != nil && !IsNil(o.Settings) { + return true + } + + return false +} + +// SetSettings gets a reference to the given TopicSettings and assigns it to the Settings field. +func (o *TopicResponse) SetSettings(v TopicSettings) { + o.Settings = &v +} + +// GetState returns the State field value +func (o *TopicResponse) GetState() TopicResponseState { + if o == nil { + var ret TopicResponseState + return ret + } + + return o.State +} + +// GetStateOk returns a tuple with the State field value +// and a boolean to check if the value has been set. +func (o *TopicResponse) GetStateOk() (*TopicResponseState, bool) { + if o == nil { + return nil, false + } + return &o.State, true +} + +// SetState sets field value +func (o *TopicResponse) SetState(v TopicResponseState) { + o.State = v +} + +// GetUri returns the Uri field value if set, zero value otherwise. +func (o *TopicResponse) GetUri() string { + if o == nil || IsNil(o.Uri) { + var ret string + return ret + } + return *o.Uri +} + +// GetUriOk returns a tuple with the Uri field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TopicResponse) GetUriOk() (*string, bool) { + if o == nil || IsNil(o.Uri) { + return nil, false + } + return o.Uri, true +} + +// HasUri returns a boolean if a field has been set. +func (o *TopicResponse) HasUri() bool { + if o != nil && !IsNil(o.Uri) { + return true + } + + return false +} + +// SetUri gets a reference to the given string and assigns it to the Uri field. +func (o *TopicResponse) SetUri(v string) { + o.Uri = &v +} + +func (o TopicResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o TopicResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["createTime"] = o.CreateTime + if !IsNil(o.Description) { + toSerialize["description"] = o.Description + } + toSerialize["displayName"] = o.DisplayName + toSerialize["id"] = o.Id + if !IsNil(o.Settings) { + toSerialize["settings"] = o.Settings + } + toSerialize["state"] = o.State + if !IsNil(o.Uri) { + toSerialize["uri"] = o.Uri + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *TopicResponse) 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{ + "createTime", + "displayName", + "id", + "state", + } + + 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) + } + } + + varTopicResponse := _TopicResponse{} + + err = json.Unmarshal(data, &varTopicResponse) + + if err != nil { + return err + } + + *o = TopicResponse(varTopicResponse) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "createTime") + delete(additionalProperties, "description") + delete(additionalProperties, "displayName") + delete(additionalProperties, "id") + delete(additionalProperties, "settings") + delete(additionalProperties, "state") + delete(additionalProperties, "uri") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableTopicResponse struct { + value *TopicResponse + isSet bool +} + +func (v NullableTopicResponse) Get() *TopicResponse { + return v.value +} + +func (v *NullableTopicResponse) Set(val *TopicResponse) { + v.value = val + v.isSet = true +} + +func (v NullableTopicResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableTopicResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableTopicResponse(val *TopicResponse) *NullableTopicResponse { + return &NullableTopicResponse{value: val, isSet: true} +} + +func (v NullableTopicResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableTopicResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/pubsub/v1alphaapi/model_topic_response_state.go b/services/pubsub/v1alphaapi/model_topic_response_state.go new file mode 100644 index 000000000..9621f4a11 --- /dev/null +++ b/services/pubsub/v1alphaapi/model_topic_response_state.go @@ -0,0 +1,115 @@ +/* +[ALPHA] STACKIT PubSub API + +This API provides endpoints for managing PubSubs. + +API version: 1alpha.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package v1alphaapi + +import ( + "encoding/json" + "fmt" +) + +// TopicResponseState The current state of the resource. +type TopicResponseState string + +// List of topicResponse_state +const ( + TOPICRESPONSESTATE_RECONCILING TopicResponseState = "reconciling" + TOPICRESPONSESTATE_ACTIVE TopicResponseState = "active" + TOPICRESPONSESTATE_DELETING TopicResponseState = "deleting" + TOPICRESPONSESTATE_UNKNOWN_DEFAULT_OPEN_API TopicResponseState = "unknown_default_open_api" +) + +// All allowed values of TopicResponseState enum +var AllowedTopicResponseStateEnumValues = []TopicResponseState{ + "reconciling", + "active", + "deleting", + "unknown_default_open_api", +} + +func (v *TopicResponseState) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + enumTypeValue := TopicResponseState(value) + for _, existing := range AllowedTopicResponseStateEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + *v = TOPICRESPONSESTATE_UNKNOWN_DEFAULT_OPEN_API + return nil +} + +// NewTopicResponseStateFromValue returns a pointer to a valid TopicResponseState +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewTopicResponseStateFromValue(v string) (*TopicResponseState, error) { + ev := TopicResponseState(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for TopicResponseState: valid values are %v", v, AllowedTopicResponseStateEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v TopicResponseState) IsValid() bool { + for _, existing := range AllowedTopicResponseStateEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to topicResponse_state value +func (v TopicResponseState) Ptr() *TopicResponseState { + return &v +} + +type NullableTopicResponseState struct { + value *TopicResponseState + isSet bool +} + +func (v NullableTopicResponseState) Get() *TopicResponseState { + return v.value +} + +func (v *NullableTopicResponseState) Set(val *TopicResponseState) { + v.value = val + v.isSet = true +} + +func (v NullableTopicResponseState) IsSet() bool { + return v.isSet +} + +func (v *NullableTopicResponseState) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableTopicResponseState(val *TopicResponseState) *NullableTopicResponseState { + return &NullableTopicResponseState{value: val, isSet: true} +} + +func (v NullableTopicResponseState) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableTopicResponseState) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/pubsub/v1alphaapi/model_topic_settings.go b/services/pubsub/v1alphaapi/model_topic_settings.go new file mode 100644 index 000000000..54d251fb9 --- /dev/null +++ b/services/pubsub/v1alphaapi/model_topic_settings.go @@ -0,0 +1,196 @@ +/* +[ALPHA] STACKIT PubSub API + +This API provides endpoints for managing PubSubs. + +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 TopicSettings type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &TopicSettings{} + +// TopicSettings Configuration settings for the topic. +type TopicSettings struct { + // Whitelist of IPs in CIDR notation that can access the topic and its underlying subscriptions. + Acl []string `json:"acl,omitempty"` + // The maximum length of time a message is persisted in storage. Messages older than this duration are automatically discarded/deleted. **Format:** Must be a scalar duration: a number (integer or decimal) followed by a unit ('s', 'm', or 'h'). **Constraints:** - **Minimum:** \"1s\" - **Maximum:** \"168h\" (7 days) + Retention *string `json:"retention,omitempty" validate:"regexp=^[0-9]+(\\\\.[0-9]+)?(s|m|h)$"` + AdditionalProperties map[string]interface{} +} + +type _TopicSettings TopicSettings + +// NewTopicSettings instantiates a new TopicSettings 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 NewTopicSettings() *TopicSettings { + this := TopicSettings{} + var retention string = "168h" + this.Retention = &retention + return &this +} + +// NewTopicSettingsWithDefaults instantiates a new TopicSettings 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 NewTopicSettingsWithDefaults() *TopicSettings { + this := TopicSettings{} + var retention string = "168h" + this.Retention = &retention + return &this +} + +// GetAcl returns the Acl field value if set, zero value otherwise. +func (o *TopicSettings) GetAcl() []string { + if o == nil || IsNil(o.Acl) { + var ret []string + return ret + } + return o.Acl +} + +// GetAclOk returns a tuple with the Acl field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TopicSettings) GetAclOk() ([]string, bool) { + if o == nil || IsNil(o.Acl) { + return nil, false + } + return o.Acl, true +} + +// HasAcl returns a boolean if a field has been set. +func (o *TopicSettings) HasAcl() bool { + if o != nil && !IsNil(o.Acl) { + return true + } + + return false +} + +// SetAcl gets a reference to the given []string and assigns it to the Acl field. +func (o *TopicSettings) SetAcl(v []string) { + o.Acl = v +} + +// GetRetention returns the Retention field value if set, zero value otherwise. +func (o *TopicSettings) GetRetention() string { + if o == nil || IsNil(o.Retention) { + var ret string + return ret + } + return *o.Retention +} + +// GetRetentionOk returns a tuple with the Retention field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TopicSettings) GetRetentionOk() (*string, bool) { + if o == nil || IsNil(o.Retention) { + return nil, false + } + return o.Retention, true +} + +// HasRetention returns a boolean if a field has been set. +func (o *TopicSettings) HasRetention() bool { + if o != nil && !IsNil(o.Retention) { + return true + } + + return false +} + +// SetRetention gets a reference to the given string and assigns it to the Retention field. +func (o *TopicSettings) SetRetention(v string) { + o.Retention = &v +} + +func (o TopicSettings) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o TopicSettings) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Acl) { + toSerialize["acl"] = o.Acl + } + if !IsNil(o.Retention) { + toSerialize["retention"] = o.Retention + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *TopicSettings) UnmarshalJSON(data []byte) (err error) { + varTopicSettings := _TopicSettings{} + + err = json.Unmarshal(data, &varTopicSettings) + + if err != nil { + return err + } + + *o = TopicSettings(varTopicSettings) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "acl") + delete(additionalProperties, "retention") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableTopicSettings struct { + value *TopicSettings + isSet bool +} + +func (v NullableTopicSettings) Get() *TopicSettings { + return v.value +} + +func (v *NullableTopicSettings) Set(val *TopicSettings) { + v.value = val + v.isSet = true +} + +func (v NullableTopicSettings) IsSet() bool { + return v.isSet +} + +func (v *NullableTopicSettings) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableTopicSettings(val *TopicSettings) *NullableTopicSettings { + return &NullableTopicSettings{value: val, isSet: true} +} + +func (v NullableTopicSettings) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableTopicSettings) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/pubsub/v1alphaapi/model_update_subscription_payload.go b/services/pubsub/v1alphaapi/model_update_subscription_payload.go new file mode 100644 index 000000000..c8081b40d --- /dev/null +++ b/services/pubsub/v1alphaapi/model_update_subscription_payload.go @@ -0,0 +1,229 @@ +/* +[ALPHA] STACKIT PubSub API + +This API provides endpoints for managing PubSubs. + +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 UpdateSubscriptionPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &UpdateSubscriptionPayload{} + +// UpdateSubscriptionPayload struct for UpdateSubscriptionPayload +type UpdateSubscriptionPayload struct { + // The description is a longer text chosen by the user to provide more context for the resource. + Description *string `json:"description,omitempty"` + // The display name is a short name chosen by the user to identify the resource. + DisplayName *string `json:"displayName,omitempty" validate:"regexp=^[a-zA-Z0-9 -]*$"` + Settings *SubscriptionSettings `json:"settings,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _UpdateSubscriptionPayload UpdateSubscriptionPayload + +// NewUpdateSubscriptionPayload instantiates a new UpdateSubscriptionPayload 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 NewUpdateSubscriptionPayload() *UpdateSubscriptionPayload { + this := UpdateSubscriptionPayload{} + return &this +} + +// NewUpdateSubscriptionPayloadWithDefaults instantiates a new UpdateSubscriptionPayload 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 NewUpdateSubscriptionPayloadWithDefaults() *UpdateSubscriptionPayload { + this := UpdateSubscriptionPayload{} + return &this +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *UpdateSubscriptionPayload) GetDescription() string { + if o == nil || IsNil(o.Description) { + var ret string + return ret + } + return *o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateSubscriptionPayload) GetDescriptionOk() (*string, bool) { + if o == nil || IsNil(o.Description) { + return nil, false + } + return o.Description, true +} + +// HasDescription returns a boolean if a field has been set. +func (o *UpdateSubscriptionPayload) HasDescription() bool { + if o != nil && !IsNil(o.Description) { + return true + } + + return false +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *UpdateSubscriptionPayload) SetDescription(v string) { + o.Description = &v +} + +// GetDisplayName returns the DisplayName field value if set, zero value otherwise. +func (o *UpdateSubscriptionPayload) GetDisplayName() string { + if o == nil || IsNil(o.DisplayName) { + var ret string + return ret + } + return *o.DisplayName +} + +// GetDisplayNameOk returns a tuple with the DisplayName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateSubscriptionPayload) GetDisplayNameOk() (*string, bool) { + if o == nil || IsNil(o.DisplayName) { + return nil, false + } + return o.DisplayName, true +} + +// HasDisplayName returns a boolean if a field has been set. +func (o *UpdateSubscriptionPayload) HasDisplayName() bool { + if o != nil && !IsNil(o.DisplayName) { + return true + } + + return false +} + +// SetDisplayName gets a reference to the given string and assigns it to the DisplayName field. +func (o *UpdateSubscriptionPayload) SetDisplayName(v string) { + o.DisplayName = &v +} + +// GetSettings returns the Settings field value if set, zero value otherwise. +func (o *UpdateSubscriptionPayload) GetSettings() SubscriptionSettings { + if o == nil || IsNil(o.Settings) { + var ret SubscriptionSettings + return ret + } + return *o.Settings +} + +// GetSettingsOk returns a tuple with the Settings field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateSubscriptionPayload) GetSettingsOk() (*SubscriptionSettings, bool) { + if o == nil || IsNil(o.Settings) { + return nil, false + } + return o.Settings, true +} + +// HasSettings returns a boolean if a field has been set. +func (o *UpdateSubscriptionPayload) HasSettings() bool { + if o != nil && !IsNil(o.Settings) { + return true + } + + return false +} + +// SetSettings gets a reference to the given SubscriptionSettings and assigns it to the Settings field. +func (o *UpdateSubscriptionPayload) SetSettings(v SubscriptionSettings) { + o.Settings = &v +} + +func (o UpdateSubscriptionPayload) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o UpdateSubscriptionPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Description) { + toSerialize["description"] = o.Description + } + if !IsNil(o.DisplayName) { + toSerialize["displayName"] = o.DisplayName + } + if !IsNil(o.Settings) { + toSerialize["settings"] = o.Settings + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *UpdateSubscriptionPayload) UnmarshalJSON(data []byte) (err error) { + varUpdateSubscriptionPayload := _UpdateSubscriptionPayload{} + + err = json.Unmarshal(data, &varUpdateSubscriptionPayload) + + if err != nil { + return err + } + + *o = UpdateSubscriptionPayload(varUpdateSubscriptionPayload) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "description") + delete(additionalProperties, "displayName") + delete(additionalProperties, "settings") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableUpdateSubscriptionPayload struct { + value *UpdateSubscriptionPayload + isSet bool +} + +func (v NullableUpdateSubscriptionPayload) Get() *UpdateSubscriptionPayload { + return v.value +} + +func (v *NullableUpdateSubscriptionPayload) Set(val *UpdateSubscriptionPayload) { + v.value = val + v.isSet = true +} + +func (v NullableUpdateSubscriptionPayload) IsSet() bool { + return v.isSet +} + +func (v *NullableUpdateSubscriptionPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableUpdateSubscriptionPayload(val *UpdateSubscriptionPayload) *NullableUpdateSubscriptionPayload { + return &NullableUpdateSubscriptionPayload{value: val, isSet: true} +} + +func (v NullableUpdateSubscriptionPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableUpdateSubscriptionPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/pubsub/v1alphaapi/model_update_topic_payload.go b/services/pubsub/v1alphaapi/model_update_topic_payload.go new file mode 100644 index 000000000..462b10a75 --- /dev/null +++ b/services/pubsub/v1alphaapi/model_update_topic_payload.go @@ -0,0 +1,229 @@ +/* +[ALPHA] STACKIT PubSub API + +This API provides endpoints for managing PubSubs. + +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 UpdateTopicPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &UpdateTopicPayload{} + +// UpdateTopicPayload struct for UpdateTopicPayload +type UpdateTopicPayload struct { + // The description is a longer text chosen by the user to provide more context for the resource. + Description *string `json:"description,omitempty"` + // The display name is a short name chosen by the user to identify the resource. + DisplayName *string `json:"displayName,omitempty" validate:"regexp=^[a-zA-Z0-9 -]*$"` + Settings *TopicSettings `json:"settings,omitempty"` + AdditionalProperties map[string]interface{} +} + +type _UpdateTopicPayload UpdateTopicPayload + +// NewUpdateTopicPayload instantiates a new UpdateTopicPayload 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 NewUpdateTopicPayload() *UpdateTopicPayload { + this := UpdateTopicPayload{} + return &this +} + +// NewUpdateTopicPayloadWithDefaults instantiates a new UpdateTopicPayload 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 NewUpdateTopicPayloadWithDefaults() *UpdateTopicPayload { + this := UpdateTopicPayload{} + return &this +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *UpdateTopicPayload) GetDescription() string { + if o == nil || IsNil(o.Description) { + var ret string + return ret + } + return *o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateTopicPayload) GetDescriptionOk() (*string, bool) { + if o == nil || IsNil(o.Description) { + return nil, false + } + return o.Description, true +} + +// HasDescription returns a boolean if a field has been set. +func (o *UpdateTopicPayload) HasDescription() bool { + if o != nil && !IsNil(o.Description) { + return true + } + + return false +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *UpdateTopicPayload) SetDescription(v string) { + o.Description = &v +} + +// GetDisplayName returns the DisplayName field value if set, zero value otherwise. +func (o *UpdateTopicPayload) GetDisplayName() string { + if o == nil || IsNil(o.DisplayName) { + var ret string + return ret + } + return *o.DisplayName +} + +// GetDisplayNameOk returns a tuple with the DisplayName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateTopicPayload) GetDisplayNameOk() (*string, bool) { + if o == nil || IsNil(o.DisplayName) { + return nil, false + } + return o.DisplayName, true +} + +// HasDisplayName returns a boolean if a field has been set. +func (o *UpdateTopicPayload) HasDisplayName() bool { + if o != nil && !IsNil(o.DisplayName) { + return true + } + + return false +} + +// SetDisplayName gets a reference to the given string and assigns it to the DisplayName field. +func (o *UpdateTopicPayload) SetDisplayName(v string) { + o.DisplayName = &v +} + +// GetSettings returns the Settings field value if set, zero value otherwise. +func (o *UpdateTopicPayload) GetSettings() TopicSettings { + if o == nil || IsNil(o.Settings) { + var ret TopicSettings + return ret + } + return *o.Settings +} + +// GetSettingsOk returns a tuple with the Settings field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateTopicPayload) GetSettingsOk() (*TopicSettings, bool) { + if o == nil || IsNil(o.Settings) { + return nil, false + } + return o.Settings, true +} + +// HasSettings returns a boolean if a field has been set. +func (o *UpdateTopicPayload) HasSettings() bool { + if o != nil && !IsNil(o.Settings) { + return true + } + + return false +} + +// SetSettings gets a reference to the given TopicSettings and assigns it to the Settings field. +func (o *UpdateTopicPayload) SetSettings(v TopicSettings) { + o.Settings = &v +} + +func (o UpdateTopicPayload) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o UpdateTopicPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Description) { + toSerialize["description"] = o.Description + } + if !IsNil(o.DisplayName) { + toSerialize["displayName"] = o.DisplayName + } + if !IsNil(o.Settings) { + toSerialize["settings"] = o.Settings + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + + return toSerialize, nil +} + +func (o *UpdateTopicPayload) UnmarshalJSON(data []byte) (err error) { + varUpdateTopicPayload := _UpdateTopicPayload{} + + err = json.Unmarshal(data, &varUpdateTopicPayload) + + if err != nil { + return err + } + + *o = UpdateTopicPayload(varUpdateTopicPayload) + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(data, &additionalProperties); err == nil { + delete(additionalProperties, "description") + delete(additionalProperties, "displayName") + delete(additionalProperties, "settings") + o.AdditionalProperties = additionalProperties + } + + return err +} + +type NullableUpdateTopicPayload struct { + value *UpdateTopicPayload + isSet bool +} + +func (v NullableUpdateTopicPayload) Get() *UpdateTopicPayload { + return v.value +} + +func (v *NullableUpdateTopicPayload) Set(val *UpdateTopicPayload) { + v.value = val + v.isSet = true +} + +func (v NullableUpdateTopicPayload) IsSet() bool { + return v.isSet +} + +func (v *NullableUpdateTopicPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableUpdateTopicPayload(val *UpdateTopicPayload) *NullableUpdateTopicPayload { + return &NullableUpdateTopicPayload{value: val, isSet: true} +} + +func (v NullableUpdateTopicPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableUpdateTopicPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/pubsub/v1alphaapi/response.go b/services/pubsub/v1alphaapi/response.go new file mode 100644 index 000000000..870dd2471 --- /dev/null +++ b/services/pubsub/v1alphaapi/response.go @@ -0,0 +1,47 @@ +/* +[ALPHA] STACKIT PubSub API + +This API provides endpoints for managing PubSubs. + +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/pubsub/v1alphaapi/utils.go b/services/pubsub/v1alphaapi/utils.go new file mode 100644 index 000000000..8c43d8ed0 --- /dev/null +++ b/services/pubsub/v1alphaapi/utils.go @@ -0,0 +1,361 @@ +/* +[ALPHA] STACKIT PubSub API + +This API provides endpoints for managing PubSubs. + +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...) +}