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

340 lines
12 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 AddKeyRequest from '../model/AddKeyRequest';
import ImportKeyRequest from '../model/ImportKeyRequest';
import KeyInfo from '../model/KeyInfo';
import ListKeys200ResponseInner from '../model/ListKeys200ResponseInner';
import UpdateKeyRequest from '../model/UpdateKeyRequest';
/**
* Key service.
* @module api/KeyApi
* @version v0.8.0
*/
export default class KeyApi {
/**
* Constructs a new KeyApi.
* @alias module:api/KeyApi
* @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;
}
/**
* Callback function to receive the result of the addKey operation.
* @callback module:api/KeyApi~addKeyCallback
* @param {String} error Error message, if any.
* @param {module:model/KeyInfo} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Create a new API key
* Creates a new API access key.
* @param {module:model/AddKeyRequest} addKeyRequest \"You can set a friendly name for this key, send an empty string instead\"
* @param {module:api/KeyApi~addKeyCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/KeyInfo}
*/
addKey(addKeyRequest, callback) {
let postBody = addKeyRequest;
// verify the required parameter 'addKeyRequest' is set
if (addKeyRequest === undefined || addKeyRequest === null) {
throw new Error("Missing the required parameter 'addKeyRequest' when calling addKey");
}
let pathParams = {
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = ['application/json'];
let accepts = ['application/json'];
let returnType = KeyInfo;
return this.apiClient.callApi(
'/key', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the deleteKey operation.
* @callback module:api/KeyApi~deleteKeyCallback
* @param {String} error Error message, if any.
* @param data This operation does not return a value.
* @param {String} response The complete HTTP response.
*/
/**
* Delete a key
* Delete a key from the cluster. Its access will be removed from all the buckets. Buckets are not automatically deleted and can be dangling. You should manually delete them before.
* @param {String} accessKey The exact API access key generated by Garage
* @param {module:api/KeyApi~deleteKeyCallback} callback The callback function, accepting three arguments: error, data, response
*/
deleteKey(accessKey, callback) {
let postBody = null;
// verify the required parameter 'accessKey' is set
if (accessKey === undefined || accessKey === null) {
throw new Error("Missing the required parameter 'accessKey' when calling deleteKey");
}
let pathParams = {
'access_key': accessKey
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = [];
let accepts = [];
let returnType = null;
return this.apiClient.callApi(
'/key?id={access_key}', 'DELETE',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the getKey operation.
* @callback module:api/KeyApi~getKeyCallback
* @param {String} error Error message, if any.
* @param {module:model/KeyInfo} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Get key information
* Return information about a specific key and return its information
* @param {String} accessKey The exact API access key generated by Garage
* @param {module:api/KeyApi~getKeyCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/KeyInfo}
*/
getKey(accessKey, callback) {
let postBody = null;
// verify the required parameter 'accessKey' is set
if (accessKey === undefined || accessKey === null) {
throw new Error("Missing the required parameter 'accessKey' when calling getKey");
}
let pathParams = {
'access_key': accessKey
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = KeyInfo;
return this.apiClient.callApi(
'/key?id={access_key}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the importKey operation.
* @callback module:api/KeyApi~importKeyCallback
* @param {String} error Error message, if any.
* @param {module:model/KeyInfo} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Import an existing key
* Imports an existing API key. This feature must only be used for migrations and backup restore. **Do not use it to generate custom key identifiers or you will break your Garage cluster.**
* @param {module:model/ImportKeyRequest} importKeyRequest Information on the key to import
* @param {module:api/KeyApi~importKeyCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/KeyInfo}
*/
importKey(importKeyRequest, callback) {
let postBody = importKeyRequest;
// verify the required parameter 'importKeyRequest' is set
if (importKeyRequest === undefined || importKeyRequest === null) {
throw new Error("Missing the required parameter 'importKeyRequest' when calling importKey");
}
let pathParams = {
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = ['application/json'];
let accepts = ['application/json'];
let returnType = KeyInfo;
return this.apiClient.callApi(
'/key/import', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the listKeys operation.
* @callback module:api/KeyApi~listKeysCallback
* @param {String} error Error message, if any.
* @param {Array.<module:model/ListKeys200ResponseInner>} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* List all keys
* Returns all API access keys in the cluster.
* @param {module:api/KeyApi~listKeysCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link Array.<module:model/ListKeys200ResponseInner>}
*/
listKeys(callback) {
let postBody = null;
let pathParams = {
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = [ListKeys200ResponseInner];
return this.apiClient.callApi(
'/key', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the searchKey operation.
* @callback module:api/KeyApi~searchKeyCallback
* @param {String} error Error message, if any.
* @param {module:model/KeyInfo} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Select key by pattern
* Find the first key matching the given pattern based on its identifier aor friendly name and return its information.
* @param {String} pattern A pattern (beginning or full string) corresponding to a key identifier or friendly name
* @param {module:api/KeyApi~searchKeyCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/KeyInfo}
*/
searchKey(pattern, callback) {
let postBody = null;
// verify the required parameter 'pattern' is set
if (pattern === undefined || pattern === null) {
throw new Error("Missing the required parameter 'pattern' when calling searchKey");
}
let pathParams = {
'pattern': pattern
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = KeyInfo;
return this.apiClient.callApi(
'/key?search={pattern}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the updateKey operation.
* @callback module:api/KeyApi~updateKeyCallback
* @param {String} error Error message, if any.
* @param {module:model/KeyInfo} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Update a key
* Updates information about the specified API access key.
* @param {String} accessKey The exact API access key generated by Garage
* @param {module:model/UpdateKeyRequest} updateKeyRequest For a given key, provide a first set with the permissions to grant, and a second set with the permissions to remove
* @param {module:api/KeyApi~updateKeyCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/KeyInfo}
*/
updateKey(accessKey, updateKeyRequest, callback) {
let postBody = updateKeyRequest;
// verify the required parameter 'accessKey' is set
if (accessKey === undefined || accessKey === null) {
throw new Error("Missing the required parameter 'accessKey' when calling updateKey");
}
// verify the required parameter 'updateKeyRequest' is set
if (updateKeyRequest === undefined || updateKeyRequest === null) {
throw new Error("Missing the required parameter 'updateKeyRequest' when calling updateKey");
}
let pathParams = {
'access_key': accessKey
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = ['application/json'];
let accepts = ['application/json'];
let returnType = KeyInfo;
return this.apiClient.callApi(
'/key?id={access_key}', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
}