Client

Automatically generated client from Dagger API.

class dagger.api.gen.BuildArg[source]
name: str
value: str
class dagger.api.gen.CacheID[source]

A global cache volume identifier.

class dagger.api.gen.CacheSharingMode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Sharing mode of the cache volume.

LOCKED = 'LOCKED'

Shares the cache volume amongst many build pipelines, but will serialize the writes

PRIVATE = 'PRIVATE'

Keeps a cache volume for a single build pipeline

SHARED = 'SHARED'

Shares the cache volume amongst many build pipelines

class dagger.api.gen.CacheVolume(ctx: Context)[source]

A directory whose contents persist across runs.

id() CacheID[source]

Note

This is lazyly evaluated, no operation is actually run.

Returns:

A global cache volume identifier.

Return type:

CacheID

class dagger.api.gen.Client(ctx: Context)[source]
cache_volume(key: str) CacheVolume[source]

Constructs a cache volume for a given cache key.

Parameters:

key – A string identifier to target this cache volume (e.g. “myapp- cache”).

container(id: ContainerID | None = None, platform: Platform | None = None) Container[source]

Loads a container from ID.

Null ID returns an empty container (scratch).

Optional platform argument initializes new containers to execute and publish as that platform. Platform defaults to that of the builder’s host.

default_platform() Platform[source]

The default platform of the builder.

Returns:

The platform config OS and architecture in a Container. The format is [os]/[platform]/[version] (e.g. darwin/arm64/v7, windows/amd64, linux/arm64).

Return type:

Platform

directory(id: DirectoryID | None = None) Directory[source]

Load a directory by ID. No argument produces an empty directory.

file(id: FileID) File[source]

Loads a file by ID.

git(url: str, keep_git_dir: bool | None = None) GitRepository[source]

Queries a git repository.

host() Host[source]

Queries the host environment.

http(url: str) File[source]

Returns a file containing an http remote url content.

pipeline(name: str, description: str | None = None) Client[source]

Creates a named sub-pipeline

project(name: str) Project[source]

Look up a project by name

secret(id: SecretID) Secret[source]

Loads a secret from its ID.

socket(id: SocketID | None = None) Socket[source]

Loads a socket by its ID.

class dagger.api.gen.Container(ctx: Context)[source]

An OCI-compatible container, also known as a docker container.

build(context: Directory, dockerfile: str | None = None, build_args: Sequence[BuildArg] | None = None, target: str | None = None) Container[source]

Initializes this container from a Dockerfile build, using the context, a dockerfile file path and some additional buildArgs.

Parameters:
  • context – Directory context used by the Dockerfile.

  • dockerfile – Path to the Dockerfile to use. Defaults to ‘./Dockerfile’.

  • build_args – Additional build arguments.

  • target – Target build stage to build.

default_args() list[str] | None[source]

Retrieves default arguments for future commands.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

Optional[list[str]]

directory(path: str) Directory[source]

Retrieves a directory at the given path. Mounts are included.

entrypoint() list[str] | None[source]

Retrieves entrypoint to be prepended to the arguments of all commands.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

Optional[list[str]]

env_variable(name: str) str | None[source]

Retrieves the value of the specified environment variable.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

Optional[str]

env_variables() EnvVariable[source]

Retrieves the list of environment variables passed to commands.

exec(args: Sequence[str] | None = None, stdin: str | None = None, redirect_stdout: str | None = None, redirect_stderr: str | None = None, experimental_privileged_nesting: bool | None = None) Container[source]

Retrieves this container after executing the specified command inside it.

Deprecated

Replaced by with_exec().

Parameters:
  • args – Command to run instead of the container’s default command.

  • stdin – Content to write to the command’s standard input before closing.

  • redirect_stdout – Redirect the command’s standard output to a file in the container.

  • redirect_stderr – Redirect the command’s standard error to a file in the container.

  • experimental_privileged_nesting – Provide dagger access to the executed command. Do not use this option unless you trust the command being executed. The command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM.

exit_code() int | None[source]

Exit code of the last executed command. Zero means success.

Null if no command has been executed.

Returns:

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

Return type:

Optional[int]

export(path: str, platform_variants: Sequence[Container] | None = None) bool[source]

Writes the container as an OCI tarball to the destination file path on the host for the specified platformVariants.

