From 39aea296bb4a3f876a3327b40bb9e1c919fae8fe Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Fri, 8 Nov 2024 11:18:06 +0000 Subject: [PATCH] Generate iaas --- services/iaas/api_default.go | 106 +++++++++++++++--------------- services/iaas/api_default_test.go | 24 +++---- services/iaas/model_port_range.go | 2 +- 3 files changed, 66 insertions(+), 66 deletions(-) diff --git a/services/iaas/api_default.go b/services/iaas/api_default.go index f66fe51ce..21f464a45 100644 --- a/services/iaas/api_default.go +++ b/services/iaas/api_default.go @@ -26,30 +26,30 @@ import ( // DefaultApiService DefaultApi service type DefaultApiService service -type ApiAddNICToServerRequest struct { +type ApiAddNetworkToServerRequest struct { ctx context.Context apiService *DefaultApiService projectId string serverId string - nicId string + networkId string } -func (r ApiAddNICToServerRequest) Execute() error { +func (r ApiAddNetworkToServerRequest) Execute() error { var ( - localVarHTTPMethod = http.MethodPut + localVarHTTPMethod = http.MethodPost localVarPostBody interface{} formFiles []formFile ) a := r.apiService - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.AddNICToServer") + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.AddNetworkToServer") if err != nil { return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/v1beta1/projects/{projectId}/servers/{serverId}/nics/{nicId}" + localVarPath := localBasePath + "/v1beta1/projects/{projectId}/servers/{serverId}/networks/{networkId}" localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) localVarPath = strings.Replace(localVarPath, "{"+"serverId"+"}", url.PathEscape(ParameterValueToString(r.serverId, "serverId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"nicId"+"}", url.PathEscape(ParameterValueToString(r.nicId, "nicId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"networkId"+"}", url.PathEscape(ParameterValueToString(r.networkId, "networkId")), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -66,11 +66,11 @@ func (r ApiAddNICToServerRequest) Execute() error { if strlen(r.serverId) > 36 { return fmt.Errorf("serverId must have less than 36 elements") } - if strlen(r.nicId) < 36 { - return fmt.Errorf("nicId must have at least 36 elements") + if strlen(r.networkId) < 36 { + return fmt.Errorf("networkId must have at least 36 elements") } - if strlen(r.nicId) > 36 { - return fmt.Errorf("nicId must have less than 36 elements") + if strlen(r.networkId) > 36 { + return fmt.Errorf("networkId must have less than 36 elements") } // to determine the Content-Type header @@ -166,17 +166,6 @@ func (r ApiAddNICToServerRequest) Execute() error { newErr.Model = v return newErr } - if localVarHTTPResponse.StatusCode == 409 { - var v Error - 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 == 500 { var v Error err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) @@ -194,61 +183,61 @@ func (r ApiAddNICToServerRequest) Execute() error { } /* -AddNICToServer: Attach an existing network interface. +AddNetworkToServer: Create and attach a network interface from the specified network. -Attach an existing network interface to a server. +Create and attach a network interface from the specified network to the server. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param projectId The identifier (ID) of a STACKIT Project. @param serverId The identifier (ID) of a STACKIT Server. - @param nicId The identifier (ID) of a network interface. - @return ApiAddNICToServerRequest + @param networkId The identifier (ID) of a STACKIT Network. + @return ApiAddNetworkToServerRequest */ -func (a *APIClient) AddNICToServer(ctx context.Context, projectId string, serverId string, nicId string) ApiAddNICToServerRequest { - return ApiAddNICToServerRequest{ +func (a *APIClient) AddNetworkToServer(ctx context.Context, projectId string, serverId string, networkId string) ApiAddNetworkToServerRequest { + return ApiAddNetworkToServerRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, serverId: serverId, - nicId: nicId, + networkId: networkId, } } -func (a *APIClient) AddNICToServerExecute(ctx context.Context, projectId string, serverId string, nicId string) error { - r := ApiAddNICToServerRequest{ +func (a *APIClient) AddNetworkToServerExecute(ctx context.Context, projectId string, serverId string, networkId string) error { + r := ApiAddNetworkToServerRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, serverId: serverId, - nicId: nicId, + networkId: networkId, } return r.Execute() } -type ApiAddNetworkToServerRequest struct { +type ApiAddNicToServerRequest struct { ctx context.Context apiService *DefaultApiService projectId string serverId string - networkId string + nicId string } -func (r ApiAddNetworkToServerRequest) Execute() error { +func (r ApiAddNicToServerRequest) Execute() error { var ( - localVarHTTPMethod = http.MethodPost + localVarHTTPMethod = http.MethodPut localVarPostBody interface{} formFiles []formFile ) a := r.apiService - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.AddNetworkToServer") + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.AddNicToServer") if err != nil { return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/v1beta1/projects/{projectId}/servers/{serverId}/networks/{networkId}" + localVarPath := localBasePath + "/v1beta1/projects/{projectId}/servers/{serverId}/nics/{nicId}" localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) localVarPath = strings.Replace(localVarPath, "{"+"serverId"+"}", url.PathEscape(ParameterValueToString(r.serverId, "serverId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"networkId"+"}", url.PathEscape(ParameterValueToString(r.networkId, "networkId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"nicId"+"}", url.PathEscape(ParameterValueToString(r.nicId, "nicId")), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -265,11 +254,11 @@ func (r ApiAddNetworkToServerRequest) Execute() error { if strlen(r.serverId) > 36 { return fmt.Errorf("serverId must have less than 36 elements") } - if strlen(r.networkId) < 36 { - return fmt.Errorf("networkId must have at least 36 elements") + if strlen(r.nicId) < 36 { + return fmt.Errorf("nicId must have at least 36 elements") } - if strlen(r.networkId) > 36 { - return fmt.Errorf("networkId must have less than 36 elements") + if strlen(r.nicId) > 36 { + return fmt.Errorf("nicId must have less than 36 elements") } // to determine the Content-Type header @@ -365,6 +354,17 @@ func (r ApiAddNetworkToServerRequest) Execute() error { newErr.Model = v return newErr } + if localVarHTTPResponse.StatusCode == 409 { + var v Error + 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 == 500 { var v Error err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) @@ -382,33 +382,33 @@ func (r ApiAddNetworkToServerRequest) Execute() error { } /* -AddNetworkToServer: Create and attach a network interface from the specified network. +AddNicToServer: Attach an existing network interface. -Create and attach a network interface from the specified network to the server. +Attach an existing network interface to a server. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param projectId The identifier (ID) of a STACKIT Project. @param serverId The identifier (ID) of a STACKIT Server. - @param networkId The identifier (ID) of a STACKIT Network. - @return ApiAddNetworkToServerRequest + @param nicId The identifier (ID) of a network interface. + @return ApiAddNicToServerRequest */ -func (a *APIClient) AddNetworkToServer(ctx context.Context, projectId string, serverId string, networkId string) ApiAddNetworkToServerRequest { - return ApiAddNetworkToServerRequest{ +func (a *APIClient) AddNicToServer(ctx context.Context, projectId string, serverId string, nicId string) ApiAddNicToServerRequest { + return ApiAddNicToServerRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, serverId: serverId, - networkId: networkId, + nicId: nicId, } } -func (a *APIClient) AddNetworkToServerExecute(ctx context.Context, projectId string, serverId string, networkId string) error { - r := ApiAddNetworkToServerRequest{ +func (a *APIClient) AddNicToServerExecute(ctx context.Context, projectId string, serverId string, nicId string) error { + r := ApiAddNicToServerRequest{ apiService: a.defaultApi, ctx: ctx, projectId: projectId, serverId: serverId, - networkId: networkId, + nicId: nicId, } return r.Execute() } diff --git a/services/iaas/api_default_test.go b/services/iaas/api_default_test.go index a09f7eaa5..59f67ac55 100644 --- a/services/iaas/api_default_test.go +++ b/services/iaas/api_default_test.go @@ -23,14 +23,14 @@ import ( func Test_iaas_DefaultApiService(t *testing.T) { - t.Run("Test DefaultApiService AddNICToServer", func(t *testing.T) { - path := "/v1beta1/projects/{projectId}/servers/{serverId}/nics/{nicId}" + t.Run("Test DefaultApiService AddNetworkToServer", func(t *testing.T) { + path := "/v1beta1/projects/{projectId}/servers/{serverId}/networks/{networkId}" projectIdValue := "projectId" path = strings.Replace(path, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) serverIdValue := "serverId" path = strings.Replace(path, "{"+"serverId"+"}", url.PathEscape(ParameterValueToString(serverIdValue, "serverId")), -1) - nicIdValue := "nicId" - path = strings.Replace(path, "{"+"nicId"+"}", url.PathEscape(ParameterValueToString(nicIdValue, "nicId")), -1) + networkIdValue := "networkId" + path = strings.Replace(path, "{"+"networkId"+"}", url.PathEscape(ParameterValueToString(networkIdValue, "networkId")), -1) testDefaultApiServeMux := http.NewServeMux() testDefaultApiServeMux.HandleFunc(path, func(w http.ResponseWriter, req *http.Request) { @@ -66,23 +66,23 @@ func Test_iaas_DefaultApiService(t *testing.T) { projectId := "projectId" serverId := "serverId" - nicId := "nicId" + networkId := "networkId" - reqErr := apiClient.AddNICToServer(context.Background(), projectId, serverId, nicId).Execute() + reqErr := apiClient.AddNetworkToServer(context.Background(), projectId, serverId, networkId).Execute() if reqErr != nil { t.Fatalf("error in call: %v", reqErr) } }) - t.Run("Test DefaultApiService AddNetworkToServer", func(t *testing.T) { - path := "/v1beta1/projects/{projectId}/servers/{serverId}/networks/{networkId}" + t.Run("Test DefaultApiService AddNicToServer", func(t *testing.T) { + path := "/v1beta1/projects/{projectId}/servers/{serverId}/nics/{nicId}" projectIdValue := "projectId" path = strings.Replace(path, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) serverIdValue := "serverId" path = strings.Replace(path, "{"+"serverId"+"}", url.PathEscape(ParameterValueToString(serverIdValue, "serverId")), -1) - networkIdValue := "networkId" - path = strings.Replace(path, "{"+"networkId"+"}", url.PathEscape(ParameterValueToString(networkIdValue, "networkId")), -1) + nicIdValue := "nicId" + path = strings.Replace(path, "{"+"nicId"+"}", url.PathEscape(ParameterValueToString(nicIdValue, "nicId")), -1) testDefaultApiServeMux := http.NewServeMux() testDefaultApiServeMux.HandleFunc(path, func(w http.ResponseWriter, req *http.Request) { @@ -118,9 +118,9 @@ func Test_iaas_DefaultApiService(t *testing.T) { projectId := "projectId" serverId := "serverId" - networkId := "networkId" + nicId := "nicId" - reqErr := apiClient.AddNetworkToServer(context.Background(), projectId, serverId, networkId).Execute() + reqErr := apiClient.AddNicToServer(context.Background(), projectId, serverId, nicId).Execute() if reqErr != nil { t.Fatalf("error in call: %v", reqErr) diff --git a/services/iaas/model_port_range.go b/services/iaas/model_port_range.go index 81eb71cae..c2ba08fa5 100644 --- a/services/iaas/model_port_range.go +++ b/services/iaas/model_port_range.go @@ -22,7 +22,7 @@ type PortRange struct { // The maximum port number. Should be greater or equal to the minimum. // REQUIRED Max *int64 `json:"max"` - // The minimum port number. Should be less or equal to the minimum. + // The minimum port number. Should be less or equal to the maximum. // REQUIRED Min *int64 `json:"min"` }