import {z} from 'zod' export type GetApiOrganizationsOrganizationNameProjectsProjectNameQueuesOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const containerImage = z.string().min(1).max(2048); export const containerImageCaching = z.boolean(); export const containerLoggingAxiom = z.object({api_token: z.string().min(1).max(1000), dataset: z.string().min(1).max(1000), host: z.string().min(1).max(1000)}); export const containerLoggingDatadogTag = z.object({name: z.string().min(1).max(1000), value: z.string().min(1).max(1000)}); export const containerLoggingDatadog = z.object({api_key: z.string().min(1).max(1000), host: z.string().min(1).max(1000), tags: z.array(containerLoggingDatadogTag).nullable()}); export const containerLoggingHttpCompression = z.enum(["none", "gzip"]); export const containerLoggingHttpFormat = z.enum(["json", "json_lines"]); export const containerLoggingHttpHeader = z.object({name: z.string().min(1).max(1000), value: z.string().min(1).max(1000)}); export const containerLoggingHttp = z.object({compression: containerLoggingHttpCompression, format: containerLoggingHttpFormat, headers: z.array(containerLoggingHttpHeader).nullable(), host: z.string().min(1).max(1000), password: z.string().min(1).max(1000).nullable().optional(), path: z.string().min(1).max(1000).nullable().optional(), port: z.number().int().gte(1).lte(65535), user: z.string().min(1).max(1000).nullable().optional()}); export const containerLoggingNewRelic = z.object({host: z.string().min(1).max(1000), ingestion_key: z.string().min(1).max(1000)}); export const containerLoggingSplunk = z.object({host: z.string().min(1).max(1000), token: z.string().min(1).max(1000)}); export const containerLoggingTcp = z.object({host: z.string().min(1).max(1000), port: z.number().int().gte(1).lte(65535)}); export const containerLogging = z.object({axiom: containerLoggingAxiom.optional(), datadog: containerLoggingDatadog.optional(), http: containerLoggingHttp.optional(), new_relic: containerLoggingNewRelic.optional(), splunk: containerLoggingSplunk.optional(), tcp: containerLoggingTcp.optional()}); export const containerResourceRequirements = z.object({cpu: z.number().int().gte(1).lte(1024), gpu_classes: z.array(z.string()), memory: z.number().int().gte(1024).lte(1073741824), shm_size: z.number().int().gte(64).lte(1073741824).optional(), storage_amount: z.number().int().gte(1073741824).lte(1125899906842624).optional()}); export const container = z.object({command: z.array(z.string().min(1).max(2048)).nullable(), environment_variables: z.record(z.string(), z.string().max(2048)).optional(), hash: z.string().min(47).max(135).optional(), image: containerImage, image_caching: containerImageCaching.optional(), logging: containerLogging.optional(), resources: containerResourceRequirements, size: z.number().int().gte(0).lte(9223372036854776000).optional()}); export const countryCode = z.enum(["af", "al", "dz", "as", "ad", "ao", "ai", "aq", "ag", "ar", "am", "aw", "au", "at", "az", "bs", "bh", "bd", "bb", "by", "be", "bz", "bj", "bm", "bt", "bo", "bq", "ba", "bw", "bv", "br", "io", "bn", "bg", "bf", "bi", "cv", "kh", "cm", "ca", "ky", "cf", "td", "cl", "cn", "cx", "cc", "co", "km", "cd", "cg", "ck", "cr", "hr", "cu", "cw", "cy", "cz", "ci", "dk", "dj", "dm", "do", "ec", "eg", "sv", "gq", "er", "ee", "sz", "et", "fk", "fo", "fj", "fi", "fr", "gf", "pf", "tf", "ga", "gm", "ge", "de", "gh", "gi", "gr", "gl", "gd", "gp", "gu", "gt", "gg", "gn", "gw", "gy", "ht", "hm", "va", "hn", "hk", "hu", "is", "in", "id", "ir", "iq", "ie", "im", "il", "it", "jm", "jp", "je", "jo", "kz", "ke", "ki", "kp", "kr", "kw", "kg", "la", "lv", "lb", "ls", "lr", "ly", "li", "lt", "lu", "mo", "mg", "mw", "my", "mv", "ml", "mt", "mh", "mq", "mr", "mu", "yt", "mx", "fm", "md", "mc", "mn", "me", "ms", "ma", "mz", "mm", "na", "nr", "np", "nl", "nc", "nz", "ni", "ne", "ng", "nu", "nf", "mp", "no", "om", "pk", "pw", "ps", "pa", "pg", "py", "pe", "ph", "pn", "pl", "pt", "pr", "qa", "mk", "ro", "ru", "rw", "re", "bl", "sh", "kn", "lc", "mf", "pm", "vc", "ws", "sm", "st", "sa", "sn", "rs", "sc", "sl", "sg", "sx", "sk", "si", "sb", "so", "za", "gs", "ss", "es", "lk", "sd", "sr", "sj", "se", "ch", "sy", "tw", "tj", "tz", "th", "tl", "tg", "tk", "to", "tt", "tn", "tr", "tm", "tc", "tv", "ug", "ua", "ae", "gb", "um", "us", "uy", "uz", "vu", "ve", "vn", "vg", "vi", "wf", "eh", "ye", "zm", "zw", "ax"]); export const containerGroupInstanceStatusCount = z.object({allocating_count: z.number().int().gte(0).lte(2147483647), creating_count: z.number().int().gte(0).lte(2147483647), running_count: z.number().int().gte(0).lte(2147483647), stopping_count: z.number().int().gte(0).lte(2147483647)}); export const containerGroupStatus = z.enum(["pending", "running", "stopped", "succeeded", "failed", "deploying"]); export const containerGroupState = z.object({description: z.string().max(1000).nullable().optional(), finish_time: z.string(), instance_status_counts: containerGroupInstanceStatusCount, start_time: z.string(), status: containerGroupStatus}); export const displayName = z.string().min(2).max(63); export const containerGroupId = z.string(); export const containerGroupProbeExec = z.object({command: z.array(z.string().min(1).max(2048))}); export const containerGroupProbeGrpc = z.object({port: z.number().int().gte(0).lte(65536), service: z.string().max(1024)}); export const containerGroupProbeHttpHeader = z.object({name: z.string().min(1).max(256), value: z.string().min(1).max(1024)}); export const containerGroupProbeHttpHeaders = z.array(containerGroupProbeHttpHeader); export const containerProbeHttpScheme = z.enum(["http", "https"]).nullable(); export const containerGroupProbeHttp = z.object({headers: containerGroupProbeHttpHeaders, path: z.string().min(1).max(2048), port: z.number().int().gte(0).lte(65536), scheme: containerProbeHttpScheme}); export const containerGroupProbeTcp = z.object({port: z.number().int().gte(0).lte(65535)}); export const containerGroupLivenessProbe = z.object({exec: containerGroupProbeExec.optional(), failure_threshold: z.number().int().gte(1).lte(20), grpc: containerGroupProbeGrpc.optional(), http: containerGroupProbeHttp.optional(), initial_delay_seconds: z.number().int().gte(0).lte(1200), period_seconds: z.number().int().gte(1).lte(120), success_threshold: z.number().int().gte(1).lte(10), tcp: containerGroupProbeTcp.optional(), timeout_seconds: z.number().int().gte(1).lte(60)}).nullable(); export const containerGroupName = z.string().min(2).max(63); export const containerGroupNetworkingClientRequestTimeout = z.number().int().gte(1).lte(100000); export const containerGroupNetworkingLoadBalancer = z.enum(["round_robin", "least_number_of_connections"]); export const containerGroupNetworkingPort = z.number().int().gte(1).lte(65535); export const containerNetworkingProtocol = z.literal("http"); export const containerGroupNetworkingServerResponseTimeout = z.number().int().gte(1).lte(100000); export const containerGroupNetworkingSingleConnectionLimit = z.boolean(); export const containerGroupNetworking = z.object({auth: z.boolean(), client_request_timeout: containerGroupNetworkingClientRequestTimeout.optional(), dns: z.string().min(1).max(253), load_balancer: containerGroupNetworkingLoadBalancer, port: containerGroupNetworkingPort, protocol: containerNetworkingProtocol, server_response_timeout: containerGroupNetworkingServerResponseTimeout.optional(), single_connection_limit: containerGroupNetworkingSingleConnectionLimit.optional()}); export const organizationName = z.string().min(2).max(63); export const containerGroupPriority = z.enum(["high", "medium", "low", "batch"]).nullable(); export const projectName = z.string().min(2).max(63); export const containerGroupQueueAutoscaler = z.object({desired_queue_length: z.number().int().gte(1).lte(100), max_downscale_per_minute: z.number().int().gte(1).lte(100).optional(), max_replicas: z.number().int().gte(1).lte(500), max_upscale_per_minute: z.number().int().gte(1).lte(100).optional(), min_replicas: z.number().int().gte(0).lte(100), polling_period: z.number().int().gte(15).lte(1800).optional()}); export const containerGroupQueueConnection = z.object({path: z.string().min(1).max(1024), port: z.number().int().gte(1).lte(65535), queue_name: z.string().min(2).max(63)}); export const containerGroupReadinessProbe = z.object({exec: containerGroupProbeExec.optional(), failure_threshold: z.number().int().gte(1).lte(20), grpc: containerGroupProbeGrpc.optional(), http: containerGroupProbeHttp.optional(), initial_delay_seconds: z.number().int().gte(0).lte(1200), period_seconds: z.number().int().gte(1).lte(120), success_threshold: z.number().int().gte(1).lte(10), tcp: containerGroupProbeTcp.optional(), timeout_seconds: z.number().int().gte(1).lte(60)}).nullable(); export const containerGroupReplicas = z.number().int().gte(0).lte(500); export const containerRestartPolicy = z.enum(["always", "on_failure", "never"]); export const containerGroupScalingAction = z.object({replicas: z.number().int().gte(0).lte(500), schedule: z.string()}); export const containerGroupStartupProbe = z.object({exec: containerGroupProbeExec.optional(), failure_threshold: z.number().int().gte(1).lte(20), grpc: containerGroupProbeGrpc.optional(), http: containerGroupProbeHttp.optional(), initial_delay_seconds: z.number().int().gte(0).lte(1200), period_seconds: z.number().int().gte(1).lte(120), success_threshold: z.number().int().gte(1).lte(10), tcp: containerGroupProbeTcp.optional(), timeout_seconds: z.number().int().gte(1).lte(60)}).nullable(); export const containerGroup = z.object({autostart_policy: z.boolean(), container: container, country_codes: z.array(countryCode), create_time: z.string(), current_state: containerGroupState, display_name: displayName, id: containerGroupId, liveness_probe: containerGroupLivenessProbe.optional(), name: containerGroupName, networking: containerGroupNetworking.optional(), organization_name: organizationName, pending_change: z.boolean(), priority: containerGroupPriority, project_name: projectName, queue_autoscaler: containerGroupQueueAutoscaler.optional(), queue_connection: containerGroupQueueConnection.optional(), readiness_probe: containerGroupReadinessProbe.optional(), readme: z.string().min(2).max(65000).optional(), replicas: containerGroupReplicas, restart_policy: containerRestartPolicy, "scaling-actions": z.array(containerGroupScalingAction), "scheduled-scaling-enabled": z.boolean(), startup_probe: containerGroupStartupProbe.optional(), update_time: z.string(), version: z.number().int().gte(1).lte(2147483647)}); export const queue = z.object({container_groups: z.array(containerGroup), create_time: z.string(), current_queue_length: z.number().int().gte(0).lte(2147483647).optional(), description: z.string().max(500).optional(), display_name: z.string().min(2).max(63), id: z.string(), name: z.string().min(2).max(63), update_time: z.string()}); export const queueCollection = z.object({items: z.array(queue)}); 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 Queues * * GET /organizations/{organization_name}/projects/{project_name}/queues */ export const getApiOrganizationsOrganizationNameProjectsProjectNameQueues = async (options?: GetApiOrganizationsOrganizationNameProjectsProjectNameQueuesOptions) => { const {baseUrl = "https://api.salad.com/api/public", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (ApiKeyAuth !== undefined) headers.set("Salad-Api-Key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/organizations/${encodeURIComponent(String(args.organization_name))}/projects/${encodeURIComponent(String(args.project_name))}/queues${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(queueCollection, await res.json()) };