cloudflare
Version:
The official TypeScript library for the Cloudflare API
142 lines • 5.78 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.OAuthClients = exports.BaseOAuthClients = 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 BaseOAuthClients = /* @__PURE__ */ (() => {
class BaseOAuthClients extends resource_1.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((0, path_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/oauth_clients`, (pagination_1.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((0, path_1.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((0, path_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/oauth_clients/${oauthClientID}/rotate_secret`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseOAuthClients._key = Object.freeze([
'iam',
'oauthClients',
]);
return BaseOAuthClients;
})();
exports.BaseOAuthClients = BaseOAuthClients;
class OAuthClients extends BaseOAuthClients {
}
exports.OAuthClients = OAuthClients;
//# sourceMappingURL=oauth-clients.js.map