UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

137 lines • 5.47 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import { SinglePage } from "../../core/pagination.mjs"; import { path } from "../../internal/utils/path.mjs"; export var BaseOAuthClients = /* @__PURE__ */ (() => { class BaseOAuthClients extends APIResource { /** * Create a new OAuth client for an account. * * @example * ```ts * const oauthClient = await client.iam.oauthClients.create({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * client_name: 'My OAuth App', * grant_types: ['authorization_code', 'refresh_token'], * redirect_uris: ['https://example.com/callback'], * response_types: ['code'], * scopes: ['account.read'], * token_endpoint_auth_method: 'client_secret_post', * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/oauth_clients`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * Update an existing OAuth client. Only include fields you want to update. * * @example * ```ts * const oauthClient = await client.iam.oauthClients.update( * 'a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ update(oauthClientID, params, options) { const { account_id, ...body } = params; return this._client.patch(path `/accounts/${account_id}/oauth_clients/${oauthClientID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * List all OAuth clients for an account. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const oauthClientListResponse of client.iam.oauthClients.list( * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id } = params; return this._client.getAPIList(path `/accounts/${account_id}/oauth_clients`, (SinglePage), options); } /** * Delete an OAuth client. * * @example * ```ts * const oauthClient = await client.iam.oauthClients.delete( * 'a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(oauthClientID, params, options) { const { account_id } = params; return this._client.delete(path `/accounts/${account_id}/oauth_clients/${oauthClientID}`, options)._thenUnwrap((obj) => obj.result); } /** * Removes the old client secret after a rotation, keeping only the new one. Use * this after you have updated your client configuration to use the new secret. The * `has_rotated_secret` field on the client indicates whether there is an old * secret to delete. * * @example * ```ts * const response = * await client.iam.oauthClients.deleteRotatedSecret( * 'a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ deleteRotatedSecret(oauthClientID, params, options) { const { account_id } = params; return this._client.delete(path `/accounts/${account_id}/oauth_clients/${oauthClientID}/rotate_secret`, options)._thenUnwrap((obj) => obj.result); } /** * Get details of a specific OAuth client. * * @example * ```ts * const oauthClient = await client.iam.oauthClients.get( * 'a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(oauthClientID, params, options) { const { account_id } = params; return this._client.get(path `/accounts/${account_id}/oauth_clients/${oauthClientID}`, options)._thenUnwrap((obj) => obj.result); } /** * Creates a second client secret so you can update your client configuration * before deleting the old one. The `has_rotated_secret` field on the client will * be set to `true`. * * @example * ```ts * const response = await client.iam.oauthClients.rotateSecret( * 'a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ rotateSecret(oauthClientID, params, options) { const { account_id } = params; return this._client.post(path `/accounts/${account_id}/oauth_clients/${oauthClientID}/rotate_secret`, options)._thenUnwrap((obj) => obj.result); } } BaseOAuthClients._key = Object.freeze([ 'iam', 'oauthClients', ]); return BaseOAuthClients; })(); export class OAuthClients extends BaseOAuthClients { } //# sourceMappingURL=oauth-clients.mjs.map