2022-11-13 11:28:54 +00:00
/ * *
2023-11-22 17:30:42 +00:00
* Garage Administration API v0 + garage - v0 . 9.0
2022-11-13 11:28:54 +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:30:42 +00:00
* The version of the OpenAPI document : v0 . 9.0
2022-11-13 11:28:54 +00:00
*
*
* NOTE : This class is auto generated by OpenAPI Generator ( https : //openapi-generator.tech).
* https : //openapi-generator.tech
* Do not edit the class manually .
*
* /
import ApiClient from "../ApiClient" ;
2023-11-22 17:30:42 +00:00
import ApplyLayout200Response from '../model/ApplyLayout200Response' ;
2022-11-13 11:28:54 +00:00
import ClusterLayout from '../model/ClusterLayout' ;
import LayoutVersion from '../model/LayoutVersion' ;
2023-11-22 17:30:42 +00:00
import NodeRoleChange from '../model/NodeRoleChange' ;
2022-11-13 11:28:54 +00:00
/ * *
* Layout service .
* @ module api / LayoutApi
2023-11-22 17:30:42 +00:00
* @ version v0 . 9.0
2022-11-13 11:28:54 +00:00
* /
export default class LayoutApi {
/ * *
* Constructs a new LayoutApi .
* @ alias module : api / LayoutApi
* @ class
* @ param { module : ApiClient } [ apiClient ] Optional API client implementation to use ,
* default to { @ link module : ApiClient # instance } if unspecified .
* /
constructor ( apiClient ) {
this . apiClient = apiClient || ApiClient . instance ;
}
/ * *
* Send modifications to the cluster layout
2023-11-22 17:30:42 +00:00
* 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 . 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 ) .
* @ param { Array . < module : model / NodeRoleChange > } nodeRoleChange 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 .
* @ return { Promise } a { @ link https : //www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/ClusterLayout} and HTTP response
2022-11-13 11:28:54 +00:00
* /
2023-11-22 17:30:42 +00:00
addLayoutWithHttpInfo ( nodeRoleChange ) {
let postBody = nodeRoleChange ;
// verify the required parameter 'nodeRoleChange' is set
if ( nodeRoleChange === undefined || nodeRoleChange === null ) {
throw new Error ( "Missing the required parameter 'nodeRoleChange' when calling addLayout" ) ;
2022-11-13 11:28:54 +00:00
}
let pathParams = {
} ;
let queryParams = {
} ;
let headerParams = {
} ;
let formParams = {
} ;
let authNames = [ 'bearerAuth' ] ;
let contentTypes = [ 'application/json' ] ;
2023-11-22 17:30:42 +00:00
let accepts = [ 'application/json' ] ;
let returnType = ClusterLayout ;
2022-11-13 11:28:54 +00:00
return this . apiClient . callApi (
'/layout' , 'POST' ,
pathParams , queryParams , headerParams , formParams , postBody ,
2022-11-13 11:56:24 +00:00
authNames , contentTypes , accepts , returnType , null
2022-11-13 11:28:54 +00:00
) ;
}
/ * *
2022-11-13 11:56:24 +00:00
* Send modifications to the cluster layout
2023-11-22 17:30:42 +00:00
* 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 . 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 ) .
* @ param { Array . < module : model / NodeRoleChange > } nodeRoleChange 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 .
* @ return { Promise } a { @ link https : //www.promisejs.org/|Promise}, with data of type {@link module:model/ClusterLayout}
2022-11-13 11:28:54 +00:00
* /
2023-11-22 17:30:42 +00:00
addLayout ( nodeRoleChange ) {
return this . addLayoutWithHttpInfo ( nodeRoleChange )
2022-11-13 11:56:24 +00:00
. then ( function ( response _and _data ) {
return response _and _data . data ;
} ) ;
}
2022-11-13 11:28:54 +00:00
/ * *
* Apply staged layout
2023-11-22 17:30:42 +00:00
* Applies to the cluster the layout changes currently registered as staged layout changes . * 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 11:28:54 +00:00
* @ param { module : model / 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 .
2023-11-22 17:30:42 +00:00
* @ return { Promise } a { @ link https : //www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/ApplyLayout200Response} and HTTP response
2022-11-13 11:28:54 +00:00
* /
2022-11-13 11:56:24 +00:00
applyLayoutWithHttpInfo ( layoutVersion ) {
2022-11-13 11:28:54 +00:00
let postBody = layoutVersion ;
// verify the required parameter 'layoutVersion' is set
if ( layoutVersion === undefined || layoutVersion === null ) {
throw new Error ( "Missing the required parameter 'layoutVersion' when calling applyLayout" ) ;
}
let pathParams = {
} ;
let queryParams = {
} ;
let headerParams = {
} ;
let formParams = {
} ;
let authNames = [ 'bearerAuth' ] ;
let contentTypes = [ 'application/json' ] ;
2023-11-22 17:30:42 +00:00
let accepts = [ 'application/json' ] ;
let returnType = ApplyLayout200Response ;
2022-11-13 11:28:54 +00:00
return this . apiClient . callApi (
'/layout/apply' , 'POST' ,
pathParams , queryParams , headerParams , formParams , postBody ,
2022-11-13 11:56:24 +00:00
authNames , contentTypes , accepts , returnType , null
2022-11-13 11:28:54 +00:00
) ;
}
/ * *
2022-11-13 11:56:24 +00:00
* Apply staged layout
2023-11-22 17:30:42 +00:00
* Applies to the cluster the layout changes currently registered as staged layout changes . * 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 11:56:24 +00:00
* @ param { module : model / 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 .
2023-11-22 17:30:42 +00:00
* @ return { Promise } a { @ link https : //www.promisejs.org/|Promise}, with data of type {@link module:model/ApplyLayout200Response}
2022-11-13 11:28:54 +00:00
* /
2022-11-13 11:56:24 +00:00
applyLayout ( layoutVersion ) {
return this . applyLayoutWithHttpInfo ( layoutVersion )
. then ( function ( response _and _data ) {
return response _and _data . data ;
} ) ;
}
2022-11-13 11:28:54 +00:00
/ * *
* Details on the current and staged layout
2023-11-22 17:30:42 +00:00
* Returns the cluster ' s current layout , including : - Currently configured cluster layout - Staged changes to the cluster layout * Capacity is given in bytes * * The info returned by this endpoint is a subset of the info returned by ` GET /status ` . *
2022-11-13 11:56:24 +00:00
* @ return { Promise } a { @ link https : //www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/ClusterLayout} and HTTP response
2022-11-13 11:28:54 +00:00
* /
2022-11-13 11:56:24 +00:00
getLayoutWithHttpInfo ( ) {
2022-11-13 11:28:54 +00:00
let postBody = null ;
let pathParams = {
} ;
let queryParams = {
} ;
let headerParams = {
} ;
let formParams = {
} ;
let authNames = [ 'bearerAuth' ] ;
let contentTypes = [ ] ;
let accepts = [ 'application/json' ] ;
let returnType = ClusterLayout ;
return this . apiClient . callApi (
'/layout' , 'GET' ,
pathParams , queryParams , headerParams , formParams , postBody ,
2022-11-13 11:56:24 +00:00
authNames , contentTypes , accepts , returnType , null
2022-11-13 11:28:54 +00:00
) ;
}
/ * *
2022-11-13 11:56:24 +00:00
* Details on the current and staged layout
2023-11-22 17:30:42 +00:00
* Returns the cluster ' s current layout , including : - Currently configured cluster layout - Staged changes to the cluster layout * Capacity is given in bytes * * The info returned by this endpoint is a subset of the info returned by ` GET /status ` . *
2022-11-13 11:56:24 +00:00
* @ return { Promise } a { @ link https : //www.promisejs.org/|Promise}, with data of type {@link module:model/ClusterLayout}
2022-11-13 11:28:54 +00:00
* /
2022-11-13 11:56:24 +00:00
getLayout ( ) {
return this . getLayoutWithHttpInfo ( )
. then ( function ( response _and _data ) {
return response _and _data . data ;
} ) ;
}
2022-11-13 11:28:54 +00:00
/ * *
* Clear staged layout
* Clears all of the staged layout changes .
* @ param { module : model / 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 .
2022-11-13 11:56:24 +00:00
* @ return { Promise } a { @ link https : //www.promisejs.org/|Promise}, with an object containing HTTP response
2022-11-13 11:28:54 +00:00
* /
2022-11-13 11:56:24 +00:00
revertLayoutWithHttpInfo ( layoutVersion ) {
2022-11-13 11:28:54 +00:00
let postBody = layoutVersion ;
// verify the required parameter 'layoutVersion' is set
if ( layoutVersion === undefined || layoutVersion === null ) {
throw new Error ( "Missing the required parameter 'layoutVersion' when calling revertLayout" ) ;
}
let pathParams = {
} ;
let queryParams = {
} ;
let headerParams = {
} ;
let formParams = {
} ;
let authNames = [ 'bearerAuth' ] ;
let contentTypes = [ 'application/json' ] ;
let accepts = [ ] ;
let returnType = null ;
return this . apiClient . callApi (
'/layout/revert' , 'POST' ,
pathParams , queryParams , headerParams , formParams , postBody ,
2022-11-13 11:56:24 +00:00
authNames , contentTypes , accepts , returnType , null
2022-11-13 11:28:54 +00:00
) ;
}
2022-11-13 11:56:24 +00:00
/ * *
* Clear staged layout
* Clears all of the staged layout changes .
* @ param { module : model / 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 .
* @ return { Promise } a { @ link https : //www.promisejs.org/|Promise}
* /
revertLayout ( layoutVersion ) {
return this . revertLayoutWithHttpInfo ( layoutVersion )
. then ( function ( response _and _data ) {
return response _and _data . data ;
} ) ;
}
2022-11-13 11:28:54 +00:00
}