/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v3";
import {
  RatelimitRequest,
  RatelimitRequest$Outbound,
  RatelimitRequest$outboundSchema,
} from "./ratelimitrequest.js";

export type V2IdentitiesUpdateIdentityRequestBody = {
  /**
   * The ID of the identity to update. Accepts either the externalId (your system-generated identifier) or the identityId (internal identifier returned by the identity service).
   */
  identity: string;
  /**
   * Replaces all existing metadata with this new metadata object.
   *
   * @remarks
   * Omitting this field preserves existing metadata, while providing an empty object clears all metadata.
   * Avoid storing sensitive data here as it's returned in verification responses.
   * Large metadata objects increase verification latency and should stay under 10KB total size.
   */
  meta?: { [k: string]: any } | undefined;
  /**
   * Replaces all existing identity rate limits with this complete list of rate limits.
   *
   * @remarks
   * Omitting this field preserves existing rate limits, while providing an empty array removes all rate limits.
   * These limits are shared across all keys belonging to this identity, preventing abuse through multiple keys.
   * Rate limit changes take effect immediately but may take up to 30 seconds to propagate across all regions.
   */
  ratelimits?: Array<RatelimitRequest> | undefined;
};

/** @internal */
export type V2IdentitiesUpdateIdentityRequestBody$Outbound = {
  identity: string;
  meta?: { [k: string]: any } | undefined;
  ratelimits?: Array<RatelimitRequest$Outbound> | undefined;
};

/** @internal */
export const V2IdentitiesUpdateIdentityRequestBody$outboundSchema: z.ZodType<
  V2IdentitiesUpdateIdentityRequestBody$Outbound,
  z.ZodTypeDef,
  V2IdentitiesUpdateIdentityRequestBody
> = z.object({
  identity: z.string(),
  meta: z.record(z.any()).optional(),
  ratelimits: z.array(RatelimitRequest$outboundSchema).optional(),
});

export function v2IdentitiesUpdateIdentityRequestBodyToJSON(
  v2IdentitiesUpdateIdentityRequestBody: V2IdentitiesUpdateIdentityRequestBody,
): string {
  return JSON.stringify(
    V2IdentitiesUpdateIdentityRequestBody$outboundSchema.parse(
      v2IdentitiesUpdateIdentityRequestBody,
    ),
  );
}
