Client

Automatically generated client from Dagger API.

class dagger.api.gen.BuildArg[source]

Key value object that represents a build argument.

name: str

The build argument name.

value: str

The build argument value.

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

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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., “modules- 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

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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, experimental_service_host: Container | None = None) GitRepository[source]

Queries a git repository.

Parameters:
  • url – Url of the git repository. Can be formatted as https://{host}/{owner}/{repo}, git@{host}/{owner}/{repo} Suffix “.git” is optional.

  • keep_git_dir – Set to true to keep .git directory.

  • experimental_service_host – A service which must be started before the repo is fetched.

host() Host[source]

Queries the host environment.

http(url: str, experimental_service_host: Container | None = None) File[source]

Returns a file containing an http remote url content.

Parameters:
  • url – HTTP url to get the content from (e.g., “https://docs.dagger.io”).

  • experimental_service_host – A service which must be started before the URL is fetched.

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.

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

  • dockerfile – Path to the Dockerfile to use. Default: ‘./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]]

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

directory(path: str) Directory[source]

Retrieves a directory at the given path.

Mounts are included.

Parameters:

path – The path of the directory to retrieve (e.g., “./src”).

endpoint(port: int | None = None, scheme: str | None = None) str[source]

Retrieves an endpoint that clients can use to reach this container.

If no port is specified, the first exposed port is used. If none exist an error is returned.

If a scheme is specified, a URL is returned. Otherwise, a host:port pair is returned.

Parameters:
  • port – The exposed port number for the endpoint

  • scheme – Return a URL with the given scheme, eg. http for http://

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

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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]]

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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

Retrieves the value of the specified environment variable.

Parameters:

name – The name of the environment variable to retrieve (e.g., “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:

Optional[str]

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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 (e.g., [“run”, “main.go”]).

  • stdin – Content to write to the command’s standard input before closing (e.g., “Hello world”).

  • redirect_stdout – Redirect the command’s standard output to a file in the container (e.g., “/tmp/stdout”).

  • redirect_stderr – Redirect the command’s standard error to a file in the container (e.g., “/tmp/stderr”).

  • 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]

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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 platform variants.

Return true on success.

It can also publishes platform variants.

Parameters:
  • path – Host’s destination path (e.g., “./tarball”). 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

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

exposed_ports() Port[source]

Retrieves the list of exposed ports

file(path: str) File[source]

Retrieves a file at the given path.

Mounts are included.

Parameters:

path – The path of the file to retrieve (e.g., “./README.md”).

from_(address: str) Container[source]

Initializes this container from a pulled base image.

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().

hostname() str[source]

Retrieves a hostname which can be used by clients to reach this container.

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

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

image_ref() str | None[source]

The unique image reference which can only be retrieved immediately after the ‘Container.From’ call.

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]

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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]

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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]

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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

Publishes this container as a new image to the specified address.

Publish returns a fully qualified ref.

It can also publish platform variants.

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

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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]

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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]

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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]

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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

Configures default arguments for future commands.

Parameters:

args – Arguments to prepend to future executions (e.g., [“-v”, “–no- cache”]).

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.

