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

import * as z from "zod/v3";

export type V2KeysRemoveRolesRequestBody = {
  /**
   * Specifies which key loses the roles using the database identifier returned from createKey.
   *
   * @remarks
   * Do not confuse this with the actual API key string that users include in requests.
   * Removing roles only affects direct assignments, not permissions inherited from other sources.
   * Role changes take effect immediately but may take up to 30 seconds to propagate across all regions.
   */
  keyId: string;
  /**
   * Removes direct role assignments from the key without affecting other role sources or permissions.
   *
   * @remarks
   * Operations are idempotent - removing non-assigned roles has no effect and causes no errors.
   *
   * After removal, the key loses access to permissions that were only granted through these roles.
   * Invalid role references cause the entire operation to fail atomically, ensuring consistent state.
   */
  roles: Array<string>;
};

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

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

export function v2KeysRemoveRolesRequestBodyToJSON(
  v2KeysRemoveRolesRequestBody: V2KeysRemoveRolesRequestBody,
): string {
  return JSON.stringify(
    V2KeysRemoveRolesRequestBody$outboundSchema.parse(
      v2KeysRemoveRolesRequestBody,
    ),
  );
}
