270 lines
8.4 KiB
Go
270 lines
8.4 KiB
Go
/*
|
|
* oc-catalog API
|
|
*
|
|
* Backend of the oc-search project
|
|
*
|
|
* API version: 1.0.0
|
|
* Contact: opencloud@irt-saintexupery.com
|
|
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
|
*/
|
|
|
|
package swagger
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"io/ioutil"
|
|
"net/http"
|
|
"net/url"
|
|
"strings"
|
|
)
|
|
|
|
// Linger please
|
|
var (
|
|
_ context.Context
|
|
)
|
|
|
|
type DatacenterApiService service
|
|
|
|
/*
|
|
DatacenterApiService
|
|
submit Datacenter object
|
|
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
- @param body The object content
|
|
*/
|
|
func (a *DatacenterApiService) DatacenterControllerCreateDatacenter(ctx context.Context, body ModelsDatacenterNewModel) (*http.Response, error) {
|
|
var (
|
|
localVarHttpMethod = strings.ToUpper("Post")
|
|
localVarPostBody interface{}
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
)
|
|
|
|
// create path and map variables
|
|
localVarPath := a.client.cfg.BasePath + "/datacenter/"
|
|
|
|
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{}
|
|
|
|
// set Accept header
|
|
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
|
if localVarHttpHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
|
}
|
|
// body params
|
|
localVarPostBody = &body
|
|
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
localVarHttpResponse, err := a.client.callAPI(r)
|
|
if err != nil || localVarHttpResponse == nil {
|
|
return localVarHttpResponse, err
|
|
}
|
|
|
|
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
|
|
localVarHttpResponse.Body.Close()
|
|
if err != nil {
|
|
return localVarHttpResponse, err
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode >= 300 {
|
|
newErr := GenericSwaggerError{
|
|
body: localVarBody,
|
|
error: localVarHttpResponse.Status,
|
|
}
|
|
|
|
return localVarHttpResponse, newErr
|
|
}
|
|
|
|
return localVarHttpResponse, nil
|
|
}
|
|
|
|
/*
|
|
DatacenterApiService
|
|
Return Datacenter objects if found in the DB. Not found IDs will be ignored
|
|
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
- @param iDs List of datacenter IDs
|
|
|
|
@return []ModelsComputingModel
|
|
*/
|
|
func (a *DatacenterApiService) DatacenterControllerGetMultipleDatacentersByIDs(ctx context.Context, iDs []string) ([]ModelsComputingModel, *http.Response, error) {
|
|
var (
|
|
localVarHttpMethod = strings.ToUpper("Get")
|
|
localVarPostBody interface{}
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue []ModelsComputingModel
|
|
)
|
|
|
|
// create path and map variables
|
|
localVarPath := a.client.cfg.BasePath + "/datacenter/multi/{IDs}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"IDs"+"}", fmt.Sprintf("%v", iDs), -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{}
|
|
|
|
// set Accept header
|
|
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
|
if localVarHttpHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
|
}
|
|
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHttpResponse, err := a.client.callAPI(r)
|
|
if err != nil || localVarHttpResponse == nil {
|
|
return localVarReturnValue, localVarHttpResponse, err
|
|
}
|
|
|
|
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
|
|
localVarHttpResponse.Body.Close()
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHttpResponse, err
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode < 300 {
|
|
// If we succeed, return the data, otherwise pass on to decode error.
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
return localVarReturnValue, localVarHttpResponse, err
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode >= 300 {
|
|
newErr := GenericSwaggerError{
|
|
body: localVarBody,
|
|
error: localVarHttpResponse.Status,
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 200 {
|
|
var v []ModelsComputingModel
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
|
}
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHttpResponse, nil
|
|
}
|
|
|
|
/*
|
|
DatacenterApiService
|
|
find datacenter by ID
|
|
- @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
- @param iD the ID you want to get
|
|
|
|
@return ModelsDatacenterModel
|
|
*/
|
|
func (a *DatacenterApiService) DatacenterControllerGetOneDatacenter(ctx context.Context, iD string) (ModelsDatacenterModel, *http.Response, error) {
|
|
var (
|
|
localVarHttpMethod = strings.ToUpper("Get")
|
|
localVarPostBody interface{}
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue ModelsDatacenterModel
|
|
)
|
|
|
|
// create path and map variables
|
|
localVarPath := a.client.cfg.BasePath + "/datacenter/{ID}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"ID"+"}", fmt.Sprintf("%v", iD), -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{}
|
|
|
|
// set Accept header
|
|
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
|
if localVarHttpHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
|
}
|
|
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHttpResponse, err := a.client.callAPI(r)
|
|
if err != nil || localVarHttpResponse == nil {
|
|
return localVarReturnValue, localVarHttpResponse, err
|
|
}
|
|
|
|
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
|
|
localVarHttpResponse.Body.Close()
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHttpResponse, err
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode < 300 {
|
|
// If we succeed, return the data, otherwise pass on to decode error.
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
return localVarReturnValue, localVarHttpResponse, err
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode >= 300 {
|
|
newErr := GenericSwaggerError{
|
|
body: localVarBody,
|
|
error: localVarHttpResponse.Status,
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 200 {
|
|
var v ModelsDatacenterModel
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
|
}
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHttpResponse, nil
|
|
}
|