UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

175 lines • 6.52 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Secrets = exports.BaseSecrets = void 0; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../../core/resource.js"); const pagination_1 = require("../../../core/pagination.js"); const path_1 = require("../../../internal/utils/path.js"); var BaseSecrets = /* @__PURE__ */ (() => { class BaseSecrets extends resource_1.APIResource { /** * Creates a secret in the account. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const secretCreateResponse of client.secretsStore.stores.secrets.create( * '023e105f4ecef8ad9ca31a8372d0c353', * { * account_id: '985e105f4ecef8ad9ca31a8372d0c353', * body: [ * { * name: 'MY_API_KEY', * scopes: [ * 'workers', * 'ai_gateway', * 'dex', * 'access', * 'websearch', * ], * value: 'api-token-secret-123', * }, * ], * }, * )) { * // ... * } * ``` */ create(storeID, params, options) { const { account_id, body } = params; return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/secrets_store/stores/${storeID}/secrets`, (pagination_1.SinglePage), { body: body, method: 'post', ...options }); } /** * Lists all store secrets. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const secretListResponse of client.secretsStore.stores.secrets.list( * '023e105f4ecef8ad9ca31a8372d0c353', * { account_id: '985e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(storeID, params, options) { const { account_id, ...query } = params; return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/secrets_store/stores/${storeID}/secrets`, (pagination_1.V4PagePaginationArray), { query, ...options }); } /** * Deletes a single secret. * * @example * ```ts * const secret = * await client.secretsStore.stores.secrets.delete( * '3fd85f74b32742f1bff64a85009dda07', * { * account_id: '985e105f4ecef8ad9ca31a8372d0c353', * store_id: '023e105f4ecef8ad9ca31a8372d0c353', * }, * ); * ``` */ delete(secretID, params, options) { const { account_id, store_id } = params; return this._client.delete((0, path_1.path) `/accounts/${account_id}/secrets_store/stores/${store_id}/secrets/${secretID}`, options)._thenUnwrap((obj) => obj.result); } /** * Deletes one or more secrets. * * @example * ```ts * const response = * await client.secretsStore.stores.secrets.bulkDelete( * '023e105f4ecef8ad9ca31a8372d0c353', * { account_id: '985e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ bulkDelete(storeID, params, options) { const { account_id } = params; return this._client.delete((0, path_1.path) `/accounts/${account_id}/secrets_store/stores/${storeID}/secrets`, options)._thenUnwrap((obj) => obj.result); } /** * Creates a duplicate of the secret, keeping the value. * * @example * ```ts * const response = * await client.secretsStore.stores.secrets.duplicate( * '3fd85f74b32742f1bff64a85009dda07', * { * account_id: '985e105f4ecef8ad9ca31a8372d0c353', * store_id: '023e105f4ecef8ad9ca31a8372d0c353', * name: 'MY_API_KEY', * scopes: [ * 'workers', * 'ai_gateway', * 'dex', * 'access', * 'websearch', * ], * }, * ); * ``` */ duplicate(secretID, params, options) { const { account_id, store_id, ...body } = params; return this._client.post((0, path_1.path) `/accounts/${account_id}/secrets_store/stores/${store_id}/secrets/${secretID}/duplicate`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * Updates a single secret. * * @example * ```ts * const response = * await client.secretsStore.stores.secrets.edit( * '3fd85f74b32742f1bff64a85009dda07', * { * account_id: '985e105f4ecef8ad9ca31a8372d0c353', * store_id: '023e105f4ecef8ad9ca31a8372d0c353', * }, * ); * ``` */ edit(secretID, params, options) { const { account_id, store_id, ...body } = params; return this._client.patch((0, path_1.path) `/accounts/${account_id}/secrets_store/stores/${store_id}/secrets/${secretID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Returns details of a single secret. * * @example * ```ts * const secret = await client.secretsStore.stores.secrets.get( * '3fd85f74b32742f1bff64a85009dda07', * { * account_id: '985e105f4ecef8ad9ca31a8372d0c353', * store_id: '023e105f4ecef8ad9ca31a8372d0c353', * }, * ); * ``` */ get(secretID, params, options) { const { account_id, store_id } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/secrets_store/stores/${store_id}/secrets/${secretID}`, options)._thenUnwrap((obj) => obj.result); } } BaseSecrets._key = Object.freeze([ 'secretsStore', 'stores', 'secrets', ]); return BaseSecrets; })(); exports.BaseSecrets = BaseSecrets; class Secrets extends BaseSecrets { } exports.Secrets = Secrets; //# sourceMappingURL=secrets.js.map