// 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 Credentials extends APIResource { /** * Creates a new credential within a credential set. * * @example * ```ts * const credential = * await client.vulnerabilityScanner.credentialSets.credentials.create( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * location: 'header', * location_name: 'Authorization', * name: 'Admin API key', * value: 'Bearer EXAMPLE_TOKEN', * }, * ); * ``` */ create( credentialSetId: string, params: CredentialCreateParams, options?: Core.RequestOptions, ): Core.APIPromise { const { account_id, ...body } = params; return ( this._client.post( `/accounts/${account_id}/vuln_scanner/credential_sets/${credentialSetId}/credentials`, { body, ...options }, ) as Core.APIPromise<{ result: CredentialCreateResponse }> )._thenUnwrap((obj) => obj.result); } /** * Replaces a credential. All fields must be provided. * * @example * ```ts * const credential = * await client.vulnerabilityScanner.credentialSets.credentials.update( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * location: 'header', * location_name: 'Authorization', * name: 'Admin API key', * value: 'Bearer EXAMPLE_TOKEN', * }, * ); * ``` */ update( credentialSetId: string, credentialId: string, params: CredentialUpdateParams, options?: Core.RequestOptions, ): Core.APIPromise { const { account_id, ...body } = params; return ( this._client.put( `/accounts/${account_id}/vuln_scanner/credential_sets/${credentialSetId}/credentials/${credentialId}`, { body, ...options }, ) as Core.APIPromise<{ result: CredentialUpdateResponse }> )._thenUnwrap((obj) => obj.result); } /** * Returns all credentials within a credential set. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const credentialListResponse of client.vulnerabilityScanner.credentialSets.credentials.list( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list( credentialSetId: string, params: CredentialListParams, options?: Core.RequestOptions, ): Core.PagePromise { const { account_id, ...query } = params; return this._client.getAPIList( `/accounts/${account_id}/vuln_scanner/credential_sets/${credentialSetId}/credentials`, CredentialListResponsesV4PagePaginationArray, { query, ...options }, ); } /** * Deletes a credential. * * @example * ```ts * const credential = * await client.vulnerabilityScanner.credentialSets.credentials.delete( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete( credentialSetId: string, credentialId: string, params: CredentialDeleteParams, options?: Core.RequestOptions, ): Core.APIPromise { const { account_id } = params; return ( this._client.delete( `/accounts/${account_id}/vuln_scanner/credential_sets/${credentialSetId}/credentials/${credentialId}`, options, ) as Core.APIPromise<{ result: CredentialDeleteResponse | null }> )._thenUnwrap((obj) => obj.result); } /** * Updates a credential with only the provided fields; omitted fields remain * unchanged. * * @example * ```ts * const response = * await client.vulnerabilityScanner.credentialSets.credentials.edit( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ edit( credentialSetId: string, credentialId: string, params: CredentialEditParams, options?: Core.RequestOptions, ): Core.APIPromise { const { account_id, ...body } = params; return ( this._client.patch( `/accounts/${account_id}/vuln_scanner/credential_sets/${credentialSetId}/credentials/${credentialId}`, { body, ...options }, ) as Core.APIPromise<{ result: CredentialEditResponse }> )._thenUnwrap((obj) => obj.result); } /** * Returns a single credential by ID. * * @example * ```ts * const credential = * await client.vulnerabilityScanner.credentialSets.credentials.get( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get( credentialSetId: string, credentialId: string, params: CredentialGetParams, options?: Core.RequestOptions, ): Core.APIPromise { const { account_id } = params; return ( this._client.get( `/accounts/${account_id}/vuln_scanner/credential_sets/${credentialSetId}/credentials/${credentialId}`, options, ) as Core.APIPromise<{ result: CredentialGetResponse }> )._thenUnwrap((obj) => obj.result); } } export class CredentialListResponsesV4PagePaginationArray extends V4PagePaginationArray {} /** * A credential attached to API requests during scanning. The credential `value` is * write-only and never returned in responses. */ export interface CredentialCreateResponse { /** * Credential identifier. */ id: string; /** * Parent credential set identifier. */ credential_set_id: string; /** * Where the credential is attached in outgoing requests. */ location: 'header' | 'cookie'; /** * Name of the header or cookie where the credential is attached. */ location_name: string; /** * Human-readable name. */ name: string; } /** * A credential attached to API requests during scanning. The credential `value` is * write-only and never returned in responses. */ export interface CredentialUpdateResponse { /** * Credential identifier. */ id: string; /** * Parent credential set identifier. */ credential_set_id: string; /** * Where the credential is attached in outgoing requests. */ location: 'header' | 'cookie'; /** * Name of the header or cookie where the credential is attached. */ location_name: string; /** * Human-readable name. */ name: string; } /** * A credential attached to API requests during scanning. The credential `value` is * write-only and never returned in responses. */ export interface CredentialListResponse { /** * Credential identifier. */ id: string; /** * Parent credential set identifier. */ credential_set_id: string; /** * Where the credential is attached in outgoing requests. */ location: 'header' | 'cookie'; /** * Name of the header or cookie where the credential is attached. */ location_name: string; /** * Human-readable name. */ name: string; } export type CredentialDeleteResponse = unknown; /** * A credential attached to API requests during scanning. The credential `value` is * write-only and never returned in responses. */ export interface CredentialEditResponse { /** * Credential identifier. */ id: string; /** * Parent credential set identifier. */ credential_set_id: string; /** * Where the credential is attached in outgoing requests. */ location: 'header' | 'cookie'; /** * Name of the header or cookie where the credential is attached. */ location_name: string; /** * Human-readable name. */ name: string; } /** * A credential attached to API requests during scanning. The credential `value` is * write-only and never returned in responses. */ export interface CredentialGetResponse { /** * Credential identifier. */ id: string; /** * Parent credential set identifier. */ credential_set_id: string; /** * Where the credential is attached in outgoing requests. */ location: 'header' | 'cookie'; /** * Name of the header or cookie where the credential is attached. */ location_name: string; /** * Human-readable name. */ name: string; } export interface CredentialCreateParams { /** * Path param: Identifier. */ account_id: string; /** * Body param: Where the credential is attached in outgoing requests. */ location: 'header' | 'cookie'; /** * Body param: Name of the header or cookie where the credential is attached. */ location_name: string; /** * Body param: Human-readable name. */ name: string; /** * Body param: The credential value (e.g. API key, session token). Write-only. * Never returned in responses. */ value: string; } export interface CredentialUpdateParams { /** * Path param: Identifier. */ account_id: string; /** * Body param: Where the credential is attached in outgoing requests. */ location: 'header' | 'cookie'; /** * Body param: Name of the header or cookie where the credential is attached. */ location_name: string; /** * Body param: Human-readable name. */ name: string; /** * Body param: The credential value. Write-only. Never returned in responses. */ value: string; } export interface CredentialListParams extends V4PagePaginationArrayParams { /** * Path param: Identifier. */ account_id: string; } export interface CredentialDeleteParams { /** * Identifier. */ account_id: string; } export interface CredentialEditParams { /** * Path param: Identifier. */ account_id: string; /** * Body param: Where the credential is attached in outgoing requests. */ location?: 'header' | 'cookie'; /** * Body param: Name of the header or cookie where the credential is attached. */ location_name?: string; /** * Body param: Human-readable name. */ name?: string; /** * Body param: The credential value. Write-only. Never returned in responses. */ value?: string; } export interface CredentialGetParams { /** * Identifier. */ account_id: string; } Credentials.CredentialListResponsesV4PagePaginationArray = CredentialListResponsesV4PagePaginationArray; export declare namespace Credentials { export { type CredentialCreateResponse as CredentialCreateResponse, type CredentialUpdateResponse as CredentialUpdateResponse, type CredentialListResponse as CredentialListResponse, type CredentialDeleteResponse as CredentialDeleteResponse, type CredentialEditResponse as CredentialEditResponse, type CredentialGetResponse as CredentialGetResponse, CredentialListResponsesV4PagePaginationArray as CredentialListResponsesV4PagePaginationArray, type CredentialCreateParams as CredentialCreateParams, type CredentialUpdateParams as CredentialUpdateParams, type CredentialListParams as CredentialListParams, type CredentialDeleteParams as CredentialDeleteParams, type CredentialEditParams as CredentialEditParams, type CredentialGetParams as CredentialGetParams, }; }