From 8a16f490dbb45daf433ed0d57b7ea8e696bcd5df Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Tue, 13 May 2025 14:57:56 +0000 Subject: [PATCH] Generate stackitmarketplace --- services/stackitmarketplace/api_default.go | 170 +++++++++++++++++- .../stackitmarketplace/api_default_test.go | 49 +++++ .../model_organization_id.go | 80 +++++++++ .../stackitmarketplace/model_project_id.go | 2 +- .../model_vendor_subscription.go | 45 ++++- 5 files changed, 342 insertions(+), 4 deletions(-) create mode 100644 services/stackitmarketplace/model_organization_id.go diff --git a/services/stackitmarketplace/api_default.go b/services/stackitmarketplace/api_default.go index aed62f184..cadd26d1a 100644 --- a/services/stackitmarketplace/api_default.go +++ b/services/stackitmarketplace/api_default.go @@ -1071,9 +1071,9 @@ func (r ApiListVendorSubscriptionsRequest) Execute() (*ListVendorSubscriptionsRe } /* -ListVendorSubscriptions: List all subscriptions +ListVendorSubscriptions: List all subscriptions of a project. -List all subscriptions. +List all subscriptions of a project. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param projectId The project ID. @@ -1272,3 +1272,169 @@ func (a *APIClient) ResolveCustomerExecute(ctx context.Context, projectId string } return r.Execute() } + +type ApiVendorsSubscriptionsRejectRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + subscriptionId string +} + +func (r ApiVendorsSubscriptionsRejectRequest) Execute() error { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.VendorsSubscriptionsReject") + if err != nil { + return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1/vendors/projects/{projectId}/subscriptions/{subscriptionId}/reject" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -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 fmt.Errorf("projectId must have at least 36 elements") + } + if strlen(r.projectId) > 36 { + return fmt.Errorf("projectId must have less than 36 elements") + } + if strlen(r.subscriptionId) < 36 { + return fmt.Errorf("subscriptionId must have at least 36 elements") + } + if strlen(r.subscriptionId) > 36 { + return fmt.Errorf("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 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{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v ErrorResponse + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v ErrorResponse + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return newErr + } + if localVarHTTPResponse.StatusCode == 403 { + var v ErrorResponse + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v ErrorResponse + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return newErr + } + + return nil +} + +/* +VendorsSubscriptionsReject: Reject a subscription + +Reject a subscription (in any lifecycle state). Only available for subscriptions to products with lifecycle state `PRODUCT_PREVIEW`. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId The project ID. + @param subscriptionId The subscription ID. + @return ApiVendorsSubscriptionsRejectRequest +*/ +func (a *APIClient) VendorsSubscriptionsReject(ctx context.Context, projectId string, subscriptionId string) ApiVendorsSubscriptionsRejectRequest { + return ApiVendorsSubscriptionsRejectRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + subscriptionId: subscriptionId, + } +} + +func (a *APIClient) VendorsSubscriptionsRejectExecute(ctx context.Context, projectId string, subscriptionId string) error { + r := ApiVendorsSubscriptionsRejectRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + subscriptionId: subscriptionId, + } + return r.Execute() +} diff --git a/services/stackitmarketplace/api_default_test.go b/services/stackitmarketplace/api_default_test.go index 3f0b04d36..a091af679 100644 --- a/services/stackitmarketplace/api_default_test.go +++ b/services/stackitmarketplace/api_default_test.go @@ -377,4 +377,53 @@ func Test_stackitmarketplace_DefaultApiService(t *testing.T) { } }) + t.Run("Test DefaultApiService VendorsSubscriptionsReject", func(t *testing.T) { + _apiUrlPath := "/v1/vendors/projects/{projectId}/subscriptions/{subscriptionId}/reject" + projectIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + subscriptionIdValue := uuid.NewString() + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"subscriptionId"+"}", url.PathEscape(ParameterValueToString(subscriptionIdValue, "subscriptionId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for stackitmarketplace_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + projectId := projectIdValue + subscriptionId := subscriptionIdValue + + reqErr := apiClient.VendorsSubscriptionsReject(context.Background(), projectId, subscriptionId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + }) + } diff --git a/services/stackitmarketplace/model_organization_id.go b/services/stackitmarketplace/model_organization_id.go new file mode 100644 index 000000000..1d9dccbc6 --- /dev/null +++ b/services/stackitmarketplace/model_organization_id.go @@ -0,0 +1,80 @@ +/* +STACKIT Marketplace API + +API to manage STACKIT Marketplace. + +API version: 1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package stackitmarketplace + +import ( + "encoding/json" +) + +// checks if the OrganizationId type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &OrganizationId{} + +// OrganizationId The associated organization ID. +type OrganizationId struct { +} + +// NewOrganizationId instantiates a new OrganizationId 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 NewOrganizationId() *OrganizationId { + this := OrganizationId{} + return &this +} + +// NewOrganizationIdWithDefaults instantiates a new OrganizationId 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 NewOrganizationIdWithDefaults() *OrganizationId { + this := OrganizationId{} + return &this +} + +func (o OrganizationId) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + return toSerialize, nil +} + +type NullableOrganizationId struct { + value *OrganizationId + isSet bool +} + +func (v NullableOrganizationId) Get() *OrganizationId { + return v.value +} + +func (v *NullableOrganizationId) Set(val *OrganizationId) { + v.value = val + v.isSet = true +} + +func (v NullableOrganizationId) IsSet() bool { + return v.isSet +} + +func (v *NullableOrganizationId) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableOrganizationId(val *OrganizationId) *NullableOrganizationId { + return &NullableOrganizationId{value: val, isSet: true} +} + +func (v NullableOrganizationId) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableOrganizationId) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/stackitmarketplace/model_project_id.go b/services/stackitmarketplace/model_project_id.go index b76c2bbd0..93347f9c6 100644 --- a/services/stackitmarketplace/model_project_id.go +++ b/services/stackitmarketplace/model_project_id.go @@ -17,7 +17,7 @@ import ( // checks if the ProjectId type satisfies the MappedNullable interface at compile time var _ MappedNullable = &ProjectId{} -// ProjectId The associated consumer project ID. +// ProjectId The associated project ID. type ProjectId struct { } diff --git a/services/stackitmarketplace/model_vendor_subscription.go b/services/stackitmarketplace/model_vendor_subscription.go index 91365b7cf..28b8712f6 100644 --- a/services/stackitmarketplace/model_vendor_subscription.go +++ b/services/stackitmarketplace/model_vendor_subscription.go @@ -37,6 +37,26 @@ func setVendorSubscriptionGetLifecycleStateAttributeType(arg *VendorSubscription *arg = &val } +/* + types and functions for organizationId +*/ + +// isModel +type VendorSubscriptionGetOrganizationIdAttributeType = *OrganizationId +type VendorSubscriptionGetOrganizationIdArgType = OrganizationId +type VendorSubscriptionGetOrganizationIdRetType = OrganizationId + +func getVendorSubscriptionGetOrganizationIdAttributeTypeOk(arg VendorSubscriptionGetOrganizationIdAttributeType) (ret VendorSubscriptionGetOrganizationIdRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setVendorSubscriptionGetOrganizationIdAttributeType(arg *VendorSubscriptionGetOrganizationIdAttributeType, val VendorSubscriptionGetOrganizationIdRetType) { + *arg = &val +} + /* types and functions for product */ @@ -102,6 +122,8 @@ type VendorSubscription struct { // REQUIRED LifecycleState VendorSubscriptionGetLifecycleStateAttributeType `json:"lifecycleState"` // REQUIRED + OrganizationId VendorSubscriptionGetOrganizationIdAttributeType `json:"organizationId"` + // REQUIRED Product VendorSubscriptionGetProductAttributeType `json:"product"` // REQUIRED ProjectId VendorSubscriptionGetProjectIdAttributeType `json:"projectId"` @@ -115,9 +137,10 @@ type _VendorSubscription VendorSubscription // 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 NewVendorSubscription(lifecycleState VendorSubscriptionGetLifecycleStateArgType, product VendorSubscriptionGetProductArgType, projectId VendorSubscriptionGetProjectIdArgType, subscriptionId VendorSubscriptionGetSubscriptionIdArgType) *VendorSubscription { +func NewVendorSubscription(lifecycleState VendorSubscriptionGetLifecycleStateArgType, organizationId VendorSubscriptionGetOrganizationIdArgType, product VendorSubscriptionGetProductArgType, projectId VendorSubscriptionGetProjectIdArgType, subscriptionId VendorSubscriptionGetSubscriptionIdArgType) *VendorSubscription { this := VendorSubscription{} setVendorSubscriptionGetLifecycleStateAttributeType(&this.LifecycleState, lifecycleState) + setVendorSubscriptionGetOrganizationIdAttributeType(&this.OrganizationId, organizationId) setVendorSubscriptionGetProductAttributeType(&this.Product, product) setVendorSubscriptionGetProjectIdAttributeType(&this.ProjectId, projectId) setVendorSubscriptionGetSubscriptionIdAttributeType(&this.SubscriptionId, subscriptionId) @@ -149,6 +172,23 @@ func (o *VendorSubscription) SetLifecycleState(v VendorSubscriptionGetLifecycleS setVendorSubscriptionGetLifecycleStateAttributeType(&o.LifecycleState, v) } +// GetOrganizationId returns the OrganizationId field value +func (o *VendorSubscription) GetOrganizationId() (ret VendorSubscriptionGetOrganizationIdRetType) { + ret, _ = o.GetOrganizationIdOk() + return ret +} + +// GetOrganizationIdOk returns a tuple with the OrganizationId field value +// and a boolean to check if the value has been set. +func (o *VendorSubscription) GetOrganizationIdOk() (ret VendorSubscriptionGetOrganizationIdRetType, ok bool) { + return getVendorSubscriptionGetOrganizationIdAttributeTypeOk(o.OrganizationId) +} + +// SetOrganizationId sets field value +func (o *VendorSubscription) SetOrganizationId(v VendorSubscriptionGetOrganizationIdRetType) { + setVendorSubscriptionGetOrganizationIdAttributeType(&o.OrganizationId, v) +} + // GetProduct returns the Product field value func (o *VendorSubscription) GetProduct() (ret VendorSubscriptionGetProductRetType) { ret, _ = o.GetProductOk() @@ -205,6 +245,9 @@ func (o VendorSubscription) ToMap() (map[string]interface{}, error) { if val, ok := getVendorSubscriptionGetLifecycleStateAttributeTypeOk(o.LifecycleState); ok { toSerialize["LifecycleState"] = val } + if val, ok := getVendorSubscriptionGetOrganizationIdAttributeTypeOk(o.OrganizationId); ok { + toSerialize["OrganizationId"] = val + } if val, ok := getVendorSubscriptionGetProductAttributeTypeOk(o.Product); ok { toSerialize["Product"] = val }