cloudflare
Version:
The official TypeScript library for the Cloudflare API
104 lines • 3.96 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Stores = exports.BaseStores = void 0;
const tslib_1 = require("../../../internal/tslib.js");
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../../core/resource.js");
const SecretsAPI = tslib_1.__importStar(require("./secrets.js"));
const secrets_1 = require("./secrets.js");
const pagination_1 = require("../../../core/pagination.js");
const path_1 = require("../../../internal/utils/path.js");
var BaseStores = /* @__PURE__ */ (() => {
class BaseStores extends resource_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/secrets_store/stores`, (pagination_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/secrets_store/stores/${storeID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseStores._key = Object.freeze([
'secretsStore',
'stores',
]);
return BaseStores;
})();
exports.BaseStores = BaseStores;
var Stores = /* @__PURE__ */ (() => {
class Stores extends BaseStores {
constructor() {
super(...arguments);
this.secrets = new SecretsAPI.Secrets(this._client);
}
}
Stores.Secrets = secrets_1.Secrets;
Stores.BaseSecrets = secrets_1.BaseSecrets;
return Stores;
})();
exports.Stores = Stores;
//# sourceMappingURL=stores.js.map