cloudflare
Version:
The official TypeScript library for the Cloudflare API
135 lines • 5.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TargetEnvironments = exports.BaseTargetEnvironments = 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 BaseTargetEnvironments = /* @__PURE__ */ (() => {
class BaseTargetEnvironments extends resource_1.APIResource {
/**
* Creates a new target environment for the account.
*
* @example
* ```ts
* const targetEnvironment =
* await client.vulnerabilityScanner.targetEnvironments.create(
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* name: 'Production Zone',
* target: {
* type: 'zone',
* zone_tag: 'd8e8fca2dc0f896fd7cb4cb0031ba249',
* },
* },
* );
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/vuln_scanner/target_environments`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Replaces a target environment. All fields must be provided.
*
* @example
* ```ts
* const targetEnvironment =
* await client.vulnerabilityScanner.targetEnvironments.update(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* name: 'Production Zone',
* target: {
* type: 'zone',
* zone_tag: 'd8e8fca2dc0f896fd7cb4cb0031ba249',
* },
* },
* );
* ```
*/
update(targetEnvironmentID, params, options) {
const { account_id, ...body } = params;
return this._client.put((0, path_1.path) `/accounts/${account_id}/vuln_scanner/target_environments/${targetEnvironmentID}`, { body, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Returns all target environments for the account.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const targetEnvironmentListResponse of client.vulnerabilityScanner.targetEnvironments.list(
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/vuln_scanner/target_environments`, (pagination_1.V4PagePaginationArray), { query, ...options });
}
/**
* Removes a target environment.
*
* @example
* ```ts
* const targetEnvironment =
* await client.vulnerabilityScanner.targetEnvironments.delete(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(targetEnvironmentID, params, options) {
const { account_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/vuln_scanner/target_environments/${targetEnvironmentID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Updates a target environment with only the provided fields; omitted fields
* remain unchanged.
*
* @example
* ```ts
* const response =
* await client.vulnerabilityScanner.targetEnvironments.edit(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
edit(targetEnvironmentID, params, options) {
const { account_id, ...body } = params;
return this._client.patch((0, path_1.path) `/accounts/${account_id}/vuln_scanner/target_environments/${targetEnvironmentID}`, { body, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Returns a single target environment by ID.
*
* @example
* ```ts
* const targetEnvironment =
* await client.vulnerabilityScanner.targetEnvironments.get(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(targetEnvironmentID, params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/vuln_scanner/target_environments/${targetEnvironmentID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseTargetEnvironments._key = Object.freeze([
'vulnerabilityScanner',
'targetEnvironments',
]);
return BaseTargetEnvironments;
})();
exports.BaseTargetEnvironments = BaseTargetEnvironments;
class TargetEnvironments extends BaseTargetEnvironments {
}
exports.TargetEnvironments = TargetEnvironments;
//# sourceMappingURL=target-environments.js.map