2022-11-13 13:22:00 +00:00
/ *
2023-11-22 17:28:14 +00:00
Garage Administration API v0 + garage - v0 .9 .0
2022-11-13 13:22:00 +00:00
Administrate your Garage cluster programatically , including status , layout , keys , buckets , and maintainance tasks . * Disclaimer : The API is not stable yet , hence its v0 tag . The API can change at any time , and changes can include breaking backward compatibility . Read the changelog and upgrade your scripts before upgrading . Additionnaly , this specification is very early stage and can contain bugs , especially on error return codes / types that are not tested yet . Do not expect a well finished and polished product ! *
2023-11-22 17:28:14 +00:00
API version : v0 .9 .0
2022-11-13 13:22:00 +00:00
* /
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package garage
import (
"bytes"
"context"
"io/ioutil"
"net/http"
"net/url"
)
// LayoutApiService LayoutApi service
type LayoutApiService service
type ApiAddLayoutRequest struct {
ctx context . Context
ApiService * LayoutApiService
2023-11-22 17:28:14 +00:00
nodeRoleChange * [ ] NodeRoleChange
2022-11-13 13:22:00 +00:00
}
2023-11-22 17:28:14 +00:00
// To add a new node to the layout or to change the configuration of an existing node, simply set the values you want (`zone`, `capacity`, and `tags`). To remove a node, simply pass the `remove: true` field. This logic is represented in OpenAPI with a \"One Of\" object. Contrary to the CLI that may update only a subset of the fields capacity, zone and tags, when calling this API all of these values must be specified.
func ( r ApiAddLayoutRequest ) NodeRoleChange ( nodeRoleChange [ ] NodeRoleChange ) ApiAddLayoutRequest {
r . nodeRoleChange = & nodeRoleChange
2022-11-13 13:22:00 +00:00
return r
}
2023-11-22 17:28:14 +00:00
func ( r ApiAddLayoutRequest ) Execute ( ) ( * ClusterLayout , * http . Response , error ) {
2022-11-13 13:22:00 +00:00
return r . ApiService . AddLayoutExecute ( r )
}
/ *
AddLayout Send modifications to the cluster layout
Send modifications to the cluster layout . These modifications will be included in the staged role changes , visible in subsequent calls of ` GET /layout ` . Once the set of staged changes is satisfactory , the user may call ` POST /layout/apply ` to apply the changed changes , or ` POST /layout/revert ` to clear all of the staged changes in the layout .
2023-11-22 17:28:14 +00:00
Setting the capacity to ` null ` will configure the node as a gateway .
Otherwise , capacity must be now set in bytes ( before Garage 0.9 it was arbitrary weights ) .
For example to declare 100 GB , you must set ` capacity: 100000000000 ` .
Garage uses internally the International System of Units ( SI ) , it assumes that 1 kB = 1000 bytes , and displays storage as kB , MB , GB ( and not KiB , MiB , GiB that assume 1 KiB = 1024 bytes ) .
2022-11-13 13:22:00 +00:00
@ param ctx context . Context - for authentication , logging , cancellation , deadlines , tracing , etc . Passed from http . Request or context . Background ( ) .
@ return ApiAddLayoutRequest
* /
func ( a * LayoutApiService ) AddLayout ( ctx context . Context ) ApiAddLayoutRequest {
return ApiAddLayoutRequest {
ApiService : a ,
ctx : ctx ,
}
}
// Execute executes the request
2023-11-22 17:28:14 +00:00
// @return ClusterLayout
func ( a * LayoutApiService ) AddLayoutExecute ( r ApiAddLayoutRequest ) ( * ClusterLayout , * http . Response , error ) {
2022-11-13 13:22:00 +00:00
var (
localVarHTTPMethod = http . MethodPost
localVarPostBody interface { }
formFiles [ ] formFile
2023-11-22 17:28:14 +00:00
localVarReturnValue * ClusterLayout
2022-11-13 13:22:00 +00:00
)
localBasePath , err := a . client . cfg . ServerURLWithContext ( r . ctx , "LayoutApiService.AddLayout" )
if err != nil {
2023-11-22 17:28:14 +00:00
return localVarReturnValue , nil , & GenericOpenAPIError { error : err . Error ( ) }
2022-11-13 13:22:00 +00:00
}
localVarPath := localBasePath + "/layout"
localVarHeaderParams := make ( map [ string ] string )
localVarQueryParams := url . Values { }
localVarFormParams := url . Values { }
2023-11-22 17:28:14 +00:00
if r . nodeRoleChange == nil {
return localVarReturnValue , nil , reportError ( "nodeRoleChange is required and must be specified" )
2022-11-13 13:22:00 +00:00
}
// 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
2023-11-22 17:28:14 +00:00
localVarHTTPHeaderAccepts := [ ] string { "application/json" }
2022-11-13 13:22:00 +00:00
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept ( localVarHTTPHeaderAccepts )
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams [ "Accept" ] = localVarHTTPHeaderAccept
}
// body params
2023-11-22 17:28:14 +00:00
localVarPostBody = r . nodeRoleChange
2022-11-13 13:22:00 +00:00
req , err := a . client . prepareRequest ( r . ctx , localVarPath , localVarHTTPMethod , localVarPostBody , localVarHeaderParams , localVarQueryParams , localVarFormParams , formFiles )
if err != nil {
2023-11-22 17:28:14 +00:00
return localVarReturnValue , nil , err
2022-11-13 13:22:00 +00:00
}
localVarHTTPResponse , err := a . client . callAPI ( req )
if err != nil || localVarHTTPResponse == nil {
2023-11-22 17:28:14 +00:00
return localVarReturnValue , localVarHTTPResponse , err
2022-11-13 13:22:00 +00:00
}
localVarBody , err := ioutil . ReadAll ( localVarHTTPResponse . Body )
localVarHTTPResponse . Body . Close ( )
localVarHTTPResponse . Body = ioutil . NopCloser ( bytes . NewBuffer ( localVarBody ) )
if err != nil {
2023-11-22 17:28:14 +00:00
return localVarReturnValue , localVarHTTPResponse , err
2022-11-13 13:22:00 +00:00
}
if localVarHTTPResponse . StatusCode >= 300 {
newErr := & GenericOpenAPIError {
body : localVarBody ,
error : localVarHTTPResponse . Status ,
}
2023-11-22 17:28:14 +00:00
return localVarReturnValue , localVarHTTPResponse , newErr
2022-11-13 13:22:00 +00:00
}
2023-11-22 17:28:14 +00:00
err = a . client . decode ( & localVarReturnValue , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr := & GenericOpenAPIError {
body : localVarBody ,
error : err . Error ( ) ,
}
return localVarReturnValue , localVarHTTPResponse , newErr
}
return localVarReturnValue , localVarHTTPResponse , nil
2022-11-13 13:22:00 +00:00
}
type ApiApplyLayoutRequest struct {
ctx context . Context
ApiService * LayoutApiService
layoutVersion * LayoutVersion
}
// Similarly to the CLI, the body must include the version of the new layout that will be created, which MUST be 1 + the value of the currently existing layout in the cluster.
func ( r ApiApplyLayoutRequest ) LayoutVersion ( layoutVersion LayoutVersion ) ApiApplyLayoutRequest {
r . layoutVersion = & layoutVersion
return r
}
2023-11-22 17:28:14 +00:00
func ( r ApiApplyLayoutRequest ) Execute ( ) ( * ApplyLayout200Response , * http . Response , error ) {
2022-11-13 13:22:00 +00:00
return r . ApiService . ApplyLayoutExecute ( r )
}
/ *
ApplyLayout Apply staged layout
Applies to the cluster the layout changes currently registered as staged layout changes .
2023-11-22 17:28:14 +00:00
* Note : do not try to parse the ` message ` field of the response , it is given as an array of string specifically because its format is not stable . *
2022-11-13 13:22:00 +00:00
@ param ctx context . Context - for authentication , logging , cancellation , deadlines , tracing , etc . Passed from http . Request or context . Background ( ) .
@ return ApiApplyLayoutRequest
* /
func ( a * LayoutApiService ) ApplyLayout ( ctx context . Context ) ApiApplyLayoutRequest {
return ApiApplyLayoutRequest {
ApiService : a ,
ctx : ctx ,
}
}
// Execute executes the request
2023-11-22 17:28:14 +00:00
// @return ApplyLayout200Response
func ( a * LayoutApiService ) ApplyLayoutExecute ( r ApiApplyLayoutRequest ) ( * ApplyLayout200Response , * http . Response , error ) {
2022-11-13 13:22:00 +00:00
var (
localVarHTTPMethod = http . MethodPost
localVarPostBody interface { }
formFiles [ ] formFile
2023-11-22 17:28:14 +00:00
localVarReturnValue * ApplyLayout200Response
2022-11-13 13:22:00 +00:00
)
localBasePath , err := a . client . cfg . ServerURLWithContext ( r . ctx , "LayoutApiService.ApplyLayout" )
if err != nil {
2023-11-22 17:28:14 +00:00
return localVarReturnValue , nil , & GenericOpenAPIError { error : err . Error ( ) }
2022-11-13 13:22:00 +00:00
}
localVarPath := localBasePath + "/layout/apply"
localVarHeaderParams := make ( map [ string ] string )
localVarQueryParams := url . Values { }
localVarFormParams := url . Values { }
if r . layoutVersion == nil {
2023-11-22 17:28:14 +00:00
return localVarReturnValue , nil , reportError ( "layoutVersion is required and must be specified" )
2022-11-13 13:22:00 +00:00
}
// 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
2023-11-22 17:28:14 +00:00
localVarHTTPHeaderAccepts := [ ] string { "application/json" }
2022-11-13 13:22:00 +00:00
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept ( localVarHTTPHeaderAccepts )
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams [ "Accept" ] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r . layoutVersion
req , err := a . client . prepareRequest ( r . ctx , localVarPath , localVarHTTPMethod , localVarPostBody , localVarHeaderParams , localVarQueryParams , localVarFormParams , formFiles )
if err != nil {
2023-11-22 17:28:14 +00:00
return localVarReturnValue , nil , err
2022-11-13 13:22:00 +00:00
}
localVarHTTPResponse , err := a . client . callAPI ( req )
if err != nil || localVarHTTPResponse == nil {
2023-11-22 17:28:14 +00:00
return localVarReturnValue , localVarHTTPResponse , err
2022-11-13 13:22:00 +00:00
}
localVarBody , err := ioutil . ReadAll ( localVarHTTPResponse . Body )
localVarHTTPResponse . Body . Close ( )
localVarHTTPResponse . Body = ioutil . NopCloser ( bytes . NewBuffer ( localVarBody ) )
if err != nil {
2023-11-22 17:28:14 +00:00
return localVarReturnValue , localVarHTTPResponse , err
2022-11-13 13:22:00 +00:00
}
if localVarHTTPResponse . StatusCode >= 300 {
newErr := & GenericOpenAPIError {
body : localVarBody ,
error : localVarHTTPResponse . Status ,
}
2023-11-22 17:28:14 +00:00
return localVarReturnValue , localVarHTTPResponse , newErr
}
err = a . client . decode ( & localVarReturnValue , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr := & GenericOpenAPIError {
body : localVarBody ,
error : err . Error ( ) ,
}
return localVarReturnValue , localVarHTTPResponse , newErr
2022-11-13 13:22:00 +00:00
}
2023-11-22 17:28:14 +00:00
return localVarReturnValue , localVarHTTPResponse , nil
2022-11-13 13:22:00 +00:00
}
type ApiGetLayoutRequest struct {
ctx context . Context
ApiService * LayoutApiService
}
func ( r ApiGetLayoutRequest ) Execute ( ) ( * ClusterLayout , * http . Response , error ) {
return r . ApiService . GetLayoutExecute ( r )
}
/ *
GetLayout Details on the current and staged layout
Returns the cluster ' s current layout , including :
- Currently configured cluster layout
- Staged changes to the cluster layout
2023-11-22 17:28:14 +00:00
* Capacity is given in bytes *
2022-11-13 13:22:00 +00:00
* The info returned by this endpoint is a subset of the info returned by ` GET /status ` . *
@ param ctx context . Context - for authentication , logging , cancellation , deadlines , tracing , etc . Passed from http . Request or context . Background ( ) .
@ return ApiGetLayoutRequest
* /
func ( a * LayoutApiService ) GetLayout ( ctx context . Context ) ApiGetLayoutRequest {
return ApiGetLayoutRequest {
ApiService : a ,
ctx : ctx ,
}
}
// Execute executes the request
// @return ClusterLayout
func ( a * LayoutApiService ) GetLayoutExecute ( r ApiGetLayoutRequest ) ( * ClusterLayout , * http . Response , error ) {
var (
localVarHTTPMethod = http . MethodGet
localVarPostBody interface { }
formFiles [ ] formFile
localVarReturnValue * ClusterLayout
)
localBasePath , err := a . client . cfg . ServerURLWithContext ( r . ctx , "LayoutApiService.GetLayout" )
if err != nil {
return localVarReturnValue , nil , & GenericOpenAPIError { error : err . Error ( ) }
}
localVarPath := localBasePath + "/layout"
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 := a . client . prepareRequest ( r . ctx , localVarPath , localVarHTTPMethod , localVarPostBody , localVarHeaderParams , localVarQueryParams , localVarFormParams , formFiles )
if err != nil {
return localVarReturnValue , nil , err
}
localVarHTTPResponse , err := a . client . callAPI ( req )
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue , localVarHTTPResponse , err
}
localVarBody , err := ioutil . ReadAll ( localVarHTTPResponse . Body )
localVarHTTPResponse . Body . Close ( )
localVarHTTPResponse . Body = ioutil . NopCloser ( bytes . NewBuffer ( localVarBody ) )
if err != nil {
return localVarReturnValue , localVarHTTPResponse , err
}
if localVarHTTPResponse . StatusCode >= 300 {
newErr := & GenericOpenAPIError {
body : localVarBody ,
error : localVarHTTPResponse . Status ,
}
return localVarReturnValue , localVarHTTPResponse , newErr
}
err = a . client . decode ( & localVarReturnValue , localVarBody , localVarHTTPResponse . Header . Get ( "Content-Type" ) )
if err != nil {
newErr := & GenericOpenAPIError {
body : localVarBody ,
error : err . Error ( ) ,
}
return localVarReturnValue , localVarHTTPResponse , newErr
}
return localVarReturnValue , localVarHTTPResponse , nil
}
type ApiRevertLayoutRequest struct {
ctx context . Context
ApiService * LayoutApiService
layoutVersion * LayoutVersion
}
// Reverting the staged changes is done by incrementing the version number and clearing the contents of the staged change list. Similarly to the CLI, the body must include the incremented version number, which MUST be 1 + the value of the currently existing layout in the cluster.
func ( r ApiRevertLayoutRequest ) LayoutVersion ( layoutVersion LayoutVersion ) ApiRevertLayoutRequest {
r . layoutVersion = & layoutVersion
return r
}
func ( r ApiRevertLayoutRequest ) Execute ( ) ( * http . Response , error ) {
return r . ApiService . RevertLayoutExecute ( r )
}
/ *
RevertLayout Clear staged layout
Clears all of the staged layout changes .
@ param ctx context . Context - for authentication , logging , cancellation , deadlines , tracing , etc . Passed from http . Request or context . Background ( ) .
@ return ApiRevertLayoutRequest
* /
func ( a * LayoutApiService ) RevertLayout ( ctx context . Context ) ApiRevertLayoutRequest {
return ApiRevertLayoutRequest {
ApiService : a ,
ctx : ctx ,
}
}
// Execute executes the request
func ( a * LayoutApiService ) RevertLayoutExecute ( r ApiRevertLayoutRequest ) ( * http . Response , error ) {
var (
localVarHTTPMethod = http . MethodPost
localVarPostBody interface { }
formFiles [ ] formFile
)
localBasePath , err := a . client . cfg . ServerURLWithContext ( r . ctx , "LayoutApiService.RevertLayout" )
if err != nil {
return nil , & GenericOpenAPIError { error : err . Error ( ) }
}
localVarPath := localBasePath + "/layout/revert"
localVarHeaderParams := make ( map [ string ] string )
localVarQueryParams := url . Values { }
localVarFormParams := url . Values { }
if r . layoutVersion == nil {
return nil , reportError ( "layoutVersion is required and must be specified" )
}
// 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 { }
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept ( localVarHTTPHeaderAccepts )
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams [ "Accept" ] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r . layoutVersion
req , err := a . client . prepareRequest ( r . ctx , localVarPath , localVarHTTPMethod , localVarPostBody , localVarHeaderParams , localVarQueryParams , localVarFormParams , formFiles )
if err != nil {
return nil , err
}
localVarHTTPResponse , err := a . client . callAPI ( req )
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse , err
}
localVarBody , err := ioutil . ReadAll ( localVarHTTPResponse . Body )
localVarHTTPResponse . Body . Close ( )
localVarHTTPResponse . Body = ioutil . NopCloser ( bytes . NewBuffer ( localVarBody ) )
if err != nil {
return localVarHTTPResponse , err
}
if localVarHTTPResponse . StatusCode >= 300 {
newErr := & GenericOpenAPIError {
body : localVarBody ,
error : localVarHTTPResponse . Status ,
}
return localVarHTTPResponse , newErr
}
return localVarHTTPResponse , nil
}