Parameters:
  • path – Location of the written directory (e.g., “/tmp/directory”).

  • directory – Identifier of the directory to write

  • exclude – Patterns to exclude in the written directory (e.g., [“node_modules/**”, “.gitignore”, “.git/”]).

  • include – Patterns to include in the written directory (e.g., [”*.go”, “go.mod”, “go.sum”]).

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

Retrieves this container but with a different command entrypoint.

Parameters:

args – Entrypoint to use for future executions (e.g., [“go”, “run”]).

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

Retrieves this container plus the given environment variable.

Parameters:
  • name – The name of the environment variable (e.g., “HOST”).

  • value – The value of the environment variable. (e.g., “localhost”).

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 (e.g., [“run”, “main.go”]).

  • stdin – Content to write to the command’s standard input before closing (e.g., “Hello world”).

  • redirect_stdout – Redirect the command’s standard output to a file in the container (e.g., “/tmp/stdout”).

  • redirect_stderr – Redirect the command’s standard error to a file in the container (e.g., “/tmp/stderr”).

  • experimental_privileged_nesting – Provides 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_exposed_port(port: int, protocol: NetworkProtocol | None = None, description: str | None = None) Container[source]

Expose a network port.

Exposed ports serve two purposes:

  • For health checks and introspection, when running services

  • For setting the EXPOSE OCI field when publishing the container

Parameters:
  • port – Port number to expose

  • protocol – Transport layer network protocol

  • description – Optional port description

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.

Parameters:
  • path – Location of the copied file (e.g., “/tmp/file.txt”).

  • source – Identifier of the file to copy.

  • permissions – Permission given to the copied file (e.g., 0600). Default: 0644.

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.

Parameters:
  • name – The name of the label (e.g., “org.opencontainers.artifact.created”).

  • value – The value of the label (e.g., “2023-01-01T00:00:00Z”).

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 – Location of the cache directory (e.g., “/cache/node_modules”).

  • cache – Identifier of the cache volume to mount.

  • source – Identifier of the 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.

Parameters:
  • path – Location of the mounted directory (e.g., “/mnt/directory”).

  • source – Identifier of the mounted directory.

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

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

Parameters:
  • path – Location of the mounted file (e.g., “/tmp/file.txt”).

  • source – Identifier of the mounted file.

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

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

Parameters:
  • path – Location of the secret file (e.g., “/tmp/secret.txt”).

  • source – Identifier of the secret to mount.

with_mounted_temp(path: str) Container[source]

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

Parameters:

path – Location of the temporary directory (e.g., “/tmp/temp_dir”).

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.

Parameters:
  • path – Location of the written file (e.g., “/tmp/file.txt”).

  • contents – Content of the file to write (e.g., “Hello world!”).

  • permissions – Permission given to the written file (e.g., 0600). Default: 0644.

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.

Parameters:
  • name – The name of the secret variable (e.g., “API_SECRET”).

  • secret – The identifier of the secret value.

with_service_binding(alias: str, service: Container) Container[source]

Establish a runtime dependency on a service. The service will be started automatically when needed and detached when it is no longer needed.

The service will be reachable from the container via the provided hostname alias.

The service dependency will also convey to any files or directories produced by the container.

Parameters:
  • alias – A name that can be used to reach the service from the container

  • service – Identifier of the service container

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

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

Parameters:
  • path – Location of the forwarded Unix socket (e.g., “/tmp/socket”).

  • source – Identifier of the socket to forward.

with_user(name: str) Container[source]

Retrieves this container with a different command user.

Parameters:

name – The user to set (e.g., “root”).

with_workdir(path: str) Container[source]

Retrieves this container with a different working directory.

Parameters:

path – The path to set as the working directory (e.g., “/app”).

without_env_variable(name: str) Container[source]

Retrieves this container minus the given environment variable.

Parameters:

name – The name of the environment variable (e.g., “HOST”).

without_exposed_port(port: int, protocol: NetworkProtocol | None = None) Container[source]

Unexpose a previously exposed port.

Parameters:
  • port – Port number to unexpose

  • protocol – Port protocol to unexpose

without_label(name: str) Container[source]

Retrieves this container minus the given environment label.

Parameters:

name – The name of the label to remove (e.g., “org.opencontainers.artifact.created”).

without_mount(path: str) Container[source]

Retrieves this container after unmounting everything at the given path.

Parameters:

path – Location of the cache directory (e.g., “/cache/node_modules”).

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.

Parameters:

path – Location of the socket to remove (e.g., “/tmp/socket”).

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]

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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.

Parameters:

other – Identifier of the directory to compare.

directory(path: str) Directory[source]

Retrieves a directory at the given path.

Parameters:

path – Location of the directory to retrieve (e.g., “/src”).

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 (e.g., “frontend.Dockerfile”). Defaults: ‘./Dockerfile’.

  • platform – The platform to build.

  • build_args – Build arguments to use in the build.

  • 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.

Parameters:

path – Location of the directory to look at (e.g., “/src”).

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]

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

export(path: str) bool[source]

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

Parameters:

path – Location of the copied directory (e.g., “logs/”).

Returns:

The Boolean scalar type represents true or false.

Return type:

bool

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

file(path: str) File[source]

Retrieves a file at the given path.

Parameters:

path – Location of the file to retrieve (e.g., “README.md”).

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

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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 – Location of the written directory (e.g., “/src/”).

  • directory – Identifier of the directory to copy.

  • 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.

Parameters:
  • path – Location of the copied file (e.g., “/file.txt”).

  • source – Identifier of the file to copy.

  • permissions – Permission given to the copied file (e.g., 0600). Default: 0644.

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

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

Parameters:
  • path – Location of the directory created (e.g., “/logs”).

  • permissions – Permission granted to the created directory (e.g., 0777). Default: 0755.

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.

Parameters:
  • path – Location of the written file (e.g., “/file.txt”).

  • contents – Content of the written file (e.g., “Hello world!”).

  • permissions – Permission given to the copied file (e.g., 0600). Default: 0644.

with_timestamps(timestamp: int) Directory[source]

Retrieves this directory with all file/dir timestamps set to the given time.

Parameters:

timestamp – Timestamp to set dir/files in. Formatted in seconds following Unix epoch (e.g., 1672531199).

without_directory(path: str) Directory[source]

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

Parameters:

path – Location of the directory to remove (e.g., “.github/”).

without_file(path: str) Directory[source]

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

Parameters:

path – Location of the file to remove (e.g., “/file.txt”).

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

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

export(path: str) bool[source]

Writes the file to a file path on the host.

Parameters:

path – Location of the written directory (e.g., “output.txt”).

Returns:

The Boolean scalar type represents true or false.

Return type:

bool

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

with_timestamps(timestamp: int) File[source]

Retrieves this file with its created/modified timestamps set to the given time.

Parameters:

timestamp – Timestamp to set dir/files in. Formatted in seconds following Unix epoch (e.g., 1672531199).

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

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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.

Parameters:

name – Branch’s name (e.g., “main”).

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]

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

commit(id: str) GitRef[source]

Returns details on one commit.

Parameters:

id – Identifier of the commit (e.g., “b6315d8f2810962c601af73f86831f6866ea798b”).

tag(name: str) GitRef[source]

Returns details on one tag.

Parameters:

name – Tag’s name (e.g., “v0.3.9”).

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]

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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.

Parameters:
  • path – Location of the directory to access (e.g., “.”).

  • 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.*”]).

env_variable(name: str) HostVariable[source]

Accesses an environment variable on the host.

Parameters:

name – Name of the environment variable (e.g., “PATH”).

unix_socket(path: str) Socket[source]

Accesses a Unix socket on the host.

Parameters:

path – Location of the Unix socket (e.g., “/var/run/docker.sock”).

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.

Parameters:
  • 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.*”]).

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

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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

Transport layer network protocol associated to a port.

TCP(Transmission Control Protocol) = 'TCP'

TCP (Transmission Control Protocol)

UDP(User Datagram Protocol) = 'UDP'

UDP (User Datagram Protocol)

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.Port(ctx: Context)[source]

A port exposed by a container.

description() str | None[source]

The port description.

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]

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

port() int[source]

The port number.

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

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

protocol() NetworkProtocol[source]

The transport layer network protocol.

Returns:

Transport layer network protocol associated to a port.

Return type:

NetworkProtocol

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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]

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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]

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

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

Raises:
  • ExecuteTimeoutError – If the time to execute the query exceeds the configured timeout.

  • QueryError – If the API returns an error.

class dagger.api.gen.SocketID[source]

A content-addressed socket identifier.