cloudflare
Version:
The official TypeScript library for the Cloudflare API
130 lines • 5.18 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../core/resource.mjs";
import { V4PagePaginationArray } from "../../core/pagination.mjs";
import { path } from "../../internal/utils/path.mjs";
export var BaseTargetEnvironments = /* @__PURE__ */ (() => {
class BaseTargetEnvironments extends 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(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(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(path `/accounts/${account_id}/vuln_scanner/target_environments`, (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(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(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(path `/accounts/${account_id}/vuln_scanner/target_environments/${targetEnvironmentID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseTargetEnvironments._key = Object.freeze([
'vulnerabilityScanner',
'targetEnvironments',
]);
return BaseTargetEnvironments;
})();
export class TargetEnvironments extends BaseTargetEnvironments {
}
//# sourceMappingURL=target-environments.mjs.map