/* * 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 ListServiceAccountApiKeysRequest = { orgId: string; saId: string; /** * Optional external end-user identifier forwarded by the API gateway. */ xOnBehalfOf?: string | undefined; }; export const ListServiceAccountApiKeysUserType = { User: "user", ServiceAccount: "service-account", } as const; export type ListServiceAccountApiKeysUserType = ClosedEnum< typeof ListServiceAccountApiKeysUserType >; export type ListServiceAccountApiKeysResponseBody = { id: string; name?: string | null | undefined; key?: string | undefined; prefix?: string | null | undefined; start?: string | null | undefined; userId: string; userType: ListServiceAccountApiKeysUserType; orgId: string | null; teamId: string | null; scopes: Array; expiresAt?: string | null | undefined; }; /** @internal */ export const ListServiceAccountApiKeysRequest$inboundSchema: z.ZodType< ListServiceAccountApiKeysRequest, z.ZodTypeDef, unknown > = z.object({ orgId: z.string(), saId: z.string(), "X-On-Behalf-Of": z.string().optional(), }).transform((v) => { return remap$(v, { "X-On-Behalf-Of": "xOnBehalfOf", }); }); /** @internal */ export type ListServiceAccountApiKeysRequest$Outbound = { orgId: string; saId: string; "X-On-Behalf-Of"?: string | undefined; }; /** @internal */ export const ListServiceAccountApiKeysRequest$outboundSchema: z.ZodType< ListServiceAccountApiKeysRequest$Outbound, z.ZodTypeDef, ListServiceAccountApiKeysRequest > = z.object({ orgId: z.string(), saId: z.string(), xOnBehalfOf: z.string().optional(), }).transform((v) => { return remap$(v, { xOnBehalfOf: "X-On-Behalf-Of", }); }); export function listServiceAccountApiKeysRequestToJSON( listServiceAccountApiKeysRequest: ListServiceAccountApiKeysRequest, ): string { return JSON.stringify( ListServiceAccountApiKeysRequest$outboundSchema.parse( listServiceAccountApiKeysRequest, ), ); } export function listServiceAccountApiKeysRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListServiceAccountApiKeysRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListServiceAccountApiKeysRequest' from JSON`, ); } /** @internal */ export const ListServiceAccountApiKeysUserType$inboundSchema: z.ZodNativeEnum< typeof ListServiceAccountApiKeysUserType > = z.nativeEnum(ListServiceAccountApiKeysUserType); /** @internal */ export const ListServiceAccountApiKeysUserType$outboundSchema: z.ZodNativeEnum< typeof ListServiceAccountApiKeysUserType > = ListServiceAccountApiKeysUserType$inboundSchema; /** @internal */ export const ListServiceAccountApiKeysResponseBody$inboundSchema: z.ZodType< ListServiceAccountApiKeysResponseBody, 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: ListServiceAccountApiKeysUserType$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 ListServiceAccountApiKeysResponseBody$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 ListServiceAccountApiKeysResponseBody$outboundSchema: z.ZodType< ListServiceAccountApiKeysResponseBody$Outbound, z.ZodTypeDef, ListServiceAccountApiKeysResponseBody > = 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: ListServiceAccountApiKeysUserType$outboundSchema, orgId: z.nullable(z.string()), teamId: z.nullable(z.string()), scopes: z.array(z.string()), expiresAt: z.nullable(z.string()).optional(), }); export function listServiceAccountApiKeysResponseBodyToJSON( listServiceAccountApiKeysResponseBody: ListServiceAccountApiKeysResponseBody, ): string { return JSON.stringify( ListServiceAccountApiKeysResponseBody$outboundSchema.parse( listServiceAccountApiKeysResponseBody, ), ); } export function listServiceAccountApiKeysResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListServiceAccountApiKeysResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListServiceAccountApiKeysResponseBody' from JSON`, ); }