/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: bf736beaf25d */ import * as z from "zod/v4"; import { safeParse } from "../lib/schemas.js"; import { ClosedEnum } from "../types/enums.js"; import { Result as SafeParseResult } from "../types/fp.js"; import { APIKeyDeploymentSetupConfig, APIKeyDeploymentSetupConfig$inboundSchema, } from "./apikeydeploymentsetupconfig.js"; import { SDKValidationError } from "./errors/sdkvalidationerror.js"; export const APIKeyType = { Workspace: "workspace", Project: "project", Deployment: "deployment", DeploymentGroup: "deployment-group", Manager: "manager", } as const; export type APIKeyType = ClosedEnum; /** * User information associated with the API key */ export type CreatedByUser = { id: string; email: string; image: string | null; }; /** * API key information */ export type APIKey = { /** * Unique identifier for the api key. */ id: string; description: string | null; keyPrefix: string; type: APIKeyType; role: string; workspaceId: string; projectId: string | null; deploymentId: string | null; deploymentGroupId: string | null; managerId: string | null; enabled: boolean; createdAt: Date; expiresAt: Date | null; lastUsedAt: Date | null; revokedAt: Date | null; deploymentSetupConfig: APIKeyDeploymentSetupConfig | null; /** * User information associated with the API key */ createdByUser: CreatedByUser | null; }; /** @internal */ export const APIKeyType$inboundSchema: z.ZodEnum = z.enum( APIKeyType, ); /** @internal */ export const CreatedByUser$inboundSchema: z.ZodType = z .object({ id: z.string(), email: z.string(), image: z.nullable(z.string()), }); export function createdByUserFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreatedByUser$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreatedByUser' from JSON`, ); } /** @internal */ export const APIKey$inboundSchema: z.ZodType = z.object({ id: z.string(), description: z.nullable(z.string()), keyPrefix: z.string(), type: APIKeyType$inboundSchema, role: z.string(), workspaceId: z.string(), projectId: z.nullable(z.string()), deploymentId: z.nullable(z.string()), deploymentGroupId: z.nullable(z.string()), managerId: z.nullable(z.string()), enabled: z.boolean(), createdAt: z.iso.datetime({ offset: true }).transform(v => new Date(v)), expiresAt: z.nullable( z.iso.datetime({ offset: true }).transform(v => new Date(v)), ), lastUsedAt: z.nullable( z.iso.datetime({ offset: true }).transform(v => new Date(v)), ), revokedAt: z.nullable( z.iso.datetime({ offset: true }).transform(v => new Date(v)), ), deploymentSetupConfig: z.nullable(APIKeyDeploymentSetupConfig$inboundSchema), createdByUser: z.nullable(z.lazy(() => CreatedByUser$inboundSchema)), }); export function apiKeyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => APIKey$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'APIKey' from JSON`, ); }