Client¶
Automatically generated client from Dagger API.
- class dagger.api.gen.CacheVolume(ctx: Context)[source]¶
A directory whose contents persist across runs.
- 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:
- directory(id: DirectoryID | None = None) Directory [source]¶
Load a directory by ID. No argument produces an empty directory.
- 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.
- 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.
- 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:
- 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:
- 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]
- 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:
- 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:
- 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) Container [source]¶
Retrieves this container plus a cache volume mounted at the given path.
- 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_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_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.
- 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.
- 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.
- 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:
- 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:
- 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.
- class dagger.api.gen.EnvVariable(ctx: Context)[source]¶
A simple key value object that represents an environment variable.
- 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:
- 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:
- 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:
- class dagger.api.gen.GitRef(ctx: Context)[source]¶
A git ref (tag, branch or commit).
- class dagger.api.gen.GitRepository(ctx: Context)[source]¶
A git repository.
- 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.
- class dagger.api.gen.HostVariable(ctx: Context)[source]¶
An environment variable on the host environment.
- class dagger.api.gen.Label(ctx: Context)[source]¶
A simple key value object that represents a label.
- 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
- install() bool [source]¶
install the project’s schema
- Returns:
The Boolean scalar type represents true or false.
- Return type:
- 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:
- 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.