import {z} from 'zod' export type GetApiV1AccountsAccountIdTrainingSessionsTrainingSessionIdCheckpointsArgs = {pageSize?: number | undefined, pageToken?: string | undefined, account_id: string, training_session_id: string}; export type GetApiV1AccountsAccountIdTrainingSessionsTrainingSessionIdCheckpointsOptions = {baseUrl: string, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const gatewayCheckpointType = z.enum(["CHECKPOINT_TYPE_UNSPECIFIED", "CHECKPOINT_TYPE_INFERENCE_BASE", "CHECKPOINT_TYPE_INFERENCE_ARC_V2", "CHECKPOINT_TYPE_INFERENCE_LORA", "CHECKPOINT_TYPE_TRAINING", "CHECKPOINT_TYPE_TRAINING_LORA"]); export const checkpointAvailabilityAvailabilityClass = z.enum(["AVAILABILITY_CLASS_UNSPECIFIED", "SINGLE_REGION", "MANAGED_DURABLE"]); export const gatewayRegion = z.enum(["REGION_UNSPECIFIED", "US_IOWA_1", "US_VIRGINIA_1", "US_VIRGINIA_2", "US_ILLINOIS_1", "AP_TOKYO_1", "US_ARIZONA_1", "US_TEXAS_1", "US_ILLINOIS_2", "EU_FRANKFURT_1", "US_TEXAS_2", "EU_ICELAND_1", "EU_ICELAND_2", "US_WASHINGTON_1", "US_WASHINGTON_2", "US_WASHINGTON_3", "AP_TOKYO_2", "US_CALIFORNIA_1", "US_UTAH_1", "US_ARIZONA_3", "US_GEORGIA_1", "US_GEORGIA_2", "US_WASHINGTON_4", "US_GEORGIA_3", "NA_BRITISHCOLUMBIA_1", "US_GEORGIA_4", "US_OHIO_1", "US_NEWYORK_1", "EU_NETHERLANDS_1", "US_WASHINGTON_5", "US_MINNESOTA_1", "US_CALIFORNIA_2", "NA_BRITISHCOLUMBIA_2", "AP_MALAYSIA_2", "US_OREGON_1", "NA_BRITISHCOLUMBIA_3", "AP_NEWSOUTHWALES_1", "AP_TAIWAN_1"]); export const gatewayCheckpointAvailability = z.object({availabilityClass: checkpointAvailabilityAvailabilityClass.optional(), region: gatewayRegion.optional(), createTime: z.string().optional(), updateTime: z.string().optional()}); export const gatewayTrainingSessionCheckpoint = z.object({name: z.string().optional(), checkpointType: gatewayCheckpointType.optional(), checkpointName: z.string().optional(), createTime: z.string().optional(), promotable: z.boolean().optional(), updateTime: z.string().optional(), availability: z.array(gatewayCheckpointAvailability).optional()}); export const gatewayListTrainingSessionCheckpointsResponse = z.object({trainingSessionCheckpoints: z.array(gatewayTrainingSessionCheckpoint).optional(), nextPageToken: z.string().optional(), totalSize: z.number().int().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * List the checkpoints saved during a TrainingSession. Access is scoped * to the session's account. * * GET /v1/accounts/{account_id}/trainingSessions/{training_session_id}/checkpoints */ export const getApiV1AccountsAccountIdTrainingSessionsTrainingSessionIdCheckpoints = async (args: GetApiV1AccountsAccountIdTrainingSessionsTrainingSessionIdCheckpointsArgs, options: GetApiV1AccountsAccountIdTrainingSessionsTrainingSessionIdCheckpointsOptions) => { const {baseUrl, fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.pageSize != null) query.append("pageSize", String(args.pageSize)) if (args.pageToken != null) query.append("pageToken", String(args.pageToken)) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/accounts/${encodeURIComponent(String(args.account_id))}/trainingSessions/${encodeURIComponent(String(args.training_session_id))}/checkpoints${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(gatewayListTrainingSessionCheckpointsResponse, await res.json()) };