cloudflare
Version:
The official TypeScript library for the Cloudflare API
64 lines • 2.87 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from 'cloudflare/resource';
import * as NamespacesAPI from 'cloudflare/resources/kv/namespaces/namespaces';
import * as BulkAPI from 'cloudflare/resources/kv/namespaces/bulk';
import * as KeysAPI from 'cloudflare/resources/kv/namespaces/keys';
import * as MetadataAPI from 'cloudflare/resources/kv/namespaces/metadata';
import * as ValuesAPI from 'cloudflare/resources/kv/namespaces/values';
import { V4PagePaginationArray } from 'cloudflare/pagination';
export class Namespaces extends APIResource {
constructor() {
super(...arguments);
this.bulk = new BulkAPI.Bulk(this._client);
this.keys = new KeysAPI.Keys(this._client);
this.metadata = new MetadataAPI.Metadata(this._client);
this.values = new ValuesAPI.Values(this._client);
}
/**
* Creates a namespace under the given title. A `400` is returned if the account
* already owns a namespace with this title. A namespace must be explicitly deleted
* to be replaced.
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post(`/accounts/${account_id}/storage/kv/namespaces`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Modifies a namespace's title.
*/
update(namespaceId, params, options) {
const { account_id, ...body } = params;
return this._client.put(`/accounts/${account_id}/storage/kv/namespaces/${namespaceId}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Returns the namespaces owned by an account.
*/
list(params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList(`/accounts/${account_id}/storage/kv/namespaces`, WorkersKVNamespacesV4PagePaginationArray, { query, ...options });
}
/**
* Deletes the namespace corresponding to the given ID.
*/
delete(namespaceId, params, options) {
const { account_id } = params;
return this._client.delete(`/accounts/${account_id}/storage/kv/namespaces/${namespaceId}`, options)._thenUnwrap((obj) => obj.result);
}
}
export class WorkersKVNamespacesV4PagePaginationArray extends V4PagePaginationArray {
}
(function (Namespaces) {
Namespaces.WorkersKVNamespacesV4PagePaginationArray = NamespacesAPI.WorkersKVNamespacesV4PagePaginationArray;
Namespaces.Bulk = BulkAPI.Bulk;
Namespaces.Keys = KeysAPI.Keys;
Namespaces.WorkersKVKeysCursorLimitPagination = KeysAPI.WorkersKVKeysCursorLimitPagination;
Namespaces.Metadata = MetadataAPI.Metadata;
Namespaces.Values = ValuesAPI.Values;
})(Namespaces || (Namespaces = {}));
//# sourceMappingURL=namespaces.mjs.map