diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b4d5c8e2..885414e81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ ## Release (2025-XX-XX) -- `stackitmarketplace`: [v1.1.0](services/stackitmarketplace/CHANGELOG.md#v110-2025-05-13) - - **Breaking Change:** Added organization id to `VendorSubscription` +- `stackitmarketplace`: + - [v1.2.0](services/stackitmarketplace/CHANGELOG.md#v120-2025-05-14) + - **Feature:** Add new method `VendorsSubscriptionsReject` + - [v1.1.0](services/stackitmarketplace/CHANGELOG.md#v110-2025-05-13) + - **Breaking Change:** Added organization id to `VendorSubscription` - `ske`: [v0.22.4](services/ske/CHANGELOG.md#v0224-2025-05-13) - **Feature:** Added `ClusterError` diff --git a/services/stackitmarketplace/CHANGELOG.md b/services/stackitmarketplace/CHANGELOG.md index e8bb1fc1a..7e9be5288 100644 --- a/services/stackitmarketplace/CHANGELOG.md +++ b/services/stackitmarketplace/CHANGELOG.md @@ -1,3 +1,6 @@ +## v1.2.0 (2025-05-14) +- **Feature:** Add new method `VendorsSubscriptionsReject` + ## v1.1.0 (2025-05-13) - **Breaking Change:** Added organization id to `VendorSubscription` diff --git a/services/stackitmarketplace/api_default.go b/services/stackitmarketplace/api_default.go index 843e0601b..cadd26d1a 100644 --- a/services/stackitmarketplace/api_default.go +++ b/services/stackitmarketplace/api_default.go @@ -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) + } + }) + }