Constructor Summary
Public Constructor | ||
public |
constructor(client: KintoClient, name: String, options: Object) Constructor. |
Member Summary
Public Members | ||
public |
name: String The bucket name. |
Private Members | ||
private |
_retry: * |
|
private |
_safe: * |
Method Summary
Public Methods | ||
public |
async addPermissions(permissions: Object, options: Object): Promise<Object, Error> Append principals to the bucket permissions. |
|
public |
async batch(fn: Function, options: Object): Promise<Object, Error> Performs batch operations at the current bucket level. |
|
public |
collection(name: String, options: Object): Collection Selects a collection. |
|
public |
async createCollection(id: String | undefined, options: Object): Promise<Object, Error> Creates a new collection in current bucket. |
|
public |
async createGroup(id: String | undefined, members: Array<String>, options: Object): Promise<Object, Error> Creates a new group in current bucket. |
|
public |
async deleteCollection(collection: Object | String, options: Object): Promise<Object, Error> Deletes a collection from the current bucket. |
|
public |
async deleteGroup(group: Object | String, options: Object): Promise<Object, Error> Deletes a group from the current bucket. |
|
public |
async getData(options: Object): Promise<Object, Error> Retrieves bucket data. |
|
public |
async getGroup(id: String, options: Object): Promise<Object, Error> Creates a new group in current bucket. |
|
public |
async getPermissions(options: Object): Promise<Object, Error> Retrieves the list of permissions for this bucket. |
|
public |
async listCollections(options: Object): Promise<Array<Object>, Error> Retrieves the list of collections in the current bucket. |
|
public |
async listGroups(options: Object): Promise<Array<Object>, Error> Retrieves the list of groups in the current bucket. |
|
public |
async listHistory(options: Object): Promise<Array<Object>, Error> Retrieves the list of history entries in the current bucket. |
|
public |
async removePermissions(permissions: Object, options: Object): Promise<Object, Error> Remove principals from the bucket permissions. |
|
public |
async setData(data: Object, options: Object): Promise<Object, Error> Set bucket data. |
|
public |
async setPermissions(permissions: Object, options: Object): Promise<Object, Error> Replaces all existing bucket permissions with the ones provided. |
|
public |
async updateGroup(group: Object, options: Object): Promise<Object, Error> Updates an existing group in current bucket. |
Private Methods | ||
private |
_getHeaders(options: *): {...undefined: Object} Get the value of "headers" for a given request, merging the per-request headers with our own "default" headers. |
|
private |
_getRetry(options: *): * As _getSafe, but for "retry". |
|
private |
_getSafe(options: Object): Boolean Get the value of "safe" for a given request, using the per-request option if present or falling back to our default otherwise. |
Public Constructors
public constructor(client: KintoClient, name: String, options: Object) source
Constructor.
Params:
Name | Type | Attribute | Description |
client | KintoClient | The client instance. |
|
name | String | The bucket name. |
|
options | Object |
|
The headers object option. |
options.headers | Object |
|
The headers object option. |
options.safe | Boolean |
|
The safe option. |
options.retry | Number |
|
The retry option. |
Public Methods
public async addPermissions(permissions: Object, options: Object): Promise<Object, Error> source
Append principals to the bucket permissions.
Params:
Name | Type | Attribute | Description |
permissions | Object | The permissions object. |
|
options | Object |
|
The options object |
options.safe | Boolean |
|
The safe option. |
options.headers | Object |
|
The headers object option. |
options.retry | Number |
|
Number of retries to make when faced with transient errors. |
options.last_modified | Object |
|
The last_modified option. |
Return:
Promise<Object, Error> |
Test:
public async batch(fn: Function, options: Object): Promise<Object, Error> source
Performs batch operations at the current bucket level.
Params:
Name | Type | Attribute | Description |
fn | Function | The batch operation function. |
|
options | Object |
|
The options object. |
options.headers | Object |
|
The headers object option. |
options.safe | Boolean |
|
The safe option. |
options.retry | Number |
|
The retry option. |
options.aggregate | Boolean |
|
Produces a grouped result object. |
Return:
Promise<Object, Error> |
Test:
public collection(name: String, options: Object): Collection source
Selects a collection.
Params:
Name | Type | Attribute | Description |
name | String | The collection name. |
|
options | Object |
|
The options object. |
options.headers | Object |
|
The headers object option. |
options.safe | Boolean |
|
The safe option. |
Test:
public async createCollection(id: String | undefined, options: Object): Promise<Object, Error> source
Creates a new collection in current bucket.
Params:
Name | Type | Attribute | Description |
id | String | undefined | The collection id. |
|
options | Object |
|
The options object. |
options.safe | Boolean |
|
The safe option. |
options.headers | Object |
|
The headers object option. |
options.retry | Number |
|
Number of retries to make when faced with transient errors. |
options.permissions | Object |
|
The permissions object. |
options.data | Object |
|
The data object. |
Return:
Promise<Object, Error> |
public async createGroup(id: String | undefined, members: Array<String>, options: Object): Promise<Object, Error> source
Creates a new group in current bucket.
Params:
Name | Type | Attribute | Description |
id | String | undefined | The group id. |
|
members | Array<String> |
|
The list of principals. |
options | Object |
|
The options object. |
options.data | Object |
|
The data object. |
options.permissions | Object |
|
The permissions object. |
options.safe | Boolean |
|
The safe option. |
options.headers | Object |
|
The headers object option. |
options.retry | Number |
|
Number of retries to make when faced with transient errors. |
Return:
Promise<Object, Error> |
Test:
public async deleteCollection(collection: Object | String, options: Object): Promise<Object, Error> source
Deletes a collection from the current bucket.
Params:
Name | Type | Attribute | Description |
collection | Object | String | The collection to delete. |
|
options | Object |
|
The options object. |
options.headers | Object |
|
The headers object option. |
options.retry | Number |
|
Number of retries to make when faced with transient errors. |
options.safe | Boolean |
|
The safe option. |
options.last_modified | Number |
|
The last_modified option. |
Return:
Promise<Object, Error> |
Test:
public async deleteGroup(group: Object | String, options: Object): Promise<Object, Error> source
Deletes a group from the current bucket.
Params:
Name | Type | Attribute | Description |
group | Object | String | The group to delete. |
|
options | Object |
|
The options object. |
options.headers | Object |
|
The headers object option. |
options.retry | Number |
|
Number of retries to make when faced with transient errors. |
options.safe | Boolean |
|
The safe option. |
options.last_modified | Number |
|
The last_modified option. |
Return:
Promise<Object, Error> |
public async getData(options: Object): Promise<Object, Error> source
Retrieves bucket data.
Params:
Name | Type | Attribute | Description |
options | Object |
|
The options object. |
options.headers | Object |
|
The headers object option. |
options.retry | Number |
|
Number of retries to make when faced with transient errors. |
Return:
Promise<Object, Error> |
Test:
public async getGroup(id: String, options: Object): Promise<Object, Error> source
Creates a new group in current bucket.
Params:
Name | Type | Attribute | Description |
id | String | The group id. |
|
options | Object |
|
The options object. |
options.headers | Object |
|
The headers object option. |
options.retry | Number |
|
Number of retries to make when faced with transient errors. |
Return:
Promise<Object, Error> |
Test:
public async getPermissions(options: Object): Promise<Object, Error> source
Retrieves the list of permissions for this bucket.
Params:
Name | Type | Attribute | Description |
options | Object |
|
The options object. |
options.headers | Object |
|
The headers object option. |
options.retry | Number |
|
Number of retries to make when faced with transient errors. |
Return:
Promise<Object, Error> |
Test:
public async listCollections(options: Object): Promise<Array<Object>, Error> source
Retrieves the list of collections in the current bucket.
Params:
Name | Type | Attribute | Description |
options | Object |
|
The options object. |
options.headers | Object |
|
The headers object option. |
options.retry | Number |
|
Number of retries to make when faced with transient errors. |
Return:
Promise<Array<Object>, Error> |
public async listGroups(options: Object): Promise<Array<Object>, Error> source
Retrieves the list of groups in the current bucket.
Params:
Name | Type | Attribute | Description |
options | Object |
|
The options object. |
options.headers | Object |
|
The headers object option. |
options.retry | Number |
|
Number of retries to make when faced with transient errors. |
Return:
Promise<Array<Object>, Error> |
Test:
public async listHistory(options: Object): Promise<Array<Object>, Error> source
Retrieves the list of history entries in the current bucket.
Params:
Name | Type | Attribute | Description |
options | Object |
|
The options object. |
options.headers | Object |
|
The headers object option. |
options.retry | Number |
|
Number of retries to make when faced with transient errors. |
Return:
Promise<Array<Object>, Error> |
Decorators:
- capable(["history"])
public async removePermissions(permissions: Object, options: Object): Promise<Object, Error> source
Remove principals from the bucket permissions.
Params:
Name | Type | Attribute | Description |
permissions | Object | The permissions object. |
|
options | Object |
|
The options object |
options.safe | Boolean |
|
The safe option. |
options.headers | Object |
|
The headers object option. |
options.retry | Number |
|
Number of retries to make when faced with transient errors. |
options.last_modified | Object |
|
The last_modified option. |
Return:
Promise<Object, Error> |
public async setData(data: Object, options: Object): Promise<Object, Error> source
Set bucket data.
Params:
Name | Type | Attribute | Description |
data | Object | The bucket data object. |
|
options | Object |
|
The options object. |
options.headers | Object |
|
The headers object option. |
options.safe | Boolean |
|
The safe option. |
options.retry | Number |
|
Number of retries to make when faced with transient errors. |
options.patch | Boolean |
|
The patch option. |
options.last_modified | Number |
|
The last_modified option. |
Return:
Promise<Object, Error> |
public async setPermissions(permissions: Object, options: Object): Promise<Object, Error> source
Replaces all existing bucket permissions with the ones provided.
Params:
Name | Type | Attribute | Description |
permissions | Object | The permissions object. |
|
options | Object |
|
The options object |
options.safe | Boolean |
|
The safe option. |
options.headers | Object |
|
The headers object option. |
options.retry | Number |
|
Number of retries to make when faced with transient errors. |
options.last_modified | Object |
|
The last_modified option. |
Return:
Promise<Object, Error> |
Test:
public async updateGroup(group: Object, options: Object): Promise<Object, Error> source
Updates an existing group in current bucket.
Params:
Name | Type | Attribute | Description |
group | Object | The group object. |
|
options | Object |
|
The options object. |
options.data | Object |
|
The data object. |
options.permissions | Object |
|
The permissions object. |
options.safe | Boolean |
|
The safe option. |
options.headers | Object |
|
The headers object option. |
options.retry | Number |
|
Number of retries to make when faced with transient errors. |
options.last_modified | Number |
|
The last_modified option. |
Return:
Promise<Object, Error> |
Private Methods
private _getHeaders(options: *): {...undefined: Object} source
Get the value of "headers" for a given request, merging the per-request headers with our own "default" headers.
Params:
Name | Type | Attribute | Description |
options | * |
Return:
{...undefined: Object} |
private _getRetry(options: *): * source
As _getSafe, but for "retry".
Params:
Name | Type | Attribute | Description |
options | * |
Return:
* |
private _getSafe(options: Object): Boolean source
Get the value of "safe" for a given request, using the per-request option if present or falling back to our default otherwise.
Params:
Name | Type | Attribute | Description |
options | Object | The options for a request. |
Return:
Boolean |