/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ListScopedApiKeysRequest = { orgId?: string | undefined; teamId?: string | undefined; /** * Optional external end-user identifier forwarded by the API gateway. */ xOnBehalfOf?: string | undefined; }; export const ListScopedApiKeysUserType = { User: "user", ServiceAccount: "service-account", } as const; export type ListScopedApiKeysUserType = ClosedEnum< typeof ListScopedApiKeysUserType >; export type ResponseBody = { id: string; name?: string | null | undefined; key?: string | undefined; prefix?: string | null | undefined; start?: string | null | undefined; userId: string; userType: ListScopedApiKeysUserType; orgId: string | null; teamId: string | null; scopes: Array; expiresAt?: string | null | undefined; }; /** @internal */ export const ListScopedApiKeysRequest$inboundSchema: z.ZodType< ListScopedApiKeysRequest, z.ZodTypeDef, unknown > = z.object({ orgId: z.string().optional(), teamId: z.string().optional(), "X-On-Behalf-Of": z.string().optional(), }).transform((v) => { return remap$(v, { "X-On-Behalf-Of": "xOnBehalfOf", }); }); /** @internal */ export type ListScopedApiKeysRequest$Outbound = { orgId?: string | undefined; teamId?: string | undefined; "X-On-Behalf-Of"?: string | undefined; }; /** @internal */ export const ListScopedApiKeysRequest$outboundSchema: z.ZodType< ListScopedApiKeysRequest$Outbound, z.ZodTypeDef, ListScopedApiKeysRequest > = z.object({ orgId: z.string().optional(), teamId: z.string().optional(), xOnBehalfOf: z.string().optional(), }).transform((v) => { return remap$(v, { xOnBehalfOf: "X-On-Behalf-Of", }); }); export function listScopedApiKeysRequestToJSON( listScopedApiKeysRequest: ListScopedApiKeysRequest, ): string { return JSON.stringify( ListScopedApiKeysRequest$outboundSchema.parse(listScopedApiKeysRequest), ); } export function listScopedApiKeysRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListScopedApiKeysRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListScopedApiKeysRequest' from JSON`, ); } /** @internal */ export const ListScopedApiKeysUserType$inboundSchema: z.ZodNativeEnum< typeof ListScopedApiKeysUserType > = z.nativeEnum(ListScopedApiKeysUserType); /** @internal */ export const ListScopedApiKeysUserType$outboundSchema: z.ZodNativeEnum< typeof ListScopedApiKeysUserType > = ListScopedApiKeysUserType$inboundSchema; /** @internal */ export const ResponseBody$inboundSchema: z.ZodType< ResponseBody, z.ZodTypeDef, unknown > = z.object({ id: z.string(), name: z.nullable(z.string()).optional(), key: z.string().optional(), prefix: z.nullable(z.string()).optional(), start: z.nullable(z.string()).optional(), userId: z.string(), userType: ListScopedApiKeysUserType$inboundSchema, orgId: z.nullable(z.string()), teamId: z.nullable(z.string()), scopes: z.array(z.string()), expiresAt: z.nullable(z.string()).optional(), }); /** @internal */ export type ResponseBody$Outbound = { id: string; name?: string | null | undefined; key?: string | undefined; prefix?: string | null | undefined; start?: string | null | undefined; userId: string; userType: string; orgId: string | null; teamId: string | null; scopes: Array; expiresAt?: string | null | undefined; }; /** @internal */ export const ResponseBody$outboundSchema: z.ZodType< ResponseBody$Outbound, z.ZodTypeDef, ResponseBody > = z.object({ id: z.string(), name: z.nullable(z.string()).optional(), key: z.string().optional(), prefix: z.nullable(z.string()).optional(), start: z.nullable(z.string()).optional(), userId: z.string(), userType: ListScopedApiKeysUserType$outboundSchema, orgId: z.nullable(z.string()), teamId: z.nullable(z.string()), scopes: z.array(z.string()), expiresAt: z.nullable(z.string()).optional(), }); export function responseBodyToJSON(responseBody: ResponseBody): string { return JSON.stringify(ResponseBody$outboundSchema.parse(responseBody)); } export function responseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ResponseBody' from JSON`, ); }