// 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 BaseBehaviours extends APIResource {
  static override readonly _key: readonly ['zeroTrust', 'riskScoring', 'behaviours'] = Object.freeze([
    'zeroTrust',
    'riskScoring',
    'behaviours',
  ] as const);

  /**
   * Updates risk score behavior configurations, defining weights and thresholds for
   * risk calculation.
   *
   * @example
   * ```ts
   * const behaviour =
   *   await client.zeroTrust.riskScoring.behaviours.update({
   *     account_id: 'account_id',
   *     behaviors: {
   *       foo: { enabled: true, risk_level: 'low' },
   *     },
   *   });
   * ```
   */
  update(params: BehaviourUpdateParams, options?: RequestOptions): APIPromise<BehaviourUpdateResponse> {
    const { account_id, ...body } = params;
    return (
      this._client.put(path`/accounts/${account_id}/zt_risk_scoring/behaviors`, {
        body,
        ...options,
      }) as APIPromise<{ result: BehaviourUpdateResponse }>
    )._thenUnwrap((obj) => obj.result);
  }

  /**
   * Retrieves configured risk score behaviors that define how user actions affect
   * their overall risk score.
   *
   * @example
   * ```ts
   * const behaviour =
   *   await client.zeroTrust.riskScoring.behaviours.get({
   *     account_id: 'account_id',
   *   });
   * ```
   */
  get(params: BehaviourGetParams, options?: RequestOptions): APIPromise<BehaviourGetResponse> {
    const { account_id } = params;
    return (
      this._client.get(path`/accounts/${account_id}/zt_risk_scoring/behaviors`, options) as APIPromise<{
        result: BehaviourGetResponse;
      }>
    )._thenUnwrap((obj) => obj.result);
  }
}
export class Behaviours extends BaseBehaviours {}

export interface BehaviourUpdateResponse {
  behaviors: { [key: string]: BehaviourUpdateResponse.Behaviors };
}

export namespace BehaviourUpdateResponse {
  export interface Behaviors {
    enabled: boolean;

    risk_level: 'low' | 'medium' | 'high';
  }
}

export interface BehaviourGetResponse {
  behaviors: { [key: string]: BehaviourGetResponse.Behaviors };
}

export namespace BehaviourGetResponse {
  export interface Behaviors {
    description: string;

    enabled: boolean;

    name: string;

    risk_level: 'low' | 'medium' | 'high';
  }
}

export interface BehaviourUpdateParams {
  /**
   * Path param: Account ID.
   */
  account_id: string;

  /**
   * Body param
   */
  behaviors: { [key: string]: BehaviourUpdateParams.Behaviors };
}

export namespace BehaviourUpdateParams {
  export interface Behaviors {
    enabled: boolean;

    risk_level: 'low' | 'medium' | 'high';
  }
}

export interface BehaviourGetParams {
  account_id: string;
}

export declare namespace Behaviours {
  export {
    type BehaviourUpdateResponse as BehaviourUpdateResponse,
    type BehaviourGetResponse as BehaviourGetResponse,
    type BehaviourUpdateParams as BehaviourUpdateParams,
    type BehaviourGetParams as BehaviourGetParams,
  };
}
