garage-admin-sdk-js/docs/KeyApi.md

307 lines
8.8 KiB
Markdown

# garage.KeyApi
All URIs are relative to *http://localhost:3903/v1*
Method | HTTP request | Description
------------- | ------------- | -------------
[**addKey**](KeyApi.md#addKey) | **POST** /key?list | Create a new API key
[**deleteKey**](KeyApi.md#deleteKey) | **DELETE** /key | Delete a key
[**getKey**](KeyApi.md#getKey) | **GET** /key | Get key information
[**importKey**](KeyApi.md#importKey) | **POST** /key/import | Import an existing key
[**listKeys**](KeyApi.md#listKeys) | **GET** /key?list | List all keys
[**updateKey**](KeyApi.md#updateKey) | **POST** /key | Update a key
## addKey
> KeyInfo addKey(addKeyRequest)
Create a new API key
Creates a new API access key.
### Example
```javascript
import garage from 'garage_administration_api_v0garage_v0_9_0';
let defaultClient = garage.ApiClient.instance;
// Configure Bearer access token for authorization: bearerAuth
let bearerAuth = defaultClient.authentications['bearerAuth'];
bearerAuth.accessToken = "YOUR ACCESS TOKEN"
let apiInstance = new garage.KeyApi();
let addKeyRequest = new garage.AddKeyRequest(); // AddKeyRequest | You can set a friendly name for this key. If you don't want to, you can set the name to `null`. *Note: the secret key is returned in the response.*
apiInstance.addKey(addKeyRequest).then((data) => {
console.log('API called successfully. Returned data: ' + data);
}, (error) => {
console.error(error);
});
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**addKeyRequest** | [**AddKeyRequest**](AddKeyRequest.md)| You can set a friendly name for this key. If you don't want to, you can set the name to `null`. *Note: the secret key is returned in the response.* |
### Return type
[**KeyInfo**](KeyInfo.md)
### Authorization
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json
## deleteKey
> deleteKey(id)
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.
### Example
```javascript
import garage from 'garage_administration_api_v0garage_v0_9_0';
let defaultClient = garage.ApiClient.instance;
// Configure Bearer access token for authorization: bearerAuth
let bearerAuth = defaultClient.authentications['bearerAuth'];
bearerAuth.accessToken = "YOUR ACCESS TOKEN"
let apiInstance = new garage.KeyApi();
let id = GK31c2f218a2e44f485b94239e; // String | The exact API access key generated by Garage
apiInstance.deleteKey(id).then(() => {
console.log('API called successfully.');
}, (error) => {
console.error(error);
});
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**id** | **String**| The exact API access key generated by Garage |
### Return type
null (empty response body)
### Authorization
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
## getKey
> KeyInfo getKey(opts)
Get key information
Return information about a specific key like its identifiers, its permissions and buckets on which it has permissions. You can search by specifying the exact key identifier (`id`) or by specifying a pattern (`search`). For confidentiality reasons, the secret key is not returned by default: you must pass the `showSecretKey` query parameter to get it.
### Example
```javascript
import garage from 'garage_administration_api_v0garage_v0_9_0';
let defaultClient = garage.ApiClient.instance;
// Configure Bearer access token for authorization: bearerAuth
let bearerAuth = defaultClient.authentications['bearerAuth'];
bearerAuth.accessToken = "YOUR ACCESS TOKEN"
let apiInstance = new garage.KeyApi();
let opts = {
'id': GK31c2f218a2e44f485b94239e, // String | The exact API access key generated by Garage. Incompatible with `search`.
'search': test-k, // String | A pattern (beginning or full string) corresponding to a key identifier or friendly name. Incompatible with `id`.
'showSecretKey': true // String | Wether or not the secret key should be returned in the response
};
apiInstance.getKey(opts).then((data) => {
console.log('API called successfully. Returned data: ' + data);
}, (error) => {
console.error(error);
});
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**id** | **String**| The exact API access key generated by Garage. Incompatible with `search`. | [optional]
**search** | **String**| A pattern (beginning or full string) corresponding to a key identifier or friendly name. Incompatible with `id`. | [optional]
**showSecretKey** | **String**| Wether or not the secret key should be returned in the response | [optional] [default to 'false']
### Return type
[**KeyInfo**](KeyInfo.md)
### Authorization
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
## importKey
> KeyInfo importKey(importKeyRequest)
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.**
### Example
```javascript
import garage from 'garage_administration_api_v0garage_v0_9_0';
let defaultClient = garage.ApiClient.instance;
// Configure Bearer access token for authorization: bearerAuth
let bearerAuth = defaultClient.authentications['bearerAuth'];
bearerAuth.accessToken = "YOUR ACCESS TOKEN"
let apiInstance = new garage.KeyApi();
let importKeyRequest = new garage.ImportKeyRequest(); // ImportKeyRequest | Information on the key to import
apiInstance.importKey(importKeyRequest).then((data) => {
console.log('API called successfully. Returned data: ' + data);
}, (error) => {
console.error(error);
});
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**importKeyRequest** | [**ImportKeyRequest**](ImportKeyRequest.md)| Information on the key to import |
### Return type
[**KeyInfo**](KeyInfo.md)
### Authorization
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json
## listKeys
> [ListKeys200ResponseInner] listKeys()
List all keys
Returns all API access keys in the cluster.
### Example
```javascript
import garage from 'garage_administration_api_v0garage_v0_9_0';
let defaultClient = garage.ApiClient.instance;
// Configure Bearer access token for authorization: bearerAuth
let bearerAuth = defaultClient.authentications['bearerAuth'];
bearerAuth.accessToken = "YOUR ACCESS TOKEN"
let apiInstance = new garage.KeyApi();
apiInstance.listKeys().then((data) => {
console.log('API called successfully. Returned data: ' + data);
}, (error) => {
console.error(error);
});
```
### Parameters
This endpoint does not need any parameter.
### Return type
[**[ListKeys200ResponseInner]**](ListKeys200ResponseInner.md)
### Authorization
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
## updateKey
> KeyInfo updateKey(id, updateKeyRequest)
Update a key
Updates information about the specified API access key. *Note: the secret key is not returned in the response, `null` is sent instead.*
### Example
```javascript
import garage from 'garage_administration_api_v0garage_v0_9_0';
let defaultClient = garage.ApiClient.instance;
// Configure Bearer access token for authorization: bearerAuth
let bearerAuth = defaultClient.authentications['bearerAuth'];
bearerAuth.accessToken = "YOUR ACCESS TOKEN"
let apiInstance = new garage.KeyApi();
let id = GK31c2f218a2e44f485b94239e; // String | The exact API access key generated by Garage
let updateKeyRequest = new garage.UpdateKeyRequest(); // UpdateKeyRequest | For a given key, provide a first set with the permissions to grant, and a second set with the permissions to remove
apiInstance.updateKey(id, updateKeyRequest).then((data) => {
console.log('API called successfully. Returned data: ' + data);
}, (error) => {
console.error(error);
});
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**id** | **String**| The exact API access key generated by Garage |
**updateKeyRequest** | [**UpdateKeyRequest**](UpdateKeyRequest.md)| For a given key, provide a first set with the permissions to grant, and a second set with the permissions to remove |
### Return type
[**KeyInfo**](KeyInfo.md)
### Authorization
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json