Return true on success.

Parameters:
  • path – Host’s destination path. Path can be relative to the engine’s workdir or absolute.

  • platform_variants – Identifiers for other platform specific containers. Used for multi-platform image.

Returns:

The Boolean scalar type represents true or false.

Return type:

bool

file(path: str) File[source]

Retrieves a file at the given path. Mounts are included.

from_(address: str) Container[source]

Initializes this container from the base image published at the given address.

Parameters:

address – Image’s address from its registry. Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main).

fs() Directory[source]

Retrieves this container’s root filesystem. Mounts are not included.

Deprecated

Replaced by rootfs().

id() ContainerID[source]

A unique identifier for this container.

Note

This is lazyly evaluated, no operation is actually run.

Returns:

A unique container identifier. Null designates an empty container (scratch).

Return type:

ContainerID

label(name: str) str | None[source]

Retrieves the value of the specified label.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

Optional[str]

labels() Label[source]

Retrieves the list of labels passed to container.

mounts() list[str][source]

Retrieves the list of paths where a directory is mounted.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

list[str]

pipeline(name: str, description: str | None = None) Container[source]

Creates a named sub-pipeline

platform() Platform[source]

The platform this container executes and publishes as.

Returns:

The platform config OS and architecture in a Container. The format is [os]/[platform]/[version] (e.g. darwin/arm64/v7, windows/amd64, linux/arm64).

Return type:

Platform

publish(address: str, platform_variants: Sequence[Container] | None = None) str[source]

Publishes this container as a new image to the specified address, for the platformVariants, returning a fully qualified ref.

Parameters:
  • address – Registry’s address to publish the image to. Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main).

  • platform_variants – Identifiers for other platform specific containers. Used for multi-platform image.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

rootfs() Directory[source]

Retrieves this container’s root filesystem. Mounts are not included.

stderr() str | None[source]

The error stream of the last executed command.

Null if no command has been executed.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

Optional[str]

stdout() str | None[source]

The output stream of the last executed command.

Null if no command has been executed.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

Optional[str]

user() str | None[source]

Retrieves the user to be set for all commands.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

Optional[str]

with_default_args(args: Sequence[str] | None = None) Container[source]

Configures default arguments for future commands.

with_directory(path: str, directory: Directory, exclude: Sequence[str] | None = None, include: Sequence[str] | None = None) Container[source]

Retrieves this container plus a directory written at the given path.

with_entrypoint(args: Sequence[str]) Container[source]

Retrieves this container but with a different command entrypoint.

with_env_variable(name: str, value: str) Container[source]

Retrieves this container plus the given environment variable.

with_exec(args: Sequence[str], stdin: str | None = None, redirect_stdout: str | None = None, redirect_stderr: str | None = None, experimental_privileged_nesting: bool | None = None) Container[source]

Retrieves this container after executing the specified command inside it.

Parameters:
  • args – Command to run instead of the container’s default command.

  • stdin – Content to write to the command’s standard input before closing.

  • redirect_stdout – Redirect the command’s standard output to a file in the container.

  • redirect_stderr – Redirect the command’s standard error to a file in the container.

  • experimental_privileged_nesting – Provide dagger access to the executed command. Do not use this option unless you trust the command being executed. The command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM.

with_file(path: str, source: File, permissions: int | None = None) Container[source]

Retrieves this container plus the contents of the given file copied to the given path.

with_fs(id: Directory) Container[source]

Initializes this container from this DirectoryID.

Deprecated

Replaced by with_rootfs().

with_label(name: str, value: str) Container[source]

Retrieves this container plus the given label.

with_mounted_cache(path: str, cache: CacheVolume, source: Directory | None = None, sharing: CacheSharingMode | None = None) Container[source]

Retrieves this container plus a cache volume mounted at the given path.

Parameters:
  • path – Path to mount the cache volume at.

  • cache – ID of the cache to mount.

  • source – Directory to use as the cache volume’s root.

  • sharing – Sharing mode of the cache volume.

with_mounted_directory(path: str, source: Directory) Container[source]

Retrieves this container plus a directory mounted at the given path.

with_mounted_file(path: str, source: File) Container[source]

Retrieves this container plus a file mounted at the given path.

