garage-admin-sdk-js/docs/KeyApi.md
2022-11-13 12:56:24 +01:00

349 lines
9.1 KiB
Markdown

# garage.KeyApi
All URIs are relative to *http://localhost:3903/v0*
Method | HTTP request | Description
------------- | ------------- | -------------
[**addKey**](KeyApi.md#addKey) | **POST** /key | Create a new API key
[**deleteKey**](KeyApi.md#deleteKey) | **DELETE** /key?id={access_key} | Delete a key
[**getKey**](KeyApi.md#getKey) | **GET** /key?id={access_key} | Get key information
[**importKey**](KeyApi.md#importKey) | **POST** /key/import | Import an existing key
[**listKeys**](KeyApi.md#listKeys) | **GET** /key | List all keys
[**searchKey**](KeyApi.md#searchKey) | **GET** /key?search={pattern} | Select key by pattern
[**updateKey**](KeyApi.md#updateKey) | **POST** /key?id={access_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_8_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, send an empty string instead\"
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, send an empty string instead\" |
### Return type
[**KeyInfo**](KeyInfo.md)
### Authorization
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json
## deleteKey
> deleteKey(accessKey)
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_8_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 accessKey = GK31c2f218a2e44f485b94239e; // String | The exact API access key generated by Garage
apiInstance.deleteKey(accessKey).then(() => {
console.log('API called successfully.');
}, (error) => {
console.error(error);
});
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**accessKey** | **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(accessKey)
Get key information
Return information about a specific key and return its information
### Example
```javascript
import garage from 'garage_administration_api_v0garage_v0_8_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 accessKey = GK31c2f218a2e44f485b94239e; // String | The exact API access key generated by Garage
apiInstance.getKey(accessKey).then((data) => {
console.log('API called successfully. Returned data: ' + data);
}, (error) => {
console.error(error);
});
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**accessKey** | **String**| The exact API access key generated by Garage |
### 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_8_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_8_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
## searchKey
> KeyInfo searchKey(pattern)
Select key by pattern
Find the first key matching the given pattern based on its identifier aor friendly name and return its information.
### Example
```javascript
import garage from 'garage_administration_api_v0garage_v0_8_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 pattern = test-k; // String | A pattern (beginning or full string) corresponding to a key identifier or friendly name
apiInstance.searchKey(pattern).then((data) => {
console.log('API called successfully. Returned data: ' + data);
}, (error) => {
console.error(error);
});
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pattern** | **String**| A pattern (beginning or full string) corresponding to a key identifier or friendly name |
### Return type
[**KeyInfo**](KeyInfo.md)
### Authorization
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
## updateKey
> KeyInfo updateKey(accessKey, updateKeyRequest)
Update a key
Updates information about the specified API access key.
### Example
```javascript
import garage from 'garage_administration_api_v0garage_v0_8_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 accessKey = 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(accessKey, updateKeyRequest).then((data) => {
console.log('API called successfully. Returned data: ' + data);
}, (error) => {
console.error(error);
});
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**accessKey** | **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