982 lines
34 KiB
Go
982 lines
34 KiB
Go
/*
|
|
STACKIT Run Commands Service API
|
|
|
|
API endpoints for the STACKIT Run Commands Service API
|
|
|
|
API version: 2beta.0
|
|
*/
|
|
|
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
|
|
package runcommandbeta
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"fmt"
|
|
"io"
|
|
"net/http"
|
|
"net/url"
|
|
"strings"
|
|
|
|
"github.com/stackitcloud/stackit-sdk-go/core/config"
|
|
"github.com/stackitcloud/stackit-sdk-go/core/oapierror"
|
|
)
|
|
|
|
type DefaultApi interface {
|
|
/*
|
|
CreateCommand Method for CreateCommand
|
|
Creates a new command for execution
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId ID of the project
|
|
@param serverId Server ID of the machine
|
|
@param region region
|
|
@return ApiCreateCommandRequest
|
|
*/
|
|
CreateCommand(ctx context.Context, projectId string, serverId string, region string) ApiCreateCommandRequest
|
|
/*
|
|
CreateCommandExecute executes the request
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId ID of the project
|
|
@param serverId Server ID of the machine
|
|
@param region region
|
|
@return NewCommandResponse
|
|
|
|
*/
|
|
CreateCommandExecute(ctx context.Context, projectId string, serverId string, region string) (*NewCommandResponse, error)
|
|
/*
|
|
GetCommand Method for GetCommand
|
|
Returns details about a command
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId ID of the project
|
|
@param region region
|
|
@param serverId Server ID of the machine
|
|
@param commandId ID of the command
|
|
@return ApiGetCommandRequest
|
|
*/
|
|
GetCommand(ctx context.Context, projectId string, region string, serverId string, commandId string) ApiGetCommandRequest
|
|
/*
|
|
GetCommandExecute executes the request
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId ID of the project
|
|
@param region region
|
|
@param serverId Server ID of the machine
|
|
@param commandId ID of the command
|
|
@return CommandDetails
|
|
|
|
*/
|
|
GetCommandExecute(ctx context.Context, projectId string, region string, serverId string, commandId string) (*CommandDetails, error)
|
|
/*
|
|
GetCommandTemplate Method for GetCommandTemplate
|
|
Returns details about a command template
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId ID of the project
|
|
@param serverId Server ID of the machine
|
|
@param commandTemplateName Name of the template
|
|
@param region region
|
|
@return ApiGetCommandTemplateRequest
|
|
*/
|
|
GetCommandTemplate(ctx context.Context, projectId string, serverId string, commandTemplateName string, region string) ApiGetCommandTemplateRequest
|
|
/*
|
|
GetCommandTemplateExecute executes the request
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId ID of the project
|
|
@param serverId Server ID of the machine
|
|
@param commandTemplateName Name of the template
|
|
@param region region
|
|
@return CommandTemplateSchema
|
|
|
|
*/
|
|
GetCommandTemplateExecute(ctx context.Context, projectId string, serverId string, commandTemplateName string, region string) (*CommandTemplateSchema, error)
|
|
/*
|
|
ListCommandTemplates Method for ListCommandTemplates
|
|
Returns a list of command templates
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return ApiListCommandTemplatesRequest
|
|
*/
|
|
ListCommandTemplates(ctx context.Context) ApiListCommandTemplatesRequest
|
|
/*
|
|
ListCommandTemplatesExecute executes the request
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return CommandTemplateResponse
|
|
|
|
*/
|
|
ListCommandTemplatesExecute(ctx context.Context) (*CommandTemplateResponse, error)
|
|
/*
|
|
ListCommands Method for ListCommands
|
|
Returns a list of commands
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId ID of the project
|
|
@param serverId Server ID of the machine
|
|
@param region region
|
|
@return ApiListCommandsRequest
|
|
*/
|
|
ListCommands(ctx context.Context, projectId string, serverId string, region string) ApiListCommandsRequest
|
|
/*
|
|
ListCommandsExecute executes the request
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId ID of the project
|
|
@param serverId Server ID of the machine
|
|
@param region region
|
|
@return GetCommandsResponse
|
|
|
|
*/
|
|
ListCommandsExecute(ctx context.Context, projectId string, serverId string, region string) (*GetCommandsResponse, error)
|
|
}
|
|
|
|
type ApiCreateCommandRequest interface {
|
|
// Command to post
|
|
CreateCommandPayload(createCommandPayload CreateCommandPayload) ApiCreateCommandRequest
|
|
Execute() (*NewCommandResponse, error)
|
|
}
|
|
|
|
type ApiGetCommandRequest interface {
|
|
Execute() (*CommandDetails, error)
|
|
}
|
|
|
|
type ApiGetCommandTemplateRequest interface {
|
|
Execute() (*CommandTemplateSchema, error)
|
|
}
|
|
|
|
type ApiListCommandTemplatesRequest interface {
|
|
// The type of the Operating System (windows or linux). If not provided will return data for all OS types.
|
|
OsType(osType string) ApiListCommandTemplatesRequest
|
|
Execute() (*CommandTemplateResponse, error)
|
|
}
|
|
|
|
type ApiListCommandsRequest interface {
|
|
Execute() (*GetCommandsResponse, error)
|
|
}
|
|
|
|
// DefaultApiService DefaultApi service
|
|
type DefaultApiService service
|
|
|
|
type CreateCommandRequest struct {
|
|
ctx context.Context
|
|
apiService *DefaultApiService
|
|
projectId string
|
|
serverId string
|
|
region string
|
|
createCommandPayload *CreateCommandPayload
|
|
}
|
|
|
|
// Command to post
|
|
|
|
func (r CreateCommandRequest) CreateCommandPayload(createCommandPayload CreateCommandPayload) ApiCreateCommandRequest {
|
|
r.createCommandPayload = &createCommandPayload
|
|
return r
|
|
}
|
|
|
|
func (r CreateCommandRequest) Execute() (*NewCommandResponse, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPost
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *NewCommandResponse
|
|
)
|
|
a := r.apiService
|
|
client, ok := a.client.(*APIClient)
|
|
if !ok {
|
|
return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
|
|
}
|
|
localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.CreateCommand")
|
|
if err != nil {
|
|
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v2beta/projects/{projectId}/regions/{region}/servers/{serverId}/commands"
|
|
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, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -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"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
// body params
|
|
localVarPostBody = r.createCommandPayload
|
|
req, err := 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 := 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 == 400 {
|
|
var v ErrorResponse
|
|
err = 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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v ErrorResponse
|
|
err = 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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 404 {
|
|
var v ErrorResponse
|
|
err = 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
|
|
}
|
|
|
|
err = 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
|
|
}
|
|
|
|
/*
|
|
CreateCommand: Method for CreateCommand
|
|
|
|
Creates a new command for execution
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId ID of the project
|
|
@param serverId Server ID of the machine
|
|
@param region region
|
|
@return ApiCreateCommandRequest
|
|
*/
|
|
func (a *APIClient) CreateCommand(ctx context.Context, projectId string, serverId string, region string) ApiCreateCommandRequest {
|
|
return CreateCommandRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
serverId: serverId,
|
|
region: region,
|
|
}
|
|
}
|
|
|
|
func (a *APIClient) CreateCommandExecute(ctx context.Context, projectId string, serverId string, region string) (*NewCommandResponse, error) {
|
|
r := CreateCommandRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
serverId: serverId,
|
|
region: region,
|
|
}
|
|
return r.Execute()
|
|
}
|
|
|
|
type GetCommandRequest struct {
|
|
ctx context.Context
|
|
apiService *DefaultApiService
|
|
projectId string
|
|
region string
|
|
serverId string
|
|
commandId string
|
|
}
|
|
|
|
func (r GetCommandRequest) Execute() (*CommandDetails, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *CommandDetails
|
|
)
|
|
a := r.apiService
|
|
client, ok := a.client.(*APIClient)
|
|
if !ok {
|
|
return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
|
|
}
|
|
localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetCommand")
|
|
if err != nil {
|
|
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v2beta/projects/{projectId}/regions/{region}/servers/{serverId}/commands/{commandId}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1)
|
|
localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -1)
|
|
localVarPath = strings.Replace(localVarPath, "{"+"serverId"+"}", url.PathEscape(ParameterValueToString(r.serverId, "serverId")), -1)
|
|
localVarPath = strings.Replace(localVarPath, "{"+"commandId"+"}", url.PathEscape(ParameterValueToString(r.commandId, "commandId")), -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"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := 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 := 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 == 400 {
|
|
var v ErrorResponse
|
|
err = 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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v ErrorResponse
|
|
err = 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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 404 {
|
|
var v ErrorResponse
|
|
err = 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
|
|
}
|
|
|
|
err = 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
|
|
}
|
|
|
|
/*
|
|
GetCommand: Method for GetCommand
|
|
|
|
Returns details about a command
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId ID of the project
|
|
@param region region
|
|
@param serverId Server ID of the machine
|
|
@param commandId ID of the command
|
|
@return ApiGetCommandRequest
|
|
*/
|
|
func (a *APIClient) GetCommand(ctx context.Context, projectId string, region string, serverId string, commandId string) ApiGetCommandRequest {
|
|
return GetCommandRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
serverId: serverId,
|
|
commandId: commandId,
|
|
}
|
|
}
|
|
|
|
func (a *APIClient) GetCommandExecute(ctx context.Context, projectId string, region string, serverId string, commandId string) (*CommandDetails, error) {
|
|
r := GetCommandRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
region: region,
|
|
serverId: serverId,
|
|
commandId: commandId,
|
|
}
|
|
return r.Execute()
|
|
}
|
|
|
|
type GetCommandTemplateRequest struct {
|
|
ctx context.Context
|
|
apiService *DefaultApiService
|
|
projectId string
|
|
serverId string
|
|
commandTemplateName string
|
|
region string
|
|
}
|
|
|
|
func (r GetCommandTemplateRequest) Execute() (*CommandTemplateSchema, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *CommandTemplateSchema
|
|
)
|
|
a := r.apiService
|
|
client, ok := a.client.(*APIClient)
|
|
if !ok {
|
|
return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
|
|
}
|
|
localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetCommandTemplate")
|
|
if err != nil {
|
|
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v2beta/projects/{projectId}/regions/{region}/servers/{serverId}/command-templates/{commandTemplateName}"
|
|
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, "{"+"commandTemplateName"+"}", url.PathEscape(ParameterValueToString(r.commandTemplateName, "commandTemplateName")), -1)
|
|
localVarPath = strings.Replace(localVarPath, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -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"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := 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 := 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 == 400 {
|
|
var v ErrorResponse
|
|
err = 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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v ErrorResponse
|
|
err = 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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 404 {
|
|
var v ErrorResponse
|
|
err = 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
|
|
}
|
|
|
|
err = 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
|
|
}
|
|
|
|
/*
|
|
GetCommandTemplate: Method for GetCommandTemplate
|
|
|
|
Returns details about a command template
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId ID of the project
|
|
@param serverId Server ID of the machine
|
|
@param commandTemplateName Name of the template
|
|
@param region region
|
|
@return ApiGetCommandTemplateRequest
|
|
*/
|
|
func (a *APIClient) GetCommandTemplate(ctx context.Context, projectId string, serverId string, commandTemplateName string, region string) ApiGetCommandTemplateRequest {
|
|
return GetCommandTemplateRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
serverId: serverId,
|
|
commandTemplateName: commandTemplateName,
|
|
region: region,
|
|
}
|
|
}
|
|
|
|
func (a *APIClient) GetCommandTemplateExecute(ctx context.Context, projectId string, serverId string, commandTemplateName string, region string) (*CommandTemplateSchema, error) {
|
|
r := GetCommandTemplateRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
serverId: serverId,
|
|
commandTemplateName: commandTemplateName,
|
|
region: region,
|
|
}
|
|
return r.Execute()
|
|
}
|
|
|
|
type ListCommandTemplatesRequest struct {
|
|
ctx context.Context
|
|
apiService *DefaultApiService
|
|
osType *string
|
|
}
|
|
|
|
// The type of the Operating System (windows or linux). If not provided will return data for all OS types.
|
|
|
|
func (r ListCommandTemplatesRequest) OsType(osType string) ApiListCommandTemplatesRequest {
|
|
r.osType = &osType
|
|
return r
|
|
}
|
|
|
|
func (r ListCommandTemplatesRequest) Execute() (*CommandTemplateResponse, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *CommandTemplateResponse
|
|
)
|
|
a := r.apiService
|
|
client, ok := a.client.(*APIClient)
|
|
if !ok {
|
|
return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
|
|
}
|
|
localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListCommandTemplates")
|
|
if err != nil {
|
|
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v2beta/command-templates"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
if r.osType != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "osType", r.osType, "")
|
|
}
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := 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 := 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 == 400 {
|
|
var v ErrorResponse
|
|
err = 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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v ErrorResponse
|
|
err = 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
|
|
}
|
|
|
|
err = 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
|
|
}
|
|
|
|
/*
|
|
ListCommandTemplates: Method for ListCommandTemplates
|
|
|
|
Returns a list of command templates
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return ApiListCommandTemplatesRequest
|
|
*/
|
|
func (a *APIClient) ListCommandTemplates(ctx context.Context) ApiListCommandTemplatesRequest {
|
|
return ListCommandTemplatesRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
func (a *APIClient) ListCommandTemplatesExecute(ctx context.Context) (*CommandTemplateResponse, error) {
|
|
r := ListCommandTemplatesRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
}
|
|
return r.Execute()
|
|
}
|
|
|
|
type ListCommandsRequest struct {
|
|
ctx context.Context
|
|
apiService *DefaultApiService
|
|
projectId string
|
|
serverId string
|
|
region string
|
|
}
|
|
|
|
func (r ListCommandsRequest) Execute() (*GetCommandsResponse, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *GetCommandsResponse
|
|
)
|
|
a := r.apiService
|
|
client, ok := a.client.(*APIClient)
|
|
if !ok {
|
|
return localVarReturnValue, fmt.Errorf("could not parse client to type APIClient")
|
|
}
|
|
localBasePath, err := client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListCommands")
|
|
if err != nil {
|
|
return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v2beta/projects/{projectId}/regions/{region}/servers/{serverId}/commands"
|
|
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, "{"+"region"+"}", url.PathEscape(ParameterValueToString(r.region, "region")), -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"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := 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 := 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 == 400 {
|
|
var v ErrorResponse
|
|
err = 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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 401 {
|
|
var v ErrorResponse
|
|
err = 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
|
|
}
|
|
if localVarHTTPResponse.StatusCode == 404 {
|
|
var v ErrorResponse
|
|
err = 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
|
|
}
|
|
|
|
err = 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
|
|
}
|
|
|
|
/*
|
|
ListCommands: Method for ListCommands
|
|
|
|
Returns a list of commands
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param projectId ID of the project
|
|
@param serverId Server ID of the machine
|
|
@param region region
|
|
@return ApiListCommandsRequest
|
|
*/
|
|
func (a *APIClient) ListCommands(ctx context.Context, projectId string, serverId string, region string) ApiListCommandsRequest {
|
|
return ListCommandsRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
serverId: serverId,
|
|
region: region,
|
|
}
|
|
}
|
|
|
|
func (a *APIClient) ListCommandsExecute(ctx context.Context, projectId string, serverId string, region string) (*GetCommandsResponse, error) {
|
|
r := ListCommandsRequest{
|
|
apiService: a.defaultApi,
|
|
ctx: ctx,
|
|
projectId: projectId,
|
|
serverId: serverId,
|
|
region: region,
|
|
}
|
|
return r.Execute()
|
|
}
|