with_mounted_secret(path: str, source: Secret) Container[source]

Retrieves this container plus a secret mounted into a file at the given path.

with_mounted_temp(path: str) Container[source]

Retrieves this container plus a temporary directory mounted at the given path.

with_new_file(path: str, contents: str | None = None, permissions: int | None = None) Container[source]

Retrieves this container plus a new file written at the given path.

with_registry_auth(address: str, username: str, secret: Secret) Container[source]

Retrieves this container with a registry authentication for a given address.

Parameters:
  • address – Registry’s address to bind the authentication to. Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main).

  • username – The username of the registry’s account (e.g., “Dagger”).

  • secret – The API key, password or token to authenticate to this registry.

with_rootfs(id: Directory) Container[source]

Initializes this container from this DirectoryID.

with_secret_variable(name: str, secret: Secret) Container[source]

Retrieves this container plus an env variable containing the given secret.

with_unix_socket(path: str, source: Socket) Container[source]

Retrieves this container plus a socket forwarded to the given Unix socket path.

with_user(name: str) Container[source]

Retrieves this containers with a different command user.

with_workdir(path: str) Container[source]

Retrieves this container with a different working directory.

without_env_variable(name: str) Container[source]

Retrieves this container minus the given environment variable.

without_label(name: str) Container[source]

Retrieves this container minus the given environment label.

without_mount(path: str) Container[source]

Retrieves this container after unmounting everything at the given path.

without_registry_auth(address: str) Container[source]

Retrieves this container without the registry authentication of a given address.

Parameters:

address – Registry’s address to remove the authentication from. Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main).

without_unix_socket(path: str) Container[source]

Retrieves this container with a previously added Unix socket removed.

workdir() str | None[source]

Retrieves the working directory for all commands.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

Optional[str]

class dagger.api.gen.ContainerID[source]

A unique container identifier. Null designates an empty container (scratch).

class dagger.api.gen.Directory(ctx: Context)[source]

A directory.

diff(other: Directory) Directory[source]

Gets the difference between this directory and an another directory.

directory(path: str) Directory[source]

Retrieves a directory at the given path.

docker_build(dockerfile: str | None = None, platform: Platform | None = None, build_args: Sequence[BuildArg] | None = None, target: str | None = None) Container[source]

Builds a new Docker container from this directory.

Parameters:
  • dockerfile – Path to the Dockerfile to use. Defaults to ‘./Dockerfile’.

  • platform – The platform to build.

  • build_args – Additional build arguments.

  • target – Target build stage to build.

entries(path: str | None = None) list[str][source]

Returns a list of files and directories at the given path.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

list[str]

export(path: str) bool[source]

Writes the contents of the directory to a path on the host.

Returns:

The Boolean scalar type represents true or false.

Return type:

bool

file(path: str) File[source]

Retrieves a file at the given path.

id() DirectoryID[source]

The content-addressed identifier of the directory.

Note

This is lazyly evaluated, no operation is actually run.

Returns:

A content-addressed directory identifier.

Return type:

DirectoryID

load_project(config_path: str) Project[source]

load a project’s metadata

pipeline(name: str, description: str | None = None) Directory[source]

Creates a named sub-pipeline.

with_directory(path: str, directory: Directory, exclude: Sequence[str] | None = None, include: Sequence[str] | None = None) Directory[source]

Retrieves this directory plus a directory written at the given path.

Parameters:
  • path

  • directory

  • exclude – Exclude artifacts that match the given pattern. (e.g. [“node_modules/”, “.git*”]).

  • include – Include only artifacts that match the given pattern. (e.g. [“app/”, “package.*”]).

with_file(path: str, source: File, permissions: int | None = None) Directory[source]

Retrieves this directory plus the contents of the given file copied to the given path.

with_new_directory(path: str, permissions: int | None = None) Directory[source]

Retrieves this directory plus a new directory created at the given path.

with_new_file(path: str, contents: str, permissions: int | None = None) Directory[source]

Retrieves this directory plus a new file written at the given path.

with_timestamps(timestamp: int) Directory[source]

Retrieves this directory with all file/dir timestamps set to the given time, in seconds from the Unix epoch.

without_directory(path: str) Directory[source]

Retrieves this directory with the directory at the given path removed.

without_file(path: str) Directory[source]

