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

590 lines
24 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 AllowBucketKeyRequest from '../model/AllowBucketKeyRequest';
import BucketInfo from '../model/BucketInfo';
import CreateBucketRequest from '../model/CreateBucketRequest';
import ListBuckets200ResponseInner from '../model/ListBuckets200ResponseInner';
import UpdateBucketRequest from '../model/UpdateBucketRequest';
/**
* Bucket service.
* @module api/BucketApi
* @version v0.8.0
*/
export default class BucketApi {
/**
* Constructs a new BucketApi.
* @alias module:api/BucketApi
* @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 allowBucketKey operation.
* @callback module:api/BucketApi~allowBucketKeyCallback
* @param {String} error Error message, if any.
* @param {module:model/BucketInfo} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Allow key
* ⚠️ **DISCLAIMER**: Garage's developers are aware that this endpoint has an unconventional semantic. Be extra careful when implementing it, its behavior is not obvious. Allows a key to do read/write/owner operations on a bucket. Flags in permissions which have the value true will be activated. Other flags will remain unchanged (ie. they will keep their internal value). For example, if you set read to true, the key will be allowed to read the bucket. If you set it to false, the key will keeps its previous read permission. If you want to disallow read for the key, check the DenyBucketKey operation.
* @param {module:model/AllowBucketKeyRequest} allowBucketKeyRequest Aliases to put on the new bucket
* @param {module:api/BucketApi~allowBucketKeyCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/BucketInfo}
*/
allowBucketKey(allowBucketKeyRequest, callback) {
let postBody = allowBucketKeyRequest;
// verify the required parameter 'allowBucketKeyRequest' is set
if (allowBucketKeyRequest === undefined || allowBucketKeyRequest === null) {
throw new Error("Missing the required parameter 'allowBucketKeyRequest' when calling allowBucketKey");
}
let pathParams = {
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = ['application/json'];
let accepts = ['application/json'];
let returnType = BucketInfo;
return this.apiClient.callApi(
'/bucket/allow', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the createBucket operation.
* @callback module:api/BucketApi~createBucketCallback
* @param {String} error Error message, if any.
* @param {module:model/BucketInfo} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Create a bucket
* Creates a new bucket, either with a global alias, a local one, or no alias at all. Technically, you can also specify both `globalAlias` and `localAlias` and that would create two aliases.
* @param {module:model/CreateBucketRequest} createBucketRequest Aliases to put on the new bucket
* @param {module:api/BucketApi~createBucketCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/BucketInfo}
*/
createBucket(createBucketRequest, callback) {
let postBody = createBucketRequest;
// verify the required parameter 'createBucketRequest' is set
if (createBucketRequest === undefined || createBucketRequest === null) {
throw new Error("Missing the required parameter 'createBucketRequest' when calling createBucket");
}
let pathParams = {
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = ['application/json'];
let accepts = ['application/json'];
let returnType = BucketInfo;
return this.apiClient.callApi(
'/bucket', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the deleteBucket operation.
* @callback module:api/BucketApi~deleteBucketCallback
* @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 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 {module:api/BucketApi~deleteBucketCallback} callback The callback function, accepting three arguments: error, data, response
*/
deleteBucket(bucketId, callback) {
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");
}
let pathParams = {
'bucket_id': bucketId
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = [];
let accepts = [];
let returnType = null;
return this.apiClient.callApi(
'/bucket?id={bucket_id}', 'DELETE',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the deleteBucketGlobalAlias operation.
* @callback module:api/BucketApi~deleteBucketGlobalAliasCallback
* @param {String} error Error message, if any.
* @param {module:model/BucketInfo} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Delete a global alias
* Delete a global alias from the target bucket
* @param {String} id
* @param {String} alias
* @param {module:api/BucketApi~deleteBucketGlobalAliasCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/BucketInfo}
*/
deleteBucketGlobalAlias(id, alias, callback) {
let postBody = null;
// verify the required parameter 'id' is set
if (id === undefined || id === null) {
throw new Error("Missing the required parameter 'id' when calling deleteBucketGlobalAlias");
}
// verify the required parameter 'alias' is set
if (alias === undefined || alias === null) {
throw new Error("Missing the required parameter 'alias' when calling deleteBucketGlobalAlias");
}
let pathParams = {
};
let queryParams = {
'id': id,
'alias': alias
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = BucketInfo;
return this.apiClient.callApi(
'/bucket/alias/global', 'DELETE',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the deleteBucketLocalAlias operation.
* @callback module:api/BucketApi~deleteBucketLocalAliasCallback
* @param {String} error Error message, if any.
* @param {module:model/BucketInfo} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Delete a local alias
* Delete a local alias, bound to specified account, from the target bucket
* @param {String} id
* @param {String} accessKeyId
* @param {String} alias
* @param {module:api/BucketApi~deleteBucketLocalAliasCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/BucketInfo}
*/
deleteBucketLocalAlias(id, accessKeyId, alias, callback) {
let postBody = null;
// verify the required parameter 'id' is set
if (id === undefined || id === null) {
throw new Error("Missing the required parameter 'id' when calling deleteBucketLocalAlias");
}
// verify the required parameter 'accessKeyId' is set
if (accessKeyId === undefined || accessKeyId === null) {
throw new Error("Missing the required parameter 'accessKeyId' when calling deleteBucketLocalAlias");
}
// verify the required parameter 'alias' is set
if (alias === undefined || alias === null) {
throw new Error("Missing the required parameter 'alias' when calling deleteBucketLocalAlias");
}
let pathParams = {
};
let queryParams = {
'id': id,
'accessKeyId': accessKeyId,
'alias': alias
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = BucketInfo;
return this.apiClient.callApi(
'/bucket/alias/local', 'DELETE',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the denyBucketKey operation.
* @callback module:api/BucketApi~denyBucketKeyCallback
* @param {String} error Error message, if any.
* @param {module:model/BucketInfo} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Deny key
* ⚠️ **DISCLAIMER**: Garage's developers are aware that this endpoint has an unconventional semantic. Be extra careful when implementing it, its behavior is not obvious. Denies a key from doing read/write/owner operations on a bucket. Flags in permissions which have the value true will be deactivated. Other flags will remain unchanged. For example, if you set read to true, the key will be denied from reading. If you set read to false, the key will keep its previous permissions. If you want the key to have the reading permission, check the AllowBucketKey operation.
* @param {module:model/AllowBucketKeyRequest} allowBucketKeyRequest Aliases to put on the new bucket
* @param {module:api/BucketApi~denyBucketKeyCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/BucketInfo}
*/
denyBucketKey(allowBucketKeyRequest, callback) {
let postBody = allowBucketKeyRequest;
// verify the required parameter 'allowBucketKeyRequest' is set
if (allowBucketKeyRequest === undefined || allowBucketKeyRequest === null) {
throw new Error("Missing the required parameter 'allowBucketKeyRequest' when calling denyBucketKey");
}
let pathParams = {
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = ['application/json'];
let accepts = ['application/json'];
let returnType = BucketInfo;
return this.apiClient.callApi(
'/bucket/deny', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the findBucketInfo operation.
* @callback module:api/BucketApi~findBucketInfoCallback
* @param {String} error Error message, if any.
* @param {module:model/BucketInfo} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Find a bucket
* Find a bucket by its global alias
* @param {String} alias The exact global alias of one of the existing buckets
* @param {module:api/BucketApi~findBucketInfoCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/BucketInfo}
*/
findBucketInfo(alias, callback) {
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 = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = [];
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, callback
);
}
/**
* Callback function to receive the result of the getBucketInfo operation.
* @callback module:api/BucketApi~getBucketInfoCallback
* @param {String} error Error message, if any.
* @param {module:model/BucketInfo} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* 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
* @param {module:api/BucketApi~getBucketInfoCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/BucketInfo}
*/
getBucketInfo(bucketId, callback) {
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',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the listBuckets operation.
* @callback module:api/BucketApi~listBucketsCallback
* @param {String} error Error message, if any.
* @param {Array.<module:model/ListBuckets200ResponseInner>} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* List all buckets
* List all the buckets on the cluster with their UUID and their global and local aliases.
* @param {module:api/BucketApi~listBucketsCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link Array.<module:model/ListBuckets200ResponseInner>}
*/
listBuckets(callback) {
let postBody = null;
let pathParams = {
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = [ListBuckets200ResponseInner];
return this.apiClient.callApi(
'/bucket', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the putBucketGlobalAlias operation.
* @callback module:api/BucketApi~putBucketGlobalAliasCallback
* @param {String} error Error message, if any.
* @param {module:model/BucketInfo} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Add a global alias
* Add a global alias to the target bucket
* @param {String} id
* @param {String} alias
* @param {module:api/BucketApi~putBucketGlobalAliasCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/BucketInfo}
*/
putBucketGlobalAlias(id, alias, callback) {
let postBody = null;
// verify the required parameter 'id' is set
if (id === undefined || id === null) {
throw new Error("Missing the required parameter 'id' when calling putBucketGlobalAlias");
}
// verify the required parameter 'alias' is set
if (alias === undefined || alias === null) {
throw new Error("Missing the required parameter 'alias' when calling putBucketGlobalAlias");
}
let pathParams = {
};
let queryParams = {
'id': id,
'alias': alias
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = BucketInfo;
return this.apiClient.callApi(
'/bucket/alias/global', 'PUT',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the putBucketLocalAlias operation.
* @callback module:api/BucketApi~putBucketLocalAliasCallback
* @param {String} error Error message, if any.
* @param {module:model/BucketInfo} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Add a local alias
* Add a local alias, bound to specified account, to the target bucket
* @param {String} id
* @param {String} accessKeyId
* @param {String} alias
* @param {module:api/BucketApi~putBucketLocalAliasCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/BucketInfo}
*/
putBucketLocalAlias(id, accessKeyId, alias, callback) {
let postBody = null;
// verify the required parameter 'id' is set
if (id === undefined || id === null) {
throw new Error("Missing the required parameter 'id' when calling putBucketLocalAlias");
}
// verify the required parameter 'accessKeyId' is set
if (accessKeyId === undefined || accessKeyId === null) {
throw new Error("Missing the required parameter 'accessKeyId' when calling putBucketLocalAlias");
}
// verify the required parameter 'alias' is set
if (alias === undefined || alias === null) {
throw new Error("Missing the required parameter 'alias' when calling putBucketLocalAlias");
}
let pathParams = {
};
let queryParams = {
'id': id,
'accessKeyId': accessKeyId,
'alias': alias
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = BucketInfo;
return this.apiClient.callApi(
'/bucket/alias/local', 'PUT',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the updateBucket operation.
* @callback module:api/BucketApi~updateBucketCallback
* @param {String} error Error message, if any.
* @param {module:model/BucketInfo} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Update a bucket
* All fields (`websiteAccess` and `quotas`) are optionnal. 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 {module:model/UpdateBucketRequest} updateBucketRequest Requested changes on the bucket. Both root fields are optionals.
* @param {module:api/BucketApi~updateBucketCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/BucketInfo}
*/
updateBucket(bucketId, updateBucketRequest, callback) {
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 'updateBucketRequest' is set
if (updateBucketRequest === undefined || updateBucketRequest === null) {
throw new Error("Missing the required parameter 'updateBucketRequest' when calling updateBucket");
}
let pathParams = {
'bucket_id': bucketId
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = ['application/json'];
let accepts = ['application/json'];
let returnType = BucketInfo;
return this.apiClient.callApi(
'/bucket?id={bucket_id}', 'PUT',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
}