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

657 lines
27 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;
}
/**
* 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
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/BucketInfo} and HTTP response
*/
allowBucketKeyWithHttpInfo(allowBucketKeyRequest) {
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
);
}
/**
* 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
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/BucketInfo}
*/
allowBucketKey(allowBucketKeyRequest) {
return this.allowBucketKeyWithHttpInfo(allowBucketKeyRequest)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* 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
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/BucketInfo} and HTTP response
*/
createBucketWithHttpInfo(createBucketRequest) {
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
);
}
/**
* 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
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/BucketInfo}
*/
createBucket(createBucketRequest) {
return this.createBucketWithHttpInfo(createBucketRequest)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* 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
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response
*/
deleteBucketWithHttpInfo(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 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
);
}
/**
* 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
* @return {Promise} a {@link https://www.promisejs.org/|Promise}
*/
deleteBucket(bucketId) {
return this.deleteBucketWithHttpInfo(bucketId)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* Delete a global alias
* Delete a global alias from the target bucket
* @param {String} id
* @param {String} alias
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/BucketInfo} and HTTP response
*/
deleteBucketGlobalAliasWithHttpInfo(id, alias) {
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
);
}
/**
* Delete a global alias
* Delete a global alias from the target bucket
* @param {String} id
* @param {String} alias
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/BucketInfo}
*/
deleteBucketGlobalAlias(id, alias) {
return this.deleteBucketGlobalAliasWithHttpInfo(id, alias)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* 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
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/BucketInfo} and HTTP response
*/
deleteBucketLocalAliasWithHttpInfo(id, accessKeyId, alias) {
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
);
}
/**
* 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
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/BucketInfo}
*/
deleteBucketLocalAlias(id, accessKeyId, alias) {
return this.deleteBucketLocalAliasWithHttpInfo(id, accessKeyId, alias)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* 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
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/BucketInfo} and HTTP response
*/
denyBucketKeyWithHttpInfo(allowBucketKeyRequest) {
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
);
}
/**
* 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
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/BucketInfo}
*/
denyBucketKey(allowBucketKeyRequest) {
return this.denyBucketKeyWithHttpInfo(allowBucketKeyRequest)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* 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 an object containing data of type {@link module:model/BucketInfo} and HTTP response
*/
findBucketInfoWithHttpInfo(alias) {
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
);
}
/**
* 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',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null
);
}
/**
* 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 data of type {@link module:model/BucketInfo}
*/
getBucketInfo(bucketId) {
return this.getBucketInfoWithHttpInfo(bucketId)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* List all buckets
* List all the buckets on the cluster with their UUID and their global and local aliases.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Array.<module:model/ListBuckets200ResponseInner>} and HTTP response
*/
listBucketsWithHttpInfo() {
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
);
}
/**
* List all buckets
* List all the buckets on the cluster with their UUID and their global and local aliases.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Array.<module:model/ListBuckets200ResponseInner>}
*/
listBuckets() {
return this.listBucketsWithHttpInfo()
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* Add a global alias
* Add a global alias to the target bucket
* @param {String} id
* @param {String} alias
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/BucketInfo} and HTTP response
*/
putBucketGlobalAliasWithHttpInfo(id, alias) {
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
);
}
/**
* Add a global alias
* Add a global alias to the target bucket
* @param {String} id
* @param {String} alias
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/BucketInfo}
*/
putBucketGlobalAlias(id, alias) {
return this.putBucketGlobalAliasWithHttpInfo(id, alias)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* 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
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/BucketInfo} and HTTP response
*/
putBucketLocalAliasWithHttpInfo(id, accessKeyId, alias) {
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
);
}
/**
* 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
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/BucketInfo}
*/
putBucketLocalAlias(id, accessKeyId, alias) {
return this.putBucketLocalAliasWithHttpInfo(id, accessKeyId, alias)
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* 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.
* @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) {
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
);
}
/**
* 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.
* @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)
.then(function(response_and_data) {
return response_and_data.data;
});
}
}