/* * 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 ReissueOwnerKeyRequestBody = { userId?: string | undefined; teamId?: string | undefined; }; export type ReissueOwnerKeyRequest = { id: string; /** * Optional external end-user identifier forwarded by the API gateway. */ xOnBehalfOf?: string | undefined; requestBody?: ReissueOwnerKeyRequestBody | undefined; }; export const ReissueOwnerKeyUserType = { User: "user", ServiceAccount: "service-account", } as const; export type ReissueOwnerKeyUserType = ClosedEnum< typeof ReissueOwnerKeyUserType >; export type ApiKey = { id: string; name?: string | null | undefined; key?: string | undefined; prefix?: string | null | undefined; start?: string | null | undefined; userId: string; userType: ReissueOwnerKeyUserType; orgId: string | null; teamId: string | null; scopes: Array; expiresAt?: string | null | undefined; }; /** * Owner key re-issued (plaintext returned once) */ export type ReissueOwnerKeyResponseBody = { message: string; userId: string; apiKey: ApiKey; }; /** @internal */ export const ReissueOwnerKeyRequestBody$inboundSchema: z.ZodType< ReissueOwnerKeyRequestBody, z.ZodTypeDef, unknown > = z.object({ userId: z.string().optional(), teamId: z.string().optional(), }); /** @internal */ export type ReissueOwnerKeyRequestBody$Outbound = { userId?: string | undefined; teamId?: string | undefined; }; /** @internal */ export const ReissueOwnerKeyRequestBody$outboundSchema: z.ZodType< ReissueOwnerKeyRequestBody$Outbound, z.ZodTypeDef, ReissueOwnerKeyRequestBody > = z.object({ userId: z.string().optional(), teamId: z.string().optional(), }); export function reissueOwnerKeyRequestBodyToJSON( reissueOwnerKeyRequestBody: ReissueOwnerKeyRequestBody, ): string { return JSON.stringify( ReissueOwnerKeyRequestBody$outboundSchema.parse(reissueOwnerKeyRequestBody), ); } export function reissueOwnerKeyRequestBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ReissueOwnerKeyRequestBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ReissueOwnerKeyRequestBody' from JSON`, ); } /** @internal */ export const ReissueOwnerKeyRequest$inboundSchema: z.ZodType< ReissueOwnerKeyRequest, z.ZodTypeDef, unknown > = z.object({ id: z.string(), "X-On-Behalf-Of": z.string().optional(), RequestBody: z.lazy(() => ReissueOwnerKeyRequestBody$inboundSchema) .optional(), }).transform((v) => { return remap$(v, { "X-On-Behalf-Of": "xOnBehalfOf", "RequestBody": "requestBody", }); }); /** @internal */ export type ReissueOwnerKeyRequest$Outbound = { id: string; "X-On-Behalf-Of"?: string | undefined; RequestBody?: ReissueOwnerKeyRequestBody$Outbound | undefined; }; /** @internal */ export const ReissueOwnerKeyRequest$outboundSchema: z.ZodType< ReissueOwnerKeyRequest$Outbound, z.ZodTypeDef, ReissueOwnerKeyRequest > = z.object({ id: z.string(), xOnBehalfOf: z.string().optional(), requestBody: z.lazy(() => ReissueOwnerKeyRequestBody$outboundSchema) .optional(), }).transform((v) => { return remap$(v, { xOnBehalfOf: "X-On-Behalf-Of", requestBody: "RequestBody", }); }); export function reissueOwnerKeyRequestToJSON( reissueOwnerKeyRequest: ReissueOwnerKeyRequest, ): string { return JSON.stringify( ReissueOwnerKeyRequest$outboundSchema.parse(reissueOwnerKeyRequest), ); } export function reissueOwnerKeyRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ReissueOwnerKeyRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ReissueOwnerKeyRequest' from JSON`, ); } /** @internal */ export const ReissueOwnerKeyUserType$inboundSchema: z.ZodNativeEnum< typeof ReissueOwnerKeyUserType > = z.nativeEnum(ReissueOwnerKeyUserType); /** @internal */ export const ReissueOwnerKeyUserType$outboundSchema: z.ZodNativeEnum< typeof ReissueOwnerKeyUserType > = ReissueOwnerKeyUserType$inboundSchema; /** @internal */ export const ApiKey$inboundSchema: z.ZodType = 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: ReissueOwnerKeyUserType$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 ApiKey$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 ApiKey$outboundSchema: z.ZodType< ApiKey$Outbound, z.ZodTypeDef, ApiKey > = 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: ReissueOwnerKeyUserType$outboundSchema, orgId: z.nullable(z.string()), teamId: z.nullable(z.string()), scopes: z.array(z.string()), expiresAt: z.nullable(z.string()).optional(), }); export function apiKeyToJSON(apiKey: ApiKey): string { return JSON.stringify(ApiKey$outboundSchema.parse(apiKey)); } export function apiKeyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ApiKey$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ApiKey' from JSON`, ); } /** @internal */ export const ReissueOwnerKeyResponseBody$inboundSchema: z.ZodType< ReissueOwnerKeyResponseBody, z.ZodTypeDef, unknown > = z.object({ message: z.string(), userId: z.string(), apiKey: z.lazy(() => ApiKey$inboundSchema), }); /** @internal */ export type ReissueOwnerKeyResponseBody$Outbound = { message: string; userId: string; apiKey: ApiKey$Outbound; }; /** @internal */ export const ReissueOwnerKeyResponseBody$outboundSchema: z.ZodType< ReissueOwnerKeyResponseBody$Outbound, z.ZodTypeDef, ReissueOwnerKeyResponseBody > = z.object({ message: z.string(), userId: z.string(), apiKey: z.lazy(() => ApiKey$outboundSchema), }); export function reissueOwnerKeyResponseBodyToJSON( reissueOwnerKeyResponseBody: ReissueOwnerKeyResponseBody, ): string { return JSON.stringify( ReissueOwnerKeyResponseBody$outboundSchema.parse( reissueOwnerKeyResponseBody, ), ); } export function reissueOwnerKeyResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ReissueOwnerKeyResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ReissueOwnerKeyResponseBody' from JSON`, ); }