2022-11-13 11:28:54 +00:00
/ * *
* 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 ;
}
/ * *
* 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\"
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/KeyInfo} and HTTP response
2022-11-13 11:28:54 +00:00
* /
2022-11-13 11:56:24 +00:00
addKeyWithHttpInfo ( addKeyRequest ) {
2022-11-13 11:28:54 +00:00
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 ,
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
* 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\"
* @ return { Promise } a { @ link https : //www.promisejs.org/|Promise}, with data of type {@link module:model/KeyInfo}
2022-11-13 11:28:54 +00:00
* /
2022-11-13 11:56:24 +00:00
addKey ( addKeyRequest ) {
return this . addKeyWithHttpInfo ( addKeyRequest )
. then ( function ( response _and _data ) {
return response _and _data . data ;
} ) ;
}
2022-11-13 11:28:54 +00:00
/ * *
* 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
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
deleteKeyWithHttpInfo ( accessKey ) {
2022-11-13 11:28:54 +00:00
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 ,
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
* 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
* @ return { Promise } a { @ link https : //www.promisejs.org/|Promise}
2022-11-13 11:28:54 +00:00
* /
2022-11-13 11:56:24 +00:00
deleteKey ( accessKey ) {
return this . deleteKeyWithHttpInfo ( accessKey )
. then ( function ( response _and _data ) {
return response _and _data . data ;
} ) ;
}
2022-11-13 11:28:54 +00:00
/ * *
* Get key information
* Return information about a specific key and return its information
* @ param { String } accessKey The exact API access key generated by Garage
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/KeyInfo} and HTTP response
2022-11-13 11:28:54 +00:00
* /
2022-11-13 11:56:24 +00:00
getKeyWithHttpInfo ( accessKey ) {
2022-11-13 11:28:54 +00:00
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 ,
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
* Get key information
* Return information about a specific key and return its information
* @ param { String } accessKey The exact API access key generated by Garage
* @ return { Promise } a { @ link https : //www.promisejs.org/|Promise}, with data of type {@link module:model/KeyInfo}
2022-11-13 11:28:54 +00:00
* /
2022-11-13 11:56:24 +00:00
getKey ( accessKey ) {
return this . getKeyWithHttpInfo ( accessKey )
. then ( function ( response _and _data ) {
return response _and _data . data ;
} ) ;
}
2022-11-13 11:28:54 +00:00
/ * *
* 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
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/KeyInfo} and HTTP response
2022-11-13 11:28:54 +00:00
* /
2022-11-13 11:56:24 +00:00
importKeyWithHttpInfo ( importKeyRequest ) {
2022-11-13 11:28:54 +00:00
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 ,
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
* 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
* @ return { Promise } a { @ link https : //www.promisejs.org/|Promise}, with data of type {@link module:model/KeyInfo}
2022-11-13 11:28:54 +00:00
* /
2022-11-13 11:56:24 +00:00
importKey ( importKeyRequest ) {
return this . importKeyWithHttpInfo ( importKeyRequest )
. then ( function ( response _and _data ) {
return response _and _data . data ;
} ) ;
}
2022-11-13 11:28:54 +00:00
/ * *
* List all keys
* Returns all API access keys in the cluster .
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 Array.<module:model/ListKeys200ResponseInner>} and HTTP response
2022-11-13 11:28:54 +00:00
* /
2022-11-13 11:56:24 +00:00
listKeysWithHttpInfo ( ) {
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 = [ ListKeys200ResponseInner ] ;
return this . apiClient . callApi (
'/key' , '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
* List all keys
* Returns all API access keys in the cluster .
* @ return { Promise } a { @ link https : //www.promisejs.org/|Promise}, with data of type {@link Array.<module:model/ListKeys200ResponseInner>}
2022-11-13 11:28:54 +00:00
* /
2022-11-13 11:56:24 +00:00
listKeys ( ) {
return this . listKeysWithHttpInfo ( )
. then ( function ( response _and _data ) {
return response _and _data . data ;
} ) ;
}
2022-11-13 11:28:54 +00:00
/ * *
* 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
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/KeyInfo} and HTTP response
2022-11-13 11:28:54 +00:00
* /
2022-11-13 11:56:24 +00:00
searchKeyWithHttpInfo ( pattern ) {
2022-11-13 11:28:54 +00:00
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 ,
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
* 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
* @ return { Promise } a { @ link https : //www.promisejs.org/|Promise}, with data of type {@link module:model/KeyInfo}
2022-11-13 11:28:54 +00:00
* /
2022-11-13 11:56:24 +00:00
searchKey ( pattern ) {
return this . searchKeyWithHttpInfo ( pattern )
. then ( function ( response _and _data ) {
return response _and _data . data ;
} ) ;
}
2022-11-13 11:28:54 +00:00
/ * *
* 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
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/KeyInfo} and HTTP response
2022-11-13 11:28:54 +00:00
* /
2022-11-13 11:56:24 +00:00
updateKeyWithHttpInfo ( accessKey , updateKeyRequest ) {
2022-11-13 11:28:54 +00:00
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 ,
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
/ * *
* 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
* @ return { Promise } a { @ link https : //www.promisejs.org/|Promise}, with data of type {@link module:model/KeyInfo}
* /
updateKey ( accessKey , updateKeyRequest ) {
return this . updateKeyWithHttpInfo ( accessKey , updateKeyRequest )
. then ( function ( response _and _data ) {
return response _and _data . data ;
} ) ;
}
2022-11-13 11:28:54 +00:00
}