import {z} from 'zod' export type UpdateAutoscalingSettingsV1 = {min_replica?: (number | null) | undefined, max_replica?: (number | null) | undefined, autoscaling_window?: (number | null) | undefined, scale_down_delay?: (number | null) | undefined, concurrency_target?: (number | null) | undefined, target_utilization_percentage?: (number | null) | undefined, target_in_flight_tokens?: (number | null) | undefined, max_scale_down_rate?: (number | null) | undefined}; export type PatchApiV1ModelsModelIdDeploymentsDevelopmentAutoscalingSettingsArgs = {body: UpdateAutoscalingSettingsV1}; export type PatchApiV1ModelsModelIdDeploymentsDevelopmentAutoscalingSettingsOptions = {baseUrl: string, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const updateAutoscalingSettingsStatusV1 = z.enum(["ACCEPTED", "QUEUED", "UNCHANGED"]); export const updateAutoscalingSettingsResponseV1 = z.object({status: updateAutoscalingSettingsStatusV1, message: z.string()}); 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 }; /** * Updates a development deployment's autoscaling settings * * PATCH /v1/models/{model_id}/deployments/development/autoscaling_settings */ export const patchApiV1ModelsModelIdDeploymentsDevelopmentAutoscalingSettings = async (args: PatchApiV1ModelsModelIdDeploymentsDevelopmentAutoscalingSettingsArgs, options: PatchApiV1ModelsModelIdDeploymentsDevelopmentAutoscalingSettingsOptions) => { const {baseUrl, fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/models/${encodeURIComponent(String(args.model_id))}/deployments/development/autoscaling_settings${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(updateAutoscalingSettingsResponseV1, await res.json()) };