From 4e3e8ea9986e427f969ab31be116b7ed95ae8362 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Wed, 22 Nov 2023 21:18:18 +0100 Subject: [PATCH] api-v1, 2nd iteration --- .openapi-generator/FILES | 4 -- README.md | 20 +++---- docs/BucketApi.md | 87 +++++++--------------------- docs/KeyApi.md | 79 +++++--------------------- src/api/BucketApi.js | 120 ++++++++++++--------------------------- src/api/KeyApi.js | 91 ++++++----------------------- 6 files changed, 99 insertions(+), 302 deletions(-) diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index a214586..621e0d9 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -83,7 +83,3 @@ src/model/UpdateBucketRequestWebsiteAccess.js src/model/UpdateKeyRequest.js src/model/UpdateKeyRequestAllow.js src/model/UpdateKeyRequestDeny.js -test/model/ApplyLayout200Response.spec.js -test/model/NodeRoleChange.spec.js -test/model/NodeRoleRemove.spec.js -test/model/NodeRoleUpdate.spec.js diff --git a/README.md b/README.md index 63cef99..819a743 100644 --- a/README.md +++ b/README.md @@ -127,23 +127,21 @@ Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *garage.BucketApi* | [**allowBucketKey**](docs/BucketApi.md#allowBucketKey) | **POST** /bucket/allow | Allow key *garage.BucketApi* | [**createBucket**](docs/BucketApi.md#createBucket) | **POST** /bucket | Create a bucket -*garage.BucketApi* | [**deleteBucket**](docs/BucketApi.md#deleteBucket) | **DELETE** /bucket?id={bucket_id} | Delete a bucket +*garage.BucketApi* | [**deleteBucket**](docs/BucketApi.md#deleteBucket) | **DELETE** /bucket | Delete a bucket *garage.BucketApi* | [**deleteBucketGlobalAlias**](docs/BucketApi.md#deleteBucketGlobalAlias) | **DELETE** /bucket/alias/global | Delete a global alias *garage.BucketApi* | [**deleteBucketLocalAlias**](docs/BucketApi.md#deleteBucketLocalAlias) | **DELETE** /bucket/alias/local | Delete a local alias *garage.BucketApi* | [**denyBucketKey**](docs/BucketApi.md#denyBucketKey) | **POST** /bucket/deny | Deny key -*garage.BucketApi* | [**findBucketInfo**](docs/BucketApi.md#findBucketInfo) | **GET** /bucket?globalAlias={alias} | Find a bucket -*garage.BucketApi* | [**getBucketInfo**](docs/BucketApi.md#getBucketInfo) | **GET** /bucket?id={bucket_id} | Get a bucket -*garage.BucketApi* | [**listBuckets**](docs/BucketApi.md#listBuckets) | **GET** /bucket | List all buckets +*garage.BucketApi* | [**getBucketInfo**](docs/BucketApi.md#getBucketInfo) | **GET** /bucket | Get a bucket +*garage.BucketApi* | [**listBuckets**](docs/BucketApi.md#listBuckets) | **GET** /bucket?list | List all buckets *garage.BucketApi* | [**putBucketGlobalAlias**](docs/BucketApi.md#putBucketGlobalAlias) | **PUT** /bucket/alias/global | Add a global alias *garage.BucketApi* | [**putBucketLocalAlias**](docs/BucketApi.md#putBucketLocalAlias) | **PUT** /bucket/alias/local | Add a local alias -*garage.BucketApi* | [**updateBucket**](docs/BucketApi.md#updateBucket) | **PUT** /bucket?id={bucket_id} | Update a bucket -*garage.KeyApi* | [**addKey**](docs/KeyApi.md#addKey) | **POST** /key | Create a new API key -*garage.KeyApi* | [**deleteKey**](docs/KeyApi.md#deleteKey) | **DELETE** /key?id={access_key} | Delete a key -*garage.KeyApi* | [**getKey**](docs/KeyApi.md#getKey) | **GET** /key?id={access_key} | Get key information +*garage.BucketApi* | [**updateBucket**](docs/BucketApi.md#updateBucket) | **PUT** /bucket | Update a bucket +*garage.KeyApi* | [**addKey**](docs/KeyApi.md#addKey) | **POST** /key?list | Create a new API key +*garage.KeyApi* | [**deleteKey**](docs/KeyApi.md#deleteKey) | **DELETE** /key | Delete a key +*garage.KeyApi* | [**getKey**](docs/KeyApi.md#getKey) | **GET** /key | Get key information *garage.KeyApi* | [**importKey**](docs/KeyApi.md#importKey) | **POST** /key/import | Import an existing key -*garage.KeyApi* | [**listKeys**](docs/KeyApi.md#listKeys) | **GET** /key | List all keys -*garage.KeyApi* | [**searchKey**](docs/KeyApi.md#searchKey) | **GET** /key?search={pattern} | Select key by pattern -*garage.KeyApi* | [**updateKey**](docs/KeyApi.md#updateKey) | **POST** /key?id={access_key} | Update a key +*garage.KeyApi* | [**listKeys**](docs/KeyApi.md#listKeys) | **GET** /key?list | List all keys +*garage.KeyApi* | [**updateKey**](docs/KeyApi.md#updateKey) | **POST** /key | Update a key *garage.LayoutApi* | [**addLayout**](docs/LayoutApi.md#addLayout) | **POST** /layout | Send modifications to the cluster layout *garage.LayoutApi* | [**applyLayout**](docs/LayoutApi.md#applyLayout) | **POST** /layout/apply | Apply staged layout *garage.LayoutApi* | [**getLayout**](docs/LayoutApi.md#getLayout) | **GET** /layout | Details on the current and staged layout diff --git a/docs/BucketApi.md b/docs/BucketApi.md index 82fd123..8b8c933 100644 --- a/docs/BucketApi.md +++ b/docs/BucketApi.md @@ -6,16 +6,15 @@ Method | HTTP request | Description ------------- | ------------- | ------------- [**allowBucketKey**](BucketApi.md#allowBucketKey) | **POST** /bucket/allow | Allow key [**createBucket**](BucketApi.md#createBucket) | **POST** /bucket | Create a bucket -[**deleteBucket**](BucketApi.md#deleteBucket) | **DELETE** /bucket?id={bucket_id} | Delete a bucket +[**deleteBucket**](BucketApi.md#deleteBucket) | **DELETE** /bucket | Delete a bucket [**deleteBucketGlobalAlias**](BucketApi.md#deleteBucketGlobalAlias) | **DELETE** /bucket/alias/global | Delete a global alias [**deleteBucketLocalAlias**](BucketApi.md#deleteBucketLocalAlias) | **DELETE** /bucket/alias/local | Delete a local alias [**denyBucketKey**](BucketApi.md#denyBucketKey) | **POST** /bucket/deny | Deny key -[**findBucketInfo**](BucketApi.md#findBucketInfo) | **GET** /bucket?globalAlias={alias} | Find a bucket -[**getBucketInfo**](BucketApi.md#getBucketInfo) | **GET** /bucket?id={bucket_id} | Get a bucket -[**listBuckets**](BucketApi.md#listBuckets) | **GET** /bucket | List all buckets +[**getBucketInfo**](BucketApi.md#getBucketInfo) | **GET** /bucket | Get a bucket +[**listBuckets**](BucketApi.md#listBuckets) | **GET** /bucket?list | List all buckets [**putBucketGlobalAlias**](BucketApi.md#putBucketGlobalAlias) | **PUT** /bucket/alias/global | Add a global alias [**putBucketLocalAlias**](BucketApi.md#putBucketLocalAlias) | **PUT** /bucket/alias/local | Add a local alias -[**updateBucket**](BucketApi.md#updateBucket) | **PUT** /bucket?id={bucket_id} | Update a bucket +[**updateBucket**](BucketApi.md#updateBucket) | **PUT** /bucket | Update a bucket @@ -117,7 +116,7 @@ Name | Type | Description | Notes ## deleteBucket -> deleteBucket(bucketId) +> deleteBucket(id) Delete a bucket @@ -133,8 +132,8 @@ let bearerAuth = defaultClient.authentications['bearerAuth']; bearerAuth.accessToken = "YOUR ACCESS TOKEN" let apiInstance = new garage.BucketApi(); -let bucketId = b4018dc61b27ccb5c64ec1b24f53454bbbd180697c758c4d47a22a8921864a87; // String | The exact bucket identifier, a 32 bytes hexadecimal string -apiInstance.deleteBucket(bucketId).then(() => { +let id = b4018dc61b27ccb5c64ec1b24f53454bbbd180697c758c4d47a22a8921864a87; // String | The exact bucket identifier, a 32 bytes hexadecimal string +apiInstance.deleteBucket(id).then(() => { console.log('API called successfully.'); }, (error) => { console.error(error); @@ -147,7 +146,7 @@ apiInstance.deleteBucket(bucketId).then(() => { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **bucketId** | **String**| The exact bucket identifier, a 32 bytes hexadecimal string | + **id** | **String**| The exact bucket identifier, a 32 bytes hexadecimal string | ### Return type @@ -313,61 +312,13 @@ Name | Type | Description | Notes - **Accept**: application/json -## findBucketInfo - -> BucketInfo findBucketInfo(alias) - -Find a bucket - -Find a bucket by its global alias - -### 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.BucketApi(); -let alias = my_documents; // String | The exact global alias of one of the existing buckets -apiInstance.findBucketInfo(alias).then((data) => { - console.log('API called successfully. Returned data: ' + data); -}, (error) => { - console.error(error); -}); - -``` - -### Parameters - - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **alias** | **String**| The exact global alias of one of the existing buckets | - -### Return type - -[**BucketInfo**](BucketInfo.md) - -### Authorization - -[bearerAuth](../README.md#bearerAuth) - -### HTTP request headers - -- **Content-Type**: Not defined -- **Accept**: application/json - - ## getBucketInfo -> BucketInfo getBucketInfo(bucketId) +> BucketInfo getBucketInfo(opts) Get a bucket -Given a bucket identifier, get its information. It includes its aliases, its web configuration, keys that have some permissions on it, some statistics (number of objects, size), number of dangling multipart uploads, and its quotas (if any). +Given a bucket identifier (`id`) or a global alias (`alias`), get its information. It includes its aliases, its web configuration, keys that have some permissions on it, some statistics (number of objects, size), number of dangling multipart uploads, and its quotas (if any). ### Example @@ -379,8 +330,11 @@ let bearerAuth = defaultClient.authentications['bearerAuth']; bearerAuth.accessToken = "YOUR ACCESS TOKEN" let apiInstance = new garage.BucketApi(); -let bucketId = b4018dc61b27ccb5c64ec1b24f53454bbbd180697c758c4d47a22a8921864a87; // String | The exact bucket identifier, a 32 bytes hexadecimal string -apiInstance.getBucketInfo(bucketId).then((data) => { +let opts = { + 'id': b4018dc61b27ccb5c64ec1b24f53454bbbd180697c758c4d47a22a8921864a87, // String | The exact bucket identifier, a 32 bytes hexadecimal string. Incompatible with `alias`. + 'alias': my_documents // String | The exact global alias of one of the existing buckets. Incompatible with `id`. +}; +apiInstance.getBucketInfo(opts).then((data) => { console.log('API called successfully. Returned data: ' + data); }, (error) => { console.error(error); @@ -393,7 +347,8 @@ apiInstance.getBucketInfo(bucketId).then((data) => { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **bucketId** | **String**| The exact bucket identifier, a 32 bytes hexadecimal string | + **id** | **String**| The exact bucket identifier, a 32 bytes hexadecimal string. Incompatible with `alias`. | [optional] + **alias** | **String**| The exact global alias of one of the existing buckets. Incompatible with `id`. | [optional] ### Return type @@ -557,7 +512,7 @@ Name | Type | Description | Notes ## updateBucket -> BucketInfo updateBucket(bucketId, updateBucketRequest) +> BucketInfo updateBucket(id, updateBucketRequest) Update a bucket @@ -573,9 +528,9 @@ let bearerAuth = defaultClient.authentications['bearerAuth']; bearerAuth.accessToken = "YOUR ACCESS TOKEN" let apiInstance = new garage.BucketApi(); -let bucketId = b4018dc61b27ccb5c64ec1b24f53454bbbd180697c758c4d47a22a8921864a87; // String | The exact bucket identifier, a 32 bytes hexadecimal string +let id = b4018dc61b27ccb5c64ec1b24f53454bbbd180697c758c4d47a22a8921864a87; // String | The exact bucket identifier, a 32 bytes hexadecimal string let updateBucketRequest = new garage.UpdateBucketRequest(); // UpdateBucketRequest | Requested changes on the bucket. Both root fields are optionals. -apiInstance.updateBucket(bucketId, updateBucketRequest).then((data) => { +apiInstance.updateBucket(id, updateBucketRequest).then((data) => { console.log('API called successfully. Returned data: ' + data); }, (error) => { console.error(error); @@ -588,7 +543,7 @@ apiInstance.updateBucket(bucketId, updateBucketRequest).then((data) => { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **bucketId** | **String**| The exact bucket identifier, a 32 bytes hexadecimal string | + **id** | **String**| The exact bucket identifier, a 32 bytes hexadecimal string | **updateBucketRequest** | [**UpdateBucketRequest**](UpdateBucketRequest.md)| Requested changes on the bucket. Both root fields are optionals. | ### Return type diff --git a/docs/KeyApi.md b/docs/KeyApi.md index 3e2bc72..6b009ae 100644 --- a/docs/KeyApi.md +++ b/docs/KeyApi.md @@ -4,13 +4,12 @@ All URIs are relative to *http://localhost:3903/v1* 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 +[**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 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 +[**listKeys**](KeyApi.md#listKeys) | **GET** /key?list | List all keys +[**updateKey**](KeyApi.md#updateKey) | **POST** /key | Update a key @@ -112,11 +111,11 @@ null (empty response body) ## getKey -> KeyInfo getKey(accessKey, opts) +> KeyInfo getKey(opts) Get key information -Return information about a specific key like its identifiers, its permissions and buckets on which it has permissions. For confidentiality reasons, the secret key is not returned by default: you must pass the `showSecretKey` query parameter to get it. +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 @@ -128,11 +127,12 @@ 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 opts = { - 'showSecretKey': true // Boolean | Wether or not the secret key should be returned in the response + '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(accessKey, opts).then((data) => { +apiInstance.getKey(opts).then((data) => { console.log('API called successfully. Returned data: ' + data); }, (error) => { console.error(error); @@ -145,8 +145,9 @@ apiInstance.getKey(accessKey, opts).then((data) => { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **accessKey** | **String**| The exact API access key generated by Garage | - **showSecretKey** | **Boolean**| Wether or not the secret key should be returned in the response | [optional] [default to false] + **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 @@ -254,58 +255,6 @@ This endpoint does not need any parameter. - **Accept**: application/json -## searchKey - -> KeyInfo searchKey(pattern, opts) - -Select key by pattern - -Find the first key matching the given pattern based on its identifier or friendly name and return its information. 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 pattern = test-k; // String | A pattern (beginning or full string) corresponding to a key identifier or friendly name -let opts = { - 'showSecretKey': true // Boolean | Wether or not the secret key should be returned in the response -}; -apiInstance.searchKey(pattern, opts).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 | - **showSecretKey** | **Boolean**| 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 - - ## updateKey > KeyInfo updateKey(accessKey, updateKeyRequest) diff --git a/src/api/BucketApi.js b/src/api/BucketApi.js index ebac5cb..ad49e89 100644 --- a/src/api/BucketApi.js +++ b/src/api/BucketApi.js @@ -136,20 +136,20 @@ export default class BucketApi { /** * Delete a bucket * Delete a bucket.Deletes a storage bucket. A bucket cannot be deleted if it is not empty. **Warning:** this will delete all aliases associated with the bucket! - * @param {String} bucketId The exact bucket identifier, a 32 bytes hexadecimal string + * @param {String} id The exact bucket identifier, a 32 bytes hexadecimal string * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ - deleteBucketWithHttpInfo(bucketId) { + deleteBucketWithHttpInfo(id) { let postBody = null; - // verify the required parameter 'bucketId' is set - if (bucketId === undefined || bucketId === null) { - throw new Error("Missing the required parameter 'bucketId' when calling deleteBucket"); + // verify the required parameter 'id' is set + if (id === undefined || id === null) { + throw new Error("Missing the required parameter 'id' when calling deleteBucket"); } let pathParams = { - 'bucket_id': bucketId }; let queryParams = { + 'id': id }; let headerParams = { }; @@ -161,7 +161,7 @@ export default class BucketApi { let accepts = []; let returnType = null; return this.apiClient.callApi( - '/bucket?id={bucket_id}', 'DELETE', + '/bucket', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null ); @@ -170,11 +170,11 @@ export default class BucketApi { /** * Delete a bucket * Delete a bucket.Deletes a storage bucket. A bucket cannot be deleted if it is not empty. **Warning:** this will delete all aliases associated with the bucket! - * @param {String} bucketId The exact bucket identifier, a 32 bytes hexadecimal string + * @param {String} id The exact bucket identifier, a 32 bytes hexadecimal string * @return {Promise} a {@link https://www.promisejs.org/|Promise} */ - deleteBucket(bucketId) { - return this.deleteBucketWithHttpInfo(bucketId) + deleteBucket(id) { + return this.deleteBucketWithHttpInfo(id) .then(function(response_and_data) { return response_and_data.data; }); @@ -346,22 +346,22 @@ export default class BucketApi { /** - * Find a bucket - * Find a bucket by its global alias - * @param {String} alias The exact global alias of one of the existing buckets + * Get a bucket + * Given a bucket identifier (`id`) or a global alias (`alias`), get its information. It includes its aliases, its web configuration, keys that have some permissions on it, some statistics (number of objects, size), number of dangling multipart uploads, and its quotas (if any). + * @param {Object} opts Optional parameters + * @param {String} opts.id The exact bucket identifier, a 32 bytes hexadecimal string. Incompatible with `alias`. + * @param {String} opts.alias The exact global alias of one of the existing buckets. Incompatible with `id`. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/BucketInfo} and HTTP response */ - findBucketInfoWithHttpInfo(alias) { + getBucketInfoWithHttpInfo(opts) { + opts = opts || {}; let postBody = null; - // verify the required parameter 'alias' is set - if (alias === undefined || alias === null) { - throw new Error("Missing the required parameter 'alias' when calling findBucketInfo"); - } let pathParams = { - 'alias': alias }; let queryParams = { + 'id': opts['id'], + 'alias': opts['alias'] }; let headerParams = { }; @@ -373,55 +373,7 @@ export default class BucketApi { let accepts = ['application/json']; let returnType = BucketInfo; return this.apiClient.callApi( - '/bucket?globalAlias={alias}', 'GET', - pathParams, queryParams, headerParams, formParams, postBody, - authNames, contentTypes, accepts, returnType, null - ); - } - - /** - * Find a bucket - * Find a bucket by its global alias - * @param {String} alias The exact global alias of one of the existing buckets - * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/BucketInfo} - */ - findBucketInfo(alias) { - return this.findBucketInfoWithHttpInfo(alias) - .then(function(response_and_data) { - return response_and_data.data; - }); - } - - - /** - * Get a bucket - * Given a bucket identifier, get its information. It includes its aliases, its web configuration, keys that have some permissions on it, some statistics (number of objects, size), number of dangling multipart uploads, and its quotas (if any). - * @param {String} bucketId The exact bucket identifier, a 32 bytes hexadecimal string - * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/BucketInfo} and HTTP response - */ - getBucketInfoWithHttpInfo(bucketId) { - let postBody = null; - // verify the required parameter 'bucketId' is set - if (bucketId === undefined || bucketId === null) { - throw new Error("Missing the required parameter 'bucketId' when calling getBucketInfo"); - } - - let pathParams = { - 'bucket_id': bucketId - }; - let queryParams = { - }; - let headerParams = { - }; - let formParams = { - }; - - let authNames = ['bearerAuth']; - let contentTypes = []; - let accepts = ['application/json']; - let returnType = BucketInfo; - return this.apiClient.callApi( - '/bucket?id={bucket_id}', 'GET', + '/bucket', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null ); @@ -429,12 +381,14 @@ export default class BucketApi { /** * Get a bucket - * Given a bucket identifier, get its information. It includes its aliases, its web configuration, keys that have some permissions on it, some statistics (number of objects, size), number of dangling multipart uploads, and its quotas (if any). - * @param {String} bucketId The exact bucket identifier, a 32 bytes hexadecimal string + * Given a bucket identifier (`id`) or a global alias (`alias`), get its information. It includes its aliases, its web configuration, keys that have some permissions on it, some statistics (number of objects, size), number of dangling multipart uploads, and its quotas (if any). + * @param {Object} opts Optional parameters + * @param {String} opts.id The exact bucket identifier, a 32 bytes hexadecimal string. Incompatible with `alias`. + * @param {String} opts.alias The exact global alias of one of the existing buckets. Incompatible with `id`. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/BucketInfo} */ - getBucketInfo(bucketId) { - return this.getBucketInfoWithHttpInfo(bucketId) + getBucketInfo(opts) { + return this.getBucketInfoWithHttpInfo(opts) .then(function(response_and_data) { return response_and_data.data; }); @@ -463,7 +417,7 @@ export default class BucketApi { let accepts = ['application/json']; let returnType = [ListBuckets200ResponseInner]; return this.apiClient.callApi( - '/bucket', 'GET', + '/bucket?list', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null ); @@ -602,15 +556,15 @@ export default class BucketApi { /** * Update a bucket * All fields (`websiteAccess` and `quotas`) are optional. If they are present, the corresponding modifications are applied to the bucket, otherwise nothing is changed. In `websiteAccess`: if `enabled` is `true`, `indexDocument` must be specified. The field `errorDocument` is optional, if no error document is set a generic error message is displayed when errors happen. Conversely, if `enabled` is `false`, neither `indexDocument` nor `errorDocument` must be specified. In `quotas`: new values of `maxSize` and `maxObjects` must both be specified, or set to `null` to remove the quotas. An absent value will be considered the same as a `null`. It is not possible to change only one of the two quotas. - * @param {String} bucketId The exact bucket identifier, a 32 bytes hexadecimal string + * @param {String} id The exact bucket identifier, a 32 bytes hexadecimal string * @param {module:model/UpdateBucketRequest} updateBucketRequest Requested changes on the bucket. Both root fields are optionals. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/BucketInfo} and HTTP response */ - updateBucketWithHttpInfo(bucketId, updateBucketRequest) { + updateBucketWithHttpInfo(id, updateBucketRequest) { let postBody = updateBucketRequest; - // verify the required parameter 'bucketId' is set - if (bucketId === undefined || bucketId === null) { - throw new Error("Missing the required parameter 'bucketId' when calling updateBucket"); + // verify the required parameter 'id' is set + if (id === undefined || id === null) { + throw new Error("Missing the required parameter 'id' when calling updateBucket"); } // verify the required parameter 'updateBucketRequest' is set if (updateBucketRequest === undefined || updateBucketRequest === null) { @@ -618,9 +572,9 @@ export default class BucketApi { } let pathParams = { - 'bucket_id': bucketId }; let queryParams = { + 'id': id }; let headerParams = { }; @@ -632,7 +586,7 @@ export default class BucketApi { let accepts = ['application/json']; let returnType = BucketInfo; return this.apiClient.callApi( - '/bucket?id={bucket_id}', 'PUT', + '/bucket', 'PUT', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null ); @@ -641,12 +595,12 @@ export default class BucketApi { /** * Update a bucket * All fields (`websiteAccess` and `quotas`) are optional. If they are present, the corresponding modifications are applied to the bucket, otherwise nothing is changed. In `websiteAccess`: if `enabled` is `true`, `indexDocument` must be specified. The field `errorDocument` is optional, if no error document is set a generic error message is displayed when errors happen. Conversely, if `enabled` is `false`, neither `indexDocument` nor `errorDocument` must be specified. In `quotas`: new values of `maxSize` and `maxObjects` must both be specified, or set to `null` to remove the quotas. An absent value will be considered the same as a `null`. It is not possible to change only one of the two quotas. - * @param {String} bucketId The exact bucket identifier, a 32 bytes hexadecimal string + * @param {String} id The exact bucket identifier, a 32 bytes hexadecimal string * @param {module:model/UpdateBucketRequest} updateBucketRequest Requested changes on the bucket. Both root fields are optionals. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/BucketInfo} */ - updateBucket(bucketId, updateBucketRequest) { - return this.updateBucketWithHttpInfo(bucketId, updateBucketRequest) + updateBucket(id, updateBucketRequest) { + return this.updateBucketWithHttpInfo(id, updateBucketRequest) .then(function(response_and_data) { return response_and_data.data; }); diff --git a/src/api/KeyApi.js b/src/api/KeyApi.js index 5e84686..1c90d6a 100644 --- a/src/api/KeyApi.js +++ b/src/api/KeyApi.js @@ -66,7 +66,7 @@ export default class KeyApi { let accepts = ['application/json']; let returnType = KeyInfo; return this.apiClient.callApi( - '/key', 'POST', + '/key?list', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null ); @@ -114,7 +114,7 @@ export default class KeyApi { let accepts = []; let returnType = null; return this.apiClient.callApi( - '/key?id={access_key}', 'DELETE', + '/key', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null ); @@ -136,24 +136,22 @@ export default class KeyApi { /** * Get key information - * Return information about a specific key like its identifiers, its permissions and buckets on which it has permissions. For confidentiality reasons, the secret key is not returned by default: you must pass the `showSecretKey` query parameter to get it. - * @param {String} accessKey The exact API access key generated by Garage + * 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. * @param {Object} opts Optional parameters - * @param {Boolean} opts.showSecretKey Wether or not the secret key should be returned in the response (default to false) + * @param {String} opts.id The exact API access key generated by Garage. Incompatible with `search`. + * @param {String} opts.search A pattern (beginning or full string) corresponding to a key identifier or friendly name. Incompatible with `id`. + * @param {module:model/String} opts.showSecretKey Wether or not the secret key should be returned in the response (default to 'false') * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/KeyInfo} and HTTP response */ - getKeyWithHttpInfo(accessKey, opts) { + getKeyWithHttpInfo(opts) { opts = opts || {}; 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 = { + 'id': opts['id'], + 'search': opts['search'], 'showSecretKey': opts['showSecretKey'] }; let headerParams = { @@ -166,7 +164,7 @@ export default class KeyApi { let accepts = ['application/json']; let returnType = KeyInfo; return this.apiClient.callApi( - '/key?id={access_key}', 'GET', + '/key', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null ); @@ -174,14 +172,15 @@ export default class KeyApi { /** * Get key information - * Return information about a specific key like its identifiers, its permissions and buckets on which it has permissions. For confidentiality reasons, the secret key is not returned by default: you must pass the `showSecretKey` query parameter to get it. - * @param {String} accessKey The exact API access key generated by Garage + * 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. * @param {Object} opts Optional parameters - * @param {Boolean} opts.showSecretKey Wether or not the secret key should be returned in the response (default to false) + * @param {String} opts.id The exact API access key generated by Garage. Incompatible with `search`. + * @param {String} opts.search A pattern (beginning or full string) corresponding to a key identifier or friendly name. Incompatible with `id`. + * @param {module:model/String} opts.showSecretKey Wether or not the secret key should be returned in the response (default to 'false') * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/KeyInfo} */ - getKey(accessKey, opts) { - return this.getKeyWithHttpInfo(accessKey, opts) + getKey(opts) { + return this.getKeyWithHttpInfo(opts) .then(function(response_and_data) { return response_and_data.data; }); @@ -257,7 +256,7 @@ export default class KeyApi { let accepts = ['application/json']; let returnType = [ListKeys200ResponseInner]; return this.apiClient.callApi( - '/key', 'GET', + '/key?list', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null ); @@ -276,60 +275,6 @@ export default class KeyApi { } - /** - * Select key by pattern - * Find the first key matching the given pattern based on its identifier or friendly name and return its information. For confidentiality reasons, the secret key is not returned by default: you must pass the `showSecretKey` query parameter to get it. - * @param {String} pattern A pattern (beginning or full string) corresponding to a key identifier or friendly name - * @param {Object} opts Optional parameters - * @param {Boolean} opts.showSecretKey Wether or not the secret key should be returned in the response (default to false) - * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/KeyInfo} and HTTP response - */ - searchKeyWithHttpInfo(pattern, opts) { - opts = opts || {}; - 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 = { - 'showSecretKey': opts['showSecretKey'] - }; - 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 - ); - } - - /** - * Select key by pattern - * Find the first key matching the given pattern based on its identifier or friendly name and return its information. For confidentiality reasons, the secret key is not returned by default: you must pass the `showSecretKey` query parameter to get it. - * @param {String} pattern A pattern (beginning or full string) corresponding to a key identifier or friendly name - * @param {Object} opts Optional parameters - * @param {Boolean} opts.showSecretKey Wether or not the secret key should be returned in the response (default to false) - * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/KeyInfo} - */ - searchKey(pattern, opts) { - return this.searchKeyWithHttpInfo(pattern, opts) - .then(function(response_and_data) { - return response_and_data.data; - }); - } - - /** * 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.* @@ -363,7 +308,7 @@ export default class KeyApi { let accepts = ['application/json']; let returnType = KeyInfo; return this.apiClient.callApi( - '/key?id={access_key}', 'POST', + '/key', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null );