UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

170 lines • 6.25 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../core/resource.mjs"; import { SinglePage, V4PagePaginationArray, } from "../../../core/pagination.mjs"; import { path } from "../../../internal/utils/path.mjs"; export var BaseSecrets = /* @__PURE__ */ (() => { class BaseSecrets extends 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(path `/accounts/${account_id}/secrets_store/stores/${storeID}/secrets`, (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(path `/accounts/${account_id}/secrets_store/stores/${storeID}/secrets`, (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(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(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(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(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(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; })(); export class Secrets extends BaseSecrets { } //# sourceMappingURL=secrets.mjs.map