/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CreateServiceAccountRequestBody = { name: string; }; export type CreateServiceAccountRequest = { orgId: string; /** * Optional external end-user identifier forwarded by the API gateway. */ xOnBehalfOf?: string | undefined; requestBody?: CreateServiceAccountRequestBody | undefined; }; export type ServiceAccount = { id: string; orgId: string; name: string; createdAt: string; }; /** * Service account created */ export type CreateServiceAccountResponseBody = { serviceAccount: ServiceAccount; }; /** @internal */ export const CreateServiceAccountRequestBody$inboundSchema: z.ZodType< CreateServiceAccountRequestBody, z.ZodTypeDef, unknown > = z.object({ name: z.string(), }); /** @internal */ export type CreateServiceAccountRequestBody$Outbound = { name: string; }; /** @internal */ export const CreateServiceAccountRequestBody$outboundSchema: z.ZodType< CreateServiceAccountRequestBody$Outbound, z.ZodTypeDef, CreateServiceAccountRequestBody > = z.object({ name: z.string(), }); export function createServiceAccountRequestBodyToJSON( createServiceAccountRequestBody: CreateServiceAccountRequestBody, ): string { return JSON.stringify( CreateServiceAccountRequestBody$outboundSchema.parse( createServiceAccountRequestBody, ), ); } export function createServiceAccountRequestBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateServiceAccountRequestBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateServiceAccountRequestBody' from JSON`, ); } /** @internal */ export const CreateServiceAccountRequest$inboundSchema: z.ZodType< CreateServiceAccountRequest, z.ZodTypeDef, unknown > = z.object({ orgId: z.string(), "X-On-Behalf-Of": z.string().optional(), RequestBody: z.lazy(() => CreateServiceAccountRequestBody$inboundSchema) .optional(), }).transform((v) => { return remap$(v, { "X-On-Behalf-Of": "xOnBehalfOf", "RequestBody": "requestBody", }); }); /** @internal */ export type CreateServiceAccountRequest$Outbound = { orgId: string; "X-On-Behalf-Of"?: string | undefined; RequestBody?: CreateServiceAccountRequestBody$Outbound | undefined; }; /** @internal */ export const CreateServiceAccountRequest$outboundSchema: z.ZodType< CreateServiceAccountRequest$Outbound, z.ZodTypeDef, CreateServiceAccountRequest > = z.object({ orgId: z.string(), xOnBehalfOf: z.string().optional(), requestBody: z.lazy(() => CreateServiceAccountRequestBody$outboundSchema) .optional(), }).transform((v) => { return remap$(v, { xOnBehalfOf: "X-On-Behalf-Of", requestBody: "RequestBody", }); }); export function createServiceAccountRequestToJSON( createServiceAccountRequest: CreateServiceAccountRequest, ): string { return JSON.stringify( CreateServiceAccountRequest$outboundSchema.parse( createServiceAccountRequest, ), ); } export function createServiceAccountRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateServiceAccountRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateServiceAccountRequest' from JSON`, ); } /** @internal */ export const ServiceAccount$inboundSchema: z.ZodType< ServiceAccount, z.ZodTypeDef, unknown > = z.object({ id: z.string(), orgId: z.string(), name: z.string(), createdAt: z.string(), }); /** @internal */ export type ServiceAccount$Outbound = { id: string; orgId: string; name: string; createdAt: string; }; /** @internal */ export const ServiceAccount$outboundSchema: z.ZodType< ServiceAccount$Outbound, z.ZodTypeDef, ServiceAccount > = z.object({ id: z.string(), orgId: z.string(), name: z.string(), createdAt: z.string(), }); export function serviceAccountToJSON(serviceAccount: ServiceAccount): string { return JSON.stringify(ServiceAccount$outboundSchema.parse(serviceAccount)); } export function serviceAccountFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ServiceAccount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ServiceAccount' from JSON`, ); } /** @internal */ export const CreateServiceAccountResponseBody$inboundSchema: z.ZodType< CreateServiceAccountResponseBody, z.ZodTypeDef, unknown > = z.object({ serviceAccount: z.lazy(() => ServiceAccount$inboundSchema), }); /** @internal */ export type CreateServiceAccountResponseBody$Outbound = { serviceAccount: ServiceAccount$Outbound; }; /** @internal */ export const CreateServiceAccountResponseBody$outboundSchema: z.ZodType< CreateServiceAccountResponseBody$Outbound, z.ZodTypeDef, CreateServiceAccountResponseBody > = z.object({ serviceAccount: z.lazy(() => ServiceAccount$outboundSchema), }); export function createServiceAccountResponseBodyToJSON( createServiceAccountResponseBody: CreateServiceAccountResponseBody, ): string { return JSON.stringify( CreateServiceAccountResponseBody$outboundSchema.parse( createServiceAccountResponseBody, ), ); } export function createServiceAccountResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateServiceAccountResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateServiceAccountResponseBody' from JSON`, ); }