Retrieves this directory with the file at the given path removed.

class dagger.api.gen.DirectoryID[source]

A content-addressed directory identifier.

class dagger.api.gen.EnvVariable(ctx: Context)[source]

A simple key value object that represents an environment variable.

name() str[source]

The environment variable name.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

value() str[source]

The environment variable value.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

class dagger.api.gen.File(ctx: Context)[source]

A file.

contents() str[source]

Retrieves the contents of the file.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

export(path: str) bool[source]

Writes the file to a file path on the host.

Returns:

The Boolean scalar type represents true or false.

Return type:

bool

id() FileID[source]

Retrieves the content-addressed identifier of the file.

Note

This is lazyly evaluated, no operation is actually run.

Returns:

A file identifier.

Return type:

FileID

secret() Secret[source]

Retrieves a secret referencing the contents of this file.

size() int[source]

Gets the size of the file, in bytes.

Returns:

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

Return type:

int

with_timestamps(timestamp: int) File[source]

Retrieves this file with its created/modified timestamps set to the given time, in seconds from the Unix epoch.

class dagger.api.gen.FileID[source]

A file identifier.

class dagger.api.gen.GitRef(ctx: Context)[source]

A git ref (tag, branch or commit).

digest() str[source]

The digest of the current value of this ref.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

tree(ssh_known_hosts: str | None = None, ssh_auth_socket: Socket | None = None) Directory[source]

The filesystem tree at this ref.

class dagger.api.gen.GitRepository(ctx: Context)[source]

A git repository.

branch(name: str) GitRef[source]

Returns details on one branch.

branches() list[str][source]

Lists of branches on the repository.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

list[str]

commit(id: str) GitRef[source]

Returns details on one commit.

tag(name: str) GitRef[source]

Returns details on one tag.

tags() list[str][source]

Lists of tags on the repository.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

list[str]

class dagger.api.gen.Host(ctx: Context)[source]

Information about the host execution environment.

directory(path: str, exclude: Sequence[str] | None = None, include: Sequence[str] | None = None) Directory[source]

Accesses a directory on the host.

env_variable(name: str) HostVariable[source]

Accesses an environment variable on the host.

unix_socket(path: str) Socket[source]

Accesses a Unix socket on the host.

workdir(exclude: Sequence[str] | None = None, include: Sequence[str] | None = None) Directory[source]

Retrieves the current working directory on the host.

Deprecated

Use directory() with path set to ‘.’ instead.

class dagger.api.gen.HostVariable(ctx: Context)[source]

An environment variable on the host environment.

secret() Secret[source]

A secret referencing the value of this variable.

value() str[source]

The value of this variable.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

class dagger.api.gen.Label(ctx: Context)[source]

A simple key value object that represents a label.

name() str[source]

The label name.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

value() str[source]

The label value.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

class dagger.api.gen.Platform[source]

The platform config OS and architecture in a Container. The format is [os]/[platform]/[version] (e.g. darwin/arm64/v7, windows/amd64, linux/arm64).

class dagger.api.gen.Project(ctx: Context)[source]

A set of scripts and/or extensions

extensions() Project[source]

extensions in this project

generated_code() Directory[source]

Code files generated by the SDKs in the project

install() bool[source]

install the project’s schema

Returns:

The Boolean scalar type represents true or false.

Return type:

bool

name() str[source]

name of the project

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

schema() str | None[source]

schema provided by the project

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

Optional[str]

sdk() str | None[source]

sdk used to generate code for and/or execute this project

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

Optional[str]

class dagger.api.gen.Secret(ctx: Context)[source]

A reference to a secret value, which can be handled more safely than the value itself.

id() SecretID[source]

The identifier for this secret.

Note

This is lazyly evaluated, no operation is actually run.

Returns:

A unique identifier for a secret.

Return type:

SecretID

plaintext() str[source]

The value of this secret.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

class dagger.api.gen.SecretID[source]

A unique identifier for a secret.

class dagger.api.gen.Socket(ctx: Context)[source]
id() SocketID[source]

The content-addressed identifier of the socket.

Note

This is lazyly evaluated, no operation is actually run.

Returns:

A content-addressed socket identifier.

Return type:

SocketID

class dagger.api.gen.SocketID[source]

A content-addressed socket identifier.