From aeb4c6dc9bcf0f91077d8bca29de9064517dcbf0 Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Thu, 14 Nov 2024 09:08:34 +0000 Subject: [PATCH] Generate serverupdate --- go.work | 1 + .../serverupdate/.openapi-generator/VERSION | 1 + services/serverupdate/api_default.go | 1609 +++++++++++++++++ services/serverupdate/api_default_test.go | 668 +++++++ services/serverupdate/client.go | 631 +++++++ services/serverupdate/configuration.go | 41 + services/serverupdate/go.mod | 10 + services/serverupdate/go.sum | 7 + .../serverupdate/model_backup_properties.go | 177 ++ .../model_create_update_payload.go | 183 ++ .../model_create_update_schedule_payload.go | 224 +++ .../model_enable_service_payload.go | 116 ++ .../model_enable_service_resource_payload.go | 116 ++ .../model_get_update_schedules_response.go | 116 ++ .../model_get_updates_list_response.go | 116 ++ services/serverupdate/model_update.go | 332 ++++ .../serverupdate/model_update_schedule.go | 224 +++ .../model_update_update_schedule_payload.go | 224 +++ services/serverupdate/utils.go | 347 ++++ 19 files changed, 5143 insertions(+) create mode 100644 services/serverupdate/.openapi-generator/VERSION create mode 100644 services/serverupdate/api_default.go create mode 100644 services/serverupdate/api_default_test.go create mode 100644 services/serverupdate/client.go create mode 100644 services/serverupdate/configuration.go create mode 100644 services/serverupdate/go.mod create mode 100644 services/serverupdate/go.sum create mode 100644 services/serverupdate/model_backup_properties.go create mode 100644 services/serverupdate/model_create_update_payload.go create mode 100644 services/serverupdate/model_create_update_schedule_payload.go create mode 100644 services/serverupdate/model_enable_service_payload.go create mode 100644 services/serverupdate/model_enable_service_resource_payload.go create mode 100644 services/serverupdate/model_get_update_schedules_response.go create mode 100644 services/serverupdate/model_get_updates_list_response.go create mode 100644 services/serverupdate/model_update.go create mode 100644 services/serverupdate/model_update_schedule.go create mode 100644 services/serverupdate/model_update_update_schedule_payload.go create mode 100644 services/serverupdate/utils.go diff --git a/go.work b/go.work index 9388de216..17be4dfba 100644 --- a/go.work +++ b/go.work @@ -50,6 +50,7 @@ use ( ./services/runcommand ./services/secretsmanager ./services/serverbackup + ./services/serverupdate ./services/serviceaccount ./services/serviceenablement ./services/ske diff --git a/services/serverupdate/.openapi-generator/VERSION b/services/serverupdate/.openapi-generator/VERSION new file mode 100644 index 000000000..cd802a1ec --- /dev/null +++ b/services/serverupdate/.openapi-generator/VERSION @@ -0,0 +1 @@ +6.6.0 \ No newline at end of file diff --git a/services/serverupdate/api_default.go b/services/serverupdate/api_default.go new file mode 100644 index 000000000..d2f9a3587 --- /dev/null +++ b/services/serverupdate/api_default.go @@ -0,0 +1,1609 @@ +/* +STACKIT Server Update Management API + +API endpoints for Server Update Operations on STACKIT Servers. + +API version: 1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package serverupdate + +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" +) + +// DefaultApiService DefaultApi service +type DefaultApiService service + +type ApiCreateUpdateRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + serverId string + createUpdatePayload *CreateUpdatePayload +} + +func (r ApiCreateUpdateRequest) CreateUpdatePayload(createUpdatePayload CreateUpdatePayload) ApiCreateUpdateRequest { + r.createUpdatePayload = &createUpdatePayload + return r +} + +func (r ApiCreateUpdateRequest) Execute() (*Update, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Update + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.CreateUpdate") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1/projects/{projectId}/servers/{serverId}/updates" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"serverId"+"}", url.PathEscape(ParameterValueToString(r.serverId, "serverId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // 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", "text/plain"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.createUpdatePayload + 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{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 401 { + var v string + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + 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 +} + +/* +CreateUpdate: create update + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId portal project id + @param serverId openstack server id + @return ApiCreateUpdateRequest +*/ +func (a *APIClient) CreateUpdate(ctx context.Context, projectId string, serverId string) ApiCreateUpdateRequest { + return ApiCreateUpdateRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + serverId: serverId, + } +} + +func (a *APIClient) CreateUpdateExecute(ctx context.Context, projectId string, serverId string) (*Update, error) { + r := ApiCreateUpdateRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + serverId: serverId, + } + return r.Execute() +} + +type ApiCreateUpdateScheduleRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + serverId string + createUpdateSchedulePayload *CreateUpdateSchedulePayload +} + +func (r ApiCreateUpdateScheduleRequest) CreateUpdateSchedulePayload(createUpdateSchedulePayload CreateUpdateSchedulePayload) ApiCreateUpdateScheduleRequest { + r.createUpdateSchedulePayload = &createUpdateSchedulePayload + return r +} + +func (r ApiCreateUpdateScheduleRequest) Execute() (*UpdateSchedule, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *UpdateSchedule + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.CreateUpdateSchedule") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1/projects/{projectId}/servers/{serverId}/update-schedules" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"serverId"+"}", url.PathEscape(ParameterValueToString(r.serverId, "serverId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // 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", "text/plain"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.createUpdateSchedulePayload + 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{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 401 { + var v string + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + 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 +} + +/* +CreateUpdateSchedule: create update schedule + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId portal project id + @param serverId openstack server id + @return ApiCreateUpdateScheduleRequest +*/ +func (a *APIClient) CreateUpdateSchedule(ctx context.Context, projectId string, serverId string) ApiCreateUpdateScheduleRequest { + return ApiCreateUpdateScheduleRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + serverId: serverId, + } +} + +func (a *APIClient) CreateUpdateScheduleExecute(ctx context.Context, projectId string, serverId string) (*UpdateSchedule, error) { + r := ApiCreateUpdateScheduleRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + serverId: serverId, + } + return r.Execute() +} + +type ApiDeleteUpdateScheduleRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + serverId string + scheduleId string +} + +func (r ApiDeleteUpdateScheduleRequest) Execute() error { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.DeleteUpdateSchedule") + if err != nil { + return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1/projects/{projectId}/servers/{serverId}/update-schedules/{scheduleId}" + 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, "{"+"scheduleId"+"}", url.PathEscape(ParameterValueToString(r.scheduleId, "scheduleId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // 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{"text/plain"} + + // 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 == 401 { + var v string + 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 newErr + } + + return nil +} + +/* +DeleteUpdateSchedule: delete update schedule + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId portal project id + @param serverId openstack server id + @param scheduleId update schedule id + @return ApiDeleteUpdateScheduleRequest +*/ +func (a *APIClient) DeleteUpdateSchedule(ctx context.Context, projectId string, serverId string, scheduleId string) ApiDeleteUpdateScheduleRequest { + return ApiDeleteUpdateScheduleRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + serverId: serverId, + scheduleId: scheduleId, + } +} + +func (a *APIClient) DeleteUpdateScheduleExecute(ctx context.Context, projectId string, serverId string, scheduleId string) error { + r := ApiDeleteUpdateScheduleRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + serverId: serverId, + scheduleId: scheduleId, + } + return r.Execute() +} + +type ApiDisableServiceRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + serverId string +} + +func (r ApiDisableServiceRequest) Execute() error { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.DisableService") + if err != nil { + return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1/projects/{projectId}/servers/{serverId}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"serverId"+"}", url.PathEscape(ParameterValueToString(r.serverId, "serverId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // 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{"text/plain"} + + // 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 == 401 { + var v string + 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 newErr + } + + return nil +} + +/* +DisableService: disable update service + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId portal project id + @param serverId openstack server id + @return ApiDisableServiceRequest +*/ +func (a *APIClient) DisableService(ctx context.Context, projectId string, serverId string) ApiDisableServiceRequest { + return ApiDisableServiceRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + serverId: serverId, + } +} + +/* +Deprecated: +*/ +func (a *APIClient) DisableServiceExecute(ctx context.Context, projectId string, serverId string) error { + r := ApiDisableServiceRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + serverId: serverId, + } + return r.Execute() +} + +type ApiDisableServiceResourceRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + serverId string +} + +func (r ApiDisableServiceResourceRequest) Execute() error { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.DisableServiceResource") + if err != nil { + return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1/projects/{projectId}/servers/{serverId}/service" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"serverId"+"}", url.PathEscape(ParameterValueToString(r.serverId, "serverId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // 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{"text/plain"} + + // 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 == 401 { + var v string + 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 newErr + } + + return nil +} + +/* +DisableServiceResource: disable update service + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId portal project id + @param serverId openstack server id + @return ApiDisableServiceResourceRequest +*/ +func (a *APIClient) DisableServiceResource(ctx context.Context, projectId string, serverId string) ApiDisableServiceResourceRequest { + return ApiDisableServiceResourceRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + serverId: serverId, + } +} + +func (a *APIClient) DisableServiceResourceExecute(ctx context.Context, projectId string, serverId string) error { + r := ApiDisableServiceResourceRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + serverId: serverId, + } + return r.Execute() +} + +type ApiEnableServiceRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + serverId string + enableServicePayload *EnableServicePayload +} + +func (r ApiEnableServiceRequest) EnableServicePayload(enableServicePayload EnableServicePayload) ApiEnableServiceRequest { + r.enableServicePayload = &enableServicePayload + return r +} + +func (r ApiEnableServiceRequest) Execute() error { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.EnableService") + if err != nil { + return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1/projects/{projectId}/servers/{serverId}" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"serverId"+"}", url.PathEscape(ParameterValueToString(r.serverId, "serverId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // 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{"text/plain"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.enableServicePayload + 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 == 401 { + var v string + 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 newErr + } + + return nil +} + +/* +EnableService: enable update service + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId portal project id + @param serverId openstack server id + @return ApiEnableServiceRequest +*/ +func (a *APIClient) EnableService(ctx context.Context, projectId string, serverId string) ApiEnableServiceRequest { + return ApiEnableServiceRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + serverId: serverId, + } +} + +/* +Deprecated: +*/ +func (a *APIClient) EnableServiceExecute(ctx context.Context, projectId string, serverId string) error { + r := ApiEnableServiceRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + serverId: serverId, + } + return r.Execute() +} + +type ApiEnableServiceResourceRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + serverId string + enableServiceResourcePayload *EnableServiceResourcePayload +} + +func (r ApiEnableServiceResourceRequest) EnableServiceResourcePayload(enableServiceResourcePayload EnableServiceResourcePayload) ApiEnableServiceResourceRequest { + r.enableServiceResourcePayload = &enableServiceResourcePayload + return r +} + +func (r ApiEnableServiceResourceRequest) Execute() error { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.EnableServiceResource") + if err != nil { + return &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1/projects/{projectId}/servers/{serverId}/service" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"serverId"+"}", url.PathEscape(ParameterValueToString(r.serverId, "serverId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // 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{"text/plain"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.enableServiceResourcePayload + 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 == 401 { + var v string + 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 newErr + } + + return nil +} + +/* +EnableServiceResource: enable update service + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId portal project id + @param serverId openstack server id + @return ApiEnableServiceResourceRequest +*/ +func (a *APIClient) EnableServiceResource(ctx context.Context, projectId string, serverId string) ApiEnableServiceResourceRequest { + return ApiEnableServiceResourceRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + serverId: serverId, + } +} + +func (a *APIClient) EnableServiceResourceExecute(ctx context.Context, projectId string, serverId string) error { + r := ApiEnableServiceResourceRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + serverId: serverId, + } + return r.Execute() +} + +type ApiGetUpdateRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + serverId string + updateId string +} + +func (r ApiGetUpdateRequest) Execute() (*Update, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Update + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetUpdate") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1/projects/{projectId}/servers/{serverId}/updates/{updateId}" + 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, "{"+"updateId"+"}", url.PathEscape(ParameterValueToString(r.updateId, "updateId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // 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", "text/plain"} + + // 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{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 401 { + var v string + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + 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 +} + +/* +GetUpdate: get update + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId portal project id + @param serverId openstack server id + @param updateId id of the update + @return ApiGetUpdateRequest +*/ +func (a *APIClient) GetUpdate(ctx context.Context, projectId string, serverId string, updateId string) ApiGetUpdateRequest { + return ApiGetUpdateRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + serverId: serverId, + updateId: updateId, + } +} + +func (a *APIClient) GetUpdateExecute(ctx context.Context, projectId string, serverId string, updateId string) (*Update, error) { + r := ApiGetUpdateRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + serverId: serverId, + updateId: updateId, + } + return r.Execute() +} + +type ApiGetUpdateScheduleRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + serverId string + scheduleId string +} + +func (r ApiGetUpdateScheduleRequest) Execute() (*UpdateSchedule, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *UpdateSchedule + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetUpdateSchedule") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1/projects/{projectId}/servers/{serverId}/update-schedules/{scheduleId}" + 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, "{"+"scheduleId"+"}", url.PathEscape(ParameterValueToString(r.scheduleId, "scheduleId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // 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", "text/plain"} + + // 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{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 401 { + var v string + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + 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 +} + +/* +GetUpdateSchedule: get single update schedule details + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId portal project id + @param serverId openstack server id + @param scheduleId update schedule id + @return ApiGetUpdateScheduleRequest +*/ +func (a *APIClient) GetUpdateSchedule(ctx context.Context, projectId string, serverId string, scheduleId string) ApiGetUpdateScheduleRequest { + return ApiGetUpdateScheduleRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + serverId: serverId, + scheduleId: scheduleId, + } +} + +func (a *APIClient) GetUpdateScheduleExecute(ctx context.Context, projectId string, serverId string, scheduleId string) (*UpdateSchedule, error) { + r := ApiGetUpdateScheduleRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + serverId: serverId, + scheduleId: scheduleId, + } + return r.Execute() +} + +type ApiListUpdateSchedulesRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + serverId string +} + +func (r ApiListUpdateSchedulesRequest) Execute() (*GetUpdateSchedulesResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *GetUpdateSchedulesResponse + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListUpdateSchedules") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1/projects/{projectId}/servers/{serverId}/update-schedules" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"serverId"+"}", url.PathEscape(ParameterValueToString(r.serverId, "serverId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // 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", "text/plain"} + + // 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{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 401 { + var v string + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + 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 +} + +/* +ListUpdateSchedules: get list of update schedules + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId portal project id + @param serverId openstack server id + @return ApiListUpdateSchedulesRequest +*/ +func (a *APIClient) ListUpdateSchedules(ctx context.Context, projectId string, serverId string) ApiListUpdateSchedulesRequest { + return ApiListUpdateSchedulesRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + serverId: serverId, + } +} + +func (a *APIClient) ListUpdateSchedulesExecute(ctx context.Context, projectId string, serverId string) (*GetUpdateSchedulesResponse, error) { + r := ApiListUpdateSchedulesRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + serverId: serverId, + } + return r.Execute() +} + +type ApiListUpdatesRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + serverId string +} + +func (r ApiListUpdatesRequest) Execute() (*GetUpdatesListResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *GetUpdatesListResponse + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListUpdates") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1/projects/{projectId}/servers/{serverId}/updates" + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"serverId"+"}", url.PathEscape(ParameterValueToString(r.serverId, "serverId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // 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", "text/plain"} + + // 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{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 401 { + var v string + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + 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 +} + +/* +ListUpdates: get list of updates + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId portal project id + @param serverId openstack server id + @return ApiListUpdatesRequest +*/ +func (a *APIClient) ListUpdates(ctx context.Context, projectId string, serverId string) ApiListUpdatesRequest { + return ApiListUpdatesRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + serverId: serverId, + } +} + +func (a *APIClient) ListUpdatesExecute(ctx context.Context, projectId string, serverId string) (*GetUpdatesListResponse, error) { + r := ApiListUpdatesRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + serverId: serverId, + } + return r.Execute() +} + +type ApiUpdateUpdateScheduleRequest struct { + ctx context.Context + apiService *DefaultApiService + projectId string + serverId string + scheduleId string + updateUpdateSchedulePayload *UpdateUpdateSchedulePayload +} + +func (r ApiUpdateUpdateScheduleRequest) UpdateUpdateSchedulePayload(updateUpdateSchedulePayload UpdateUpdateSchedulePayload) ApiUpdateUpdateScheduleRequest { + r.updateUpdateSchedulePayload = &updateUpdateSchedulePayload + return r +} + +func (r ApiUpdateUpdateScheduleRequest) Execute() (*UpdateSchedule, error) { + var ( + localVarHTTPMethod = http.MethodPut + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *UpdateSchedule + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.UpdateUpdateSchedule") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1/projects/{projectId}/servers/{serverId}/update-schedules/{scheduleId}" + 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, "{"+"scheduleId"+"}", url.PathEscape(ParameterValueToString(r.scheduleId, "scheduleId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // 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", "text/plain"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.updateUpdateSchedulePayload + 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{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 401 { + var v string + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + 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 +} + +/* +UpdateUpdateSchedule: update update schedule + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId portal project id + @param serverId openstack server id + @param scheduleId update schedule id + @return ApiUpdateUpdateScheduleRequest +*/ +func (a *APIClient) UpdateUpdateSchedule(ctx context.Context, projectId string, serverId string, scheduleId string) ApiUpdateUpdateScheduleRequest { + return ApiUpdateUpdateScheduleRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + serverId: serverId, + scheduleId: scheduleId, + } +} + +func (a *APIClient) UpdateUpdateScheduleExecute(ctx context.Context, projectId string, serverId string, scheduleId string) (*UpdateSchedule, error) { + r := ApiUpdateUpdateScheduleRequest{ + apiService: a.defaultApi, + ctx: ctx, + projectId: projectId, + serverId: serverId, + scheduleId: scheduleId, + } + return r.Execute() +} diff --git a/services/serverupdate/api_default_test.go b/services/serverupdate/api_default_test.go new file mode 100644 index 000000000..e2c399d76 --- /dev/null +++ b/services/serverupdate/api_default_test.go @@ -0,0 +1,668 @@ +/* +STACKIT Server Update Management API + +Testing DefaultApiService + +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); + +package serverupdate + +import ( + "context" + "encoding/json" + "net/http" + "net/http/httptest" + "net/url" + "strings" + "testing" + + "github.com/stackitcloud/stackit-sdk-go/core/config" +) + +func Test_serverupdate_DefaultApiService(t *testing.T) { + + t.Run("Test DefaultApiService CreateUpdate", func(t *testing.T) { + path := "/v1/projects/{projectId}/servers/{serverId}/updates" + 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) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(path, func(w http.ResponseWriter, req *http.Request) { + data := Update{} + 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 serverupdate_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 := "projectId" + serverId := "serverId" + + resp, reqErr := apiClient.CreateUpdate(context.Background(), projectId, serverId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if resp == nil { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService CreateUpdateSchedule", func(t *testing.T) { + path := "/v1/projects/{projectId}/servers/{serverId}/update-schedules" + 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) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(path, func(w http.ResponseWriter, req *http.Request) { + data := UpdateSchedule{} + 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 serverupdate_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 := "projectId" + serverId := "serverId" + + resp, reqErr := apiClient.CreateUpdateSchedule(context.Background(), projectId, serverId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if resp == nil { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService DeleteUpdateSchedule", func(t *testing.T) { + path := "/v1/projects/{projectId}/servers/{serverId}/update-schedules/{scheduleId}" + 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) + scheduleIdValue := "scheduleId" + path = strings.Replace(path, "{"+"scheduleId"+"}", url.PathEscape(ParameterValueToString(scheduleIdValue, "scheduleId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(path, 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 serverupdate_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 := "projectId" + serverId := "serverId" + scheduleId := "scheduleId" + + reqErr := apiClient.DeleteUpdateSchedule(context.Background(), projectId, serverId, scheduleId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + }) + + t.Run("Test DefaultApiService DisableService", func(t *testing.T) { + path := "/v1/projects/{projectId}/servers/{serverId}" + 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) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(path, 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 serverupdate_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 := "projectId" + serverId := "serverId" + + reqErr := apiClient.DisableService(context.Background(), projectId, serverId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + }) + + t.Run("Test DefaultApiService DisableServiceResource", func(t *testing.T) { + path := "/v1/projects/{projectId}/servers/{serverId}/service" + 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) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(path, 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 serverupdate_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 := "projectId" + serverId := "serverId" + + reqErr := apiClient.DisableServiceResource(context.Background(), projectId, serverId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + }) + + t.Run("Test DefaultApiService EnableService", func(t *testing.T) { + path := "/v1/projects/{projectId}/servers/{serverId}" + 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) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(path, 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 serverupdate_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 := "projectId" + serverId := "serverId" + + reqErr := apiClient.EnableService(context.Background(), projectId, serverId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + }) + + t.Run("Test DefaultApiService EnableServiceResource", func(t *testing.T) { + path := "/v1/projects/{projectId}/servers/{serverId}/service" + 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) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(path, 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 serverupdate_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 := "projectId" + serverId := "serverId" + + reqErr := apiClient.EnableServiceResource(context.Background(), projectId, serverId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + }) + + t.Run("Test DefaultApiService GetUpdate", func(t *testing.T) { + path := "/v1/projects/{projectId}/servers/{serverId}/updates/{updateId}" + 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) + updateIdValue := "updateId" + path = strings.Replace(path, "{"+"updateId"+"}", url.PathEscape(ParameterValueToString(updateIdValue, "updateId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(path, func(w http.ResponseWriter, req *http.Request) { + data := Update{} + 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 serverupdate_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 := "projectId" + serverId := "serverId" + updateId := "updateId" + + resp, reqErr := apiClient.GetUpdate(context.Background(), projectId, serverId, updateId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if resp == nil { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService GetUpdateSchedule", func(t *testing.T) { + path := "/v1/projects/{projectId}/servers/{serverId}/update-schedules/{scheduleId}" + 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) + scheduleIdValue := "scheduleId" + path = strings.Replace(path, "{"+"scheduleId"+"}", url.PathEscape(ParameterValueToString(scheduleIdValue, "scheduleId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(path, func(w http.ResponseWriter, req *http.Request) { + data := UpdateSchedule{} + 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 serverupdate_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 := "projectId" + serverId := "serverId" + scheduleId := "scheduleId" + + resp, reqErr := apiClient.GetUpdateSchedule(context.Background(), projectId, serverId, scheduleId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if resp == nil { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService ListUpdateSchedules", func(t *testing.T) { + path := "/v1/projects/{projectId}/servers/{serverId}/update-schedules" + 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) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(path, func(w http.ResponseWriter, req *http.Request) { + data := GetUpdateSchedulesResponse{} + 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 serverupdate_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 := "projectId" + serverId := "serverId" + + resp, reqErr := apiClient.ListUpdateSchedules(context.Background(), projectId, serverId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if resp == nil { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService ListUpdates", func(t *testing.T) { + path := "/v1/projects/{projectId}/servers/{serverId}/updates" + 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) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(path, func(w http.ResponseWriter, req *http.Request) { + data := GetUpdatesListResponse{} + 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 serverupdate_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 := "projectId" + serverId := "serverId" + + resp, reqErr := apiClient.ListUpdates(context.Background(), projectId, serverId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if resp == nil { + t.Fatalf("response not present") + } + }) + + t.Run("Test DefaultApiService UpdateUpdateSchedule", func(t *testing.T) { + path := "/v1/projects/{projectId}/servers/{serverId}/update-schedules/{scheduleId}" + 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) + scheduleIdValue := "scheduleId" + path = strings.Replace(path, "{"+"scheduleId"+"}", url.PathEscape(ParameterValueToString(scheduleIdValue, "scheduleId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(path, func(w http.ResponseWriter, req *http.Request) { + data := UpdateSchedule{} + 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 serverupdate_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 := "projectId" + serverId := "serverId" + scheduleId := "scheduleId" + + resp, reqErr := apiClient.UpdateUpdateSchedule(context.Background(), projectId, serverId, scheduleId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if resp == nil { + t.Fatalf("response not present") + } + }) + +} diff --git a/services/serverupdate/client.go b/services/serverupdate/client.go new file mode 100644 index 000000000..9ef01d637 --- /dev/null +++ b/services/serverupdate/client.go @@ -0,0 +1,631 @@ +/* +STACKIT Server Update Management API + +API endpoints for Server Update Operations on STACKIT Servers. + +API version: 1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package serverupdate + +import ( + "bytes" + "context" + "encoding/json" + "encoding/xml" + "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)/(?:vnd\.[^;]+\+)?json)`) + xmlCheck = regexp.MustCompile(`(?i:(?:application|text)/xml)`) + queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`) + queryDescape = strings.NewReplacer("%5B", "[", "%5D", "]") +) + +// APIClient manages communication with the STACKIT Server Update Management API API v1.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. + defaultApi *DefaultApiService +} + +type service struct { + client *APIClient +} + +// NewAPIClient creates a new API client. +// Optionally receives configuration options +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 + 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 { + 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{}, 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, collectionType) + return + } + if t, ok := obj.(time.Time); ok { + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, t.Format(time.RFC3339), 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) + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, arrayValue.Interface(), 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(), collectionType) + } + return + + case reflect.Interface: + fallthrough + case reflect.Ptr: + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, v.Elem().Interface(), 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, fmt.Errorf("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, fmt.Errorf("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 fmt.Errorf("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 fmt.Errorf("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 + } + err = file.Close() + if err != nil { + return err + } + + part, err := w.CreateFormFile(fieldName, filepath.Base(path)) + if err != nil { + return err + } + _, err = io.Copy(part, file) + + return err +} + +// A wrapper for strict JSON decoding +func newStrictDecoder(data []byte) *json.Decoder { + dec := json.NewDecoder(bytes.NewBuffer(data)) + dec.DisallowUnknownFields() + return dec +} + +// 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) { + err = xml.NewEncoder(bodyBuf).Encode(body) + } + + if err != nil { + return nil, err + } + + if bodyBuf.Len() == 0 { + err = fmt.Errorf("invalid body type %s", 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) +} diff --git a/services/serverupdate/configuration.go b/services/serverupdate/configuration.go new file mode 100644 index 000000000..c1530143f --- /dev/null +++ b/services/serverupdate/configuration.go @@ -0,0 +1,41 @@ +/* +STACKIT Server Update Management API + +API endpoints for Server Update Operations on STACKIT Servers. + +API version: 1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package serverupdate + +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: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Servers: config.ServerConfigurations{ + { + URL: "https://server-update.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/serverupdate/go.mod b/services/serverupdate/go.mod new file mode 100644 index 000000000..16d6a9a77 --- /dev/null +++ b/services/serverupdate/go.mod @@ -0,0 +1,10 @@ +module github.com/stackitcloud/stackit-sdk-go/services/serverupdate + +go 1.18 + +require github.com/stackitcloud/stackit-sdk-go/core v0.14.0 + +require ( + github.com/golang-jwt/jwt/v5 v5.2.1 // indirect + github.com/google/uuid v1.6.0 // indirect +) diff --git a/services/serverupdate/go.sum b/services/serverupdate/go.sum new file mode 100644 index 000000000..919ee7f48 --- /dev/null +++ b/services/serverupdate/go.sum @@ -0,0 +1,7 @@ +github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= +github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +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.14.0 h1:oBwwzrEHDTlZpRoQwmMQpNA8bWciTrtGkiN29nx14Z0= +github.com/stackitcloud/stackit-sdk-go/core v0.14.0/go.mod h1:mDX1mSTsB3mP+tNBGcFNx6gH1mGBN4T+dVt+lcw7nlw= diff --git a/services/serverupdate/model_backup_properties.go b/services/serverupdate/model_backup_properties.go new file mode 100644 index 000000000..474bea1e5 --- /dev/null +++ b/services/serverupdate/model_backup_properties.go @@ -0,0 +1,177 @@ +/* +STACKIT Server Update Management API + +API endpoints for Server Update Operations on STACKIT Servers. + +API version: 1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package serverupdate + +import ( + "encoding/json" +) + +// checks if the BackupProperties type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &BackupProperties{} + +// BackupProperties struct for BackupProperties +type BackupProperties struct { + // Max 255 characters + // REQUIRED + Name *string `json:"name"` + // Values are set in days (1-36500) + // Can be cast to int32 without loss of precision. + // REQUIRED + RetentionPeriod *int64 `json:"retentionPeriod"` + VolumeIds *[]string `json:"volumeIds,omitempty"` +} + +type _BackupProperties BackupProperties + +// NewBackupProperties instantiates a new BackupProperties 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 NewBackupProperties(name *string, retentionPeriod *int64) *BackupProperties { + this := BackupProperties{} + this.Name = name + this.RetentionPeriod = retentionPeriod + return &this +} + +// NewBackupPropertiesWithDefaults instantiates a new BackupProperties 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 NewBackupPropertiesWithDefaults() *BackupProperties { + this := BackupProperties{} + return &this +} + +// GetName returns the Name field value +func (o *BackupProperties) GetName() *string { + if o == nil { + var ret *string + return ret + } + + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *BackupProperties) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.Name, true +} + +// SetName sets field value +func (o *BackupProperties) SetName(v *string) { + o.Name = v +} + +// GetRetentionPeriod returns the RetentionPeriod field value +func (o *BackupProperties) GetRetentionPeriod() *int64 { + if o == nil { + var ret *int64 + return ret + } + + return o.RetentionPeriod +} + +// GetRetentionPeriodOk returns a tuple with the RetentionPeriod field value +// and a boolean to check if the value has been set. +func (o *BackupProperties) GetRetentionPeriodOk() (*int64, bool) { + if o == nil { + return nil, false + } + return o.RetentionPeriod, true +} + +// SetRetentionPeriod sets field value +func (o *BackupProperties) SetRetentionPeriod(v *int64) { + o.RetentionPeriod = v +} + +// GetVolumeIds returns the VolumeIds field value if set, zero value otherwise. +func (o *BackupProperties) GetVolumeIds() *[]string { + if o == nil || IsNil(o.VolumeIds) { + var ret *[]string + return ret + } + return o.VolumeIds +} + +// GetVolumeIdsOk returns a tuple with the VolumeIds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BackupProperties) GetVolumeIdsOk() (*[]string, bool) { + if o == nil || IsNil(o.VolumeIds) { + return nil, false + } + return o.VolumeIds, true +} + +// HasVolumeIds returns a boolean if a field has been set. +func (o *BackupProperties) HasVolumeIds() bool { + if o != nil && !IsNil(o.VolumeIds) { + return true + } + + return false +} + +// SetVolumeIds gets a reference to the given []string and assigns it to the VolumeIds field. +func (o *BackupProperties) SetVolumeIds(v *[]string) { + o.VolumeIds = v +} + +func (o BackupProperties) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["name"] = o.Name + toSerialize["retentionPeriod"] = o.RetentionPeriod + if !IsNil(o.VolumeIds) { + toSerialize["volumeIds"] = o.VolumeIds + } + return toSerialize, nil +} + +type NullableBackupProperties struct { + value *BackupProperties + isSet bool +} + +func (v NullableBackupProperties) Get() *BackupProperties { + return v.value +} + +func (v *NullableBackupProperties) Set(val *BackupProperties) { + v.value = val + v.isSet = true +} + +func (v NullableBackupProperties) IsSet() bool { + return v.isSet +} + +func (v *NullableBackupProperties) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableBackupProperties(val *BackupProperties) *NullableBackupProperties { + return &NullableBackupProperties{value: val, isSet: true} +} + +func (v NullableBackupProperties) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableBackupProperties) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/serverupdate/model_create_update_payload.go b/services/serverupdate/model_create_update_payload.go new file mode 100644 index 000000000..ebd2615b5 --- /dev/null +++ b/services/serverupdate/model_create_update_payload.go @@ -0,0 +1,183 @@ +/* +STACKIT Server Update Management API + +API endpoints for Server Update Operations on STACKIT Servers. + +API version: 1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package serverupdate + +import ( + "encoding/json" +) + +// checks if the CreateUpdatePayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &CreateUpdatePayload{} + +// CreateUpdatePayload struct for CreateUpdatePayload +type CreateUpdatePayload struct { + BackupBeforeUpdate *bool `json:"backupBeforeUpdate,omitempty"` + BackupProperties *BackupProperties `json:"backupProperties,omitempty"` + // Can be cast to int32 without loss of precision. + // REQUIRED + MaintenanceWindow *int64 `json:"maintenanceWindow"` +} + +type _CreateUpdatePayload CreateUpdatePayload + +// NewCreateUpdatePayload instantiates a new CreateUpdatePayload 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 NewCreateUpdatePayload(maintenanceWindow *int64) *CreateUpdatePayload { + this := CreateUpdatePayload{} + this.MaintenanceWindow = maintenanceWindow + return &this +} + +// NewCreateUpdatePayloadWithDefaults instantiates a new CreateUpdatePayload 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 NewCreateUpdatePayloadWithDefaults() *CreateUpdatePayload { + this := CreateUpdatePayload{} + return &this +} + +// GetBackupBeforeUpdate returns the BackupBeforeUpdate field value if set, zero value otherwise. +func (o *CreateUpdatePayload) GetBackupBeforeUpdate() *bool { + if o == nil || IsNil(o.BackupBeforeUpdate) { + var ret *bool + return ret + } + return o.BackupBeforeUpdate +} + +// GetBackupBeforeUpdateOk returns a tuple with the BackupBeforeUpdate field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateUpdatePayload) GetBackupBeforeUpdateOk() (*bool, bool) { + if o == nil || IsNil(o.BackupBeforeUpdate) { + return nil, false + } + return o.BackupBeforeUpdate, true +} + +// HasBackupBeforeUpdate returns a boolean if a field has been set. +func (o *CreateUpdatePayload) HasBackupBeforeUpdate() bool { + if o != nil && !IsNil(o.BackupBeforeUpdate) { + return true + } + + return false +} + +// SetBackupBeforeUpdate gets a reference to the given bool and assigns it to the BackupBeforeUpdate field. +func (o *CreateUpdatePayload) SetBackupBeforeUpdate(v *bool) { + o.BackupBeforeUpdate = v +} + +// GetBackupProperties returns the BackupProperties field value if set, zero value otherwise. +func (o *CreateUpdatePayload) GetBackupProperties() *BackupProperties { + if o == nil || IsNil(o.BackupProperties) { + var ret *BackupProperties + return ret + } + return o.BackupProperties +} + +// GetBackupPropertiesOk returns a tuple with the BackupProperties field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateUpdatePayload) GetBackupPropertiesOk() (*BackupProperties, bool) { + if o == nil || IsNil(o.BackupProperties) { + return nil, false + } + return o.BackupProperties, true +} + +// HasBackupProperties returns a boolean if a field has been set. +func (o *CreateUpdatePayload) HasBackupProperties() bool { + if o != nil && !IsNil(o.BackupProperties) { + return true + } + + return false +} + +// SetBackupProperties gets a reference to the given BackupProperties and assigns it to the BackupProperties field. +func (o *CreateUpdatePayload) SetBackupProperties(v *BackupProperties) { + o.BackupProperties = v +} + +// GetMaintenanceWindow returns the MaintenanceWindow field value +func (o *CreateUpdatePayload) GetMaintenanceWindow() *int64 { + if o == nil { + var ret *int64 + return ret + } + + return o.MaintenanceWindow +} + +// GetMaintenanceWindowOk returns a tuple with the MaintenanceWindow field value +// and a boolean to check if the value has been set. +func (o *CreateUpdatePayload) GetMaintenanceWindowOk() (*int64, bool) { + if o == nil { + return nil, false + } + return o.MaintenanceWindow, true +} + +// SetMaintenanceWindow sets field value +func (o *CreateUpdatePayload) SetMaintenanceWindow(v *int64) { + o.MaintenanceWindow = v +} + +func (o CreateUpdatePayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.BackupBeforeUpdate) { + toSerialize["backupBeforeUpdate"] = o.BackupBeforeUpdate + } + if !IsNil(o.BackupProperties) { + toSerialize["backupProperties"] = o.BackupProperties + } + toSerialize["maintenanceWindow"] = o.MaintenanceWindow + return toSerialize, nil +} + +type NullableCreateUpdatePayload struct { + value *CreateUpdatePayload + isSet bool +} + +func (v NullableCreateUpdatePayload) Get() *CreateUpdatePayload { + return v.value +} + +func (v *NullableCreateUpdatePayload) Set(val *CreateUpdatePayload) { + v.value = val + v.isSet = true +} + +func (v NullableCreateUpdatePayload) IsSet() bool { + return v.isSet +} + +func (v *NullableCreateUpdatePayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCreateUpdatePayload(val *CreateUpdatePayload) *NullableCreateUpdatePayload { + return &NullableCreateUpdatePayload{value: val, isSet: true} +} + +func (v NullableCreateUpdatePayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCreateUpdatePayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/serverupdate/model_create_update_schedule_payload.go b/services/serverupdate/model_create_update_schedule_payload.go new file mode 100644 index 000000000..18162c7f0 --- /dev/null +++ b/services/serverupdate/model_create_update_schedule_payload.go @@ -0,0 +1,224 @@ +/* +STACKIT Server Update Management API + +API endpoints for Server Update Operations on STACKIT Servers. + +API version: 1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package serverupdate + +import ( + "encoding/json" +) + +// checks if the CreateUpdateSchedulePayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &CreateUpdateSchedulePayload{} + +// CreateUpdateSchedulePayload struct for CreateUpdateSchedulePayload +type CreateUpdateSchedulePayload struct { + // REQUIRED + Enabled *bool `json:"enabled"` + // Can be cast to int32 without loss of precision. + // REQUIRED + Id *int64 `json:"id"` + // Can be cast to int32 without loss of precision. + // REQUIRED + MaintenanceWindow *int64 `json:"maintenanceWindow"` + // REQUIRED + Name *string `json:"name"` + // REQUIRED + Rrule *string `json:"rrule"` +} + +type _CreateUpdateSchedulePayload CreateUpdateSchedulePayload + +// NewCreateUpdateSchedulePayload instantiates a new CreateUpdateSchedulePayload 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 NewCreateUpdateSchedulePayload(enabled *bool, id *int64, maintenanceWindow *int64, name *string, rrule *string) *CreateUpdateSchedulePayload { + this := CreateUpdateSchedulePayload{} + this.Enabled = enabled + this.Id = id + this.MaintenanceWindow = maintenanceWindow + this.Name = name + this.Rrule = rrule + return &this +} + +// NewCreateUpdateSchedulePayloadWithDefaults instantiates a new CreateUpdateSchedulePayload 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 NewCreateUpdateSchedulePayloadWithDefaults() *CreateUpdateSchedulePayload { + this := CreateUpdateSchedulePayload{} + return &this +} + +// GetEnabled returns the Enabled field value +func (o *CreateUpdateSchedulePayload) GetEnabled() *bool { + if o == nil { + var ret *bool + return ret + } + + return o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value +// and a boolean to check if the value has been set. +func (o *CreateUpdateSchedulePayload) GetEnabledOk() (*bool, bool) { + if o == nil { + return nil, false + } + return o.Enabled, true +} + +// SetEnabled sets field value +func (o *CreateUpdateSchedulePayload) SetEnabled(v *bool) { + o.Enabled = v +} + +// GetId returns the Id field value +func (o *CreateUpdateSchedulePayload) GetId() *int64 { + if o == nil { + var ret *int64 + 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 *CreateUpdateSchedulePayload) GetIdOk() (*int64, bool) { + if o == nil { + return nil, false + } + return o.Id, true +} + +// SetId sets field value +func (o *CreateUpdateSchedulePayload) SetId(v *int64) { + o.Id = v +} + +// GetMaintenanceWindow returns the MaintenanceWindow field value +func (o *CreateUpdateSchedulePayload) GetMaintenanceWindow() *int64 { + if o == nil { + var ret *int64 + return ret + } + + return o.MaintenanceWindow +} + +// GetMaintenanceWindowOk returns a tuple with the MaintenanceWindow field value +// and a boolean to check if the value has been set. +func (o *CreateUpdateSchedulePayload) GetMaintenanceWindowOk() (*int64, bool) { + if o == nil { + return nil, false + } + return o.MaintenanceWindow, true +} + +// SetMaintenanceWindow sets field value +func (o *CreateUpdateSchedulePayload) SetMaintenanceWindow(v *int64) { + o.MaintenanceWindow = v +} + +// GetName returns the Name field value +func (o *CreateUpdateSchedulePayload) GetName() *string { + if o == nil { + var ret *string + return ret + } + + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *CreateUpdateSchedulePayload) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.Name, true +} + +// SetName sets field value +func (o *CreateUpdateSchedulePayload) SetName(v *string) { + o.Name = v +} + +// GetRrule returns the Rrule field value +func (o *CreateUpdateSchedulePayload) GetRrule() *string { + if o == nil { + var ret *string + return ret + } + + return o.Rrule +} + +// GetRruleOk returns a tuple with the Rrule field value +// and a boolean to check if the value has been set. +func (o *CreateUpdateSchedulePayload) GetRruleOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.Rrule, true +} + +// SetRrule sets field value +func (o *CreateUpdateSchedulePayload) SetRrule(v *string) { + o.Rrule = v +} + +func (o CreateUpdateSchedulePayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["enabled"] = o.Enabled + toSerialize["id"] = o.Id + toSerialize["maintenanceWindow"] = o.MaintenanceWindow + toSerialize["name"] = o.Name + toSerialize["rrule"] = o.Rrule + return toSerialize, nil +} + +type NullableCreateUpdateSchedulePayload struct { + value *CreateUpdateSchedulePayload + isSet bool +} + +func (v NullableCreateUpdateSchedulePayload) Get() *CreateUpdateSchedulePayload { + return v.value +} + +func (v *NullableCreateUpdateSchedulePayload) Set(val *CreateUpdateSchedulePayload) { + v.value = val + v.isSet = true +} + +func (v NullableCreateUpdateSchedulePayload) IsSet() bool { + return v.isSet +} + +func (v *NullableCreateUpdateSchedulePayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCreateUpdateSchedulePayload(val *CreateUpdateSchedulePayload) *NullableCreateUpdateSchedulePayload { + return &NullableCreateUpdateSchedulePayload{value: val, isSet: true} +} + +func (v NullableCreateUpdateSchedulePayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCreateUpdateSchedulePayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/serverupdate/model_enable_service_payload.go b/services/serverupdate/model_enable_service_payload.go new file mode 100644 index 000000000..147b4d390 --- /dev/null +++ b/services/serverupdate/model_enable_service_payload.go @@ -0,0 +1,116 @@ +/* +STACKIT Server Update Management API + +API endpoints for Server Update Operations on STACKIT Servers. + +API version: 1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package serverupdate + +import ( + "encoding/json" +) + +// checks if the EnableServicePayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &EnableServicePayload{} + +// EnableServicePayload struct for EnableServicePayload +type EnableServicePayload struct { + UpdatePolicyId *string `json:"updatePolicyId,omitempty"` +} + +// NewEnableServicePayload instantiates a new EnableServicePayload 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 NewEnableServicePayload() *EnableServicePayload { + this := EnableServicePayload{} + return &this +} + +// NewEnableServicePayloadWithDefaults instantiates a new EnableServicePayload 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 NewEnableServicePayloadWithDefaults() *EnableServicePayload { + this := EnableServicePayload{} + return &this +} + +// GetUpdatePolicyId returns the UpdatePolicyId field value if set, zero value otherwise. +func (o *EnableServicePayload) GetUpdatePolicyId() *string { + if o == nil || IsNil(o.UpdatePolicyId) { + var ret *string + return ret + } + return o.UpdatePolicyId +} + +// GetUpdatePolicyIdOk returns a tuple with the UpdatePolicyId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EnableServicePayload) GetUpdatePolicyIdOk() (*string, bool) { + if o == nil || IsNil(o.UpdatePolicyId) { + return nil, false + } + return o.UpdatePolicyId, true +} + +// HasUpdatePolicyId returns a boolean if a field has been set. +func (o *EnableServicePayload) HasUpdatePolicyId() bool { + if o != nil && !IsNil(o.UpdatePolicyId) { + return true + } + + return false +} + +// SetUpdatePolicyId gets a reference to the given string and assigns it to the UpdatePolicyId field. +func (o *EnableServicePayload) SetUpdatePolicyId(v *string) { + o.UpdatePolicyId = v +} + +func (o EnableServicePayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.UpdatePolicyId) { + toSerialize["updatePolicyId"] = o.UpdatePolicyId + } + return toSerialize, nil +} + +type NullableEnableServicePayload struct { + value *EnableServicePayload + isSet bool +} + +func (v NullableEnableServicePayload) Get() *EnableServicePayload { + return v.value +} + +func (v *NullableEnableServicePayload) Set(val *EnableServicePayload) { + v.value = val + v.isSet = true +} + +func (v NullableEnableServicePayload) IsSet() bool { + return v.isSet +} + +func (v *NullableEnableServicePayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableEnableServicePayload(val *EnableServicePayload) *NullableEnableServicePayload { + return &NullableEnableServicePayload{value: val, isSet: true} +} + +func (v NullableEnableServicePayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableEnableServicePayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/serverupdate/model_enable_service_resource_payload.go b/services/serverupdate/model_enable_service_resource_payload.go new file mode 100644 index 000000000..59b1268d1 --- /dev/null +++ b/services/serverupdate/model_enable_service_resource_payload.go @@ -0,0 +1,116 @@ +/* +STACKIT Server Update Management API + +API endpoints for Server Update Operations on STACKIT Servers. + +API version: 1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package serverupdate + +import ( + "encoding/json" +) + +// checks if the EnableServiceResourcePayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &EnableServiceResourcePayload{} + +// EnableServiceResourcePayload struct for EnableServiceResourcePayload +type EnableServiceResourcePayload struct { + UpdatePolicyId *string `json:"updatePolicyId,omitempty"` +} + +// NewEnableServiceResourcePayload instantiates a new EnableServiceResourcePayload 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 NewEnableServiceResourcePayload() *EnableServiceResourcePayload { + this := EnableServiceResourcePayload{} + return &this +} + +// NewEnableServiceResourcePayloadWithDefaults instantiates a new EnableServiceResourcePayload 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 NewEnableServiceResourcePayloadWithDefaults() *EnableServiceResourcePayload { + this := EnableServiceResourcePayload{} + return &this +} + +// GetUpdatePolicyId returns the UpdatePolicyId field value if set, zero value otherwise. +func (o *EnableServiceResourcePayload) GetUpdatePolicyId() *string { + if o == nil || IsNil(o.UpdatePolicyId) { + var ret *string + return ret + } + return o.UpdatePolicyId +} + +// GetUpdatePolicyIdOk returns a tuple with the UpdatePolicyId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EnableServiceResourcePayload) GetUpdatePolicyIdOk() (*string, bool) { + if o == nil || IsNil(o.UpdatePolicyId) { + return nil, false + } + return o.UpdatePolicyId, true +} + +// HasUpdatePolicyId returns a boolean if a field has been set. +func (o *EnableServiceResourcePayload) HasUpdatePolicyId() bool { + if o != nil && !IsNil(o.UpdatePolicyId) { + return true + } + + return false +} + +// SetUpdatePolicyId gets a reference to the given string and assigns it to the UpdatePolicyId field. +func (o *EnableServiceResourcePayload) SetUpdatePolicyId(v *string) { + o.UpdatePolicyId = v +} + +func (o EnableServiceResourcePayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.UpdatePolicyId) { + toSerialize["updatePolicyId"] = o.UpdatePolicyId + } + return toSerialize, nil +} + +type NullableEnableServiceResourcePayload struct { + value *EnableServiceResourcePayload + isSet bool +} + +func (v NullableEnableServiceResourcePayload) Get() *EnableServiceResourcePayload { + return v.value +} + +func (v *NullableEnableServiceResourcePayload) Set(val *EnableServiceResourcePayload) { + v.value = val + v.isSet = true +} + +func (v NullableEnableServiceResourcePayload) IsSet() bool { + return v.isSet +} + +func (v *NullableEnableServiceResourcePayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableEnableServiceResourcePayload(val *EnableServiceResourcePayload) *NullableEnableServiceResourcePayload { + return &NullableEnableServiceResourcePayload{value: val, isSet: true} +} + +func (v NullableEnableServiceResourcePayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableEnableServiceResourcePayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/serverupdate/model_get_update_schedules_response.go b/services/serverupdate/model_get_update_schedules_response.go new file mode 100644 index 000000000..15be219f8 --- /dev/null +++ b/services/serverupdate/model_get_update_schedules_response.go @@ -0,0 +1,116 @@ +/* +STACKIT Server Update Management API + +API endpoints for Server Update Operations on STACKIT Servers. + +API version: 1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package serverupdate + +import ( + "encoding/json" +) + +// checks if the GetUpdateSchedulesResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &GetUpdateSchedulesResponse{} + +// GetUpdateSchedulesResponse struct for GetUpdateSchedulesResponse +type GetUpdateSchedulesResponse struct { + Items *[]UpdateSchedule `json:"items,omitempty"` +} + +// NewGetUpdateSchedulesResponse instantiates a new GetUpdateSchedulesResponse 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 NewGetUpdateSchedulesResponse() *GetUpdateSchedulesResponse { + this := GetUpdateSchedulesResponse{} + return &this +} + +// NewGetUpdateSchedulesResponseWithDefaults instantiates a new GetUpdateSchedulesResponse 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 NewGetUpdateSchedulesResponseWithDefaults() *GetUpdateSchedulesResponse { + this := GetUpdateSchedulesResponse{} + return &this +} + +// GetItems returns the Items field value if set, zero value otherwise. +func (o *GetUpdateSchedulesResponse) GetItems() *[]UpdateSchedule { + if o == nil || IsNil(o.Items) { + var ret *[]UpdateSchedule + return ret + } + return o.Items +} + +// GetItemsOk returns a tuple with the Items field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetUpdateSchedulesResponse) GetItemsOk() (*[]UpdateSchedule, bool) { + if o == nil || IsNil(o.Items) { + return nil, false + } + return o.Items, true +} + +// HasItems returns a boolean if a field has been set. +func (o *GetUpdateSchedulesResponse) HasItems() bool { + if o != nil && !IsNil(o.Items) { + return true + } + + return false +} + +// SetItems gets a reference to the given []UpdateSchedule and assigns it to the Items field. +func (o *GetUpdateSchedulesResponse) SetItems(v *[]UpdateSchedule) { + o.Items = v +} + +func (o GetUpdateSchedulesResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Items) { + toSerialize["items"] = o.Items + } + return toSerialize, nil +} + +type NullableGetUpdateSchedulesResponse struct { + value *GetUpdateSchedulesResponse + isSet bool +} + +func (v NullableGetUpdateSchedulesResponse) Get() *GetUpdateSchedulesResponse { + return v.value +} + +func (v *NullableGetUpdateSchedulesResponse) Set(val *GetUpdateSchedulesResponse) { + v.value = val + v.isSet = true +} + +func (v NullableGetUpdateSchedulesResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableGetUpdateSchedulesResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableGetUpdateSchedulesResponse(val *GetUpdateSchedulesResponse) *NullableGetUpdateSchedulesResponse { + return &NullableGetUpdateSchedulesResponse{value: val, isSet: true} +} + +func (v NullableGetUpdateSchedulesResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableGetUpdateSchedulesResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/serverupdate/model_get_updates_list_response.go b/services/serverupdate/model_get_updates_list_response.go new file mode 100644 index 000000000..344dda62e --- /dev/null +++ b/services/serverupdate/model_get_updates_list_response.go @@ -0,0 +1,116 @@ +/* +STACKIT Server Update Management API + +API endpoints for Server Update Operations on STACKIT Servers. + +API version: 1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package serverupdate + +import ( + "encoding/json" +) + +// checks if the GetUpdatesListResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &GetUpdatesListResponse{} + +// GetUpdatesListResponse struct for GetUpdatesListResponse +type GetUpdatesListResponse struct { + Items *[]Update `json:"items,omitempty"` +} + +// NewGetUpdatesListResponse instantiates a new GetUpdatesListResponse 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 NewGetUpdatesListResponse() *GetUpdatesListResponse { + this := GetUpdatesListResponse{} + return &this +} + +// NewGetUpdatesListResponseWithDefaults instantiates a new GetUpdatesListResponse 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 NewGetUpdatesListResponseWithDefaults() *GetUpdatesListResponse { + this := GetUpdatesListResponse{} + return &this +} + +// GetItems returns the Items field value if set, zero value otherwise. +func (o *GetUpdatesListResponse) GetItems() *[]Update { + if o == nil || IsNil(o.Items) { + var ret *[]Update + return ret + } + return o.Items +} + +// GetItemsOk returns a tuple with the Items field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetUpdatesListResponse) GetItemsOk() (*[]Update, bool) { + if o == nil || IsNil(o.Items) { + return nil, false + } + return o.Items, true +} + +// HasItems returns a boolean if a field has been set. +func (o *GetUpdatesListResponse) HasItems() bool { + if o != nil && !IsNil(o.Items) { + return true + } + + return false +} + +// SetItems gets a reference to the given []Update and assigns it to the Items field. +func (o *GetUpdatesListResponse) SetItems(v *[]Update) { + o.Items = v +} + +func (o GetUpdatesListResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Items) { + toSerialize["items"] = o.Items + } + return toSerialize, nil +} + +type NullableGetUpdatesListResponse struct { + value *GetUpdatesListResponse + isSet bool +} + +func (v NullableGetUpdatesListResponse) Get() *GetUpdatesListResponse { + return v.value +} + +func (v *NullableGetUpdatesListResponse) Set(val *GetUpdatesListResponse) { + v.value = val + v.isSet = true +} + +func (v NullableGetUpdatesListResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableGetUpdatesListResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableGetUpdatesListResponse(val *GetUpdatesListResponse) *NullableGetUpdatesListResponse { + return &NullableGetUpdatesListResponse{value: val, isSet: true} +} + +func (v NullableGetUpdatesListResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableGetUpdatesListResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/serverupdate/model_update.go b/services/serverupdate/model_update.go new file mode 100644 index 000000000..da934754e --- /dev/null +++ b/services/serverupdate/model_update.go @@ -0,0 +1,332 @@ +/* +STACKIT Server Update Management API + +API endpoints for Server Update Operations on STACKIT Servers. + +API version: 1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package serverupdate + +import ( + "encoding/json" +) + +// checks if the Update type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Update{} + +// Update struct for Update +type Update struct { + // REQUIRED + EndDate *string `json:"endDate"` + FailReason *string `json:"failReason,omitempty"` + // Can be cast to int32 without loss of precision. + FailedUpdates *int64 `json:"failedUpdates,omitempty"` + // REQUIRED + Id *string `json:"id"` + // Can be cast to int32 without loss of precision. + InstalledUpdates *int64 `json:"installedUpdates,omitempty"` + // REQUIRED + OsServerId *string `json:"osServerId"` + // REQUIRED + StartDate *string `json:"startDate"` + // REQUIRED + Status *string `json:"status"` +} + +type _Update Update + +// NewUpdate instantiates a new Update 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 NewUpdate(endDate *string, id *string, osServerId *string, startDate *string, status *string) *Update { + this := Update{} + this.EndDate = endDate + this.Id = id + this.OsServerId = osServerId + this.StartDate = startDate + this.Status = status + return &this +} + +// NewUpdateWithDefaults instantiates a new Update 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 NewUpdateWithDefaults() *Update { + this := Update{} + return &this +} + +// GetEndDate returns the EndDate field value +func (o *Update) GetEndDate() *string { + if o == nil { + var ret *string + return ret + } + + return o.EndDate +} + +// GetEndDateOk returns a tuple with the EndDate field value +// and a boolean to check if the value has been set. +func (o *Update) GetEndDateOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.EndDate, true +} + +// SetEndDate sets field value +func (o *Update) SetEndDate(v *string) { + o.EndDate = v +} + +// GetFailReason returns the FailReason field value if set, zero value otherwise. +func (o *Update) GetFailReason() *string { + if o == nil || IsNil(o.FailReason) { + var ret *string + return ret + } + return o.FailReason +} + +// GetFailReasonOk returns a tuple with the FailReason field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Update) GetFailReasonOk() (*string, bool) { + if o == nil || IsNil(o.FailReason) { + return nil, false + } + return o.FailReason, true +} + +// HasFailReason returns a boolean if a field has been set. +func (o *Update) HasFailReason() bool { + if o != nil && !IsNil(o.FailReason) { + return true + } + + return false +} + +// SetFailReason gets a reference to the given string and assigns it to the FailReason field. +func (o *Update) SetFailReason(v *string) { + o.FailReason = v +} + +// GetFailedUpdates returns the FailedUpdates field value if set, zero value otherwise. +func (o *Update) GetFailedUpdates() *int64 { + if o == nil || IsNil(o.FailedUpdates) { + var ret *int64 + return ret + } + return o.FailedUpdates +} + +// GetFailedUpdatesOk returns a tuple with the FailedUpdates field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Update) GetFailedUpdatesOk() (*int64, bool) { + if o == nil || IsNil(o.FailedUpdates) { + return nil, false + } + return o.FailedUpdates, true +} + +// HasFailedUpdates returns a boolean if a field has been set. +func (o *Update) HasFailedUpdates() bool { + if o != nil && !IsNil(o.FailedUpdates) { + return true + } + + return false +} + +// SetFailedUpdates gets a reference to the given int64 and assigns it to the FailedUpdates field. +func (o *Update) SetFailedUpdates(v *int64) { + o.FailedUpdates = v +} + +// GetId returns the Id field value +func (o *Update) 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 *Update) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.Id, true +} + +// SetId sets field value +func (o *Update) SetId(v *string) { + o.Id = v +} + +// GetInstalledUpdates returns the InstalledUpdates field value if set, zero value otherwise. +func (o *Update) GetInstalledUpdates() *int64 { + if o == nil || IsNil(o.InstalledUpdates) { + var ret *int64 + return ret + } + return o.InstalledUpdates +} + +// GetInstalledUpdatesOk returns a tuple with the InstalledUpdates field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Update) GetInstalledUpdatesOk() (*int64, bool) { + if o == nil || IsNil(o.InstalledUpdates) { + return nil, false + } + return o.InstalledUpdates, true +} + +// HasInstalledUpdates returns a boolean if a field has been set. +func (o *Update) HasInstalledUpdates() bool { + if o != nil && !IsNil(o.InstalledUpdates) { + return true + } + + return false +} + +// SetInstalledUpdates gets a reference to the given int64 and assigns it to the InstalledUpdates field. +func (o *Update) SetInstalledUpdates(v *int64) { + o.InstalledUpdates = v +} + +// GetOsServerId returns the OsServerId field value +func (o *Update) GetOsServerId() *string { + if o == nil { + var ret *string + return ret + } + + return o.OsServerId +} + +// GetOsServerIdOk returns a tuple with the OsServerId field value +// and a boolean to check if the value has been set. +func (o *Update) GetOsServerIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.OsServerId, true +} + +// SetOsServerId sets field value +func (o *Update) SetOsServerId(v *string) { + o.OsServerId = v +} + +// GetStartDate returns the StartDate field value +func (o *Update) GetStartDate() *string { + if o == nil { + var ret *string + return ret + } + + return o.StartDate +} + +// GetStartDateOk returns a tuple with the StartDate field value +// and a boolean to check if the value has been set. +func (o *Update) GetStartDateOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.StartDate, true +} + +// SetStartDate sets field value +func (o *Update) SetStartDate(v *string) { + o.StartDate = v +} + +// GetStatus returns the Status field value +func (o *Update) GetStatus() *string { + if o == nil { + var ret *string + return ret + } + + return o.Status +} + +// GetStatusOk returns a tuple with the Status field value +// and a boolean to check if the value has been set. +func (o *Update) GetStatusOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.Status, true +} + +// SetStatus sets field value +func (o *Update) SetStatus(v *string) { + o.Status = v +} + +func (o Update) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["endDate"] = o.EndDate + if !IsNil(o.FailReason) { + toSerialize["failReason"] = o.FailReason + } + if !IsNil(o.FailedUpdates) { + toSerialize["failedUpdates"] = o.FailedUpdates + } + toSerialize["id"] = o.Id + if !IsNil(o.InstalledUpdates) { + toSerialize["installedUpdates"] = o.InstalledUpdates + } + toSerialize["osServerId"] = o.OsServerId + toSerialize["startDate"] = o.StartDate + toSerialize["status"] = o.Status + return toSerialize, nil +} + +type NullableUpdate struct { + value *Update + isSet bool +} + +func (v NullableUpdate) Get() *Update { + return v.value +} + +func (v *NullableUpdate) Set(val *Update) { + v.value = val + v.isSet = true +} + +func (v NullableUpdate) IsSet() bool { + return v.isSet +} + +func (v *NullableUpdate) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableUpdate(val *Update) *NullableUpdate { + return &NullableUpdate{value: val, isSet: true} +} + +func (v NullableUpdate) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableUpdate) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/serverupdate/model_update_schedule.go b/services/serverupdate/model_update_schedule.go new file mode 100644 index 000000000..8ee0e6fe7 --- /dev/null +++ b/services/serverupdate/model_update_schedule.go @@ -0,0 +1,224 @@ +/* +STACKIT Server Update Management API + +API endpoints for Server Update Operations on STACKIT Servers. + +API version: 1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package serverupdate + +import ( + "encoding/json" +) + +// checks if the UpdateSchedule type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &UpdateSchedule{} + +// UpdateSchedule struct for UpdateSchedule +type UpdateSchedule struct { + // REQUIRED + Enabled *bool `json:"enabled"` + // Can be cast to int32 without loss of precision. + // REQUIRED + Id *int64 `json:"id"` + // Can be cast to int32 without loss of precision. + // REQUIRED + MaintenanceWindow *int64 `json:"maintenanceWindow"` + // REQUIRED + Name *string `json:"name"` + // REQUIRED + Rrule *string `json:"rrule"` +} + +type _UpdateSchedule UpdateSchedule + +// NewUpdateSchedule instantiates a new UpdateSchedule 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 NewUpdateSchedule(enabled *bool, id *int64, maintenanceWindow *int64, name *string, rrule *string) *UpdateSchedule { + this := UpdateSchedule{} + this.Enabled = enabled + this.Id = id + this.MaintenanceWindow = maintenanceWindow + this.Name = name + this.Rrule = rrule + return &this +} + +// NewUpdateScheduleWithDefaults instantiates a new UpdateSchedule 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 NewUpdateScheduleWithDefaults() *UpdateSchedule { + this := UpdateSchedule{} + return &this +} + +// GetEnabled returns the Enabled field value +func (o *UpdateSchedule) GetEnabled() *bool { + if o == nil { + var ret *bool + return ret + } + + return o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value +// and a boolean to check if the value has been set. +func (o *UpdateSchedule) GetEnabledOk() (*bool, bool) { + if o == nil { + return nil, false + } + return o.Enabled, true +} + +// SetEnabled sets field value +func (o *UpdateSchedule) SetEnabled(v *bool) { + o.Enabled = v +} + +// GetId returns the Id field value +func (o *UpdateSchedule) GetId() *int64 { + if o == nil { + var ret *int64 + 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 *UpdateSchedule) GetIdOk() (*int64, bool) { + if o == nil { + return nil, false + } + return o.Id, true +} + +// SetId sets field value +func (o *UpdateSchedule) SetId(v *int64) { + o.Id = v +} + +// GetMaintenanceWindow returns the MaintenanceWindow field value +func (o *UpdateSchedule) GetMaintenanceWindow() *int64 { + if o == nil { + var ret *int64 + return ret + } + + return o.MaintenanceWindow +} + +// GetMaintenanceWindowOk returns a tuple with the MaintenanceWindow field value +// and a boolean to check if the value has been set. +func (o *UpdateSchedule) GetMaintenanceWindowOk() (*int64, bool) { + if o == nil { + return nil, false + } + return o.MaintenanceWindow, true +} + +// SetMaintenanceWindow sets field value +func (o *UpdateSchedule) SetMaintenanceWindow(v *int64) { + o.MaintenanceWindow = v +} + +// GetName returns the Name field value +func (o *UpdateSchedule) GetName() *string { + if o == nil { + var ret *string + return ret + } + + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *UpdateSchedule) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.Name, true +} + +// SetName sets field value +func (o *UpdateSchedule) SetName(v *string) { + o.Name = v +} + +// GetRrule returns the Rrule field value +func (o *UpdateSchedule) GetRrule() *string { + if o == nil { + var ret *string + return ret + } + + return o.Rrule +} + +// GetRruleOk returns a tuple with the Rrule field value +// and a boolean to check if the value has been set. +func (o *UpdateSchedule) GetRruleOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.Rrule, true +} + +// SetRrule sets field value +func (o *UpdateSchedule) SetRrule(v *string) { + o.Rrule = v +} + +func (o UpdateSchedule) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["enabled"] = o.Enabled + toSerialize["id"] = o.Id + toSerialize["maintenanceWindow"] = o.MaintenanceWindow + toSerialize["name"] = o.Name + toSerialize["rrule"] = o.Rrule + return toSerialize, nil +} + +type NullableUpdateSchedule struct { + value *UpdateSchedule + isSet bool +} + +func (v NullableUpdateSchedule) Get() *UpdateSchedule { + return v.value +} + +func (v *NullableUpdateSchedule) Set(val *UpdateSchedule) { + v.value = val + v.isSet = true +} + +func (v NullableUpdateSchedule) IsSet() bool { + return v.isSet +} + +func (v *NullableUpdateSchedule) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableUpdateSchedule(val *UpdateSchedule) *NullableUpdateSchedule { + return &NullableUpdateSchedule{value: val, isSet: true} +} + +func (v NullableUpdateSchedule) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableUpdateSchedule) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/serverupdate/model_update_update_schedule_payload.go b/services/serverupdate/model_update_update_schedule_payload.go new file mode 100644 index 000000000..20d2c6cb8 --- /dev/null +++ b/services/serverupdate/model_update_update_schedule_payload.go @@ -0,0 +1,224 @@ +/* +STACKIT Server Update Management API + +API endpoints for Server Update Operations on STACKIT Servers. + +API version: 1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package serverupdate + +import ( + "encoding/json" +) + +// checks if the UpdateUpdateSchedulePayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &UpdateUpdateSchedulePayload{} + +// UpdateUpdateSchedulePayload struct for UpdateUpdateSchedulePayload +type UpdateUpdateSchedulePayload struct { + // REQUIRED + Enabled *bool `json:"enabled"` + // Can be cast to int32 without loss of precision. + // REQUIRED + Id *int64 `json:"id"` + // Can be cast to int32 without loss of precision. + // REQUIRED + MaintenanceWindow *int64 `json:"maintenanceWindow"` + // REQUIRED + Name *string `json:"name"` + // REQUIRED + Rrule *string `json:"rrule"` +} + +type _UpdateUpdateSchedulePayload UpdateUpdateSchedulePayload + +// NewUpdateUpdateSchedulePayload instantiates a new UpdateUpdateSchedulePayload 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 NewUpdateUpdateSchedulePayload(enabled *bool, id *int64, maintenanceWindow *int64, name *string, rrule *string) *UpdateUpdateSchedulePayload { + this := UpdateUpdateSchedulePayload{} + this.Enabled = enabled + this.Id = id + this.MaintenanceWindow = maintenanceWindow + this.Name = name + this.Rrule = rrule + return &this +} + +// NewUpdateUpdateSchedulePayloadWithDefaults instantiates a new UpdateUpdateSchedulePayload 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 NewUpdateUpdateSchedulePayloadWithDefaults() *UpdateUpdateSchedulePayload { + this := UpdateUpdateSchedulePayload{} + return &this +} + +// GetEnabled returns the Enabled field value +func (o *UpdateUpdateSchedulePayload) GetEnabled() *bool { + if o == nil { + var ret *bool + return ret + } + + return o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value +// and a boolean to check if the value has been set. +func (o *UpdateUpdateSchedulePayload) GetEnabledOk() (*bool, bool) { + if o == nil { + return nil, false + } + return o.Enabled, true +} + +// SetEnabled sets field value +func (o *UpdateUpdateSchedulePayload) SetEnabled(v *bool) { + o.Enabled = v +} + +// GetId returns the Id field value +func (o *UpdateUpdateSchedulePayload) GetId() *int64 { + if o == nil { + var ret *int64 + 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 *UpdateUpdateSchedulePayload) GetIdOk() (*int64, bool) { + if o == nil { + return nil, false + } + return o.Id, true +} + +// SetId sets field value +func (o *UpdateUpdateSchedulePayload) SetId(v *int64) { + o.Id = v +} + +// GetMaintenanceWindow returns the MaintenanceWindow field value +func (o *UpdateUpdateSchedulePayload) GetMaintenanceWindow() *int64 { + if o == nil { + var ret *int64 + return ret + } + + return o.MaintenanceWindow +} + +// GetMaintenanceWindowOk returns a tuple with the MaintenanceWindow field value +// and a boolean to check if the value has been set. +func (o *UpdateUpdateSchedulePayload) GetMaintenanceWindowOk() (*int64, bool) { + if o == nil { + return nil, false + } + return o.MaintenanceWindow, true +} + +// SetMaintenanceWindow sets field value +func (o *UpdateUpdateSchedulePayload) SetMaintenanceWindow(v *int64) { + o.MaintenanceWindow = v +} + +// GetName returns the Name field value +func (o *UpdateUpdateSchedulePayload) GetName() *string { + if o == nil { + var ret *string + return ret + } + + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *UpdateUpdateSchedulePayload) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.Name, true +} + +// SetName sets field value +func (o *UpdateUpdateSchedulePayload) SetName(v *string) { + o.Name = v +} + +// GetRrule returns the Rrule field value +func (o *UpdateUpdateSchedulePayload) GetRrule() *string { + if o == nil { + var ret *string + return ret + } + + return o.Rrule +} + +// GetRruleOk returns a tuple with the Rrule field value +// and a boolean to check if the value has been set. +func (o *UpdateUpdateSchedulePayload) GetRruleOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.Rrule, true +} + +// SetRrule sets field value +func (o *UpdateUpdateSchedulePayload) SetRrule(v *string) { + o.Rrule = v +} + +func (o UpdateUpdateSchedulePayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["enabled"] = o.Enabled + toSerialize["id"] = o.Id + toSerialize["maintenanceWindow"] = o.MaintenanceWindow + toSerialize["name"] = o.Name + toSerialize["rrule"] = o.Rrule + return toSerialize, nil +} + +type NullableUpdateUpdateSchedulePayload struct { + value *UpdateUpdateSchedulePayload + isSet bool +} + +func (v NullableUpdateUpdateSchedulePayload) Get() *UpdateUpdateSchedulePayload { + return v.value +} + +func (v *NullableUpdateUpdateSchedulePayload) Set(val *UpdateUpdateSchedulePayload) { + v.value = val + v.isSet = true +} + +func (v NullableUpdateUpdateSchedulePayload) IsSet() bool { + return v.isSet +} + +func (v *NullableUpdateUpdateSchedulePayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableUpdateUpdateSchedulePayload(val *UpdateUpdateSchedulePayload) *NullableUpdateUpdateSchedulePayload { + return &NullableUpdateUpdateSchedulePayload{value: val, isSet: true} +} + +func (v NullableUpdateUpdateSchedulePayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableUpdateUpdateSchedulePayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/serverupdate/utils.go b/services/serverupdate/utils.go new file mode 100644 index 000000000..eb0b64019 --- /dev/null +++ b/services/serverupdate/utils.go @@ -0,0 +1,347 @@ +/* +STACKIT Server Update Management API + +API endpoints for Server Update Operations on STACKIT Servers. + +API version: 1.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package serverupdate + +import ( + "encoding/json" + "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 v.value.MarshalJSON() +} + +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) +}