From bfbc4c588347d7d4c25f2e5bf94dcbe6bd2e3b9a Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Thu, 12 Feb 2026 09:00:56 +0000 Subject: [PATCH] Generate rabbitmq --- services/rabbitmq/api_default_test.go | 1059 ----------------- .../rabbitmq/model_instance_parameters.go | 115 +- .../model_instance_parameters_test.go | 47 - services/rabbitmq/oas_commit | 1 + 4 files changed, 6 insertions(+), 1216 deletions(-) delete mode 100644 services/rabbitmq/api_default_test.go create mode 100644 services/rabbitmq/oas_commit diff --git a/services/rabbitmq/api_default_test.go b/services/rabbitmq/api_default_test.go deleted file mode 100644 index b0ac1b36d..000000000 --- a/services/rabbitmq/api_default_test.go +++ /dev/null @@ -1,1059 +0,0 @@ -/* -STACKIT RabbitMQ API - -Testing DefaultApiService - -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); - -package rabbitmq - -import ( - "context" - "encoding/json" - "net/http" - "net/http/httptest" - "net/url" - "strings" - "testing" - - "github.com/stackitcloud/stackit-sdk-go/core/config" -) - -func Test_rabbitmq_DefaultApiService(t *testing.T) { - - t.Run("Test DefaultApiService CreateBackup", func(t *testing.T) { - _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}/backups" - instanceIdValue := "instanceId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1) - projectIdValue := "projectId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) - - testDefaultApiServeMux := http.NewServeMux() - testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { - data := []CreateBackupResponseItem{} - w.Header().Add("Content-Type", "application/json") - json.NewEncoder(w).Encode(data) - }) - 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 rabbitmq_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) - } - - instanceId := instanceIdValue - projectId := projectIdValue - - resp, reqErr := apiClient.CreateBackup(context.Background(), instanceId, projectId).Execute() - - if reqErr != nil { - t.Fatalf("error in call: %v", reqErr) - } - if IsNil(resp) { - t.Fatalf("response not present") - } - }) - - t.Run("Test DefaultApiService CreateCredentials", func(t *testing.T) { - _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}/credentials" - projectIdValue := "projectId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) - instanceIdValue := "instanceId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1) - - testDefaultApiServeMux := http.NewServeMux() - testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { - data := CredentialsResponse{} - w.Header().Add("Content-Type", "application/json") - json.NewEncoder(w).Encode(data) - }) - 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 rabbitmq_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 - instanceId := instanceIdValue - - resp, reqErr := apiClient.CreateCredentials(context.Background(), projectId, instanceId).Execute() - - if reqErr != nil { - t.Fatalf("error in call: %v", reqErr) - } - if IsNil(resp) { - t.Fatalf("response not present") - } - }) - - t.Run("Test DefaultApiService CreateInstance", func(t *testing.T) { - _apiUrlPath := "/v1/projects/{projectId}/instances" - projectIdValue := "projectId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) - - testDefaultApiServeMux := http.NewServeMux() - testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { - data := CreateInstanceResponse{} - w.Header().Add("Content-Type", "application/json") - json.NewEncoder(w).Encode(data) - }) - 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 rabbitmq_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 - createInstancePayload := CreateInstancePayload{} - - resp, reqErr := apiClient.CreateInstance(context.Background(), projectId).CreateInstancePayload(createInstancePayload).Execute() - - if reqErr != nil { - t.Fatalf("error in call: %v", reqErr) - } - if IsNil(resp) { - t.Fatalf("response not present") - } - }) - - t.Run("Test DefaultApiService DeleteCredentials", func(t *testing.T) { - _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}/credentials/{credentialsId}" - projectIdValue := "projectId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) - instanceIdValue := "instanceId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1) - credentialsIdValue := "credentialsId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"credentialsId"+"}", url.PathEscape(ParameterValueToString(credentialsIdValue, "credentialsId")), -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 rabbitmq_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 - instanceId := instanceIdValue - credentialsId := credentialsIdValue - - reqErr := apiClient.DeleteCredentials(context.Background(), projectId, instanceId, credentialsId).Execute() - - if reqErr != nil { - t.Fatalf("error in call: %v", reqErr) - } - }) - - t.Run("Test DefaultApiService DeleteInstance", func(t *testing.T) { - _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}" - projectIdValue := "projectId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) - instanceIdValue := "instanceId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -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 rabbitmq_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 - instanceId := instanceIdValue - - reqErr := apiClient.DeleteInstance(context.Background(), projectId, instanceId).Execute() - - if reqErr != nil { - t.Fatalf("error in call: %v", reqErr) - } - }) - - t.Run("Test DefaultApiService DownloadBackup", func(t *testing.T) { - _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}/backups/{backupId}/download" - backupIdValue := int32(123) - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"backupId"+"}", url.PathEscape(ParameterValueToString(backupIdValue, "backupId")), -1) - instanceIdValue := "instanceId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1) - projectIdValue := "projectId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) - - testDefaultApiServeMux := http.NewServeMux() - testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { - w.Header().Add("Content-Type", "application/octet-stream") - binaryData := []byte{0x42, 0x69} // Example binary data - w.Write(binaryData) - }) - 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 rabbitmq_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) - } - - backupId := backupIdValue - instanceId := instanceIdValue - projectId := projectIdValue - - resp, reqErr := apiClient.DownloadBackup(context.Background(), backupId, instanceId, projectId).Execute() - - if reqErr != nil { - t.Fatalf("error in call: %v", reqErr) - } - if IsNil(resp) { - t.Fatalf("response not present") - } - }) - - t.Run("Test DefaultApiService GetCredentials", func(t *testing.T) { - _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}/credentials/{credentialsId}" - projectIdValue := "projectId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) - instanceIdValue := "instanceId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1) - credentialsIdValue := "credentialsId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"credentialsId"+"}", url.PathEscape(ParameterValueToString(credentialsIdValue, "credentialsId")), -1) - - testDefaultApiServeMux := http.NewServeMux() - testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { - data := CredentialsResponse{} - w.Header().Add("Content-Type", "application/json") - json.NewEncoder(w).Encode(data) - }) - 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 rabbitmq_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 - instanceId := instanceIdValue - credentialsId := credentialsIdValue - - resp, reqErr := apiClient.GetCredentials(context.Background(), projectId, instanceId, credentialsId).Execute() - - if reqErr != nil { - t.Fatalf("error in call: %v", reqErr) - } - if IsNil(resp) { - t.Fatalf("response not present") - } - }) - - t.Run("Test DefaultApiService GetInstance", func(t *testing.T) { - _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}" - projectIdValue := "projectId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) - instanceIdValue := "instanceId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1) - - testDefaultApiServeMux := http.NewServeMux() - testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { - data := Instance{} - w.Header().Add("Content-Type", "application/json") - json.NewEncoder(w).Encode(data) - }) - 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 rabbitmq_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 - instanceId := instanceIdValue - - resp, reqErr := apiClient.GetInstance(context.Background(), projectId, instanceId).Execute() - - if reqErr != nil { - t.Fatalf("error in call: %v", reqErr) - } - if IsNil(resp) { - t.Fatalf("response not present") - } - }) - - t.Run("Test DefaultApiService GetMetrics", func(t *testing.T) { - _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}/metrics" - instanceIdValue := "instanceId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1) - projectIdValue := "projectId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) - - testDefaultApiServeMux := http.NewServeMux() - testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { - data := GetMetricsResponse{} - w.Header().Add("Content-Type", "application/json") - json.NewEncoder(w).Encode(data) - }) - 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 rabbitmq_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) - } - - instanceId := instanceIdValue - projectId := projectIdValue - - resp, reqErr := apiClient.GetMetrics(context.Background(), instanceId, projectId).Execute() - - if reqErr != nil { - t.Fatalf("error in call: %v", reqErr) - } - if IsNil(resp) { - t.Fatalf("response not present") - } - }) - - t.Run("Test DefaultApiService ListBackups", func(t *testing.T) { - _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}/backups" - instanceIdValue := "instanceId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1) - projectIdValue := "projectId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) - - testDefaultApiServeMux := http.NewServeMux() - testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { - data := ListBackupsResponse{} - w.Header().Add("Content-Type", "application/json") - json.NewEncoder(w).Encode(data) - }) - 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 rabbitmq_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) - } - - instanceId := instanceIdValue - projectId := projectIdValue - - resp, reqErr := apiClient.ListBackups(context.Background(), instanceId, projectId).Execute() - - if reqErr != nil { - t.Fatalf("error in call: %v", reqErr) - } - if IsNil(resp) { - t.Fatalf("response not present") - } - }) - - t.Run("Test DefaultApiService ListCredentials", func(t *testing.T) { - _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}/credentials" - projectIdValue := "projectId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) - instanceIdValue := "instanceId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1) - - testDefaultApiServeMux := http.NewServeMux() - testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { - data := ListCredentialsResponse{} - w.Header().Add("Content-Type", "application/json") - json.NewEncoder(w).Encode(data) - }) - 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 rabbitmq_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 - instanceId := instanceIdValue - - resp, reqErr := apiClient.ListCredentials(context.Background(), projectId, instanceId).Execute() - - if reqErr != nil { - t.Fatalf("error in call: %v", reqErr) - } - if IsNil(resp) { - t.Fatalf("response not present") - } - }) - - t.Run("Test DefaultApiService ListInstances", func(t *testing.T) { - _apiUrlPath := "/v1/projects/{projectId}/instances" - projectIdValue := "projectId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) - - testDefaultApiServeMux := http.NewServeMux() - testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { - data := ListInstancesResponse{} - w.Header().Add("Content-Type", "application/json") - json.NewEncoder(w).Encode(data) - }) - 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 rabbitmq_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 - - resp, reqErr := apiClient.ListInstances(context.Background(), projectId).Execute() - - if reqErr != nil { - t.Fatalf("error in call: %v", reqErr) - } - if IsNil(resp) { - t.Fatalf("response not present") - } - }) - - t.Run("Test DefaultApiService ListOfferings", func(t *testing.T) { - _apiUrlPath := "/v1/projects/{projectId}/offerings" - projectIdValue := "projectId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) - - testDefaultApiServeMux := http.NewServeMux() - testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { - data := ListOfferingsResponse{} - w.Header().Add("Content-Type", "application/json") - json.NewEncoder(w).Encode(data) - }) - 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 rabbitmq_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 - - resp, reqErr := apiClient.ListOfferings(context.Background(), projectId).Execute() - - if reqErr != nil { - t.Fatalf("error in call: %v", reqErr) - } - if IsNil(resp) { - t.Fatalf("response not present") - } - }) - - t.Run("Test DefaultApiService ListRestores", func(t *testing.T) { - _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}/restores" - instanceIdValue := "instanceId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1) - projectIdValue := "projectId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) - - testDefaultApiServeMux := http.NewServeMux() - testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { - data := ListRestoresResponse{} - w.Header().Add("Content-Type", "application/json") - json.NewEncoder(w).Encode(data) - }) - 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 rabbitmq_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) - } - - instanceId := instanceIdValue - projectId := projectIdValue - - resp, reqErr := apiClient.ListRestores(context.Background(), instanceId, projectId).Execute() - - if reqErr != nil { - t.Fatalf("error in call: %v", reqErr) - } - if IsNil(resp) { - t.Fatalf("response not present") - } - }) - - t.Run("Test DefaultApiService PartialUpdateInstance", func(t *testing.T) { - _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}" - projectIdValue := "projectId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) - instanceIdValue := "instanceId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -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 rabbitmq_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 - instanceId := instanceIdValue - partialUpdateInstancePayload := PartialUpdateInstancePayload{} - - reqErr := apiClient.PartialUpdateInstance(context.Background(), projectId, instanceId).PartialUpdateInstancePayload(partialUpdateInstancePayload).Execute() - - if reqErr != nil { - t.Fatalf("error in call: %v", reqErr) - } - }) - - t.Run("Test DefaultApiService TriggerRecreate", func(t *testing.T) { - _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}/recreate" - instanceIdValue := "instanceId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1) - projectIdValue := "projectId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) - - testDefaultApiServeMux := http.NewServeMux() - testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { - data := CreateInstanceResponse{} - w.Header().Add("Content-Type", "application/json") - json.NewEncoder(w).Encode(data) - }) - 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 rabbitmq_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) - } - - instanceId := instanceIdValue - projectId := projectIdValue - - resp, reqErr := apiClient.TriggerRecreate(context.Background(), instanceId, projectId).Execute() - - if reqErr != nil { - t.Fatalf("error in call: %v", reqErr) - } - if IsNil(resp) { - t.Fatalf("response not present") - } - }) - - t.Run("Test DefaultApiService TriggerRestart", func(t *testing.T) { - _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}/restart" - instanceIdValue := "instanceId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1) - projectIdValue := "projectId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) - - testDefaultApiServeMux := http.NewServeMux() - testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { - data := CreateInstanceResponse{} - w.Header().Add("Content-Type", "application/json") - json.NewEncoder(w).Encode(data) - }) - 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 rabbitmq_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) - } - - instanceId := instanceIdValue - projectId := projectIdValue - - resp, reqErr := apiClient.TriggerRestart(context.Background(), instanceId, projectId).Execute() - - if reqErr != nil { - t.Fatalf("error in call: %v", reqErr) - } - if IsNil(resp) { - t.Fatalf("response not present") - } - }) - - t.Run("Test DefaultApiService TriggerRestore", func(t *testing.T) { - _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}/backups/{backupId}/restore" - instanceIdValue := "instanceId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1) - projectIdValue := "projectId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) - backupIdValue := int32(123) - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"backupId"+"}", url.PathEscape(ParameterValueToString(backupIdValue, "backupId")), -1) - - testDefaultApiServeMux := http.NewServeMux() - testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { - data := TriggerRestoreResponse{} - w.Header().Add("Content-Type", "application/json") - json.NewEncoder(w).Encode(data) - }) - 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 rabbitmq_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) - } - - instanceId := instanceIdValue - projectId := projectIdValue - backupId := backupIdValue - - resp, reqErr := apiClient.TriggerRestore(context.Background(), instanceId, projectId, backupId).Execute() - - if reqErr != nil { - t.Fatalf("error in call: %v", reqErr) - } - if IsNil(resp) { - t.Fatalf("response not present") - } - }) - - t.Run("Test DefaultApiService UpdateBackupsConfig", func(t *testing.T) { - _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}/backups-config" - instanceIdValue := "instanceId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1) - projectIdValue := "projectId-value" - _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) - - testDefaultApiServeMux := http.NewServeMux() - testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { - data := UpdateBackupsConfigResponse{} - w.Header().Add("Content-Type", "application/json") - json.NewEncoder(w).Encode(data) - }) - 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 rabbitmq_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) - } - - instanceId := instanceIdValue - projectId := projectIdValue - updateBackupsConfigPayload := UpdateBackupsConfigPayload{} - - resp, reqErr := apiClient.UpdateBackupsConfig(context.Background(), instanceId, projectId).UpdateBackupsConfigPayload(updateBackupsConfigPayload).Execute() - - if reqErr != nil { - t.Fatalf("error in call: %v", reqErr) - } - if IsNil(resp) { - t.Fatalf("response not present") - } - }) - -} diff --git a/services/rabbitmq/model_instance_parameters.go b/services/rabbitmq/model_instance_parameters.go index a4525ea0b..cb3966b45 100644 --- a/services/rabbitmq/model_instance_parameters.go +++ b/services/rabbitmq/model_instance_parameters.go @@ -12,7 +12,6 @@ package rabbitmq import ( "encoding/json" - "fmt" ) // checks if the InstanceParameters type satisfies the MappedNullable interface at compile time @@ -266,114 +265,10 @@ func setInstanceParametersGetTlsCiphersAttributeType(arg *InstanceParametersGetT types and functions for tls-protocols */ -// isEnum - -// InstanceParametersTlsProtocols the model 'InstanceParameters' -// value type for enums -type InstanceParametersTlsProtocols string - -// List of TlsProtocols -const ( - INSTANCEPARAMETERSTLS_PROTOCOLS__2 InstanceParametersTlsProtocols = "tlsv1.2" - INSTANCEPARAMETERSTLS_PROTOCOLS__3 InstanceParametersTlsProtocols = "tlsv1.3" -) - -// All allowed values of InstanceParameters enum -var AllowedInstanceParametersTlsProtocolsEnumValues = []InstanceParametersTlsProtocols{ - "tlsv1.2", - "tlsv1.3", -} - -func (v *InstanceParametersTlsProtocols) UnmarshalJSON(src []byte) error { - // use a type alias to prevent infinite recursion during unmarshal, - // see https://biscuit.ninja/posts/go-avoid-an-infitine-loop-with-custom-json-unmarshallers - type TmpJson InstanceParametersTlsProtocols - var value TmpJson - err := json.Unmarshal(src, &value) - if err != nil { - return err - } - // Allow unmarshalling zero value for testing purposes - var zeroValue TmpJson - if value == zeroValue { - return nil - } - enumTypeValue := InstanceParametersTlsProtocols(value) - for _, existing := range AllowedInstanceParametersTlsProtocolsEnumValues { - if existing == enumTypeValue { - *v = enumTypeValue - return nil - } - } - - return fmt.Errorf("%+v is not a valid InstanceParameters", value) -} - -// NewInstanceParametersTlsProtocolsFromValue returns a pointer to a valid InstanceParametersTlsProtocols -// for the value passed as argument, or an error if the value passed is not allowed by the enum -func NewInstanceParametersTlsProtocolsFromValue(v InstanceParametersTlsProtocols) (*InstanceParametersTlsProtocols, error) { - ev := InstanceParametersTlsProtocols(v) - if ev.IsValid() { - return &ev, nil - } else { - return nil, fmt.Errorf("invalid value '%v' for InstanceParametersTlsProtocols: valid values are %v", v, AllowedInstanceParametersTlsProtocolsEnumValues) - } -} - -// IsValid return true if the value is valid for the enum, false otherwise -func (v InstanceParametersTlsProtocols) IsValid() bool { - for _, existing := range AllowedInstanceParametersTlsProtocolsEnumValues { - if existing == v { - return true - } - } - return false -} - -// Ptr returns reference to TlsProtocolsTlsProtocols value -func (v InstanceParametersTlsProtocols) Ptr() *InstanceParametersTlsProtocols { - return &v -} - -type NullableInstanceParametersTlsProtocols struct { - value *InstanceParametersTlsProtocols - isSet bool -} - -func (v NullableInstanceParametersTlsProtocols) Get() *InstanceParametersTlsProtocols { - return v.value -} - -func (v *NullableInstanceParametersTlsProtocols) Set(val *InstanceParametersTlsProtocols) { - v.value = val - v.isSet = true -} - -func (v NullableInstanceParametersTlsProtocols) IsSet() bool { - return v.isSet -} - -func (v *NullableInstanceParametersTlsProtocols) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableInstanceParametersTlsProtocols(val *InstanceParametersTlsProtocols) *NullableInstanceParametersTlsProtocols { - return &NullableInstanceParametersTlsProtocols{value: val, isSet: true} -} - -func (v NullableInstanceParametersTlsProtocols) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableInstanceParametersTlsProtocols) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - -type InstanceParametersGetTlsProtocolsAttributeType = *InstanceParametersTlsProtocols -type InstanceParametersGetTlsProtocolsArgType = InstanceParametersTlsProtocols -type InstanceParametersGetTlsProtocolsRetType = InstanceParametersTlsProtocols +// isArray +type InstanceParametersGetTlsProtocolsAttributeType = *[]string +type InstanceParametersGetTlsProtocolsArgType = []string +type InstanceParametersGetTlsProtocolsRetType = []string func getInstanceParametersGetTlsProtocolsAttributeTypeOk(arg InstanceParametersGetTlsProtocolsAttributeType) (ret InstanceParametersGetTlsProtocolsRetType, ok bool) { if arg == nil { @@ -731,7 +626,7 @@ func (o *InstanceParameters) HasTlsProtocols() bool { return ok } -// SetTlsProtocols gets a reference to the given string and assigns it to the TlsProtocols field. +// SetTlsProtocols gets a reference to the given []string and assigns it to the TlsProtocols field. func (o *InstanceParameters) SetTlsProtocols(v InstanceParametersGetTlsProtocolsRetType) { setInstanceParametersGetTlsProtocolsAttributeType(&o.TlsProtocols, v) } diff --git a/services/rabbitmq/model_instance_parameters_test.go b/services/rabbitmq/model_instance_parameters_test.go index 8e03cab41..36793fa7a 100644 --- a/services/rabbitmq/model_instance_parameters_test.go +++ b/services/rabbitmq/model_instance_parameters_test.go @@ -9,50 +9,3 @@ API version: 1.1.0 // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. package rabbitmq - -import ( - "testing" -) - -// isEnum - -func TestInstanceParametersTlsProtocols_UnmarshalJSON(t *testing.T) { - type args struct { - src []byte - } - tests := []struct { - name string - args args - wantErr bool - }{ - { - name: `success - possible enum value no. 1`, - args: args{ - src: []byte(`"tlsv1.2"`), - }, - wantErr: false, - }, - { - name: `success - possible enum value no. 2`, - args: args{ - src: []byte(`"tlsv1.3"`), - }, - wantErr: false, - }, - { - name: "fail", - args: args{ - src: []byte("\"FOOBAR\""), - }, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - v := InstanceParametersTlsProtocols("") - if err := v.UnmarshalJSON(tt.args.src); (err != nil) != tt.wantErr { - t.Errorf("UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} diff --git a/services/rabbitmq/oas_commit b/services/rabbitmq/oas_commit new file mode 100644 index 000000000..47b49289a --- /dev/null +++ b/services/rabbitmq/oas_commit @@ -0,0 +1 @@ +d7a7113a1117f58b72d89fb9f7ecc3cc9e94c8ad