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

import * as z from "zod/v3";

export type V2KeysSetPermissionsRequestBody = {
  /**
   * Specifies which key receives the additional permissions using the database identifier returned from `keys.createKey`.
   *
   * @remarks
   * Do not confuse this with the actual API key string that users include in requests.
   */
  keyId: string;
  /**
   * The permissions to set for this key.
   *
   * @remarks
   *
   * This is a complete replacement operation - it overwrites all existing direct permissions with this new set.
   *
   * Key behaviors:
   * - Providing an empty array removes all direct permissions from the key
   * - This only affects direct permissions - permissions granted through roles are not affected
   * - All existing direct permissions not included in this list will be removed
   *
   * Any permissions that do not exist will be auto created if the root key has permissions, otherwise this operation will fail with a 403 error.
   */
  permissions: Array<string>;
};

/** @internal */
export type V2KeysSetPermissionsRequestBody$Outbound = {
  keyId: string;
  permissions: Array<string>;
};

/** @internal */
export const V2KeysSetPermissionsRequestBody$outboundSchema: z.ZodType<
  V2KeysSetPermissionsRequestBody$Outbound,
  z.ZodTypeDef,
  V2KeysSetPermissionsRequestBody
> = z.object({
  keyId: z.string(),
  permissions: z.array(z.string()),
});

export function v2KeysSetPermissionsRequestBodyToJSON(
  v2KeysSetPermissionsRequestBody: V2KeysSetPermissionsRequestBody,
): string {
  return JSON.stringify(
    V2KeysSetPermissionsRequestBody$outboundSchema.parse(
      v2KeysSetPermissionsRequestBody,
    ),
  );
}
