import {z} from 'zod' export type ContainerImage = string; export type ContainerImageCaching = boolean; export type ContainerLoggingAxiom = {api_token: string, dataset: string, host: string}; export type ContainerLoggingDatadogTag = {name: string, value: string}; export type ContainerLoggingDatadog = {api_key: string, host: string, tags: Array | null}; export type ContainerLoggingHttpCompression = 'none' | 'gzip'; export type ContainerLoggingHttpFormat = 'json' | 'json_lines'; export type ContainerLoggingHttpHeader = {name: string, value: string}; export type CreateContainerLoggingHttp = {compression: ContainerLoggingHttpCompression, format: ContainerLoggingHttpFormat, headers?: Array | undefined, host: string, password?: (string | null) | undefined, path?: (string | null) | undefined, port: number, user?: (string | null) | undefined}; export type ContainerLoggingNewRelic = {host: string, ingestion_key: string}; export type ContainerLoggingSplunk = {host: string, token: string}; export type ContainerLoggingTcp = {host: string, port: number}; export type CreateContainerLogging = {axiom?: ContainerLoggingAxiom | undefined, datadog?: ContainerLoggingDatadog | undefined, http?: CreateContainerLoggingHttp | undefined, new_relic?: ContainerLoggingNewRelic | undefined, splunk?: ContainerLoggingSplunk | undefined, tcp?: ContainerLoggingTcp | undefined}; export type ContainerGroupPriority = 'high' | 'medium' | 'low' | 'batch' | null; export type ContainerRegistryAuthenticationAwsEcr = {access_key_id: string, secret_access_key: string} | null; export type ContainerRegistryAuthenticationBasic = {password: string, username: string}; export type ContainerRegistryAuthenticationDockerHub = {personal_access_token: string, username: string}; export type ContainerRegistryAuthenticationGcpGar = {service_key: string}; export type ContainerRegistryAuthenticationGcpGcr = {service_key: string}; export type ContainerRegistryAuthentication = {aws_ecr?: ContainerRegistryAuthenticationAwsEcr | undefined, basic?: ContainerRegistryAuthenticationBasic | undefined, docker_hub?: ContainerRegistryAuthenticationDockerHub | undefined, gcp_gar?: ContainerRegistryAuthenticationGcpGar | undefined, gcp_gcr?: ContainerRegistryAuthenticationGcpGcr | undefined}; export type CreateContainerResourceRequirements = {cpu: number, gpu_classes?: Array | undefined, memory: number, shm_size?: number | undefined, storage_amount?: number | undefined}; export type CreateContainer = {command?: (Array | null) | undefined, environment_variables?: {[key: string]: string} | undefined, image: ContainerImage, image_caching?: ContainerImageCaching | undefined, logging?: CreateContainerLogging | undefined, priority?: ContainerGroupPriority | undefined, registry_authentication?: ContainerRegistryAuthentication | undefined, resources: CreateContainerResourceRequirements}; export type CountryCode = '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 type ContainerGroupProbeExec = {command: Array}; export type ContainerGroupProbeGrpc = {port: number, service: string}; export type ContainerGroupProbeHttpHeader = {name: string, value: string}; export type ContainerGroupProbeHttpHeaders = Array; export type ContainerProbeHttpScheme = 'http' | 'https' | null; export type ContainerGroupProbeHttp = {headers: ContainerGroupProbeHttpHeaders, path: string, port: number, scheme: ContainerProbeHttpScheme}; export type ContainerGroupProbeTcp = {port: number}; export type ContainerGroupLivenessProbe = {exec?: ContainerGroupProbeExec | undefined, failure_threshold: number, grpc?: ContainerGroupProbeGrpc | undefined, http?: ContainerGroupProbeHttp | undefined, initial_delay_seconds: number, period_seconds: number, success_threshold: number, tcp?: ContainerGroupProbeTcp | undefined, timeout_seconds: number} | null; export type ContainerGroupNetworkingClientRequestTimeout = number; export type ContainerGroupNetworkingLoadBalancer = 'round_robin' | 'least_number_of_connections'; export type ContainerGroupNetworkingPort = number; export type ContainerNetworkingProtocol = 'http'; export type ContainerGroupNetworkingServerResponseTimeout = number; export type ContainerGroupNetworkingSingleConnectionLimit = boolean; export type CreateContainerGroupNetworking = {auth: boolean, client_request_timeout?: ContainerGroupNetworkingClientRequestTimeout | undefined, load_balancer?: ContainerGroupNetworkingLoadBalancer | undefined, port: ContainerGroupNetworkingPort, protocol: ContainerNetworkingProtocol, server_response_timeout?: ContainerGroupNetworkingServerResponseTimeout | undefined, single_connection_limit?: ContainerGroupNetworkingSingleConnectionLimit | undefined}; export type ContainerGroupQueueAutoscaler = {desired_queue_length: number, max_downscale_per_minute?: number | undefined, max_replicas: number, max_upscale_per_minute?: number | undefined, min_replicas: number, polling_period?: number | undefined}; export type ContainerGroupQueueConnection = {path: string, port: number, queue_name: string}; export type ContainerGroupReadinessProbe = {exec?: ContainerGroupProbeExec | undefined, failure_threshold: number, grpc?: ContainerGroupProbeGrpc | undefined, http?: ContainerGroupProbeHttp | undefined, initial_delay_seconds: number, period_seconds: number, success_threshold: number, tcp?: ContainerGroupProbeTcp | undefined, timeout_seconds: number} | null; export type ContainerRestartPolicy = 'always' | 'on_failure' | 'never'; export type ContainerGroupScalingAction = {replicas: number, schedule: string}; export type ContainerGroupStartupProbe = {exec?: ContainerGroupProbeExec | undefined, failure_threshold: number, grpc?: ContainerGroupProbeGrpc | undefined, http?: ContainerGroupProbeHttp | undefined, initial_delay_seconds: number, period_seconds: number, success_threshold: number, tcp?: ContainerGroupProbeTcp | undefined, timeout_seconds: number} | null; export type ContainerGroupPrototype = {autostart_policy: boolean, container: CreateContainer, country_codes?: Array | undefined, display_name?: string | undefined, liveness_probe?: ContainerGroupLivenessProbe | undefined, name: string, networking?: CreateContainerGroupNetworking | undefined, queue_autoscaler?: ContainerGroupQueueAutoscaler | undefined, queue_connection?: ContainerGroupQueueConnection | undefined, readiness_probe?: ContainerGroupReadinessProbe | undefined, replicas: number, restart_policy: ContainerRestartPolicy, 'scaling-actions'?: Array | undefined, 'scheduled-scaling-enabled'?: boolean | undefined, startup_probe?: ContainerGroupStartupProbe | undefined}; export type CreateApiOrganizationsOrganizationNameProjectsProjectNameContainersArgs = {body: ContainerGroupPrototype}; export type CreateApiOrganizationsOrganizationNameProjectsProjectNameContainersOptions = {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 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 }; /** * Create Container Group * * POST /organizations/{organization_name}/projects/{project_name}/containers */ export const createApiOrganizationsOrganizationNameProjectsProjectNameContainers = async (args: CreateApiOrganizationsOrganizationNameProjectsProjectNameContainersArgs, options?: CreateApiOrganizationsOrganizationNameProjectsProjectNameContainersOptions) => { const {baseUrl = "https://api.salad.com/api/public", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") 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))}/containers${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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(containerGroup, await res.json()) };