cloudflare
Version:
The official TypeScript library for the Cloudflare API
147 lines • 5.68 kB
JavaScript
// 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 { buildHeaders } from "../../../internal/headers.mjs";
import { path } from "../../../internal/utils/path.mjs";
export var BaseIntegrations = /* @__PURE__ */ (() => {
class BaseIntegrations extends APIResource {
/**
* Creates a new integration for the specified application. Integration creation
* with OAuth is not supported by API at the moment. For other auth methods, use
* `GET /v2/applications/{application_id}/credential-guide` to see the required
* credential structure and example payloads for each vendor.
*
* @example
* ```ts
* const integration =
* await client.zeroTrust.casb.integrations.create({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* application: 'GOOGLE_WORKSPACE',
* credentials: { admin_email: 'admin@corp.com' },
* name: 'My Google Workspace',
* auth_method: 'service_account',
* dlp_profiles: ['e91a2360-da51-4fdf-9711-bcdecd462614'],
* permissions: [
* 'https://www.googleapis.com/auth/drive.readonly',
* ],
* use_cases: ['casb', 'ces'],
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post(path `/accounts/${account_id}/one/integrations`, { body, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Updates an integration's name, permissions, DLP profiles, use cases, or
* credentials.
*
* @example
* ```ts
* const integration =
* await client.zeroTrust.casb.integrations.update('id', {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* credentials: {
* access_token: 'new_access_token',
* refresh_token: 'new_refresh_token',
* },
* });
* ```
*/
update(id, params, options) {
const { account_id, ...body } = params;
return this._client.patch(path `/accounts/${account_id}/one/integrations/${id}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Returns a paginated list of integrations for the account.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const integrationListResponse of client.zeroTrust.casb.integrations.list(
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList(path `/accounts/${account_id}/one/integrations`, (SinglePage), { query, ...options });
}
/**
* Delete an integration by soft-deleting it.
*
* @example
* ```ts
* await client.zeroTrust.casb.integrations.delete('id', {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
delete(id, params, options) {
const { account_id } = params;
return this._client.delete(path `/accounts/${account_id}/one/integrations/${id}`, {
...options,
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
});
}
/**
* Returns full integration details including use cases and permissions.
*
* @example
* ```ts
* const integration =
* await client.zeroTrust.casb.integrations.get('id', {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
get(id, params, options) {
const { account_id } = params;
return this._client.get(path `/accounts/${account_id}/one/integrations/${id}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Pauses an integration, stopping all crawlers.
*
* @example
* ```ts
* const response =
* await client.zeroTrust.casb.integrations.pause('id', {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
pause(id, params, options) {
const { account_id } = params;
return this._client.post(path `/accounts/${account_id}/one/integrations/${id}/pause`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Resumes a paused integration, restarting crawlers.
*
* @example
* ```ts
* const response =
* await client.zeroTrust.casb.integrations.resume('id', {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
resume(id, params, options) {
const { account_id } = params;
return this._client.post(path `/accounts/${account_id}/one/integrations/${id}/resume`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseIntegrations._key = Object.freeze([
'zeroTrust',
'casb',
'integrations',
]);
return BaseIntegrations;
})();
export class Integrations extends BaseIntegrations {
}
//# sourceMappingURL=integrations.mjs.map