# Generated by spec-gen from engines/front/crates/spec. Do not edit: # change the spec and run `cargo run -p runtime-front-spec-gen -- write`. """A command run in a fresh machine, once or on a cron schedule in a timezone. Each run is a machine made at its time, deleted when its command ends, and billed as any machine is; its exit code and its last 256 KiB of output are kept. Runs of one job never overlap: a time that comes while one runs is made once it ends, and times missed make one run.""" from __future__ import annotations from dataclasses import dataclass from typing import Any, Dict, List, Literal, Optional, Tuple, Union from urllib.parse import quote from ._runtime import (AsyncPage, AsyncStream, AsyncTransport, Page, Stream, Transport, async_page, compact, open_enum, page, to_bytes) from .sandboxes import SandboxRun from .sandboxes import VolumeMount @dataclass class JobSchedule: """When a job runs: once, at `at`; or at each time of its `cron` in its `timezone`. One of the two.""" #: The one time it runs. at: Optional[str] = None #: A cron expression of five fields (minute, hour, day of month, month, day of week), as cron reads them, or `@hourly`, `@daily`, `@weekly`, `@monthly` or `@yearly`. cron: Optional[str] = None #: The IANA timezone its cron's times are in (`America/Denver`), daylight saving included; UTC when omitted. timezone: Optional[str] = None @classmethod def from_dict(cls, d: Dict[str, Any]) -> "JobSchedule": return cls( at=d.get("at"), cron=d.get("cron"), timezone=d.get("timezone"), ) def to_dict(self) -> Dict[str, Any]: return compact({ "at": self.at, "cron": self.cron, "timezone": self.timezone, }) @dataclass class JobRetry: """How a failed run is run again: a run that ends with an exit code other than 0, or at its timeout.""" #: Attempts in all for one time, the first included; 1 (no retry) when omitted. At least 1. At most 10. Default: 1. max_attempts: Optional[int] = None #: Seconds from a failed attempt's end to the next. At least 0. At most 86400. Default: 30. backoff_seconds: Optional[int] = None @classmethod def from_dict(cls, d: Dict[str, Any]) -> "JobRetry": return cls( max_attempts=d.get("maxAttempts"), backoff_seconds=d.get("backoffSeconds"), ) def to_dict(self) -> Dict[str, Any]: return compact({ "maxAttempts": self.max_attempts, "backoffSeconds": self.backoff_seconds, }) @dataclass class JobSecrets: """Which of its org's secrets each run gets, and under which variables.""" #: The secrets each run gets in their own variables, by name: only those of them whose scope admits it; [] none. At most 64 items. only: Optional[List[str]] = None #: Variables each holding the value of one of the org's visible secrets whose scope admits the run, by the secret's name, `only` or not: `{"WEBSITE_TOKEN": "CRON_SECRET"}`. env: Optional[Dict[str, str]] = None @classmethod def from_dict(cls, d: Dict[str, Any]) -> "JobSecrets": return cls( only=d["only"] if d.get("only") is not None else None, env=d.get("env"), ) def to_dict(self) -> Dict[str, Any]: return compact({ "only": self.only, "env": self.env, }) @dataclass class JobSettings: """A job's settings: what each of its runs is made with.""" #: When it runs. schedule: Optional["JobSchedule"] = None #: The command each run runs; the run ends when it ends. run: Optional["SandboxRun"] = None #: How a failed run is run again; never when omitted. retry: Optional["JobRetry"] = None #: Which of its org's secrets each run gets; every one whose scope admits it when omitted. secrets: Optional["JobSecrets"] = None #: Each run's vCPUs. At least 1. Default: 1. vcpu: Optional[int] = None #: Each run's memory in GB (1 GB is 1,024 MiB); a fraction is taken to the MiB (`0.5`). At least 1. Default: 1. memory_gb: Optional[float] = None #: Each run's disk in GB, to the MiB, over a fresh copy of its image. At least 1. Default: 4. disk_gb: Optional[float] = None #: The image each run boots, by name (its newest version), `name:version` or ID; Runtime's default image when omitted. image: Optional[str] = None #: Who its command runs as: `runtime` (uid 1000, with passwordless sudo) or `root`. Its image's when omitted, else `runtime`. user: Optional[Literal["runtime", "root", "unknown"]] = None #: Volumes each run attaches and mounts, at most one, in the job's project; a run waits while another machine holds it. volumes: Optional[List["VolumeMount"]] = None #: The most one run may cost, in US dollars (`"0.50"`): a run pauses once it has cost that, as a machine at its maxCost does. max_cost: Optional[str] = None @classmethod def from_dict(cls, d: Dict[str, Any]) -> "JobSettings": return cls( schedule=JobSchedule.from_dict(d["schedule"]) if d.get("schedule") is not None else None, run=SandboxRun.from_dict(d["run"]) if d.get("run") is not None else None, retry=JobRetry.from_dict(d["retry"]) if d.get("retry") is not None else None, secrets=JobSecrets.from_dict(d["secrets"]) if d.get("secrets") is not None else None, vcpu=d.get("vcpu"), memory_gb=d.get("memoryGB"), disk_gb=d.get("diskGB"), image=d.get("image"), user=open_enum(d["user"], ("runtime", "root",)) if d.get("user") is not None else None, volumes=[VolumeMount.from_dict(i) for i in d["volumes"]] if d.get("volumes") is not None else None, max_cost=d.get("maxCost"), ) def to_dict(self) -> Dict[str, Any]: return compact({ "schedule": self.schedule, "run": self.run, "retry": self.retry, "secrets": self.secrets, "vcpu": self.vcpu, "memoryGB": self.memory_gb, "diskGB": self.disk_gb, "image": self.image, "user": self.user, "volumes": self.volumes, "maxCost": self.max_cost, }) @dataclass class JobCreate: """A job to create: its schedule and run are required.""" #: When it runs. schedule: Optional["JobSchedule"] = None #: The command each run runs; the run ends when it ends. run: Optional["SandboxRun"] = None #: How a failed run is run again; never when omitted. retry: Optional["JobRetry"] = None #: Which of its org's secrets each run gets; every one whose scope admits it when omitted. secrets: Optional["JobSecrets"] = None #: Each run's vCPUs. At least 1. Default: 1. vcpu: Optional[int] = None #: Each run's memory in GB (1 GB is 1,024 MiB); a fraction is taken to the MiB (`0.5`). At least 1. Default: 1. memory_gb: Optional[float] = None #: Each run's disk in GB, to the MiB, over a fresh copy of its image. At least 1. Default: 4. disk_gb: Optional[float] = None #: The image each run boots, by name (its newest version), `name:version` or ID; Runtime's default image when omitted. image: Optional[str] = None #: Who its command runs as: `runtime` (uid 1000, with passwordless sudo) or `root`. Its image's when omitted, else `runtime`. user: Optional[Literal["runtime", "root", "unknown"]] = None #: Volumes each run attaches and mounts, at most one, in the job's project; a run waits while another machine holds it. volumes: Optional[List["VolumeMount"]] = None #: The most one run may cost, in US dollars (`"0.50"`): a run pauses once it has cost that, as a machine at its maxCost does. max_cost: Optional[str] = None #: Its name, unique in its project. name: Optional[str] = None #: Labels to find it by; each run carries them. labels: Optional[Dict[str, str]] = None @classmethod def from_dict(cls, d: Dict[str, Any]) -> "JobCreate": return cls( schedule=JobSchedule.from_dict(d["schedule"]) if d.get("schedule") is not None else None, run=SandboxRun.from_dict(d["run"]) if d.get("run") is not None else None, retry=JobRetry.from_dict(d["retry"]) if d.get("retry") is not None else None, secrets=JobSecrets.from_dict(d["secrets"]) if d.get("secrets") is not None else None, vcpu=d.get("vcpu"), memory_gb=d.get("memoryGB"), disk_gb=d.get("diskGB"), image=d.get("image"), user=open_enum(d["user"], ("runtime", "root",)) if d.get("user") is not None else None, volumes=[VolumeMount.from_dict(i) for i in d["volumes"]] if d.get("volumes") is not None else None, max_cost=d.get("maxCost"), name=d.get("name"), labels=d.get("labels"), ) def to_dict(self) -> Dict[str, Any]: return compact({ "schedule": self.schedule, "run": self.run, "retry": self.retry, "secrets": self.secrets, "vcpu": self.vcpu, "memoryGB": self.memory_gb, "diskGB": self.disk_gb, "image": self.image, "user": self.user, "volumes": self.volumes, "maxCost": self.max_cost, "name": self.name, "labels": self.labels, }) @dataclass class JobError: """Why a time's run was not made and will not be tried again: the answer its create got. The job waits for its next time; a run made takes it off.""" #: The time whose run was not made. at: str #: The HTTP status its create was answered with. status: int #: The error's code, as any call's error names it. code: str #: What went wrong. message: str #: The create's request ID, for support. request_id: Optional[str] = None @classmethod def from_dict(cls, d: Dict[str, Any]) -> "JobError": return cls( at=d["at"], status=d["status"], code=d["code"], message=d["message"], request_id=d.get("requestId"), ) def to_dict(self) -> Dict[str, Any]: return compact({ "at": self.at, "status": self.status, "code": self.code, "message": self.message, "requestId": self.request_id, }) @dataclass class JobInfo: """A job.""" #: Its ID. id: str #: Always `job`. object: Literal["job", "unknown"] #: Where it is: `scheduled` (its runs are made at their times), `paused` (none is), `finished` (its one time ran). state: Literal["scheduled", "paused", "finished", "deleted", "unknown"] #: Its labels. labels: Dict[str, str] #: When it runs. schedule: Optional["JobSchedule"] = None #: The command each run runs; the run ends when it ends. run: Optional["SandboxRun"] = None #: How a failed run is run again; never when omitted. retry: Optional["JobRetry"] = None #: Which of its org's secrets each run gets; every one whose scope admits it when omitted. secrets: Optional["JobSecrets"] = None #: Each run's vCPUs. At least 1. Default: 1. vcpu: Optional[int] = None #: Each run's memory in GB (1 GB is 1,024 MiB); a fraction is taken to the MiB (`0.5`). At least 1. Default: 1. memory_gb: Optional[float] = None #: Each run's disk in GB, to the MiB, over a fresh copy of its image. At least 1. Default: 4. disk_gb: Optional[float] = None #: The image each run boots, by name (its newest version), `name:version` or ID; Runtime's default image when omitted. image: Optional[str] = None #: Who its command runs as: `runtime` (uid 1000, with passwordless sudo) or `root`. Its image's when omitted, else `runtime`. user: Optional[Literal["runtime", "root", "unknown"]] = None #: Volumes each run attaches and mounts, at most one, in the job's project; a run waits while another machine holds it. volumes: Optional[List["VolumeMount"]] = None #: The most one run may cost, in US dollars (`"0.50"`): a run pauses once it has cost that, as a machine at its maxCost does. max_cost: Optional[str] = None #: Its name, unique in its project. name: Optional[str] = None #: When its next run is made, or its next retry; none when paused or finished. next_run_at: Optional[str] = None #: Why its last time's run was not made, when it was refused: that time failed and it waits for its next; none once a run is made. last_error: Optional["JobError"] = None #: When it was created. created_at: Optional[str] = None #: Its revision, changed by every change to it. revision: Optional[int] = None #: When it was deleted: a delete's answer, its state `deleted`. deleted_at: Optional[str] = None @classmethod def from_dict(cls, d: Dict[str, Any]) -> "JobInfo": return cls( id=d["id"], object=open_enum(d["object"], ("job",)), state=open_enum(d["state"], ("scheduled", "paused", "finished", "deleted",)), labels=d["labels"], schedule=JobSchedule.from_dict(d["schedule"]) if d.get("schedule") is not None else None, run=SandboxRun.from_dict(d["run"]) if d.get("run") is not None else None, retry=JobRetry.from_dict(d["retry"]) if d.get("retry") is not None else None, secrets=JobSecrets.from_dict(d["secrets"]) if d.get("secrets") is not None else None, vcpu=d.get("vcpu"), memory_gb=d.get("memoryGB"), disk_gb=d.get("diskGB"), image=d.get("image"), user=open_enum(d["user"], ("runtime", "root",)) if d.get("user") is not None else None, volumes=[VolumeMount.from_dict(i) for i in d["volumes"]] if d.get("volumes") is not None else None, max_cost=d.get("maxCost"), name=d.get("name"), next_run_at=d.get("nextRunAt"), last_error=JobError.from_dict(d["lastError"]) if d.get("lastError") is not None else None, created_at=d.get("createdAt"), revision=d.get("revision"), deleted_at=d.get("deletedAt"), ) def to_dict(self) -> Dict[str, Any]: return compact({ "id": self.id, "object": self.object, "state": self.state, "labels": self.labels, "schedule": self.schedule, "run": self.run, "retry": self.retry, "secrets": self.secrets, "vcpu": self.vcpu, "memoryGB": self.memory_gb, "diskGB": self.disk_gb, "image": self.image, "user": self.user, "volumes": self.volumes, "maxCost": self.max_cost, "name": self.name, "nextRunAt": self.next_run_at, "lastError": self.last_error, "createdAt": self.created_at, "revision": self.revision, "deletedAt": self.deleted_at, }) class Job: """One of jobs: A command run in a fresh machine, once or on a cron schedule in a timezone. Each run is a machine made at its time, deleted when its command ends, and billed as any machine is; its exit code and its last 256 KiB of output are kept. Runs of one job never overlap: a time that comes while one runs is made once it ends, and times missed make one run.""" def __init__(self, client: "Jobs", info: JobInfo) -> None: self._c = client #: What it was when last read. self.info = info @property def id(self) -> str: """Its id.""" return self.info.id def __repr__(self) -> str: return f"Job({self.info!r})" def refresh(self) -> "Job": """Returns a job.""" self.info = (self._c.get(self.id)).info return self def delete(self, *, idempotency_key: Optional[str] = None) -> JobInfo: """Deletes a job: no run is made from then on, and a run in flight is ended. Its runs' records stay readable for 7 days.""" return self._c.delete(self.id, idempotency_key=idempotency_key) def pause(self, *, idempotency_key: Optional[str] = None) -> "Job": """Pauses a job: no run is made at its times until it is resumed. A run in flight runs to its end.""" self.info = self._c.pause(self.id, idempotency_key=idempotency_key) return self def resume(self, *, idempotency_key: Optional[str] = None) -> "Job": """Resumes a paused job: its next run is made at its schedule's next time from now.""" self.info = self._c.resume(self.id, idempotency_key=idempotency_key) return self def update(self, *, schedule: Optional["JobSchedule"] = None, run: Optional["SandboxRun"] = None, retry: Optional["JobRetry"] = None, secrets: Optional["JobSecrets"] = None, vcpu: Optional[int] = None, memory_gb: Optional[float] = None, disk_gb: Optional[float] = None, image: Optional[str] = None, user: Optional[Literal["runtime", "root", "unknown"]] = None, volumes: Optional[List["VolumeMount"]] = None, max_cost: Optional[str] = None, idempotency_key: Optional[str] = None) -> "Job": """Changes a job's settings: each one named replaces its own, the rest are kept. Runs made from then on use them; one in flight runs as it was made. A new schedule's next run is at its next time from now.""" self.info = self._c.update(self.id, schedule=schedule, run=run, retry=retry, secrets=secrets, vcpu=vcpu, memory_gb=memory_gb, disk_gb=disk_gb, image=image, user=user, volumes=volumes, max_cost=max_cost, idempotency_key=idempotency_key) return self def run(self, *, idempotency_key: Optional[str] = None) -> "Job": """Makes a run now, beside its schedule; a paused job stays paused. Refused 409 while a run of it is in flight. Asked again with the same Idempotency-Key, it makes nothing more.""" self.info = self._c.run(self.id, idempotency_key=idempotency_key) return self class Jobs: """A command run in a fresh machine, once or on a cron schedule in a timezone. Each run is a machine made at its time, deleted when its command ends, and billed as any machine is; its exit code and its last 256 KiB of output are kept. Runs of one job never overlap: a time that comes while one runs is made once it ends, and times missed make one run.""" def __init__(self, transport: Transport) -> None: self._transport = transport def create(self, *, schedule: Optional["JobSchedule"] = None, run: Optional["SandboxRun"] = None, retry: Optional["JobRetry"] = None, secrets: Optional["JobSecrets"] = None, vcpu: Optional[int] = None, memory_gb: Optional[float] = None, disk_gb: Optional[float] = None, image: Optional[str] = None, user: Optional[Literal["runtime", "root", "unknown"]] = None, volumes: Optional[List["VolumeMount"]] = None, max_cost: Optional[str] = None, name: Optional[str] = None, labels: Optional[Dict[str, str]] = None, idempotency_key: Optional[str] = None) -> Job: """Creates a job. Its first run is made at its schedule's first time. Asked again with the same Idempotency-Key, it returns the same job.""" return Job(self, JobInfo.from_dict(self._transport.request("POST", f"/v2/jobs", body=compact({"schedule": schedule, "run": run, "retry": retry, "secrets": secrets, "vcpu": vcpu, "memoryGB": memory_gb, "diskGB": disk_gb, "image": image, "user": user, "volumes": volumes, "maxCost": max_cost, "name": name, "labels": labels}), idempotency_key=idempotency_key, idempotent=True))) def get(self, id: str) -> Job: """Returns a job.""" return Job(self, JobInfo.from_dict(self._transport.request("GET", f"/v2/jobs/{quote(id, safe='')}", idempotent=True))) def list(self, *, label: Optional[List[str]] = None, cursor: Optional[str] = None, limit: Optional[int] = None) -> Page[JobInfo]: """Lists the project's jobs, newest first.""" return page(self._transport.request("GET", f"/v2/jobs", query={"label": label, "cursor": cursor, "limit": limit}, idempotent=True), JobInfo.from_dict, lambda c: self.list(label=label, cursor=c, limit=limit)) def delete(self, id: str, *, idempotency_key: Optional[str] = None) -> JobInfo: """Deletes a job: no run is made from then on, and a run in flight is ended. Its runs' records stay readable for 7 days.""" return JobInfo.from_dict(self._transport.request("DELETE", f"/v2/jobs/{quote(id, safe='')}", idempotency_key=idempotency_key, idempotent=True)) def pause(self, id: str, *, idempotency_key: Optional[str] = None) -> JobInfo: """Pauses a job: no run is made at its times until it is resumed. A run in flight runs to its end.""" return JobInfo.from_dict(self._transport.request("POST", f"/v2/jobs/{quote(id, safe='')}:pause", idempotency_key=idempotency_key, idempotent=True)) def resume(self, id: str, *, idempotency_key: Optional[str] = None) -> JobInfo: """Resumes a paused job: its next run is made at its schedule's next time from now.""" return JobInfo.from_dict(self._transport.request("POST", f"/v2/jobs/{quote(id, safe='')}:resume", idempotency_key=idempotency_key, idempotent=True)) def update(self, id: str, *, schedule: Optional["JobSchedule"] = None, run: Optional["SandboxRun"] = None, retry: Optional["JobRetry"] = None, secrets: Optional["JobSecrets"] = None, vcpu: Optional[int] = None, memory_gb: Optional[float] = None, disk_gb: Optional[float] = None, image: Optional[str] = None, user: Optional[Literal["runtime", "root", "unknown"]] = None, volumes: Optional[List["VolumeMount"]] = None, max_cost: Optional[str] = None, idempotency_key: Optional[str] = None) -> JobInfo: """Changes a job's settings: each one named replaces its own, the rest are kept. Runs made from then on use them; one in flight runs as it was made. A new schedule's next run is at its next time from now.""" return JobInfo.from_dict(self._transport.request("POST", f"/v2/jobs/{quote(id, safe='')}:update", body=compact({"schedule": schedule, "run": run, "retry": retry, "secrets": secrets, "vcpu": vcpu, "memoryGB": memory_gb, "diskGB": disk_gb, "image": image, "user": user, "volumes": volumes, "maxCost": max_cost}), idempotency_key=idempotency_key, idempotent=True)) def run(self, id: str, *, idempotency_key: Optional[str] = None) -> JobInfo: """Makes a run now, beside its schedule; a paused job stays paused. Refused 409 while a run of it is in flight. Asked again with the same Idempotency-Key, it makes nothing more.""" return JobInfo.from_dict(self._transport.request("POST", f"/v2/jobs/{quote(id, safe='')}:run", idempotency_key=idempotency_key, idempotent=True)) class AsyncJob: """One of jobs: A command run in a fresh machine, once or on a cron schedule in a timezone. Each run is a machine made at its time, deleted when its command ends, and billed as any machine is; its exit code and its last 256 KiB of output are kept. Runs of one job never overlap: a time that comes while one runs is made once it ends, and times missed make one run.""" def __init__(self, client: "AsyncJobs", info: JobInfo) -> None: self._c = client #: What it was when last read. self.info = info @property def id(self) -> str: """Its id.""" return self.info.id def __repr__(self) -> str: return f"AsyncJob({self.info!r})" async def refresh(self) -> "AsyncJob": """Returns a job.""" self.info = (await self._c.get(self.id)).info return self async def delete(self, *, idempotency_key: Optional[str] = None) -> JobInfo: """Deletes a job: no run is made from then on, and a run in flight is ended. Its runs' records stay readable for 7 days.""" return await self._c.delete(self.id, idempotency_key=idempotency_key) async def pause(self, *, idempotency_key: Optional[str] = None) -> "AsyncJob": """Pauses a job: no run is made at its times until it is resumed. A run in flight runs to its end.""" self.info = await self._c.pause(self.id, idempotency_key=idempotency_key) return self async def resume(self, *, idempotency_key: Optional[str] = None) -> "AsyncJob": """Resumes a paused job: its next run is made at its schedule's next time from now.""" self.info = await self._c.resume(self.id, idempotency_key=idempotency_key) return self async def update(self, *, schedule: Optional["JobSchedule"] = None, run: Optional["SandboxRun"] = None, retry: Optional["JobRetry"] = None, secrets: Optional["JobSecrets"] = None, vcpu: Optional[int] = None, memory_gb: Optional[float] = None, disk_gb: Optional[float] = None, image: Optional[str] = None, user: Optional[Literal["runtime", "root", "unknown"]] = None, volumes: Optional[List["VolumeMount"]] = None, max_cost: Optional[str] = None, idempotency_key: Optional[str] = None) -> "AsyncJob": """Changes a job's settings: each one named replaces its own, the rest are kept. Runs made from then on use them; one in flight runs as it was made. A new schedule's next run is at its next time from now.""" self.info = await self._c.update(self.id, schedule=schedule, run=run, retry=retry, secrets=secrets, vcpu=vcpu, memory_gb=memory_gb, disk_gb=disk_gb, image=image, user=user, volumes=volumes, max_cost=max_cost, idempotency_key=idempotency_key) return self async def run(self, *, idempotency_key: Optional[str] = None) -> "AsyncJob": """Makes a run now, beside its schedule; a paused job stays paused. Refused 409 while a run of it is in flight. Asked again with the same Idempotency-Key, it makes nothing more.""" self.info = await self._c.run(self.id, idempotency_key=idempotency_key) return self class AsyncJobs: """A command run in a fresh machine, once or on a cron schedule in a timezone. Each run is a machine made at its time, deleted when its command ends, and billed as any machine is; its exit code and its last 256 KiB of output are kept. Runs of one job never overlap: a time that comes while one runs is made once it ends, and times missed make one run.""" def __init__(self, transport: AsyncTransport) -> None: self._transport = transport async def create(self, *, schedule: Optional["JobSchedule"] = None, run: Optional["SandboxRun"] = None, retry: Optional["JobRetry"] = None, secrets: Optional["JobSecrets"] = None, vcpu: Optional[int] = None, memory_gb: Optional[float] = None, disk_gb: Optional[float] = None, image: Optional[str] = None, user: Optional[Literal["runtime", "root", "unknown"]] = None, volumes: Optional[List["VolumeMount"]] = None, max_cost: Optional[str] = None, name: Optional[str] = None, labels: Optional[Dict[str, str]] = None, idempotency_key: Optional[str] = None) -> AsyncJob: """Creates a job. Its first run is made at its schedule's first time. Asked again with the same Idempotency-Key, it returns the same job.""" return AsyncJob(self, JobInfo.from_dict(await self._transport.request("POST", f"/v2/jobs", body=compact({"schedule": schedule, "run": run, "retry": retry, "secrets": secrets, "vcpu": vcpu, "memoryGB": memory_gb, "diskGB": disk_gb, "image": image, "user": user, "volumes": volumes, "maxCost": max_cost, "name": name, "labels": labels}), idempotency_key=idempotency_key, idempotent=True))) async def get(self, id: str) -> AsyncJob: """Returns a job.""" return AsyncJob(self, JobInfo.from_dict(await self._transport.request("GET", f"/v2/jobs/{quote(id, safe='')}", idempotent=True))) async def list(self, *, label: Optional[List[str]] = None, cursor: Optional[str] = None, limit: Optional[int] = None) -> AsyncPage[JobInfo]: """Lists the project's jobs, newest first.""" return async_page(await self._transport.request("GET", f"/v2/jobs", query={"label": label, "cursor": cursor, "limit": limit}, idempotent=True), JobInfo.from_dict, lambda c: self.list(label=label, cursor=c, limit=limit)) async def delete(self, id: str, *, idempotency_key: Optional[str] = None) -> JobInfo: """Deletes a job: no run is made from then on, and a run in flight is ended. Its runs' records stay readable for 7 days.""" return JobInfo.from_dict(await self._transport.request("DELETE", f"/v2/jobs/{quote(id, safe='')}", idempotency_key=idempotency_key, idempotent=True)) async def pause(self, id: str, *, idempotency_key: Optional[str] = None) -> JobInfo: """Pauses a job: no run is made at its times until it is resumed. A run in flight runs to its end.""" return JobInfo.from_dict(await self._transport.request("POST", f"/v2/jobs/{quote(id, safe='')}:pause", idempotency_key=idempotency_key, idempotent=True)) async def resume(self, id: str, *, idempotency_key: Optional[str] = None) -> JobInfo: """Resumes a paused job: its next run is made at its schedule's next time from now.""" return JobInfo.from_dict(await self._transport.request("POST", f"/v2/jobs/{quote(id, safe='')}:resume", idempotency_key=idempotency_key, idempotent=True)) async def update(self, id: str, *, schedule: Optional["JobSchedule"] = None, run: Optional["SandboxRun"] = None, retry: Optional["JobRetry"] = None, secrets: Optional["JobSecrets"] = None, vcpu: Optional[int] = None, memory_gb: Optional[float] = None, disk_gb: Optional[float] = None, image: Optional[str] = None, user: Optional[Literal["runtime", "root", "unknown"]] = None, volumes: Optional[List["VolumeMount"]] = None, max_cost: Optional[str] = None, idempotency_key: Optional[str] = None) -> JobInfo: """Changes a job's settings: each one named replaces its own, the rest are kept. Runs made from then on use them; one in flight runs as it was made. A new schedule's next run is at its next time from now.""" return JobInfo.from_dict(await self._transport.request("POST", f"/v2/jobs/{quote(id, safe='')}:update", body=compact({"schedule": schedule, "run": run, "retry": retry, "secrets": secrets, "vcpu": vcpu, "memoryGB": memory_gb, "diskGB": disk_gb, "image": image, "user": user, "volumes": volumes, "maxCost": max_cost}), idempotency_key=idempotency_key, idempotent=True)) async def run(self, id: str, *, idempotency_key: Optional[str] = None) -> JobInfo: """Makes a run now, beside its schedule; a paused job stays paused. Refused 409 while a run of it is in flight. Asked again with the same Idempotency-Key, it makes nothing more.""" return JobInfo.from_dict(await self._transport.request("POST", f"/v2/jobs/{quote(id, safe='')}:run", idempotency_key=idempotency_key, idempotent=True)) __all__ = ["JobSchedule", "JobRetry", "JobSecrets", "JobSettings", "JobCreate", "JobError", "JobInfo", "Jobs", "Job", "AsyncJobs", "AsyncJob"]