cloudflare
Version:
The official TypeScript library for the Cloudflare API
152 lines • 6.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Integrations = exports.BaseIntegrations = 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 headers_1 = require("../../../internal/headers.js");
const path_1 = require("../../../internal/utils/path.js");
var BaseIntegrations = /* @__PURE__ */ (() => {
class BaseIntegrations extends resource_1.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((0, path_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/one/integrations`, (pagination_1.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((0, path_1.path) `/accounts/${account_id}/one/integrations/${id}`, {
...options,
headers: (0, headers_1.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((0, path_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/one/integrations/${id}/resume`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseIntegrations._key = Object.freeze([
'zeroTrust',
'casb',
'integrations',
]);
return BaseIntegrations;
})();
exports.BaseIntegrations = BaseIntegrations;
class Integrations extends BaseIntegrations {
}
exports.Integrations = Integrations;
//# sourceMappingURL=integrations.js.map