// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../resource'; import * as Core from '../../core'; import { V4PagePaginationArray, type V4PagePaginationArrayParams } from '../../pagination'; export class TargetEnvironments 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: TargetEnvironmentCreateParams, options?: Core.RequestOptions, ): Core.APIPromise { const { account_id, ...body } = params; return ( this._client.post(`/accounts/${account_id}/vuln_scanner/target_environments`, { body, ...options, }) as Core.APIPromise<{ result: TargetEnvironmentCreateResponse }> )._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: string, params: TargetEnvironmentUpdateParams, options?: Core.RequestOptions, ): Core.APIPromise { const { account_id, ...body } = params; return ( this._client.put(`/accounts/${account_id}/vuln_scanner/target_environments/${targetEnvironmentId}`, { body, ...options, }) as Core.APIPromise<{ result: TargetEnvironmentUpdateResponse }> )._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: TargetEnvironmentListParams, options?: Core.RequestOptions, ): Core.PagePromise { const { account_id, ...query } = params; return this._client.getAPIList( `/accounts/${account_id}/vuln_scanner/target_environments`, TargetEnvironmentListResponsesV4PagePaginationArray, { 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: string, params: TargetEnvironmentDeleteParams, options?: Core.RequestOptions, ): Core.APIPromise { const { account_id } = params; return ( this._client.delete( `/accounts/${account_id}/vuln_scanner/target_environments/${targetEnvironmentId}`, options, ) as Core.APIPromise<{ result: TargetEnvironmentDeleteResponse | null }> )._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: string, params: TargetEnvironmentEditParams, options?: Core.RequestOptions, ): Core.APIPromise { const { account_id, ...body } = params; return ( this._client.patch(`/accounts/${account_id}/vuln_scanner/target_environments/${targetEnvironmentId}`, { body, ...options, }) as Core.APIPromise<{ result: TargetEnvironmentEditResponse }> )._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: string, params: TargetEnvironmentGetParams, options?: Core.RequestOptions, ): Core.APIPromise { const { account_id } = params; return ( this._client.get( `/accounts/${account_id}/vuln_scanner/target_environments/${targetEnvironmentId}`, options, ) as Core.APIPromise<{ result: TargetEnvironmentGetResponse }> )._thenUnwrap((obj) => obj.result); } } export class TargetEnvironmentListResponsesV4PagePaginationArray extends V4PagePaginationArray {} export interface TargetEnvironmentCreateResponse { /** * Target environment identifier. */ id: string; /** * Human-readable name. */ name: string; /** * Identifies the Cloudflare asset to scan. Uses a `type` discriminator. Currently * the service supports only `zone` targets. */ target: TargetEnvironmentCreateResponse.Target; /** * Optional description providing additional context. */ description?: string | null; } export namespace TargetEnvironmentCreateResponse { /** * Identifies the Cloudflare asset to scan. Uses a `type` discriminator. Currently * the service supports only `zone` targets. */ export interface Target { type: 'zone'; /** * Cloudflare zone tag. The zone must belong to the account. */ zone_tag: string; } } export interface TargetEnvironmentUpdateResponse { /** * Target environment identifier. */ id: string; /** * Human-readable name. */ name: string; /** * Identifies the Cloudflare asset to scan. Uses a `type` discriminator. Currently * the service supports only `zone` targets. */ target: TargetEnvironmentUpdateResponse.Target; /** * Optional description providing additional context. */ description?: string | null; } export namespace TargetEnvironmentUpdateResponse { /** * Identifies the Cloudflare asset to scan. Uses a `type` discriminator. Currently * the service supports only `zone` targets. */ export interface Target { type: 'zone'; /** * Cloudflare zone tag. The zone must belong to the account. */ zone_tag: string; } } export interface TargetEnvironmentListResponse { /** * Target environment identifier. */ id: string; /** * Human-readable name. */ name: string; /** * Identifies the Cloudflare asset to scan. Uses a `type` discriminator. Currently * the service supports only `zone` targets. */ target: TargetEnvironmentListResponse.Target; /** * Optional description providing additional context. */ description?: string | null; } export namespace TargetEnvironmentListResponse { /** * Identifies the Cloudflare asset to scan. Uses a `type` discriminator. Currently * the service supports only `zone` targets. */ export interface Target { type: 'zone'; /** * Cloudflare zone tag. The zone must belong to the account. */ zone_tag: string; } } export type TargetEnvironmentDeleteResponse = unknown; export interface TargetEnvironmentEditResponse { /** * Target environment identifier. */ id: string; /** * Human-readable name. */ name: string; /** * Identifies the Cloudflare asset to scan. Uses a `type` discriminator. Currently * the service supports only `zone` targets. */ target: TargetEnvironmentEditResponse.Target; /** * Optional description providing additional context. */ description?: string | null; } export namespace TargetEnvironmentEditResponse { /** * Identifies the Cloudflare asset to scan. Uses a `type` discriminator. Currently * the service supports only `zone` targets. */ export interface Target { type: 'zone'; /** * Cloudflare zone tag. The zone must belong to the account. */ zone_tag: string; } } export interface TargetEnvironmentGetResponse { /** * Target environment identifier. */ id: string; /** * Human-readable name. */ name: string; /** * Identifies the Cloudflare asset to scan. Uses a `type` discriminator. Currently * the service supports only `zone` targets. */ target: TargetEnvironmentGetResponse.Target; /** * Optional description providing additional context. */ description?: string | null; } export namespace TargetEnvironmentGetResponse { /** * Identifies the Cloudflare asset to scan. Uses a `type` discriminator. Currently * the service supports only `zone` targets. */ export interface Target { type: 'zone'; /** * Cloudflare zone tag. The zone must belong to the account. */ zone_tag: string; } } export interface TargetEnvironmentCreateParams { /** * Path param: Identifier. */ account_id: string; /** * Body param: Human-readable name. */ name: string; /** * Body param: Identifies the Cloudflare asset to scan. Uses a `type` * discriminator. Currently the service supports only `zone` targets. */ target: TargetEnvironmentCreateParams.Target; /** * Body param: Optional description. */ description?: string | null; } export namespace TargetEnvironmentCreateParams { /** * Identifies the Cloudflare asset to scan. Uses a `type` discriminator. Currently * the service supports only `zone` targets. */ export interface Target { type: 'zone'; /** * Cloudflare zone tag. The zone must belong to the account. */ zone_tag: string; } } export interface TargetEnvironmentUpdateParams { /** * Path param: Identifier. */ account_id: string; /** * Body param: Human-readable name. */ name: string; /** * Body param: Identifies the Cloudflare asset to scan. Uses a `type` * discriminator. Currently the service supports only `zone` targets. */ target: TargetEnvironmentUpdateParams.Target; /** * Body param: Optional description. */ description?: string | null; } export namespace TargetEnvironmentUpdateParams { /** * Identifies the Cloudflare asset to scan. Uses a `type` discriminator. Currently * the service supports only `zone` targets. */ export interface Target { type: 'zone'; /** * Cloudflare zone tag. The zone must belong to the account. */ zone_tag: string; } } export interface TargetEnvironmentListParams extends V4PagePaginationArrayParams { /** * Path param: Identifier. */ account_id: string; } export interface TargetEnvironmentDeleteParams { /** * Identifier. */ account_id: string; } export interface TargetEnvironmentEditParams { /** * Path param: Identifier. */ account_id: string; /** * Body param: Optional description. Omit to leave unchanged, set to `null` to * clear, or provide a string to update. */ description?: string | null; /** * Body param: Human-readable name. */ name?: string; /** * Body param: Identifies the Cloudflare asset to scan. Uses a `type` * discriminator. Currently the service supports only `zone` targets. */ target?: TargetEnvironmentEditParams.Target; } export namespace TargetEnvironmentEditParams { /** * Identifies the Cloudflare asset to scan. Uses a `type` discriminator. Currently * the service supports only `zone` targets. */ export interface Target { type: 'zone'; /** * Cloudflare zone tag. The zone must belong to the account. */ zone_tag: string; } } export interface TargetEnvironmentGetParams { /** * Identifier. */ account_id: string; } TargetEnvironments.TargetEnvironmentListResponsesV4PagePaginationArray = TargetEnvironmentListResponsesV4PagePaginationArray; export declare namespace TargetEnvironments { export { type TargetEnvironmentCreateResponse as TargetEnvironmentCreateResponse, type TargetEnvironmentUpdateResponse as TargetEnvironmentUpdateResponse, type TargetEnvironmentListResponse as TargetEnvironmentListResponse, type TargetEnvironmentDeleteResponse as TargetEnvironmentDeleteResponse, type TargetEnvironmentEditResponse as TargetEnvironmentEditResponse, type TargetEnvironmentGetResponse as TargetEnvironmentGetResponse, TargetEnvironmentListResponsesV4PagePaginationArray as TargetEnvironmentListResponsesV4PagePaginationArray, type TargetEnvironmentCreateParams as TargetEnvironmentCreateParams, type TargetEnvironmentUpdateParams as TargetEnvironmentUpdateParams, type TargetEnvironmentListParams as TargetEnvironmentListParams, type TargetEnvironmentDeleteParams as TargetEnvironmentDeleteParams, type TargetEnvironmentEditParams as TargetEnvironmentEditParams, type TargetEnvironmentGetParams as TargetEnvironmentGetParams, }; }