// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '../../../core/resource';
import { APIPromise } from '../../../core/api-promise';
import { RequestOptions } from '../../../internal/request-options';
import { path } from '../../../internal/utils/path';

export class BaseSettings extends APIResource {
  static override readonly _key: readonly ['zeroTrust', 'dlp', 'settings'] = Object.freeze([
    'zeroTrust',
    'dlp',
    'settings',
  ] as const);

  /**
   * Missing fields are reset to initial (unconfigured) values.
   *
   * @example
   * ```ts
   * const dlpSettings =
   *   await client.zeroTrust.dlp.settings.update({
   *     account_id: 'account_id',
   *   });
   * ```
   */
  update(params: SettingUpdateParams, options?: RequestOptions): APIPromise<DLPSettings> {
    const { account_id, ...body } = params;
    return (
      this._client.put(path`/accounts/${account_id}/dlp/settings`, { body, ...options }) as APIPromise<{
        result: DLPSettings;
      }>
    )._thenUnwrap((obj) => obj.result);
  }

  /**
   * Deletes account-level DLP settings and returns the initial values.
   *
   * @example
   * ```ts
   * const dlpSettings =
   *   await client.zeroTrust.dlp.settings.delete({
   *     account_id: 'account_id',
   *   });
   * ```
   */
  delete(params: SettingDeleteParams, options?: RequestOptions): APIPromise<DLPSettings> {
    const { account_id } = params;
    return (
      this._client.delete(path`/accounts/${account_id}/dlp/settings`, options) as APIPromise<{
        result: DLPSettings;
      }>
    )._thenUnwrap((obj) => obj.result);
  }

  /**
   * Missing fields keep their existing values.
   *
   * @example
   * ```ts
   * const dlpSettings =
   *   await client.zeroTrust.dlp.settings.edit({
   *     account_id: 'account_id',
   *   });
   * ```
   */
  edit(params: SettingEditParams, options?: RequestOptions): APIPromise<DLPSettings> {
    const { account_id, ...body } = params;
    return (
      this._client.patch(path`/accounts/${account_id}/dlp/settings`, { body, ...options }) as APIPromise<{
        result: DLPSettings;
      }>
    )._thenUnwrap((obj) => obj.result);
  }

  /**
   * Gets the account-level DLP settings.
   *
   * @example
   * ```ts
   * const dlpSettings = await client.zeroTrust.dlp.settings.get(
   *   { account_id: 'account_id' },
   * );
   * ```
   */
  get(params: SettingGetParams, options?: RequestOptions): APIPromise<DLPSettings> {
    const { account_id } = params;
    return (
      this._client.get(path`/accounts/${account_id}/dlp/settings`, options) as APIPromise<{
        result: DLPSettings;
      }>
    )._thenUnwrap((obj) => obj.result);
  }
}
export class Settings extends BaseSettings {}

/**
 * DLP account-level settings response.
 */
export interface DLPSettings {
  /**
   * Whether AI context analysis is enabled at the account level.
   */
  ai_context_analysis: boolean;

  /**
   * Whether OCR is enabled at the account level.
   */
  ocr: boolean;

  payload_logging: DLPSettings.PayloadLogging;
}

export namespace DLPSettings {
  export interface PayloadLogging {
    updated_at: string;

    /**
     * Masking level for payload logs.
     *
     * - `full`: The entire payload is masked.
     * - `partial`: Only partial payload content is masked.
     * - `clear`: No masking is applied to the payload content.
     * - `default`: DLP uses its default masking behavior.
     */
    masking_level?: 'full' | 'partial' | 'clear' | 'default';

    /**
     * Base64-encoded public key for encrypting payload logs. Null when payload logging
     * is disabled.
     */
    public_key?: string | null;
  }
}

export interface SettingUpdateParams {
  /**
   * Path param
   */
  account_id: string;

  /**
   * Body param: Whether AI context analysis is enabled at the account level.
   */
  ai_context_analysis?: boolean | null;

  /**
   * Body param: Whether OCR is enabled at the account level.
   */
  ocr?: boolean | null;

  /**
   * Body param: Request model for payload log settings within the DLP settings
   * endpoint. Unlike the legacy endpoint, null and missing are treated identically
   * here (both mean "not provided" for PATCH, "reset to default" for PUT).
   */
  payload_logging?: SettingUpdateParams.PayloadLogging;
}

export namespace SettingUpdateParams {
  /**
   * Request model for payload log settings within the DLP settings endpoint. Unlike
   * the legacy endpoint, null and missing are treated identically here (both mean
   * "not provided" for PATCH, "reset to default" for PUT).
   */
  export interface PayloadLogging {
    /**
     * Masking level for payload logs.
     *
     * - `full`: The entire payload is masked.
     * - `partial`: Only partial payload content is masked.
     * - `clear`: No masking is applied to the payload content.
     * - `default`: DLP uses its default masking behavior.
     */
    masking_level?: 'full' | 'partial' | 'clear' | 'default';

    /**
     * Base64-encoded public key for encrypting payload logs.
     *
     * - Set to a non-empty base64 string to enable payload logging with the given key.
     * - Set to an empty string to disable payload logging.
     * - Omit or set to null to leave unchanged (PATCH) or reset to disabled (PUT).
     */
    public_key?: string | null;
  }
}

export interface SettingDeleteParams {
  account_id: string;
}

export interface SettingEditParams {
  /**
   * Path param
   */
  account_id: string;

  /**
   * Body param: Whether AI context analysis is enabled at the account level.
   */
  ai_context_analysis?: boolean | null;

  /**
   * Body param: Whether OCR is enabled at the account level.
   */
  ocr?: boolean | null;

  /**
   * Body param: Request model for payload log settings within the DLP settings
   * endpoint. Unlike the legacy endpoint, null and missing are treated identically
   * here (both mean "not provided" for PATCH, "reset to default" for PUT).
   */
  payload_logging?: SettingEditParams.PayloadLogging;
}

export namespace SettingEditParams {
  /**
   * Request model for payload log settings within the DLP settings endpoint. Unlike
   * the legacy endpoint, null and missing are treated identically here (both mean
   * "not provided" for PATCH, "reset to default" for PUT).
   */
  export interface PayloadLogging {
    /**
     * Masking level for payload logs.
     *
     * - `full`: The entire payload is masked.
     * - `partial`: Only partial payload content is masked.
     * - `clear`: No masking is applied to the payload content.
     * - `default`: DLP uses its default masking behavior.
     */
    masking_level?: 'full' | 'partial' | 'clear' | 'default';

    /**
     * Base64-encoded public key for encrypting payload logs.
     *
     * - Set to a non-empty base64 string to enable payload logging with the given key.
     * - Set to an empty string to disable payload logging.
     * - Omit or set to null to leave unchanged (PATCH) or reset to disabled (PUT).
     */
    public_key?: string | null;
  }
}

export interface SettingGetParams {
  account_id: string;
}

export declare namespace Settings {
  export {
    type DLPSettings as DLPSettings,
    type SettingUpdateParams as SettingUpdateParams,
    type SettingDeleteParams as SettingDeleteParams,
    type SettingEditParams as SettingEditParams,
    type SettingGetParams as SettingGetParams,
  };
}
