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

import * as z from "zod/v3";

export type V2PortalCreateSessionRequestBody = {
  /**
   * The human-readable slug of the portal configuration to create the session against.
   *
   * @remarks
   * Identifies which app's portal the end user will access.
   * Must be 3-64 characters, lowercase alphanumeric and hyphens only,
   * must not start or end with a hyphen, and must not contain consecutive hyphens.
   */
  slug: string;
  /**
   * The end user's identifier in the customer's system.
   *
   * @remarks
   * Accepts arbitrary string values (user IDs, emails, UUIDs, etc.).
   */
  externalId: string;
  /**
   * List of RBAC tuple permissions defining what the end user can do in the Portal.
   *
   * @remarks
   * Each permission is a string in the format `{resourceType}.{resourceId}.{action}`.
   * Use `*` as resourceId to grant access to all resources of that type.
   *
   * Tab visibility is derived from the action segment:
   * - Keys tab: `read_key`, `create_key`, `update_key`, `delete_key`
   * - Analytics tab: `read_analytics`
   * - Docs tab: visible when any permission is present
   */
  permissions: Array<string>;
  /**
   * When true, creates a preview session for testing the portal experience.
   *
   * @remarks
   */
  preview?: boolean | undefined;
};

/** @internal */
export type V2PortalCreateSessionRequestBody$Outbound = {
  slug: string;
  externalId: string;
  permissions: Array<string>;
  preview: boolean;
};

/** @internal */
export const V2PortalCreateSessionRequestBody$outboundSchema: z.ZodType<
  V2PortalCreateSessionRequestBody$Outbound,
  z.ZodTypeDef,
  V2PortalCreateSessionRequestBody
> = z.object({
  slug: z.string(),
  externalId: z.string(),
  permissions: z.array(z.string()),
  preview: z.boolean().default(false),
});

export function v2PortalCreateSessionRequestBodyToJSON(
  v2PortalCreateSessionRequestBody: V2PortalCreateSessionRequestBody,
): string {
  return JSON.stringify(
    V2PortalCreateSessionRequestBody$outboundSchema.parse(
      v2PortalCreateSessionRequestBody,
    ),
  );
}
