garage-admin-sdk-js/src/api/LayoutApi.js

223 lines
9.8 KiB
JavaScript

/**
* Garage Administration API v0+garage-v0.8.0
* 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!*
*
* The version of the OpenAPI document: v0.8.0
*
*
* 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";
import ClusterLayout from '../model/ClusterLayout';
import LayoutVersion from '../model/LayoutVersion';
import NodeClusterInfo from '../model/NodeClusterInfo';
/**
* Layout service.
* @module api/LayoutApi
* @version v0.8.0
*/
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
* 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. Note that setting the capacity to `null` will configure the node as a gateway.
* @param {Object.<String, module:model/{String: NodeClusterInfo}>} requestBody To add a new node to the layout or to change the configuration of an existing node, simply set the values you want. To remove a node, set it to `null` instead of passing a configuration 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 HTTP response
*/
addLayoutWithHttpInfo(requestBody) {
let postBody = requestBody;
// verify the required parameter 'requestBody' is set
if (requestBody === undefined || requestBody === null) {
throw new Error("Missing the required parameter 'requestBody' when calling addLayout");
}
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', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null
);
}
/**
* 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. Note that setting the capacity to `null` will configure the node as a gateway.
* @param {Object.<String, module:model/{String: NodeClusterInfo}>} requestBody To add a new node to the layout or to change the configuration of an existing node, simply set the values you want. To remove a node, set it to `null` instead of passing a configuration 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}
*/
addLayout(requestBody) {
return this.addLayoutWithHttpInfo(requestBody)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* Apply staged layout
* Applies to the cluster the layout changes currently registered as staged layout changes.
* @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.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response
*/
applyLayoutWithHttpInfo(layoutVersion) {
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'];
let accepts = [];
let returnType = null;
return this.apiClient.callApi(
'/layout/apply', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null
);
}
/**
* Apply staged layout
* Applies to the cluster the layout changes currently registered as staged layout changes.
* @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.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}
*/
applyLayout(layoutVersion) {
return this.applyLayoutWithHttpInfo(layoutVersion)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* Details on the current and staged layout
* Returns the cluster's current layout, including: - Currently configured cluster layout - Staged changes to the cluster layout *The info returned by this endpoint is a subset of the info returned by `GET /status`.*
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/ClusterLayout} and HTTP response
*/
getLayoutWithHttpInfo() {
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,
authNames, contentTypes, accepts, returnType, null
);
}
/**
* Details on the current and staged layout
* Returns the cluster's current layout, including: - Currently configured cluster layout - Staged changes to the cluster layout *The info returned by this endpoint is a subset of the info returned by `GET /status`.*
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ClusterLayout}
*/
getLayout() {
return this.getLayoutWithHttpInfo()
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* 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}, with an object containing HTTP response
*/
revertLayoutWithHttpInfo(layoutVersion) {
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,
authNames, contentTypes, accepts, returnType, null
);
}
/**
* 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;
});
}
}