Packages
Reference for packages, which keep a sandbox under a name to be made by members and whom its access lets in, and AppClient, which reaches the sandbox an app's user made as them and comes back to it.
A package is a sandbox kept under a name, made as many times as it is asked for, by the members of its project and by whom its access lets in.
A Package has its id, its name, the sandbox it makes, max, access, origins and limits (in Rust, id(), name() and info()).
See Making packages, Letting your users in and Building an app on a package.
| Member | Does |
|---|---|
put_package |
Keeps a package under name, made or replaced in whole. |
list_package |
The project’s packages, or the one an id or name names. |
create_sandbox |
Makes a sandbox of a package. |
list_sandbox |
The sandboxes made of a package that the client’s credentials made. |
remove |
Removes the package; the sandboxes made of it stay. |
AppClient.create |
Makes a sandbox of a package as an app’s user, and reaches it as them. |
AppClient.open |
Reaches again a sandbox the user made, as them. |
AppClient.close |
Closes the client, leaving its sandbox. |
AppClient.remove |
Removes its sandbox, and closes the client. |
put_package
Keeps the package name, made or replaced in whole: each sandbox made of it is made of image as create_sandbox makes one with the same options, but name and a port on local, which each sandbox is given as it is made.
Its image and volumes have to be in the project already.
Replacing a package keeps its id, and changes no sandbox made of it.
maxis how large one its access let in may resize a sandbox they made of it, each no less than what the package makes it with. One left out holds them to the size the sandbox was made with.accessis who beside the project’s members may make one, each aJwtAccess: whoever sends a JSON Web Tokenissuersigned foraudienceand carrying each ofclaims, which they then reach the sandbox with. With any, the package’s volumes are mounted read-only, since every sandbox made of it mounts the same ones.originsare the web pages they may make one from, and reach it from, each ashttps://app.example.limitsis how many sandboxes made of it by thoseaccesslets in may live at once:sandboxes, all of theirs, andper_subject, each one’s.
async def put_package( name: str, image: str | ImageName, *, # ... every option of create_sandbox but name ... max: Mapping[str, int] | None = None, access: Iterable[JwtAccess] = (), origins: Iterable[str] = (), limits: PackageLimits | None = None,) -> Package
@dataclass(frozen=True)class JwtAccess: issuer: str audience: str jwks: str | None = None claims: Mapping[str, Any] = {}
@dataclass(frozen=True)class PackageLimits: sandboxes: int | None = None per_subject: int | None = NoneputPackage(name: string, image: string | ImageName, options?: PackageOptions): Promise<Package>
interface PackageOptions extends Omit<SandboxCreateOptions, 'name'> { max?: SandboxResizeOptions access?: PackageAccess[] origins?: string[] limits?: { sandboxes?: number; perSubject?: number }}
type PackageAccess = { type: 'jwt' issuer: string audience: string jwks?: string claims?: Record<string, unknown>}pub fn put_package(&self, name: impl AsRef<str>, args: &PackagePutArgs) -> Call<Package>
impl PackagePutArgs { pub fn new(sandbox: SandboxCreateArgs) -> Self pub fn max(self, max: SandboxResizeArgs) -> Self pub fn access(self, access: PackageAccess) -> Self pub fn origin(self, origin: impl Into<String>) -> Self pub fn limits(self, limits: PackageLimits) -> Self}
pub enum PackageAccess { Jwt { issuer: String, audience: String, jwks: Option<String>, claims: Map<String, Value> },}
pub struct PackageLimits { pub sandboxes: Option<u32>, pub per_subject: Option<u32> }list_package
The project’s packages, or the one package names: by its id, or by its name in the client’s project.
async def list_package() -> list[Package]async def get_package(package: str) -> PackagelistPackage(): Promise<Package[]>getPackage(pkg: string): Promise<Package>pub fn list_package(&self) -> Call<Vec<Package>>pub fn get_package(&self, package: impl AsRef<str>) -> Call<Package>create_sandbox
Makes a sandbox of the package, answered as a Sandbox.
create_package_sandbox on the client does the same for a package by its id or name.
namefinds it again withfind_sandbox. Only a member of the project may give one; anyone else is refused with400.portsare its ports on local, eachon="local", beside the ports in the sandbox the package gives it. A port in the sandbox is refused with400.
# Packageasync def create_sandbox(*, name: str | None = None, ports: Iterable[PortSpec] = ()) -> Sandbox# Clientasync def create_package_sandbox( package: str, *, name: str | None = None, ports: Iterable[PortSpec] = ()) -> Sandbox// PackagecreateSandbox(options?: { name?: string; ports?: PortSpec[] }): Promise<Sandbox>// ClientcreatePackageSandbox(pkg: string, options?: { name?: string; ports?: PortSpec[] }): Promise<Sandbox>// Packagepub fn create_sandbox(&self, args: &PackageSandboxCreateArgs) -> Call<Sandbox>// Clientpub fn create_package_sandbox(&self, package: impl AsRef<str>, args: &PackageSandboxCreateArgs) -> Call<Sandbox>
impl PackageSandboxCreateArgs { pub fn name(self, name: impl Into<String>) -> Self pub fn port(self, port: PortSpec) -> Self}list_sandbox
The sandboxes made of the package that the client’s credentials made: to a member of the project, every one; to one its access lets in, those made with the same issuer and subject, as it lets them in now.
A request with no credentials is refused with 401.
list_package_sandbox on the client does the same for a package by its id or name.
A server that takes no credentials answers none of this.
# Packageasync def list_sandbox() -> list[Sandbox]# Clientasync def list_package_sandbox(package: str) -> list[Sandbox]// PackagelistSandbox(): Promise<Sandbox[]>// ClientlistPackageSandbox(pkg: string): Promise<Sandbox[]>// Packagepub fn list_sandbox(&self) -> Call<Vec<Sandbox>>// Clientpub fn list_package_sandbox(&self, package: impl AsRef<str>) -> Call<Vec<Sandbox>>remove
Removes the package, and what its access lets in from then on.
The sandboxes made of it stay, each reached by who made it.
Putting it again under its name makes another package, of another id, which neither lists nor counts toward its limits the sandboxes made of this one.
To take a user’s sandbox from them, remove that sandbox.
async def remove() -> Noneremove(): Promise<void>pub fn remove(&self) -> Call<()>AppClient.create
Makes a sandbox of the package named package in the project project, by the project’s id, on the server at url, as auth lets in: a bearer token of the issuer its access names, such as the ID token your app’s user signed in with.
ports are its ports on local, each on="local", beside those the package gives it in the sandbox.
From then on the client sends auth with every request, and its sandbox reaches that sandbox: auth reaches the sandboxes the user made of the package, and nothing else.
Keep the sandbox’s id to come back to it with open.
It is refused as making the sandbox is: 401 or 403 for one the package does not let in, 429 past its limits, and 400 for a port in the sandbox.
@classmethodasync def create( url: str, project: str, package: str, auth: Auth | None = None, *, ports: Iterable[PortSpec] = (),) -> AppClient
sandbox: Sandboxstatic create( url: string, project: string, pkg: string, auth?: Auth | null, options?: { ports?: PortSpec[] },): Promise<AppClient>
readonly sandbox: Sandboxpub async fn create( url: &str, project: &str, package: &str, auth: Auth, ports: impl IntoIterator<Item = PortSpec>,) -> Result<AppClient, Error>
pub fn sandbox(&self) -> &SandboxAppClient.open
Reaches again the sandbox sandbox in the project project, each by its id, one the user made of a package as auth lets in, such as list_sandbox finds.
It is refused with 401 or 403 for a sandbox they did not make, or one removed.
@classmethodasync def open(url: str, project: str, auth: Auth, sandbox: str) -> AppClientstatic open(url: string, project: string, auth: Auth, sandbox: string): Promise<AppClient>pub async fn open(url: &str, project: &str, auth: Auth, sandbox: &str) -> Result<AppClient, Error>AppClient.close
Closes the client and leaves its sandbox as it is, to come back to.
async with closes it in Python, await using in Node.js where the runtime has it, and dropping it in Rust.
async def close() -> Noneclose(): Promise<void>pub async fn close(self) -> Result<(), Error>AppClient.remove
Removes its sandbox, and closes the client.
async def remove() -> Noneremove(): Promise<void>pub async fn remove(self) -> Result<(), Error>