cloudflare
Version:
The official TypeScript library for the Cloudflare API
98 lines • 3.65 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import * as SecretsAPI from "./secrets.mjs";
import { BaseSecrets, Secrets, } from "./secrets.mjs";
import { V4PagePaginationArray, } from "../../../core/pagination.mjs";
import { path } from "../../../internal/utils/path.mjs";
export var BaseStores = /* @__PURE__ */ (() => {
class BaseStores extends APIResource {
/**
* Creates a store in the account.
*
* @example
* ```ts
* const store = await client.secretsStore.stores.create({
* account_id: '985e105f4ecef8ad9ca31a8372d0c353',
* name: 'service_x_keys',
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post(path `/accounts/${account_id}/secrets_store/stores`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Lists all the stores in an account.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const storeListResponse of client.secretsStore.stores.list(
* { account_id: '985e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList(path `/accounts/${account_id}/secrets_store/stores`, (V4PagePaginationArray), { query, ...options });
}
/**
* Deletes a single store. By default, a store that still contains secrets cannot
* be deleted and returns HTTP 409 (Conflict) with the "store_not_empty" error.
* Pass `force=true` to cascade-delete all secrets in the store. Empty stores are
* always deleted regardless of the force parameter.
*
* @example
* ```ts
* const store = await client.secretsStore.stores.delete(
* '023e105f4ecef8ad9ca31a8372d0c353',
* { account_id: '985e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(storeID, params, options) {
const { account_id, force } = params;
return this._client.delete(path `/accounts/${account_id}/secrets_store/stores/${storeID}`, {
query: { force },
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Returns details of a single store.
*
* @example
* ```ts
* const store = await client.secretsStore.stores.get(
* '023e105f4ecef8ad9ca31a8372d0c353',
* { account_id: '985e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(storeID, params, options) {
const { account_id } = params;
return this._client.get(path `/accounts/${account_id}/secrets_store/stores/${storeID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseStores._key = Object.freeze([
'secretsStore',
'stores',
]);
return BaseStores;
})();
export var Stores = /* @__PURE__ */ (() => {
class Stores extends BaseStores {
constructor() {
super(...arguments);
this.secrets = new SecretsAPI.Secrets(this._client);
}
}
Stores.Secrets = Secrets;
Stores.BaseSecrets = BaseSecrets;
return Stores;
})();
//# sourceMappingURL=stores.mjs.map