From 7040c6d7926b84b5be0d49751d037b8f97f4f55b Mon Sep 17 00:00:00 2001 From: matusdrobuliak66 Date: Sun, 23 Jul 2023 14:27:48 +0200 Subject: [PATCH 1/5] fix models-library mypy issues --- .github/workflows/ci-testing-deploy.yml | 4 + .../src/models_library/aiodocker_api.py | 6 +- .../api_schemas_long_running_tasks/base.py | 2 +- .../src/models_library/api_schemas_storage.py | 4 +- .../src/models_library/docker.py | 2 +- .../services/iter_range.py | 11 +- .../services/iter_sensitivity.py | 8 +- .../generated_models/docker_rest_api.py | 1480 ++++++++--------- .../src/models_library/generics.py | 2 +- .../src/models_library/projects.py | 4 +- .../src/models_library/projects_nodes.py | 2 +- .../src/models_library/projects_pipeline.py | 3 +- .../models_library/rest_pagination_utils.py | 14 +- .../models_library/service_settings_labels.py | 10 +- .../src/models_library/services_resources.py | 3 +- .../utils/database_models_factory.py | 16 +- .../models_library/utils/docker_compose.py | 3 +- .../models_library/utils/fastapi_encoders.py | 2 + .../src/models_library/utils/json_schema.py | 15 +- .../src/models_library/utils/nodes.py | 18 +- .../utils/specs_substitution.py | 3 +- 21 files changed, 802 insertions(+), 810 deletions(-) diff --git a/.github/workflows/ci-testing-deploy.yml b/.github/workflows/ci-testing-deploy.yml index b1d7bb45e36..3ab945abcd3 100644 --- a/.github/workflows/ci-testing-deploy.yml +++ b/.github/workflows/ci-testing-deploy.yml @@ -95,6 +95,8 @@ jobs: - 'packages/postgres-database/**' - 'packages/pytest-simcore/**' - 'services/docker-compose*' + - 'scripts/mypy/*' + - 'mypy.ini' postgres-database: - 'packages/postgres-database/**' - 'packages/pytest-simcore/**' @@ -1387,6 +1389,8 @@ jobs: run: ./ci/helpers/show_system_versions.bash - name: install run: ./ci/github/unit-testing/models-library.bash install + - name: typecheck + run: ./ci/github/unit-testing/models-library.bash typecheck - name: test run: ./ci/github/unit-testing/models-library.bash test - uses: codecov/codecov-action@v3.1.4 diff --git a/packages/models-library/src/models_library/aiodocker_api.py b/packages/models-library/src/models_library/aiodocker_api.py index aac732fb5d0..1aab4ba3441 100644 --- a/packages/models-library/src/models_library/aiodocker_api.py +++ b/packages/models-library/src/models_library/aiodocker_api.py @@ -11,7 +11,7 @@ class AioDockerContainerSpec(ContainerSpec): - Env: dict[str, str | None] | None = Field( + Env: dict[str, str | None] | None = Field( # type: ignore None, description="aiodocker expects here a dictionary and re-convert it back internally`.\n", ) @@ -37,7 +37,7 @@ class AioDockerResources1(Resources1): None, description="Define resources reservation.", alias="Reservations" ) - class Config(Resources1.Config): + class Config: allow_population_by_field_name = True @@ -55,6 +55,6 @@ class AioDockerTaskSpec(TaskSpec): class AioDockerServiceSpec(ServiceSpec): TaskTemplate: AioDockerTaskSpec | None = None - class Config(ServiceSpec.Config): + class Config: alias_generator = to_snake_case allow_population_by_field_name = True diff --git a/packages/models-library/src/models_library/api_schemas_long_running_tasks/base.py b/packages/models-library/src/models_library/api_schemas_long_running_tasks/base.py index e7aa11c9dd4..eb343ef361f 100644 --- a/packages/models-library/src/models_library/api_schemas_long_running_tasks/base.py +++ b/packages/models-library/src/models_library/api_schemas_long_running_tasks/base.py @@ -21,7 +21,7 @@ class TaskProgress(BaseModel): """ message: ProgressMessage = Field(default="") - percent: ProgressPercent = Field(default=0.0) + percent: ProgressPercent = Field(default=ProgressPercent(0.0)) @validate_arguments def update( diff --git a/packages/models-library/src/models_library/api_schemas_storage.py b/packages/models-library/src/models_library/api_schemas_storage.py index c888654f843..594c48e5136 100644 --- a/packages/models-library/src/models_library/api_schemas_storage.py +++ b/packages/models-library/src/models_library/api_schemas_storage.py @@ -131,7 +131,9 @@ class FileMetaDataGet(BaseModel): ) created_at: datetime last_modified: datetime - file_size: ByteSize = Field(-1, description="File size in bytes (-1 means invalid)") + file_size: ByteSize | int = Field( + -1, description="File size in bytes (-1 means invalid)" + ) entity_tag: ETag | None = Field( default=None, description="Entity tag (or ETag), represents a specific version of the file, None if invalid upload or datcore", diff --git a/packages/models-library/src/models_library/docker.py b/packages/models-library/src/models_library/docker.py index dcc7e487f54..b5a674a18c4 100644 --- a/packages/models-library/src/models_library/docker.py +++ b/packages/models-library/src/models_library/docker.py @@ -5,7 +5,7 @@ from models_library.generated_models.docker_rest_api import Task from models_library.products import ProductName from models_library.projects import ProjectID -from models_library.projects_nodes import NodeID +from models_library.projects_nodes_io import NodeID from models_library.users import UserID from pydantic import ( BaseModel, diff --git a/packages/models-library/src/models_library/function_services_catalog/services/iter_range.py b/packages/models-library/src/models_library/function_services_catalog/services/iter_range.py index a64d92d29eb..4267ff6881d 100644 --- a/packages/models-library/src/models_library/function_services_catalog/services/iter_range.py +++ b/packages/models-library/src/models_library/function_services_catalog/services/iter_range.py @@ -1,12 +1,12 @@ -from typing import Iterator, Optional +from typing import Iterator -from ...projects_nodes import OutputsDict +from ...projects_nodes import OutputID, OutputsDict from ...services import LATEST_INTEGRATION_VERSION, ServiceDockerData, ServiceType from .._key_labels import FUNCTION_SERVICE_KEY_PREFIX from .._utils import OM, FunctionServices, create_fake_thumbnail_url -def create_metadata(type_name: str, prefix: Optional[str] = None) -> ServiceDockerData: +def create_metadata(type_name: str, prefix: str | None = None) -> ServiceDockerData: prefix = prefix or type_name LABEL = f"{type_name.capitalize()} iterator" return ServiceDockerData.parse_obj( @@ -56,15 +56,14 @@ def create_metadata(type_name: str, prefix: Optional[str] = None) -> ServiceDock def _linspace_func( linspace_start: int = 0, linspace_stop: int = 1, linspace_step: int = 1 ) -> Iterator[int]: - for value in range(linspace_start, linspace_stop, linspace_step): - yield value + yield from range(linspace_start, linspace_stop, linspace_step) def _linspace_generator(**kwargs) -> Iterator[OutputsDict]: # Maps generator with iterable outputs. # Can have non-iterable outputs as well for value in _linspace_func(**kwargs): - yield {"out_1": value} + yield {OutputID("out_1"): value} services = FunctionServices() diff --git a/packages/models-library/src/models_library/function_services_catalog/services/iter_sensitivity.py b/packages/models-library/src/models_library/function_services_catalog/services/iter_sensitivity.py index efeb968fb41..955735547ea 100644 --- a/packages/models-library/src/models_library/function_services_catalog/services/iter_sensitivity.py +++ b/packages/models-library/src/models_library/function_services_catalog/services/iter_sensitivity.py @@ -3,7 +3,7 @@ from pydantic import schema_of -from ...projects_nodes import OutputsDict +from ...projects_nodes import OutputID, OutputsDict from ...services import LATEST_INTEGRATION_VERSION, ServiceDockerData, ServiceType from .._key_labels import FUNCTION_SERVICE_KEY_PREFIX from .._utils import EN, OM, FunctionServices, create_fake_thumbnail_url @@ -99,7 +99,11 @@ def _sensitivity_generator( for i, paramtestplus, paramtestminus in eval_sensitivity( paramrefs=paramrefs, paramdiff=paramdiff, diff_or_fact=diff_or_fact ): - yield {"out_1": i, "out_2": paramtestplus, "out_3": paramtestminus} + yield { + OutputID("out_1"): i, + OutputID("out_2"): paramtestplus, + OutputID("out_3"): paramtestminus, + } services = FunctionServices() diff --git a/packages/models-library/src/models_library/generated_models/docker_rest_api.py b/packages/models-library/src/models_library/generated_models/docker_rest_api.py index d4facc10e20..93434edd9dc 100644 --- a/packages/models-library/src/models_library/generated_models/docker_rest_api.py +++ b/packages/models-library/src/models_library/generated_models/docker_rest_api.py @@ -6,7 +6,7 @@ from datetime import datetime from enum import Enum -from typing import Any, Optional +from typing import Any from pydantic import BaseModel, Extra, Field @@ -26,11 +26,11 @@ class Port(BaseModel): An open port on a container """ - IP: Optional[str] = Field( + IP: str | None = Field( None, description="Host IP address that the container's port is mapped to" ) PrivatePort: int = Field(..., description="Port on the container") - PublicPort: Optional[int] = Field(None, description="Port exposed on the host") + PublicPort: int | None = Field(None, description="Port exposed on the host") Type: Type @@ -58,42 +58,42 @@ class MountPoint(BaseModel): """ - Type: Optional[Type1] = Field( + Type: Type1 | None = Field( None, description="The mount type:\n\n- `bind` a mount of a file or directory from the host into the container.\n- `volume` a docker volume with the given `Name`.\n- `tmpfs` a `tmpfs`.\n- `npipe` a named pipe from the host into the container.\n", example="volume", ) - Name: Optional[str] = Field( + Name: str | None = Field( None, description="Name is the name reference to the underlying data defined by `Source`\ne.g., the volume name.\n", example="myvolume", ) - Source: Optional[str] = Field( + Source: str | None = Field( None, description="Source location of the mount.\n\nFor volumes, this contains the storage location of the volume (within\n`/var/lib/docker/volumes/`). For bind-mounts, and `npipe`, this contains\nthe source (host) part of the bind-mount. For `tmpfs` mount points, this\nfield is empty.\n", example="/var/lib/docker/volumes/myvolume/_data", ) - Destination: Optional[str] = Field( + Destination: str | None = Field( None, description="Destination is the path relative to the container root (`/`) where\nthe `Source` is mounted inside the container.\n", example="/usr/share/nginx/html/", ) - Driver: Optional[str] = Field( + Driver: str | None = Field( None, description="Driver is the volume driver used to create the volume (if it is a volume).\n", example="local", ) - Mode: Optional[str] = Field( + Mode: str | None = Field( None, description='Mode is a comma separated list of options supplied by the user when\ncreating the bind/volume mount.\n\nThe default is platform-specific (`"z"` on Linux, empty on Windows).\n', example="z", ) - RW: Optional[bool] = Field( + RW: bool | None = Field( None, description="Whether the mount is mounted writable (read-write).\n", example=True, ) - Propagation: Optional[str] = Field( + Propagation: str | None = Field( None, description="Propagation describes how mounts are propagated from the host into the\nmount point, and vice-versa. Refer to the [Linux kernel documentation](https://www.kernel.org/doc/Documentation/filesystems/sharedsubtree.txt)\nfor details. This field is not used on Windows.\n", example="", @@ -105,9 +105,9 @@ class DeviceMapping(BaseModel): A device mapping between the host and container """ - PathOnHost: Optional[str] = None - PathInContainer: Optional[str] = None - CgroupPermissions: Optional[str] = None + PathOnHost: str | None = None + PathInContainer: str | None = None + CgroupPermissions: str | None = None class DeviceRequest(BaseModel): @@ -115,25 +115,25 @@ class DeviceRequest(BaseModel): A request for devices to be sent to device drivers """ - Driver: Optional[str] = Field(None, example="nvidia") - Count: Optional[int] = Field(None, example=-1) - DeviceIDs: Optional[list[str]] = Field( + Driver: str | None = Field(None, example="nvidia") + Count: int | None = Field(None, example=-1) + DeviceIDs: list[str] | None = Field( None, example=["0", "1", "GPU-fef8089b-4820-abfc-e83e-94318197576e"] ) - Capabilities: Optional[list[list[str]]] = Field( + Capabilities: list[list[str]] | None = Field( None, description="A list of capabilities; an OR list of AND lists of capabilities.\n", example=[["gpu", "nvidia", "compute"]], ) - Options: Optional[dict[str, str]] = Field( + Options: dict[str, str] | None = Field( None, description="Driver-specific options, specified as a key/value pairs. These options\nare passed directly to the driver.\n", ) class ThrottleDevice(BaseModel): - Path: Optional[str] = Field(None, description="Device path") - Rate: Optional[int] = Field(None, description="Rate", ge=0) + Path: str | None = Field(None, description="Device path") + Rate: int | None = Field(None, description="Rate", ge=0) class Propagation(str, Enum): @@ -154,11 +154,11 @@ class BindOptions(BaseModel): Optional configuration for the `bind` type. """ - Propagation: Optional[Propagation] = Field( + Propagation: Propagation | None = Field( None, description="A propagation mode with the value `[r]private`, `[r]shared`, or `[r]slave`.", ) - NonRecursive: Optional[bool] = Field( + NonRecursive: bool | None = Field( False, description="Disable recursive bind mount." ) @@ -168,10 +168,10 @@ class DriverConfig(BaseModel): Map of driver specific options """ - Name: Optional[str] = Field( + Name: str | None = Field( None, description="Name of the driver to use to create the volume." ) - Options: Optional[dict[str, str]] = Field( + Options: dict[str, str] | None = Field( None, description="key/value map of driver specific options." ) @@ -181,13 +181,13 @@ class VolumeOptions(BaseModel): Optional configuration for the `volume` type. """ - NoCopy: Optional[bool] = Field( + NoCopy: bool | None = Field( False, description="Populate volume with data from the target." ) - Labels: Optional[dict[str, str]] = Field( + Labels: dict[str, str] | None = Field( None, description="User-defined key/value metadata." ) - DriverConfig: Optional[DriverConfig] = Field( + DriverConfig: DriverConfig | None = Field( None, description="Map of driver specific options" ) @@ -197,37 +197,37 @@ class TmpfsOptions(BaseModel): Optional configuration for the `tmpfs` type. """ - SizeBytes: Optional[int] = Field( + SizeBytes: int | None = Field( None, description="The size for the tmpfs mount in bytes." ) - Mode: Optional[int] = Field( + Mode: int | None = Field( None, description="The permission mode for the tmpfs mount in an integer." ) class Mount(BaseModel): - Target: Optional[str] = Field(None, description="Container path.") - Source: Optional[str] = Field( + Target: str | None = Field(None, description="Container path.") + Source: str | None = Field( None, description="Mount source (e.g. a volume name, a host path)." ) - Type: Optional[Type1] = Field( + Type: Type1 | None = Field( None, description="The mount type. Available types:\n\n- `bind` Mounts a file or directory from the host into the container. Must exist prior to creating the container.\n- `volume` Creates a volume with the given name and options (or uses a pre-existing volume with the same name and options). These are **not** removed when the container is removed.\n- `tmpfs` Create a tmpfs with the given options. The mount source cannot be specified for tmpfs.\n- `npipe` Mounts a named pipe from the host into the container. Must exist prior to creating the container.\n", ) - ReadOnly: Optional[bool] = Field( + ReadOnly: bool | None = Field( None, description="Whether the mount should be read-only." ) - Consistency: Optional[str] = Field( + Consistency: str | None = Field( None, description="The consistency requirement for the mount: `default`, `consistent`, `cached`, or `delegated`.", ) - BindOptions: Optional[BindOptions] = Field( + BindOptions: BindOptions | None = Field( None, description="Optional configuration for the `bind` type." ) - VolumeOptions: Optional[VolumeOptions] = Field( + VolumeOptions: VolumeOptions | None = Field( None, description="Optional configuration for the `volume` type." ) - TmpfsOptions: Optional[TmpfsOptions] = Field( + TmpfsOptions: TmpfsOptions | None = Field( None, description="Optional configuration for the `tmpfs` type." ) @@ -259,25 +259,25 @@ class RestartPolicy(BaseModel): """ - Name: Optional[Name] = Field( + Name: Name | None = Field( None, description="- Empty string means not to restart\n- `no` Do not automatically restart\n- `always` Always restart\n- `unless-stopped` Restart always except when the user has manually stopped the container\n- `on-failure` Restart only when the container exit code is non-zero\n", ) - MaximumRetryCount: Optional[int] = Field( + MaximumRetryCount: int | None = Field( None, description="If `on-failure` is used, the number of times to retry before giving up.\n", ) class BlkioWeightDeviceItem(BaseModel): - Path: Optional[str] = None - Weight: Optional[int] = Field(None, ge=0) + Path: str | None = None + Weight: int | None = Field(None, ge=0) class Ulimit(BaseModel): - Name: Optional[str] = Field(None, description="Name of ulimit") - Soft: Optional[int] = Field(None, description="Soft limit") - Hard: Optional[int] = Field(None, description="Hard limit") + Name: str | None = Field(None, description="Name of ulimit") + Soft: int | None = Field(None, description="Soft limit") + Hard: int | None = Field(None, description="Hard limit") class Resources(BaseModel): @@ -285,123 +285,123 @@ class Resources(BaseModel): A container's resources (cgroups config, ulimits, etc) """ - CpuShares: Optional[int] = Field( + CpuShares: int | None = Field( None, description="An integer value representing this container's relative CPU weight\nversus other containers.\n", ) - Memory: Optional[int] = Field(0, description="Memory limit in bytes.") - CgroupParent: Optional[str] = Field( + Memory: int | None = Field(0, description="Memory limit in bytes.") + CgroupParent: str | None = Field( None, description="Path to `cgroups` under which the container's `cgroup` is created. If\nthe path is not absolute, the path is considered to be relative to the\n`cgroups` path of the init process. Cgroups are created if they do not\nalready exist.\n", ) - BlkioWeight: Optional[int] = Field( + BlkioWeight: int | None = Field( None, description="Block IO weight (relative weight).", ge=0, le=1000 ) - BlkioWeightDevice: Optional[list[BlkioWeightDeviceItem]] = Field( + BlkioWeightDevice: list[BlkioWeightDeviceItem] | None = Field( None, description='Block IO weight (relative device weight) in the form:\n\n```\n[{"Path": "device_path", "Weight": weight}]\n```\n', ) - BlkioDeviceReadBps: Optional[list[ThrottleDevice]] = Field( + BlkioDeviceReadBps: list[ThrottleDevice] | None = Field( None, description='Limit read rate (bytes per second) from a device, in the form:\n\n```\n[{"Path": "device_path", "Rate": rate}]\n```\n', ) - BlkioDeviceWriteBps: Optional[list[ThrottleDevice]] = Field( + BlkioDeviceWriteBps: list[ThrottleDevice] | None = Field( None, description='Limit write rate (bytes per second) to a device, in the form:\n\n```\n[{"Path": "device_path", "Rate": rate}]\n```\n', ) - BlkioDeviceReadIOps: Optional[list[ThrottleDevice]] = Field( + BlkioDeviceReadIOps: list[ThrottleDevice] | None = Field( None, description='Limit read rate (IO per second) from a device, in the form:\n\n```\n[{"Path": "device_path", "Rate": rate}]\n```\n', ) - BlkioDeviceWriteIOps: Optional[list[ThrottleDevice]] = Field( + BlkioDeviceWriteIOps: list[ThrottleDevice] | None = Field( None, description='Limit write rate (IO per second) to a device, in the form:\n\n```\n[{"Path": "device_path", "Rate": rate}]\n```\n', ) - CpuPeriod: Optional[int] = Field( + CpuPeriod: int | None = Field( None, description="The length of a CPU period in microseconds." ) - CpuQuota: Optional[int] = Field( + CpuQuota: int | None = Field( None, description="Microseconds of CPU time that the container can get in a CPU period.\n", ) - CpuRealtimePeriod: Optional[int] = Field( + CpuRealtimePeriod: int | None = Field( None, description="The length of a CPU real-time period in microseconds. Set to 0 to\nallocate no time allocated to real-time tasks.\n", ) - CpuRealtimeRuntime: Optional[int] = Field( + CpuRealtimeRuntime: int | None = Field( None, description="The length of a CPU real-time runtime in microseconds. Set to 0 to\nallocate no time allocated to real-time tasks.\n", ) - CpusetCpus: Optional[str] = Field( + CpusetCpus: str | None = Field( None, description="CPUs in which to allow execution (e.g., `0-3`, `0,1`).\n", example="0-3", ) - CpusetMems: Optional[str] = Field( + CpusetMems: str | None = Field( None, description="Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only\neffective on NUMA systems.\n", ) - Devices: Optional[list[DeviceMapping]] = Field( + Devices: list[DeviceMapping] | None = Field( None, description="A list of devices to add to the container." ) - DeviceCgroupRules: Optional[list[str]] = Field( + DeviceCgroupRules: list[str] | None = Field( None, description="a list of cgroup rules to apply to the container" ) - DeviceRequests: Optional[list[DeviceRequest]] = Field( + DeviceRequests: list[DeviceRequest] | None = Field( None, description="A list of requests for devices to be sent to device drivers.\n", ) - KernelMemory: Optional[int] = Field( + KernelMemory: int | None = Field( None, description="Kernel memory limit in bytes.\n\n


\n\n> **Deprecated**: This field is deprecated as the kernel 5.4 deprecated\n> `kmem.limit_in_bytes`.\n", example=209715200, ) - KernelMemoryTCP: Optional[int] = Field( + KernelMemoryTCP: int | None = Field( None, description="Hard limit for kernel TCP buffer memory (in bytes)." ) - MemoryReservation: Optional[int] = Field( + MemoryReservation: int | None = Field( None, description="Memory soft limit in bytes." ) - MemorySwap: Optional[int] = Field( + MemorySwap: int | None = Field( None, description="Total memory limit (memory + swap). Set as `-1` to enable unlimited\nswap.\n", ) - MemorySwappiness: Optional[int] = Field( + MemorySwappiness: int | None = Field( None, description="Tune a container's memory swappiness behavior. Accepts an integer\nbetween 0 and 100.\n", ge=0, le=100, ) - NanoCpus: Optional[int] = Field( + NanoCpus: int | None = Field( None, description="CPU quota in units of 10-9 CPUs." ) - OomKillDisable: Optional[bool] = Field( + OomKillDisable: bool | None = Field( None, description="Disable OOM Killer for the container." ) - Init: Optional[bool] = Field( + Init: bool | None = Field( None, description="Run an init inside the container that forwards signals and reaps\nprocesses. This field is omitted if empty, and the default (as\nconfigured on the daemon) is used.\n", ) - PidsLimit: Optional[int] = Field( + PidsLimit: int | None = Field( None, description="Tune a container's PIDs limit. Set `0` or `-1` for unlimited, or `null`\nto not change.\n", ) - Ulimits: Optional[list[Ulimit]] = Field( + Ulimits: list[Ulimit] | None = Field( None, description='A list of resource limits to set in the container. For example:\n\n```\n{"Name": "nofile", "Soft": 1024, "Hard": 2048}\n```\n', ) - CpuCount: Optional[int] = Field( + CpuCount: int | None = Field( None, description="The number of usable CPUs (Windows only).\n\nOn Windows Server containers, the processor resource controls are\nmutually exclusive. The order of precedence is `CPUCount` first, then\n`CPUShares`, and `CPUPercent` last.\n", ) - CpuPercent: Optional[int] = Field( + CpuPercent: int | None = Field( None, description="The usable percentage of the available CPUs (Windows only).\n\nOn Windows Server containers, the processor resource controls are\nmutually exclusive. The order of precedence is `CPUCount` first, then\n`CPUShares`, and `CPUPercent` last.\n", ) - IOMaximumIOps: Optional[int] = Field( + IOMaximumIOps: int | None = Field( None, description="Maximum IOps for the container system drive (Windows only)" ) - IOMaximumBandwidth: Optional[int] = Field( + IOMaximumBandwidth: int | None = Field( None, description="Maximum IO in bytes per second for the container system drive\n(Windows only).\n", ) @@ -413,9 +413,9 @@ class Limit(BaseModel): """ - NanoCPUs: Optional[int] = Field(None, example=4000000000) - MemoryBytes: Optional[int] = Field(None, example=8272408576) - Pids: Optional[int] = Field( + NanoCPUs: int | None = Field(None, example=4000000000) + MemoryBytes: int | None = Field(None, example=8272408576) + Pids: int | None = Field( 0, description="Limits the maximum number of PIDs in the container. Set `0` for unlimited.\n", example=100, @@ -423,18 +423,18 @@ class Limit(BaseModel): class NamedResourceSpec(BaseModel): - Kind: Optional[str] = None - Value: Optional[str] = None + Kind: str | None = None + Value: str | None = None class DiscreteResourceSpec(BaseModel): - Kind: Optional[str] = None - Value: Optional[int] = None + Kind: str | None = None + Value: int | None = None class GenericResource(BaseModel): - NamedResourceSpec: Optional[NamedResourceSpec] = None - DiscreteResourceSpec: Optional[DiscreteResourceSpec] = None + NamedResourceSpec: NamedResourceSpec | None = None + DiscreteResourceSpec: DiscreteResourceSpec | None = None class GenericResources(BaseModel): @@ -460,23 +460,23 @@ class HealthConfig(BaseModel): A test to perform to check that the container is healthy. """ - Test: Optional[list[str]] = Field( + Test: list[str] | None = Field( None, description='The test to perform. Possible values are:\n\n- `[]` inherit healthcheck from image or parent image\n- `["NONE"]` disable healthcheck\n- `["CMD", args...]` exec arguments directly\n- `["CMD-SHELL", command]` run command with system\'s default shell\n', ) - Interval: Optional[int] = Field( + Interval: int | None = Field( None, description="The time to wait between checks in nanoseconds. It should be 0 or at\nleast 1000000 (1 ms). 0 means inherit.\n", ) - Timeout: Optional[int] = Field( + Timeout: int | None = Field( None, description="The time to wait before considering the check to have hung. It should\nbe 0 or at least 1000000 (1 ms). 0 means inherit.\n", ) - Retries: Optional[int] = Field( + Retries: int | None = Field( None, description="The number of consecutive failures needed to consider a container as\nunhealthy. 0 means inherit.\n", ) - StartPeriod: Optional[int] = Field( + StartPeriod: int | None = Field( None, description="Start period for the container to initialize before starting\nhealth-retries countdown in nanoseconds. It should be 0 or at least\n1000000 (1 ms). 0 means inherit.\n", ) @@ -505,22 +505,22 @@ class HealthcheckResult(BaseModel): """ - Start: Optional[datetime] = Field( + Start: datetime | None = Field( None, description="Date and time at which this check started in\n[RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds.\n", example="2020-01-04T10:44:24.496525531Z", ) - End: Optional[str] = Field( + End: str | None = Field( None, description="Date and time at which this check ended in\n[RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds.\n", example="2020-01-04T10:45:21.364524523Z", ) - ExitCode: Optional[int] = Field( + ExitCode: int | None = Field( None, description="ExitCode meanings:\n\n- `0` healthy\n- `1` unhealthy\n- `2` reserved (considered unhealthy)\n- other values: error running probe\n", example=0, ) - Output: Optional[str] = Field(None, description="Output from last check") + Output: str | None = Field(None, description="Output from last check") class Type3(str, Enum): @@ -540,8 +540,8 @@ class LogConfig(BaseModel): The logging configuration for this container """ - Type: Optional[Type3] = None - Config_: Optional[dict[str, str]] = Field(None, alias="Config") + Type: Type3 | None = None + Config_: dict[str, str] | None = Field(None, alias="Config") class CgroupnsMode(str, Enum): @@ -588,82 +588,80 @@ class ContainerConfig(BaseModel): """ - Hostname: Optional[str] = Field( + Hostname: str | None = Field( None, description="The hostname to use for the container, as a valid RFC 1123 hostname.\n", example="439f4e91bd1d", ) - Domainname: Optional[str] = Field( + Domainname: str | None = Field( None, description="The domain name to use for the container.\n" ) - User: Optional[str] = Field( + User: str | None = Field( None, description="The user that commands are run as inside the container." ) - AttachStdin: Optional[bool] = Field( - False, description="Whether to attach to `stdin`." - ) - AttachStdout: Optional[bool] = Field( + AttachStdin: bool | None = Field(False, description="Whether to attach to `stdin`.") + AttachStdout: bool | None = Field( True, description="Whether to attach to `stdout`." ) - AttachStderr: Optional[bool] = Field( + AttachStderr: bool | None = Field( True, description="Whether to attach to `stderr`." ) - ExposedPorts: Optional[dict[str, dict[str, Any]]] = Field( + ExposedPorts: dict[str, dict[str, Any]] | None = Field( None, description='An object mapping ports to an empty object in the form:\n\n`{"/": {}}`\n', example={"80/tcp": {}, "443/tcp": {}}, ) - Tty: Optional[bool] = Field( + Tty: bool | None = Field( False, description="Attach standard streams to a TTY, including `stdin` if it is not closed.\n", ) - OpenStdin: Optional[bool] = Field(False, description="Open `stdin`") - StdinOnce: Optional[bool] = Field( + OpenStdin: bool | None = Field(False, description="Open `stdin`") + StdinOnce: bool | None = Field( False, description="Close `stdin` after one attached client disconnects" ) - Env: Optional[list[str]] = Field( + Env: list[str] | None = Field( None, description='A list of environment variables to set inside the container in the\nform `["VAR=value", ...]`. A variable without `=` is removed from the\nenvironment, rather than to have an empty value.\n', example=["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"], ) - Cmd: Optional[list[str]] = Field( + Cmd: list[str] | None = Field( None, description="Command to run specified as a string or an array of strings.\n", example=["/bin/sh"], ) - Healthcheck: Optional[HealthConfig] = None - ArgsEscaped: Optional[bool] = Field( + Healthcheck: HealthConfig | None = None + ArgsEscaped: bool | None = Field( False, description="Command is already escaped (Windows only)", example=False ) - Image: Optional[str] = Field( + Image: str | None = Field( None, description="The name (or reference) of the image to use when creating the container,\nor which was used when the container was created.\n", example="example-image:1.0", ) - Volumes: Optional[dict[str, dict[str, Any]]] = Field( + Volumes: dict[str, dict[str, Any]] | None = Field( None, description="An object mapping mount point paths inside the container to empty\nobjects.\n", ) - WorkingDir: Optional[str] = Field( + WorkingDir: str | None = Field( None, description="The working directory for commands to run in.", example="/public/", ) - Entrypoint: Optional[list[str]] = Field( + Entrypoint: list[str] | None = Field( None, description='The entry point for the container as a string or an array of strings.\n\nIf the array consists of exactly one empty string (`[""]`) then the\nentry point is reset to system default (i.e., the entry point used by\ndocker when there is no `ENTRYPOINT` instruction in the `Dockerfile`).\n', example=[], ) - NetworkDisabled: Optional[bool] = Field( + NetworkDisabled: bool | None = Field( None, description="Disable networking for the container." ) - MacAddress: Optional[str] = Field(None, description="MAC address of the container.") - OnBuild: Optional[list[str]] = Field( + MacAddress: str | None = Field(None, description="MAC address of the container.") + OnBuild: list[str] | None = Field( None, description="`ONBUILD` metadata that were defined in the image's `Dockerfile`.\n", example=[], ) - Labels: Optional[dict[str, str]] = Field( + Labels: dict[str, str] | None = Field( None, description="User-defined key/value metadata.", example={ @@ -671,15 +669,15 @@ class ContainerConfig(BaseModel): "com.example.some-other-label": "some-other-value", }, ) - StopSignal: Optional[str] = Field( + StopSignal: str | None = Field( None, description="Signal to stop a container as a string or unsigned integer.\n", example="SIGTERM", ) - StopTimeout: Optional[int] = Field( + StopTimeout: int | None = Field( 10, description="Timeout to stop a container in seconds." ) - Shell: Optional[list[str]] = Field( + Shell: list[str] | None = Field( None, description="Shell for when `RUN`, `CMD`, and `ENTRYPOINT` uses a shell.\n", example=["/bin/sh", "-c"], @@ -691,8 +689,8 @@ class Address(BaseModel): Address represents an IPv4 or IPv6 IP address. """ - Addr: Optional[str] = Field(None, description="IP address.") - PrefixLen: Optional[int] = Field(None, description="Mask length of the IP address.") + Addr: str | None = Field(None, description="IP address.") + PrefixLen: int | None = Field(None, description="Mask length of the IP address.") class PortMap(BaseModel): @@ -706,8 +704,6 @@ class PortMap(BaseModel): """ - pass - class Config: extra = Extra.allow @@ -719,12 +715,12 @@ class PortBinding(BaseModel): """ - HostIp: Optional[str] = Field( + HostIp: str | None = Field( None, description="Host IP address that the container's port is mapped to.", example="127.0.0.1", ) - HostPort: Optional[str] = Field( + HostPort: str | None = Field( None, description="Host port number that the container's port is mapped to.", example="4443", @@ -759,7 +755,7 @@ class RootFS(BaseModel): """ Type: str = Field(..., example="layers") - Layers: Optional[list[str]] = Field( + Layers: list[str] | None = Field( None, example=[ "sha256:1834950e52ce4d5a88a1bbd131c537f4d0e56d10ff0dd69e66be3b7dfa9df7e6", @@ -775,7 +771,7 @@ class Metadata(BaseModel): """ - LastTagTime: Optional[str] = Field( + LastTagTime: str | None = Field( None, description="Date and time at which the image was last tagged in\n[RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds.\n\nThis information is only available if the image was tagged locally,\nand omitted otherwise.\n", example="2022-02-28T14:40:02.623929178Z", @@ -788,12 +784,12 @@ class ImageInspect(BaseModel): """ - Id: Optional[str] = Field( + Id: str | None = Field( None, description="ID is the content-addressable ID of an image.\n\nThis identifier is a content-addressable digest calculated from the\nimage's configuration (which includes the digests of layers used by\nthe image).\n\nNote that this digest differs from the `RepoDigests` below, which\nholds digests of image manifests that reference the image.\n", example="sha256:ec3f0931a6e6b6855d76b2d7b0be30e81860baccd891b2e243280bf1cd8ad710", ) - RepoTags: Optional[list[str]] = Field( + RepoTags: list[str] | None = Field( None, description='List of image names/tags in the local image cache that reference this\nimage.\n\nMultiple image tags can refer to the same imagem and this list may be\nempty if no tags reference the image, in which case the image is\n"untagged", in which case it can still be referenced by its ID.\n', example=[ @@ -803,7 +799,7 @@ class ImageInspect(BaseModel): "internal.registry.example.com:5000/example:1.0", ], ) - RepoDigests: Optional[list[str]] = Field( + RepoDigests: list[str] | None = Field( None, description="List of content-addressable digests of locally available image manifests\nthat the image is referenced from. Multiple manifests can refer to the\nsame image.\n\nThese digests are usually only available if the image was either pulled\nfrom a registry, or if the image was pushed to a registry, which is when\nthe manifest is generated and its digest calculated.\n", example=[ @@ -811,74 +807,74 @@ class ImageInspect(BaseModel): "internal.registry.example.com:5000/example@sha256:b69959407d21e8a062e0416bf13405bb2b71ed7a84dde4158ebafacfa06f5578", ], ) - Parent: Optional[str] = Field( + Parent: str | None = Field( None, description="ID of the parent image.\n\nDepending on how the image was created, this field may be empty and\nis only set for images that were built/created locally. This field\nis empty if the image was pulled from an image registry.\n", example="", ) - Comment: Optional[str] = Field( + Comment: str | None = Field( None, description="Optional message that was set when committing or importing the image.\n", example="", ) - Created: Optional[str] = Field( + Created: str | None = Field( None, description="Date and time at which the image was created, formatted in\n[RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds.\n", example="2022-02-04T21:20:12.497794809Z", ) - Container: Optional[str] = Field( + Container: str | None = Field( None, description="The ID of the container that was used to create the image.\n\nDepending on how the image was created, this field may be empty.\n", example="65974bc86f1770ae4bff79f651ebdbce166ae9aada632ee3fa9af3a264911735", ) - ContainerConfig: Optional[ContainerConfig] = None - DockerVersion: Optional[str] = Field( + ContainerConfig: ContainerConfig | None = None + DockerVersion: str | None = Field( None, description="The version of Docker that was used to build the image.\n\nDepending on how the image was created, this field may be empty.\n", example="20.10.7", ) - Author: Optional[str] = Field( + Author: str | None = Field( None, description="Name of the author that was specified when committing the image, or as\nspecified through MAINTAINER (deprecated) in the Dockerfile.\n", example="", ) - Config_: Optional[ContainerConfig] = Field(None, alias="Config") - Architecture: Optional[str] = Field( + Config_: ContainerConfig | None = Field(None, alias="Config") # type: ignore + Architecture: str | None = Field( None, description="Hardware CPU architecture that the image runs on.\n", example="arm", ) - Variant: Optional[str] = Field( + Variant: str | None = Field( None, description="CPU architecture variant (presently ARM-only).\n", example="v7", ) - Os: Optional[str] = Field( + Os: str | None = Field( None, description="Operating System the image is built to run on.\n", example="linux", ) - OsVersion: Optional[str] = Field( + OsVersion: str | None = Field( None, description="Operating System version the image is built to run on (especially\nfor Windows).\n", example="", ) - Size: Optional[int] = Field( + Size: int | None = Field( None, description="Total size of the image including all layers it is composed of.\n", example=1239828, ) - VirtualSize: Optional[int] = Field( + VirtualSize: int | None = Field( None, description="Total size of the image including all layers it is composed of.\n\nIn versions of Docker before v1.10, this field was calculated from\nthe image itself and all of its parent images. Docker v1.10 and up\nstore images self-contained, and no longer use a parent-chain, making\nthis field an equivalent of the Size field.\n\nThis field is kept for backward compatibility, but may be removed in\na future version of the API.\n", example=1239828, ) - GraphDriver: Optional[GraphDriverData] = None - RootFS: Optional[RootFS] = Field( + GraphDriver: GraphDriverData | None = None + RootFS: RootFS | None = Field( None, description="Information about the image's RootFS, including the layer IDs.\n", ) - Metadata: Optional[Metadata] = Field( + Metadata: Metadata | None = Field( None, description="Additional metadata of the image in the local cache. This information\nis local to the daemon, and not part of the image itself.\n", ) @@ -949,18 +945,18 @@ class ImageSummary(BaseModel): class AuthConfig(BaseModel): - username: Optional[str] = None - password: Optional[str] = None - email: Optional[str] = None - serveraddress: Optional[str] = None + username: str | None = None + password: str | None = None + email: str | None = None + serveraddress: str | None = None class ProcessConfig(BaseModel): - privileged: Optional[bool] = None - user: Optional[str] = None - tty: Optional[bool] = None - entrypoint: Optional[str] = None - arguments: Optional[list[str]] = None + privileged: bool | None = None + user: str | None = None + tty: bool | None = None + entrypoint: str | None = None + arguments: list[str] | None = None class Scope(str, Enum): @@ -1003,12 +999,12 @@ class Volume(BaseModel): description="Mount path of the volume on the host.", example="/var/lib/docker/volumes/tardis", ) - CreatedAt: Optional[str] = Field( + CreatedAt: str | None = Field( None, description="Date/Time the volume was created.", example="2016-06-07T20:31:11.853781916Z", ) - Status: Optional[dict[str, dict[str, Any]]] = Field( + Status: dict[str, dict[str, Any]] | None = Field( None, description='Low-level details about the volume, provided by the volume driver.\nDetails are returned as a map with key/value pairs:\n`{"key":"value","key2":"value2"}`.\n\nThe `Status` field is optional, and is omitted if the volume driver\ndoes not support this feature.\n', example={"hello": "world"}, @@ -1031,7 +1027,7 @@ class Volume(BaseModel): description="The driver specific options used when creating the volume.\n", example={"device": "tmpfs", "o": "size=100m,uid=1000", "type": "tmpfs"}, ) - UsageData: Optional[UsageData] = Field( + UsageData: UsageData | None = Field( None, description="Usage details about the volume. This information is used by the\n`GET /system/df` endpoint, and omitted in other endpoints.\n", ) @@ -1042,20 +1038,20 @@ class VolumeConfig(BaseModel): Volume configuration """ - Name: Optional[str] = Field( + Name: str | None = Field( None, description="The new volume's name. If not specified, Docker generates a name.\n", example="tardis", ) - Driver: Optional[str] = Field( + Driver: str | None = Field( "local", description="Name of the volume driver to use.", example="custom" ) - DriverOpts: Optional[dict[str, str]] = Field( + DriverOpts: dict[str, str] | None = Field( None, description="A mapping of driver options and values. These options are\npassed directly to the driver and are driver specific.\n", example={"device": "tmpfs", "o": "size=100m,uid=1000", "type": "tmpfs"}, ) - Labels: Optional[dict[str, str]] = Field( + Labels: dict[str, str] | None = Field( None, description="User-defined key/value metadata.", example={ @@ -1066,18 +1062,18 @@ class VolumeConfig(BaseModel): class IPAMConfig(BaseModel): - Subnet: Optional[str] = None - IPRange: Optional[str] = None - Gateway: Optional[str] = None - AuxiliaryAddresses: Optional[dict[str, str]] = None + Subnet: str | None = None + IPRange: str | None = None + Gateway: str | None = None + AuxiliaryAddresses: dict[str, str] | None = None class NetworkContainer(BaseModel): - Name: Optional[str] = None - EndpointID: Optional[str] = None - MacAddress: Optional[str] = None - IPv4Address: Optional[str] = None - IPv6Address: Optional[str] = None + Name: str | None = None + EndpointID: str | None = None + MacAddress: str | None = None + IPv4Address: str | None = None + IPv6Address: str | None = None class Type4(str, Enum): @@ -1100,46 +1096,46 @@ class BuildCache(BaseModel): """ - ID: Optional[str] = Field( + ID: str | None = Field( None, description="Unique ID of the build cache record.\n", example="ndlpt0hhvkqcdfkputsk4cq9c", ) - Parent: Optional[str] = Field( + Parent: str | None = Field( None, description="ID of the parent build cache record.\n", example="hw53o5aio51xtltp5xjp8v7fx", ) - Type: Optional[Type4] = Field( + Type: Type4 | None = Field( None, description="Cache record type.\n", example="regular" ) - Description: Optional[str] = Field( + Description: str | None = Field( None, description="Description of the build-step that produced the build cache.\n", example="mount / from exec /bin/sh -c echo 'Binary::apt::APT::Keep-Downloaded-Packages \"true\";' > /etc/apt/apt.conf.d/keep-cache", ) - InUse: Optional[bool] = Field( + InUse: bool | None = Field( None, description="Indicates if the build cache is in use.\n", example=False ) - Shared: Optional[bool] = Field( + Shared: bool | None = Field( None, description="Indicates if the build cache is shared.\n", example=True ) - Size: Optional[int] = Field( + Size: int | None = Field( None, description="Amount of disk space used by the build cache (in bytes).\n", example=51, ) - CreatedAt: Optional[str] = Field( + CreatedAt: str | None = Field( None, description="Date and time at which the build cache was created in\n[RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds.\n", example="2016-08-18T10:44:24.496525531Z", ) - LastUsedAt: Optional[str] = Field( + LastUsedAt: str | None = Field( None, description="Date and time at which the build cache was last used in\n[RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds.\n", example="2017-08-09T07:09:37.632105588Z", ) - UsageCount: Optional[int] = Field(None, example=26) + UsageCount: int | None = Field(None, example=26) class ImageID(BaseModel): @@ -1147,17 +1143,17 @@ class ImageID(BaseModel): Image ID or Digest """ - ID: Optional[str] = None + ID: str | None = None class ErrorDetail(BaseModel): - code: Optional[int] = None - message: Optional[str] = None + code: int | None = None + message: str | None = None class ProgressDetail(BaseModel): - current: Optional[int] = None - total: Optional[int] = None + current: int | None = None + total: int | None = None class ErrorResponse(BaseModel): @@ -1182,9 +1178,9 @@ class EndpointIPAMConfig(BaseModel): """ - IPv4Address: Optional[str] = Field(None, example="172.20.30.33") - IPv6Address: Optional[str] = Field(None, example="2001:db8:abcd::3033") - LinkLocalIPs: Optional[list[str]] = Field( + IPv4Address: str | None = Field(None, example="172.20.30.33") + IPv6Address: str | None = Field(None, example="2001:db8:abcd::3033") + LinkLocalIPs: list[str] | None = Field( None, example=["169.254.34.68", "fe80::3468"] ) @@ -1226,9 +1222,9 @@ class PluginPrivilege(BaseModel): """ - Name: Optional[str] = Field(None, example="network") - Description: Optional[str] = None - Value: Optional[list[str]] = Field(None, example=["host"]) + Name: str | None = Field(None, example="network") + Description: str | None = None + Value: list[str] | None = Field(None, example=["host"]) class Settings(BaseModel): @@ -1258,7 +1254,7 @@ class Interface(BaseModel): Types: list[PluginInterfaceType] = Field(..., example=["docker.volumedriver/1.0"]) Socket: str = Field(..., example="plugins.sock") - ProtocolScheme: Optional[ProtocolScheme] = Field( + ProtocolScheme: ProtocolScheme | None = Field( None, description="Protocol to use for clients connecting to the plugin.", example="some.protocol/v1.0", @@ -1266,8 +1262,8 @@ class Interface(BaseModel): class User(BaseModel): - UID: Optional[int] = Field(None, example=1000) - GID: Optional[int] = Field(None, example=1000) + UID: int | None = Field(None, example=1000) + GID: int | None = Field(None, example=1000) class Network1(BaseModel): @@ -1288,8 +1284,8 @@ class Args(BaseModel): class Rootfs(BaseModel): - type: Optional[str] = Field(None, example="layers") - diff_ids: Optional[list[str]] = Field( + type: str | None = Field(None, example="layers") + diff_ids: list[str] | None = Field( None, example=[ "sha256:675532206fbf3030b8458f88d6e26d4eb1577688a25efec97154c94e8b6b4887", @@ -1303,7 +1299,7 @@ class Config(BaseModel): The config of a plugin. """ - DockerVersion: Optional[str] = Field( + DockerVersion: str | None = Field( None, description="Docker Version used to create the plugin", example="17.06.0-ce", @@ -1317,7 +1313,7 @@ class Config(BaseModel): ..., example=["/usr/bin/sample-volume-plugin", "/data"] ) WorkDir: str = Field(..., example="/bin/") - User: Optional[User] = None + User: User | None = None Network: Network1 Linux: Linux PropagatedMount: str = Field(..., example="/mnt/volumes") @@ -1336,7 +1332,7 @@ class Config(BaseModel): ], ) Args: Args - rootfs: Optional[Rootfs] = None + rootfs: Rootfs | None = None class Plugin(BaseModel): @@ -1344,7 +1340,7 @@ class Plugin(BaseModel): A plugin for the Engine API """ - Id: Optional[str] = Field( + Id: str | None = Field( None, example="5724e2c8652da337ab2eedd19fc6fc0ec908e4bd907c7421bf6a8dfc70c4c078" ) Name: str = Field(..., example="tiborvass/sample-volume-plugin") @@ -1356,7 +1352,7 @@ class Plugin(BaseModel): Settings: Settings = Field( ..., description="Settings that can be modified by users." ) - PluginReference: Optional[str] = Field( + PluginReference: str | None = Field( None, description="plugin remote reference used to push/pull the plugin", example="localhost:5000/tiborvass/sample-volume-plugin:latest", @@ -1379,7 +1375,7 @@ class ObjectVersion(BaseModel): """ - Index: Optional[int] = Field(None, example=373531) + Index: int | None = Field(None, example=373531) class Role(str, Enum): @@ -1402,16 +1398,12 @@ class Availability(str, Enum): class NodeSpec(BaseModel): - Name: Optional[str] = Field( - None, description="Name for the node.", example="my-node" - ) - Labels: Optional[dict[str, str]] = Field( + Name: str | None = Field(None, description="Name for the node.", example="my-node") + Labels: dict[str, str] | None = Field( None, description="User-defined key/value metadata." ) - Role: Optional[Role] = Field( - None, description="Role of the node.", example="manager" - ) - Availability: Optional[Availability] = Field( + Role: Role | None = Field(None, description="Role of the node.", example="manager") + Availability: Availability | None = Field( None, description="Availability of the node.", example="active" ) @@ -1422,12 +1414,12 @@ class Platform(BaseModel): """ - Architecture: Optional[str] = Field( + Architecture: str | None = Field( None, description="Architecture represents the hardware architecture (for example,\n`x86_64`).\n", example="x86_64", ) - OS: Optional[str] = Field( + OS: str | None = Field( None, description="OS represents the Operating System (for example, `linux` or `windows`).\n", example="linux", @@ -1435,8 +1427,8 @@ class Platform(BaseModel): class Plugin1(BaseModel): - Type: Optional[str] = None - Name: Optional[str] = None + Type: str | None = None + Name: str | None = None class EngineDescription(BaseModel): @@ -1444,9 +1436,9 @@ class EngineDescription(BaseModel): EngineDescription provides information about an engine. """ - EngineVersion: Optional[str] = Field(None, example="17.06.0") - Labels: Optional[dict[str, str]] = Field(None, example={"foo": "bar"}) - Plugins: Optional[list[Plugin1]] = Field( + EngineVersion: str | None = Field(None, example="17.06.0") + Labels: dict[str, str] | None = Field(None, example={"foo": "bar"}) + Plugins: list[Plugin1] | None = Field( None, example=[ {"Type": "Log", "Name": "awslogs"}, @@ -1478,14 +1470,14 @@ class TLSInfo(BaseModel): """ - TrustRoot: Optional[str] = Field( + TrustRoot: str | None = Field( None, description="The root CA certificate(s) that are used to validate leaf TLS\ncertificates.\n", ) - CertIssuerSubject: Optional[str] = Field( + CertIssuerSubject: str | None = Field( None, description="The base64-url-safe-encoded raw subject bytes of the issuer." ) - CertIssuerPublicKey: Optional[str] = Field( + CertIssuerPublicKey: str | None = Field( None, description="The base64-url-safe-encoded raw public key bytes of the issuer.\n", ) @@ -1517,7 +1509,7 @@ class Orchestration(BaseModel): Orchestration configuration. """ - TaskHistoryRetentionLimit: Optional[int] = Field( + TaskHistoryRetentionLimit: int | None = Field( None, description="The number of historic tasks to keep per instance or node. If\nnegative, never remove completed or failed tasks.\n", example=10, @@ -1529,24 +1521,24 @@ class Raft(BaseModel): Raft configuration. """ - SnapshotInterval: Optional[int] = Field( + SnapshotInterval: int | None = Field( None, description="The number of log entries between snapshots.", example=10000 ) - KeepOldSnapshots: Optional[int] = Field( + KeepOldSnapshots: int | None = Field( None, description="The number of snapshots to keep beyond the current snapshot.\n", ) - LogEntriesForSlowFollowers: Optional[int] = Field( + LogEntriesForSlowFollowers: int | None = Field( None, description="The number of log entries to keep around to sync up slow followers\nafter a snapshot is created.\n", example=500, ) - ElectionTick: Optional[int] = Field( + ElectionTick: int | None = Field( None, description="The number of ticks that a follower will wait for a message from\nthe leader before becoming a candidate and starting an election.\n`ElectionTick` must be greater than `HeartbeatTick`.\n\nA tick currently defaults to one second, so these translate\ndirectly to seconds currently, but this is NOT guaranteed.\n", example=3, ) - HeartbeatTick: Optional[int] = Field( + HeartbeatTick: int | None = Field( None, description="The number of ticks between heartbeats. Every HeartbeatTick ticks,\nthe leader will send a heartbeat to the followers.\n\nA tick currently defaults to one second, so these translate\ndirectly to seconds currently, but this is NOT guaranteed.\n", example=1, @@ -1558,7 +1550,7 @@ class Dispatcher(BaseModel): Dispatcher configuration. """ - HeartbeatPeriod: Optional[int] = Field( + HeartbeatPeriod: int | None = Field( None, description="The delay for an agent to send a heartbeat to the dispatcher.\n", example=5000000000, @@ -1576,18 +1568,18 @@ class Protocol(str, Enum): class ExternalCA(BaseModel): - Protocol: Optional[Protocol] = Field( + Protocol: Protocol | None = Field( Protocol.cfssl, description="Protocol for communication with the external CA (currently\nonly `cfssl` is supported).\n", ) - URL: Optional[str] = Field( + URL: str | None = Field( None, description="URL where certificate signing requests should be sent.\n" ) - Options: Optional[dict[str, str]] = Field( + Options: dict[str, str] | None = Field( None, description="An object with key/value pairs that are interpreted as\nprotocol-specific options for the external CA driver.\n", ) - CACert: Optional[str] = Field( + CACert: str | None = Field( None, description="The root CA certificate (in PEM format) this external CA uses\nto issue TLS certificates (assumed to be to the current swarm\nroot CA certificate if not provided).\n", ) @@ -1598,24 +1590,24 @@ class CAConfig(BaseModel): CA configuration. """ - NodeCertExpiry: Optional[int] = Field( + NodeCertExpiry: int | None = Field( None, description="The duration node certificates are issued for.", example=7776000000000000, ) - ExternalCAs: Optional[list[ExternalCA]] = Field( + ExternalCAs: list[ExternalCA] | None = Field( None, description="Configuration for forwarding signing requests to an external\ncertificate authority.\n", ) - SigningCACert: Optional[str] = Field( + SigningCACert: str | None = Field( None, description="The desired signing CA certificate for all swarm node TLS leaf\ncertificates, in PEM format.\n", ) - SigningCAKey: Optional[str] = Field( + SigningCAKey: str | None = Field( None, description="The desired signing CA key for all swarm node TLS leaf certificates,\nin PEM format.\n", ) - ForceRotate: Optional[int] = Field( + ForceRotate: int | None = Field( None, description="An integer whose purpose is to force swarm to generate a new\nsigning CA certificate and key, if none have been specified in\n`SigningCACert` and `SigningCAKey`\n", ) @@ -1626,7 +1618,7 @@ class EncryptionConfig(BaseModel): Parameters related to encryption-at-rest. """ - AutoLockManagers: Optional[bool] = Field( + AutoLockManagers: bool | None = Field( None, description="If set, generate a key and use it to lock data stored on the\nmanagers.\n", example=False, @@ -1643,12 +1635,12 @@ class LogDriver(BaseModel): """ - Name: Optional[str] = Field( + Name: str | None = Field( None, description="The log driver to use as a default for new tasks.\n", example="json-file", ) - Options: Optional[dict[str, str]] = Field( + Options: dict[str, str] | None = Field( None, description="Driver-specific options for the selectd log driver, specified\nas key/value pairs.\n", example={"max-file": "10", "max-size": "100m"}, @@ -1660,7 +1652,7 @@ class TaskDefaults(BaseModel): Defaults for creating tasks in this cluster. """ - LogDriver: Optional[LogDriver] = Field( + LogDriver: LogDriver | None = Field( None, description="The log driver to use for tasks created in the orchestrator if\nunspecified by a service.\n\nUpdating this value only affects new tasks. Existing tasks continue\nto use their previously configured log driver until recreated.\n", ) @@ -1671,10 +1663,8 @@ class SwarmSpec(BaseModel): User modifiable swarm configuration. """ - Name: Optional[str] = Field( - None, description="Name of the swarm.", example="default" - ) - Labels: Optional[dict[str, str]] = Field( + Name: str | None = Field(None, description="Name of the swarm.", example="default") + Labels: dict[str, str] | None = Field( None, description="User-defined key/value metadata.", example={ @@ -1682,18 +1672,16 @@ class SwarmSpec(BaseModel): "com.example.corp.department": "engineering", }, ) - Orchestration: Optional[Orchestration] = Field( + Orchestration: Orchestration | None = Field( None, description="Orchestration configuration." ) - Raft: Optional[Raft] = Field(None, description="Raft configuration.") - Dispatcher: Optional[Dispatcher] = Field( - None, description="Dispatcher configuration." - ) - CAConfig: Optional[CAConfig] = Field(None, description="CA configuration.") - EncryptionConfig: Optional[EncryptionConfig] = Field( + Raft: Raft | None = Field(None, description="Raft configuration.") + Dispatcher: Dispatcher | None = Field(None, description="Dispatcher configuration.") + CAConfig: CAConfig | None = Field(None, description="CA configuration.") + EncryptionConfig: EncryptionConfig | None = Field( None, description="Parameters related to encryption-at-rest." ) - TaskDefaults: Optional[TaskDefaults] = Field( + TaskDefaults: TaskDefaults | None = Field( None, description="Defaults for creating tasks in this cluster." ) @@ -1705,37 +1693,37 @@ class ClusterInfo(BaseModel): """ - ID: Optional[str] = Field( + ID: str | None = Field( None, description="The ID of the swarm.", example="abajmipo7b4xz5ip2nrla6b11" ) - Version: Optional[ObjectVersion] = None - CreatedAt: Optional[str] = Field( + Version: ObjectVersion | None = None + CreatedAt: str | None = Field( None, description="Date and time at which the swarm was initialised in\n[RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds.\n", example="2016-08-18T10:44:24.496525531Z", ) - UpdatedAt: Optional[str] = Field( + UpdatedAt: str | None = Field( None, description="Date and time at which the swarm was last updated in\n[RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds.\n", example="2017-08-09T07:09:37.632105588Z", ) - Spec: Optional[SwarmSpec] = None - TLSInfo: Optional[TLSInfo] = None - RootRotationInProgress: Optional[bool] = Field( + Spec: SwarmSpec | None = None + TLSInfo: TLSInfo | None = None + RootRotationInProgress: bool | None = Field( None, description="Whether there is currently a root CA rotation in progress for the swarm\n", example=False, ) - DataPathPort: Optional[int] = Field( + DataPathPort: int | None = Field( 4789, description="DataPathPort specifies the data path port number for data traffic.\nAcceptable port range is 1024 to 49151.\nIf no port is set or is set to 0, the default port (4789) is used.\n", example=4789, ) - DefaultAddrPool: Optional[list[str]] = Field( + DefaultAddrPool: list[str] | None = Field( None, description="Default Address Pool specifies default subnet pools for global scope\nnetworks.\n", ) - SubnetSize: Optional[int] = Field( + SubnetSize: int | None = Field( 24, description="SubnetSize specifies the subnet size of the networks created from the\ndefault subnet pool.\n", example=24, @@ -1749,12 +1737,12 @@ class JoinTokens(BaseModel): """ - Worker: Optional[str] = Field( + Worker: str | None = Field( None, description="The token workers can use to join the swarm.\n", example="SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-1awxwuwd3z9j1z3puu7rcgdbx", ) - Manager: Optional[str] = Field( + Manager: str | None = Field( None, description="The token managers can use to join the swarm.\n", example="SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-7p73s1dx5in4tatdymyhg9hu2", @@ -1762,7 +1750,7 @@ class JoinTokens(BaseModel): class Swarm(ClusterInfo): - JoinTokens: Optional[JoinTokens] = None + JoinTokens: JoinTokens | None = None class PluginSpec(BaseModel): @@ -1778,16 +1766,14 @@ class PluginSpec(BaseModel): """ - Name: Optional[str] = Field( + Name: str | None = Field( None, description="The name or 'alias' to use for the plugin." ) - Remote: Optional[str] = Field( - None, description="The plugin image reference to use." - ) - Disabled: Optional[bool] = Field( + Remote: str | None = Field(None, description="The plugin image reference to use.") + Disabled: bool | None = Field( None, description="Disable the plugin once scheduled." ) - PluginPrivilege: Optional[list[PluginPrivilege]] = None + PluginPrivilege: list[PluginPrivilege] | None = None class CredentialSpec(BaseModel): @@ -1795,18 +1781,18 @@ class CredentialSpec(BaseModel): CredentialSpec for managed service account (Windows only) """ - Config_: Optional[str] = Field( + Config_: str | None = Field( None, alias="Config", description="Load credential spec from a Swarm Config with the given ID.\nThe specified config must also be present in the Configs\nfield with the Runtime property set.\n\n


\n\n\n> **Note**: `CredentialSpec.File`, `CredentialSpec.Registry`,\n> and `CredentialSpec.Config` are mutually exclusive.\n", example="0bt9dmxjvjiqermk6xrop3ekq", ) - File: Optional[str] = Field( + File: str | None = Field( None, description="Load credential spec from this file. The file is read by\nthe daemon, and must be present in the `CredentialSpecs`\nsubdirectory in the docker data directory, which defaults\nto `C:\\ProgramData\\Docker\\` on Windows.\n\nFor example, specifying `spec.json` loads\n`C:\\ProgramData\\Docker\\CredentialSpecs\\spec.json`.\n\n


\n\n> **Note**: `CredentialSpec.File`, `CredentialSpec.Registry`,\n> and `CredentialSpec.Config` are mutually exclusive.\n", example="spec.json", ) - Registry: Optional[str] = Field( + Registry: str | None = Field( None, description="Load credential spec from this value in the Windows\nregistry. The specified registry value must be located in:\n\n`HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Virtualization\\Containers\\CredentialSpecs`\n\n


\n\n\n> **Note**: `CredentialSpec.File`, `CredentialSpec.Registry`,\n> and `CredentialSpec.Config` are mutually exclusive.\n", ) @@ -1817,11 +1803,11 @@ class SELinuxContext(BaseModel): SELinux labels of the container """ - Disable: Optional[bool] = Field(None, description="Disable SELinux") - User: Optional[str] = Field(None, description="SELinux user label") - Role: Optional[str] = Field(None, description="SELinux role label") - Type: Optional[str] = Field(None, description="SELinux type label") - Level: Optional[str] = Field(None, description="SELinux level label") + Disable: bool | None = Field(None, description="Disable SELinux") + User: str | None = Field(None, description="SELinux user label") + Role: str | None = Field(None, description="SELinux role label") + Type: str | None = Field(None, description="SELinux type label") + Level: str | None = Field(None, description="SELinux level label") class Privileges(BaseModel): @@ -1829,10 +1815,10 @@ class Privileges(BaseModel): Security options for the container """ - CredentialSpec: Optional[CredentialSpec] = Field( + CredentialSpec: CredentialSpec | None = Field( None, description="CredentialSpec for managed service account (Windows only)" ) - SELinuxContext: Optional[SELinuxContext] = Field( + SELinuxContext: SELinuxContext | None = Field( None, description="SELinux labels of the container" ) @@ -1844,13 +1830,13 @@ class DNSConfig(BaseModel): """ - Nameservers: Optional[list[str]] = Field( + Nameservers: list[str] | None = Field( None, description="The IP addresses of the name servers." ) - Search: Optional[list[str]] = Field( + Search: list[str] | None = Field( None, description="A search list for host-name lookup." ) - Options: Optional[list[str]] = Field( + Options: list[str] | None = Field( None, description="A list of internal resolver variables to be modified (e.g.,\n`debug`, `ndots:3`, etc.).\n", ) @@ -1862,26 +1848,26 @@ class File(BaseModel): """ - Name: Optional[str] = Field( + Name: str | None = Field( None, description="Name represents the final filename in the filesystem.\n" ) - UID: Optional[str] = Field(None, description="UID represents the file UID.") - GID: Optional[str] = Field(None, description="GID represents the file GID.") - Mode: Optional[int] = Field( + UID: str | None = Field(None, description="UID represents the file UID.") + GID: str | None = Field(None, description="GID represents the file GID.") + Mode: int | None = Field( None, description="Mode represents the FileMode of the file." ) class Secret(BaseModel): - File: Optional[File] = Field( + File: File | None = Field( None, description="File represents a specific target that is backed by a file.\n", ) - SecretID: Optional[str] = Field( + SecretID: str | None = Field( None, description="SecretID represents the ID of the specific secret that we're\nreferencing.\n", ) - SecretName: Optional[str] = Field( + SecretName: str | None = Field( None, description="SecretName is the name of the secret that this references,\nbut this is just provided for lookup/display purposes. The\nsecret in the reference will be identified by its ID.\n", ) @@ -1901,19 +1887,19 @@ class File1(File): class Config1(BaseModel): - File: Optional[File1] = Field( + File: File1 | None = Field( None, description="File represents a specific target that is backed by a file.\n\n


\n\n> **Note**: `Configs.File` and `Configs.Runtime` are mutually exclusive\n", ) - Runtime: Optional[dict[str, Any]] = Field( + Runtime: dict[str, Any] | None = Field( None, description="Runtime represents a target that is not mounted into the\ncontainer but is used by the task\n\n


\n\n> **Note**: `Configs.File` and `Configs.Runtime` are mutually\n> exclusive\n", ) - ConfigID: Optional[str] = Field( + ConfigID: str | None = Field( None, description="ConfigID represents the ID of the specific config that we're\nreferencing.\n", ) - ConfigName: Optional[str] = Field( + ConfigName: str | None = Field( None, description="ConfigName is the name of the config that this references,\nbut this is just provided for lookup/display purposes. The\nconfig in the reference will be identified by its ID.\n", ) @@ -1936,90 +1922,90 @@ class ContainerSpec(BaseModel): """ - Image: Optional[str] = Field( + Image: str | None = Field( None, description="The image name to use for the container" ) - Labels: Optional[dict[str, str]] = Field( + Labels: dict[str, str] | None = Field( None, description="User-defined key/value data." ) - Command: Optional[list[str]] = Field( + Command: list[str] | None = Field( None, description="The command to be run in the image." ) - Args: Optional[list[str]] = Field(None, description="Arguments to the command.") - Hostname: Optional[str] = Field( + Args: list[str] | None = Field(None, description="Arguments to the command.") + Hostname: str | None = Field( None, description="The hostname to use for the container, as a valid\n[RFC 1123](https://tools.ietf.org/html/rfc1123) hostname.\n", ) - Env: Optional[list[str]] = Field( + Env: list[str] | None = Field( None, description="A list of environment variables in the form `VAR=value`.\n" ) - Dir: Optional[str] = Field( + Dir: str | None = Field( None, description="The working directory for commands to run in." ) - User: Optional[str] = Field(None, description="The user inside the container.") - Groups: Optional[list[str]] = Field( + User: str | None = Field(None, description="The user inside the container.") + Groups: list[str] | None = Field( None, description="A list of additional groups that the container process will run as.\n", ) - Privileges: Optional[Privileges] = Field( + Privileges: Privileges | None = Field( None, description="Security options for the container" ) - TTY: Optional[bool] = Field( + TTY: bool | None = Field( None, description="Whether a pseudo-TTY should be allocated." ) - OpenStdin: Optional[bool] = Field(None, description="Open `stdin`") - ReadOnly: Optional[bool] = Field( + OpenStdin: bool | None = Field(None, description="Open `stdin`") + ReadOnly: bool | None = Field( None, description="Mount the container's root filesystem as read only." ) - Mounts: Optional[list[Mount]] = Field( + Mounts: list[Mount] | None = Field( None, description="Specification for mounts to be added to containers created as part\nof the service.\n", ) - StopSignal: Optional[str] = Field(None, description="Signal to stop the container.") - StopGracePeriod: Optional[int] = Field( + StopSignal: str | None = Field(None, description="Signal to stop the container.") + StopGracePeriod: int | None = Field( None, description="Amount of time to wait for the container to terminate before\nforcefully killing it.\n", ) - HealthCheck: Optional[HealthConfig] = None - Hosts: Optional[list[str]] = Field( + HealthCheck: HealthConfig | None = None + Hosts: list[str] | None = Field( None, description="A list of hostname/IP mappings to add to the container's `hosts`\nfile. The format of extra hosts is specified in the\n[hosts(5)](http://man7.org/linux/man-pages/man5/hosts.5.html)\nman page:\n\n IP_address canonical_hostname [aliases...]\n", ) - DNSConfig: Optional[DNSConfig] = Field( + DNSConfig: DNSConfig | None = Field( None, description="Specification for DNS related configurations in resolver configuration\nfile (`resolv.conf`).\n", ) - Secrets: Optional[list[Secret]] = Field( + Secrets: list[Secret] | None = Field( None, description="Secrets contains references to zero or more secrets that will be\nexposed to the service.\n", ) - Configs: Optional[list[Config1]] = Field( + Configs: list[Config1] | None = Field( None, description="Configs contains references to zero or more configs that will be\nexposed to the service.\n", ) - Isolation: Optional[Isolation] = Field( + Isolation: Isolation | None = Field( None, description="Isolation technology of the containers running the service.\n(Windows only)\n", ) - Init: Optional[bool] = Field( + Init: bool | None = Field( None, description="Run an init inside the container that forwards signals and reaps\nprocesses. This field is omitted if empty, and the default (as\nconfigured on the daemon) is used.\n", ) - Sysctls: Optional[dict[str, str]] = Field( + Sysctls: dict[str, str] | None = Field( None, description="Set kernel namedspaced parameters (sysctls) in the container.\nThe Sysctls option on services accepts the same sysctls as the\nare supported on containers. Note that while the same sysctls are\nsupported, no guarantees or checks are made about their\nsuitability for a clustered environment, and it's up to the user\nto determine whether a given sysctl will work properly in a\nService.\n", ) - CapabilityAdd: Optional[list[str]] = Field( + CapabilityAdd: list[str] | None = Field( None, description="A list of kernel capabilities to add to the default set\nfor the container.\n", example=["CAP_NET_RAW", "CAP_SYS_ADMIN", "CAP_SYS_CHROOT", "CAP_SYSLOG"], ) - CapabilityDrop: Optional[list[str]] = Field( + CapabilityDrop: list[str] | None = Field( None, description="A list of kernel capabilities to drop from the default set\nfor the container.\n", example=["CAP_NET_RAW"], ) - Ulimits: Optional[list[Ulimit1]] = Field( + Ulimits: list[Ulimit1] | None = Field( None, description='A list of resource limits to set in the container. For example: `{"Name": "nofile", "Soft": 1024, "Hard": 2048}`"\n', ) @@ -2039,7 +2025,7 @@ class NetworkAttachmentSpec(BaseModel): """ - ContainerID: Optional[str] = Field( + ContainerID: str | None = Field( None, description="ID of the container represented by this task" ) @@ -2061,30 +2047,30 @@ class RestartPolicy1(BaseModel): """ - Condition: Optional[Condition] = Field(None, description="Condition for restart.") - Delay: Optional[int] = Field(None, description="Delay between restart attempts.") - MaxAttempts: Optional[int] = Field( + Condition: Condition | None = Field(None, description="Condition for restart.") + Delay: int | None = Field(None, description="Delay between restart attempts.") + MaxAttempts: int | None = Field( 0, description="Maximum attempts to restart a given container before giving up\n(default value is 0, which is ignored).\n", ) - Window: Optional[int] = Field( + Window: int | None = Field( 0, description="Windows is the time window used to evaluate the restart policy\n(default value is 0, which is unbounded).\n", ) class Spread(BaseModel): - SpreadDescriptor: Optional[str] = Field( + SpreadDescriptor: str | None = Field( None, description="label descriptor, such as `engine.labels.az`.\n" ) class Preference(BaseModel): - Spread: Optional[Spread] = None + Spread: Spread | None = None class Placement(BaseModel): - Constraints: Optional[list[str]] = Field( + Constraints: list[str] | None = Field( None, description="An array of constraint expressions to limit the set of nodes where\na task can be scheduled. Constraint expressions can either use a\n_match_ (`==`) or _exclude_ (`!=`) rule. Multiple constraints find\nnodes that satisfy every expression (AND match). Constraints can\nmatch node or Docker Engine labels as follows:\n\nnode attribute | matches | example\n---------------------|--------------------------------|-----------------------------------------------\n`node.id` | Node ID | `node.id==2ivku8v2gvtg4`\n`node.hostname` | Node hostname | `node.hostname!=node-2`\n`node.role` | Node role (`manager`/`worker`) | `node.role==manager`\n`node.platform.os` | Node operating system | `node.platform.os==windows`\n`node.platform.arch` | Node architecture | `node.platform.arch==x86_64`\n`node.labels` | User-defined node labels | `node.labels.security==high`\n`engine.labels` | Docker Engine's labels | `engine.labels.operatingsystem==ubuntu-14.04`\n\n`engine.labels` apply to Docker Engine labels like operating system,\ndrivers, etc. Swarm administrators add `node.labels` for operational\npurposes by using the [`node update endpoint`](#operation/NodeUpdate).\n", example=[ @@ -2095,7 +2081,7 @@ class Placement(BaseModel): "node.platform.arch==x86_64", ], ) - Preferences: Optional[list[Preference]] = Field( + Preferences: list[Preference] | None = Field( None, description="Preferences provide a way to make the scheduler aware of factors\nsuch as topology. They are provided in order from highest to\nlowest precedence.\n", example=[ @@ -2103,11 +2089,11 @@ class Placement(BaseModel): {"Spread": {"SpreadDescriptor": "node.labels.rack"}}, ], ) - MaxReplicas: Optional[int] = Field( + MaxReplicas: int | None = Field( 0, description="Maximum number of replicas for per node (default value is 0, which\nis unlimited)\n", ) - Platforms: Optional[list[Platform]] = Field( + Platforms: list[Platform] | None = Field( None, description="Platforms stores all the platforms that the service's image can\nrun on. This field is used in the platform filter for scheduling.\nIf empty, then the platform filter is off, meaning there are no\nscheduling restrictions.\n", ) @@ -2121,8 +2107,8 @@ class LogDriver1(BaseModel): """ - Name: Optional[str] = None - Options: Optional[dict[str, str]] = None + Name: str | None = None + Options: dict[str, str] | None = None class TaskState(str, Enum): @@ -2144,21 +2130,21 @@ class TaskState(str, Enum): class ContainerStatus(BaseModel): - ContainerID: Optional[str] = None - PID: Optional[int] = None - ExitCode: Optional[int] = None + ContainerID: str | None = None + PID: int | None = None + ExitCode: int | None = None class Status1(BaseModel): - Timestamp: Optional[str] = None - State: Optional[TaskState] = None - Message: Optional[str] = None - Err: Optional[str] = None - ContainerStatus: Optional[ContainerStatus] = None + Timestamp: str | None = None + State: TaskState | None = None + Message: str | None = None + Err: str | None = None + ContainerStatus: ContainerStatus | None = None class Replicated(BaseModel): - Replicas: Optional[int] = None + Replicas: int | None = None class ReplicatedJob(BaseModel): @@ -2168,10 +2154,10 @@ class ReplicatedJob(BaseModel): """ - MaxConcurrent: Optional[int] = Field( + MaxConcurrent: int | None = Field( 1, description="The maximum number of replicas to run simultaneously.\n" ) - TotalCompletions: Optional[int] = Field( + TotalCompletions: int | None = Field( None, description="The total number of replicas desired to reach the Completed\nstate. If unset, will default to the value of `MaxConcurrent`\n", ) @@ -2182,13 +2168,13 @@ class Mode(BaseModel): Scheduling mode for the service. """ - Replicated: Optional[Replicated] = None - Global: Optional[dict[str, Any]] = None - ReplicatedJob: Optional[ReplicatedJob] = Field( + Replicated: Replicated | None = None + Global: dict[str, Any] | None = None + ReplicatedJob: ReplicatedJob | None = Field( None, description="The mode used for services with a finite number of tasks that run\nto a completed state.\n", ) - GlobalJob: Optional[dict[str, Any]] = Field( + GlobalJob: dict[str, Any] | None = Field( None, description="The mode used for services which run a task to the completed state\non each valid node.\n", ) @@ -2223,26 +2209,26 @@ class UpdateConfig(BaseModel): Specification for the update strategy of the service. """ - Parallelism: Optional[int] = Field( + Parallelism: int | None = Field( None, description="Maximum number of tasks to be updated in one iteration (0 means\nunlimited parallelism).\n", ) - Delay: Optional[int] = Field( + Delay: int | None = Field( None, description="Amount of time between updates, in nanoseconds." ) - FailureAction: Optional[FailureAction] = Field( + FailureAction: FailureAction | None = Field( None, description="Action to take if an updated task fails to run, or stops running\nduring the update.\n", ) - Monitor: Optional[int] = Field( + Monitor: int | None = Field( None, description="Amount of time to monitor each updated task for failures, in\nnanoseconds.\n", ) - MaxFailureRatio: Optional[float] = Field( + MaxFailureRatio: float | None = Field( 0, description="The fraction of tasks that may fail during an update before the\nfailure action is invoked, specified as a floating point number\nbetween 0 and 1.\n", ) - Order: Optional[Order] = Field( + Order: Order | None = Field( None, description="The order of operations when rolling out an updated task. Either\nthe old task is shut down before the new task is started, or the\nnew task is started before the old task is shut down.\n", ) @@ -2264,27 +2250,27 @@ class RollbackConfig(BaseModel): Specification for the rollback strategy of the service. """ - Parallelism: Optional[int] = Field( + Parallelism: int | None = Field( None, description="Maximum number of tasks to be rolled back in one iteration (0 means\nunlimited parallelism).\n", ) - Delay: Optional[int] = Field( + Delay: int | None = Field( None, description="Amount of time between rollback iterations, in nanoseconds.\n", ) - FailureAction: Optional[FailureAction1] = Field( + FailureAction: FailureAction1 | None = Field( None, description="Action to take if an rolled back task fails to run, or stops\nrunning during the rollback.\n", ) - Monitor: Optional[int] = Field( + Monitor: int | None = Field( None, description="Amount of time to monitor each rolled back task for failures, in\nnanoseconds.\n", ) - MaxFailureRatio: Optional[float] = Field( + MaxFailureRatio: float | None = Field( 0, description="The fraction of tasks that may fail during a rollback before the\nfailure action is invoked, specified as a floating point number\nbetween 0 and 1.\n", ) - Order: Optional[Order] = Field( + Order: Order | None = Field( None, description="The order of operations when rolling back a task. Either the old\ntask is shut down before the new task is started, or the new task\nis started before the old task is shut down.\n", ) @@ -2309,15 +2295,11 @@ class PublishMode(str, Enum): class EndpointPortConfig(BaseModel): - Name: Optional[str] = None - Protocol: Optional[Type] = None - TargetPort: Optional[int] = Field( - None, description="The port inside the container." - ) - PublishedPort: Optional[int] = Field( - None, description="The port on the swarm hosts." - ) - PublishMode: Optional[PublishMode] = Field( + Name: str | None = None + Protocol: Type | None = None + TargetPort: int | None = Field(None, description="The port inside the container.") + PublishedPort: int | None = Field(None, description="The port on the swarm hosts.") + PublishMode: PublishMode | None = Field( PublishMode.ingress, description='The mode in which port is published.\n\n


\n\n- "ingress" makes the target port accessible on every node,\n regardless of whether there is a task for the service running on\n that node or not.\n- "host" bypasses the routing mesh and publish the port directly on\n the swarm node where that service is running.\n', example="ingress", @@ -2339,25 +2321,25 @@ class EndpointSpec(BaseModel): Properties that can be configured to access and load balance a service. """ - Mode: Optional[Mode1] = Field( + Mode: Mode1 | None = Field( Mode1.vip, description="The mode of resolution to use for internal load balancing between tasks.\n", ) - Ports: Optional[list[EndpointPortConfig]] = Field( + Ports: list[EndpointPortConfig] | None = Field( None, description="List of exposed ports that this service is accessible on from the\noutside. Ports can only be provided if `vip` resolution mode is used.\n", ) class VirtualIP(BaseModel): - NetworkID: Optional[str] = None - Addr: Optional[str] = None + NetworkID: str | None = None + Addr: str | None = None class Endpoint(BaseModel): - Spec: Optional[EndpointSpec] = None - Ports: Optional[list[EndpointPortConfig]] = None - VirtualIPs: Optional[list[VirtualIP]] = None + Spec: EndpointSpec | None = None + Ports: list[EndpointPortConfig] | None = None + VirtualIPs: list[VirtualIP] | None = None class State(str, Enum): @@ -2371,10 +2353,10 @@ class UpdateStatus(BaseModel): The status of a service update. """ - State: Optional[State] = None - StartedAt: Optional[str] = None - CompletedAt: Optional[str] = None - Message: Optional[str] = None + State: State | None = None + StartedAt: str | None = None + CompletedAt: str | None = None + Message: str | None = None class ServiceStatus(BaseModel): @@ -2384,17 +2366,17 @@ class ServiceStatus(BaseModel): """ - RunningTasks: Optional[int] = Field( + RunningTasks: int | None = Field( None, description="The number of tasks for the service currently in the Running state.\n", example=7, ) - DesiredTasks: Optional[int] = Field( + DesiredTasks: int | None = Field( None, description="The number of tasks for the service desired to be running.\nFor replicated services, this is the replica count from the\nservice spec. For global services, this is computed by taking\ncount of all tasks for the service with a Desired State other\nthan Shutdown.\n", example=10, ) - CompletedTasks: Optional[int] = Field( + CompletedTasks: int | None = Field( None, description="The number of tasks for a job that are in the Completed state.\nThis field must be cross-referenced with the service type, as the\nvalue of 0 may mean the service is not in a job mode, or it may\nmean the job-mode service has no tasks yet Completed.\n", ) @@ -2409,31 +2391,31 @@ class JobStatus(BaseModel): """ - JobIteration: Optional[ObjectVersion] = Field( + JobIteration: ObjectVersion | None = Field( None, description='JobIteration is a value increased each time a Job is executed,\nsuccessfully or otherwise. "Executed", in this case, means the\njob as a whole has been started, not that an individual Task has\nbeen launched. A job is "Executed" when its ServiceSpec is\nupdated. JobIteration can be used to disambiguate Tasks belonging\nto different executions of a job. Though JobIteration will\nincrease with each subsequent execution, it may not necessarily\nincrease by 1, and so JobIteration should not be used to\n', ) - LastExecution: Optional[str] = Field( + LastExecution: str | None = Field( None, description="The last time, as observed by the server, that this job was\nstarted.\n", ) class ImageDeleteResponseItem(BaseModel): - Untagged: Optional[str] = Field( + Untagged: str | None = Field( None, description="The image ID of an image that was untagged" ) - Deleted: Optional[str] = Field( + Deleted: str | None = Field( None, description="The image ID of an image that was deleted" ) class ServiceUpdateResponse(BaseModel): - Warnings: Optional[list[str]] = Field(None, description="Optional warning messages") + Warnings: list[str] | None = Field(None, description="Optional warning messages") class HostConfig1(BaseModel): - NetworkMode: Optional[str] = None + NetworkMode: str | None = None class Driver(BaseModel): @@ -2441,8 +2423,8 @@ class Driver(BaseModel): Driver represents a driver (network, logging, secrets). """ - Name: str = Field(..., description="Name of the driver.", example="some-driver") - Options: Optional[dict[str, str]] = Field( + name: str = Field(..., description="Name of the driver.") + options: dict[str, str] | None = Field( None, description="Key/value map of driver-specific options.", example={ @@ -2453,8 +2435,8 @@ class Driver(BaseModel): class SecretSpec(BaseModel): - Name: Optional[str] = Field(None, description="User-defined name of the secret.") - Labels: Optional[dict[str, str]] = Field( + name: str | None = Field(None, description="User-defined name of the secret.") + labels: dict[str, str] | None = Field( None, description="User-defined key/value metadata.", example={ @@ -2462,50 +2444,50 @@ class SecretSpec(BaseModel): "com.example.some-other-label": "some-other-value", }, ) - Data: Optional[str] = Field( + data: str | None = Field( None, description="Base64-url-safe-encoded ([RFC 4648](https://tools.ietf.org/html/rfc4648#section-5))\ndata to store as secret.\n\nThis field is only used to _create_ a secret, and is not returned by\nother endpoints.\n", example="", ) - Driver: Optional[Driver] = Field( + driver: Driver | None = Field( None, description="Name of the secrets driver used to fetch the secret's value from an\nexternal secret store.\n", ) - Templating: Optional[Driver] = Field( + templating: Driver | None = Field( None, description="Templating driver, if applicable\n\nTemplating controls whether and how to evaluate the config payload as\na template. If no driver is set, no templating is used.\n", ) class Secret1(BaseModel): - ID: Optional[str] = Field(None, example="blt1owaxmitz71s9v5zh81zun") - Version: Optional[ObjectVersion] = None - CreatedAt: Optional[str] = Field(None, example="2017-07-20T13:55:28.678958722Z") - UpdatedAt: Optional[str] = Field(None, example="2017-07-20T13:55:28.678958722Z") - Spec: Optional[SecretSpec] = None + ID: str | None = Field(None, example="blt1owaxmitz71s9v5zh81zun") + Version: ObjectVersion | None = None + CreatedAt: str | None = Field(None, example="2017-07-20T13:55:28.678958722Z") + UpdatedAt: str | None = Field(None, example="2017-07-20T13:55:28.678958722Z") + Spec: SecretSpec | None = None class ConfigSpec(BaseModel): - Name: Optional[str] = Field(None, description="User-defined name of the config.") - Labels: Optional[dict[str, str]] = Field( + Name: str | None = Field(None, description="User-defined name of the config.") + Labels: dict[str, str] | None = Field( None, description="User-defined key/value metadata." ) - Data: Optional[str] = Field( + Data: str | None = Field( None, description="Base64-url-safe-encoded ([RFC 4648](https://tools.ietf.org/html/rfc4648#section-5))\nconfig data.\n", ) - Templating: Optional[Driver] = Field( + Templating: Driver | None = Field( None, description="Templating driver, if applicable\n\nTemplating controls whether and how to evaluate the config payload as\na template. If no driver is set, no templating is used.\n", ) class Config2(BaseModel): - ID: Optional[str] = None - Version: Optional[ObjectVersion] = None - CreatedAt: Optional[str] = None - UpdatedAt: Optional[str] = None - Spec: Optional[ConfigSpec] = None + ID: str | None = None + Version: ObjectVersion | None = None + CreatedAt: str | None = None + UpdatedAt: str | None = None + Spec: ConfigSpec | None = None class Status2(str, Enum): @@ -2529,7 +2511,7 @@ class ContainerWaitExitError(BaseModel): container waiting error, if any """ - Message: Optional[str] = Field(None, description="Details of an error") + Message: str | None = Field(None, description="Details of an error") class Platform1(BaseModel): @@ -2541,7 +2523,7 @@ class Component(BaseModel): Version: str = Field( ..., description="Version of the component\n", example="19.03.12" ) - Details: Optional[dict[str, Any]] = Field( + Details: dict[str, Any] | None = Field( None, description="Key/value pairs of strings with additional information about the\ncomponent. These values are intended for informational purposes\nonly, and their content is not defined, and not part of the API\nspecification.\n\nThese messages can be printed by the client as information to the user.\n", ) @@ -2553,54 +2535,54 @@ class SystemVersion(BaseModel): """ - Platform: Optional[Platform1] = None - Components: Optional[list[Component]] = Field( + Platform: Platform1 | None = None + Components: list[Component] | None = Field( None, description="Information about system components\n" ) - Version: Optional[str] = Field( + Version: str | None = Field( None, description="The version of the daemon", example="19.03.12" ) - ApiVersion: Optional[str] = Field( + ApiVersion: str | None = Field( None, description="The default (and highest) API version that is supported by the daemon\n", example="1.40", ) - MinAPIVersion: Optional[str] = Field( + MinAPIVersion: str | None = Field( None, description="The minimum API version that is supported by the daemon\n", example="1.12", ) - GitCommit: Optional[str] = Field( + GitCommit: str | None = Field( None, description="The Git commit of the source code that was used to build the daemon\n", example="48a66213fe", ) - GoVersion: Optional[str] = Field( + GoVersion: str | None = Field( None, description="The version Go used to compile the daemon, and the version of the Go\nruntime in use.\n", example="go1.13.14", ) - Os: Optional[str] = Field( + Os: str | None = Field( None, description='The operating system that the daemon is running on ("linux" or "windows")\n', example="linux", ) - Arch: Optional[str] = Field( + Arch: str | None = Field( None, description="The architecture that the daemon is running on\n", example="amd64", ) - KernelVersion: Optional[str] = Field( + KernelVersion: str | None = Field( None, description="The kernel version (`uname -r`) that the daemon is running on.\n\nThis field is omitted when empty.\n", example="4.19.76-linuxkit", ) - Experimental: Optional[bool] = Field( + Experimental: bool | None = Field( None, description="Indicates if the daemon is started with experimental features enabled.\n\nThis field is omitted when empty / false.\n", example=True, ) - BuildTime: Optional[str] = Field( + BuildTime: str | None = Field( None, description="The date and time that the daemon was compiled.\n", example="2020-06-22T15:49:27.000000000+00:00", @@ -2646,10 +2628,10 @@ class Isolation2(str, Enum): class DefaultAddressPool(BaseModel): - Base: Optional[str] = Field( + Base: str | None = Field( None, description="The network address in CIDR format", example="10.10.0.0/16" ) - Size: Optional[int] = Field(None, description="The network pool size", example="24") + Size: int | None = Field(None, description="The network pool size", example="24") class PluginsInfo(BaseModel): @@ -2664,22 +2646,22 @@ class PluginsInfo(BaseModel): """ - Volume: Optional[list[str]] = Field( + Volume: list[str] | None = Field( None, description="Names of available volume-drivers, and network-driver plugins.", example=["local"], ) - Network: Optional[list[str]] = Field( + Network: list[str] | None = Field( None, description="Names of available network-drivers, and network-driver plugins.", example=["bridge", "host", "ipvlan", "macvlan", "null", "overlay"], ) - Authorization: Optional[list[str]] = Field( + Authorization: list[str] | None = Field( None, description="Names of available authorization plugins.", example=["img-authz-plugin", "hbm"], ) - Log: Optional[list[str]] = Field( + Log: list[str] | None = Field( None, description="Names of available logging-drivers, and logging-driver plugins.", example=[ @@ -2701,12 +2683,12 @@ class IndexInfo(BaseModel): IndexInfo contains information about a registry. """ - Name: Optional[str] = Field( + Name: str | None = Field( None, description='Name of the registry, such as "docker.io".\n', example="docker.io", ) - Mirrors: Optional[list[str]] = Field( + Mirrors: list[str] | None = Field( None, description="List of mirrors, expressed as URIs.\n", example=[ @@ -2715,12 +2697,12 @@ class IndexInfo(BaseModel): "https://registry-3.docker.io/", ], ) - Secure: Optional[bool] = Field( + Secure: bool | None = Field( None, description="Indicates if the registry is part of the list of insecure\nregistries.\n\nIf `false`, the registry is insecure. Insecure registries accept\nun-encrypted (HTTP) and/or untrusted (HTTPS with certificates from\nunknown CAs) communication.\n\n> **Warning**: Insecure registries can be useful when running a local\n> registry. However, because its use creates security vulnerabilities\n> it should ONLY be enabled for testing purposes. For increased\n> security, users should add their CA to their system's list of\n> trusted CAs instead of enabling this option.\n", example=True, ) - Official: Optional[bool] = Field( + Official: bool | None = Field( None, description="Indicates whether this is an official registry (i.e., Docker Hub / docker.io)\n", example=True, @@ -2738,12 +2720,12 @@ class Runtime(BaseModel): """ - path: Optional[str] = Field( + path: str | None = Field( None, description="Name and, optional, path, of the OCI executable binary.\n\nIf the path is omitted, the daemon searches the host's `$PATH` for the\nbinary and uses the first result.\n", example="/usr/local/bin/my-oci-runtime", ) - runtimeArgs: Optional[list[str]] = Field( + runtimeArgs: list[str] | None = Field( None, description="List of command-line arguments to pass to the runtime when invoked.\n", example=["--debug", "--systemd-cgroup=false"], @@ -2758,12 +2740,12 @@ class Commit(BaseModel): """ - ID: Optional[str] = Field( + ID: str | None = Field( None, description="Actual commit ID of external tool.", example="cfb82a876ecc11b5ca0977d1733adbe58599088a", ) - Expected: Optional[str] = Field( + Expected: str | None = Field( None, description="Commit ID of external tool expected by dockerd as set at build time.\n", example="2d41c047c83e09a6d61d464906feb2a2f3c52aa4", @@ -2788,10 +2770,10 @@ class PeerNode(BaseModel): Represents a peer-node in the swarm """ - NodeID: Optional[str] = Field( + NodeID: str | None = Field( None, description="Unique identifier of for this node in the swarm." ) - Addr: Optional[str] = Field( + Addr: str | None = Field( None, description="IP address and ports at which this node can be reached.\n" ) @@ -2802,15 +2784,15 @@ class NetworkAttachmentConfig(BaseModel): """ - Target: Optional[str] = Field( + Target: str | None = Field( None, description="The target network for attachment. Must be a network name or ID.\n", ) - Aliases: Optional[list[str]] = Field( + Aliases: list[str] | None = Field( None, description="Discoverable alternate names for the service on this network.\n", ) - DriverOpts: Optional[dict[str, str]] = Field( + DriverOpts: dict[str, str] | None = Field( None, description="Driver attachment options for the network target.\n" ) @@ -2822,12 +2804,12 @@ class EventActor(BaseModel): """ - ID: Optional[str] = Field( + ID: str | None = Field( None, description="The ID of the object emitting the event", example="ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", ) - Attributes: Optional[dict[str, str]] = Field( + Attributes: dict[str, str] | None = Field( None, description="Various key/value attributes of the object, depending on its type.\n", example={ @@ -2873,21 +2855,17 @@ class SystemEventsResponse(BaseModel): """ - Type: Optional[Type5] = Field( + Type: Type5 | None = Field( None, description="The type of object emitting the event", example="container" ) - Action: Optional[str] = Field( - None, description="The type of event", example="create" - ) - Actor: Optional[EventActor] = None - scope: Optional[Scope1] = Field( + Action: str | None = Field(None, description="The type of event", example="create") + Actor: EventActor | None = None + scope: Scope1 | None = Field( None, description="Scope of the event. Engine events are `local` scope. Cluster (Swarm)\nevents are `swarm` scope.\n", ) - time: Optional[int] = Field( - None, description="Timestamp of event", example=1629574695 - ) - timeNano: Optional[int] = Field( + time: int | None = Field(None, description="Timestamp of event", example=1629574695) + timeNano: int | None = Field( None, description="Timestamp of event, with nanosecond accuracy", example=1629574695515050031, @@ -2901,17 +2879,17 @@ class OCIDescriptor(BaseModel): """ - mediaType: Optional[str] = Field( + mediaType: str | None = Field( None, description="The media type of the object this schema refers to.\n", example="application/vnd.docker.distribution.manifest.v2+json", ) - digest: Optional[str] = Field( + digest: str | None = Field( None, description="The digest of the targeted content.\n", example="sha256:c0537ff6a5218ef531ece93d4984efc99bbf3f7497c0a7726c88e2bb7584dc96", ) - size: Optional[int] = Field( + size: int | None = Field( None, description="The size in bytes of the blob.\n", example=3987495 ) @@ -2923,29 +2901,29 @@ class OCIPlatform(BaseModel): """ - architecture: Optional[str] = Field( + architecture: str | None = Field( None, description="The CPU architecture, for example `amd64` or `ppc64`.\n", example="arm", ) - os: Optional[str] = Field( + os: str | None = Field( None, description="The operating system, for example `linux` or `windows`.\n", example="windows", ) - os_version: Optional[str] = Field( + os_version: str | None = Field( None, alias="os.version", description="Optional field specifying the operating system version, for example on\nWindows `10.0.19041.1165`.\n", example="10.0.19041.1165", ) - os_features: Optional[list[str]] = Field( + os_features: list[str] | None = Field( None, alias="os.features", description="Optional field specifying an array of strings, each listing a required\nOS feature (for example on Windows `win32k`).\n", example=["win32k"], ) - variant: Optional[str] = Field( + variant: str | None = Field( None, description="Optional field specifying a variant of the CPU, for example `v7` to\nspecify ARMv7 when architecture is `arm`.\n", example="v7", @@ -2972,9 +2950,9 @@ class ResourceObject(BaseModel): """ - NanoCPUs: Optional[int] = Field(None, example=4000000000) - MemoryBytes: Optional[int] = Field(None, example=8272408576) - GenericResources: Optional[GenericResources] = None + NanoCPUs: int | None = Field(None, example=4000000000) + MemoryBytes: int | None = Field(None, example=8272408576) + GenericResources: GenericResources | None = None class Health(BaseModel): @@ -2983,17 +2961,17 @@ class Health(BaseModel): """ - Status: Optional[Status] = Field( + Status: Status | None = Field( None, description='Status is one of `none`, `starting`, `healthy` or `unhealthy`\n\n- "none" Indicates there is no healthcheck\n- "starting" Starting indicates that the container is not yet ready\n- "healthy" Healthy indicates that the container is running correctly\n- "unhealthy" Unhealthy indicates that the container has a problem\n', example="healthy", ) - FailingStreak: Optional[int] = Field( + FailingStreak: int | None = Field( None, description="FailingStreak is the number of consecutive failures", example=0, ) - Log: Optional[list[HealthcheckResult]] = Field( + Log: list[HealthcheckResult] | None = Field( None, description="Log contains the last few results (oldest first)\n" ) @@ -3003,179 +2981,175 @@ class HostConfig(Resources): Container configuration that depends on the host we are running on """ - Binds: Optional[list[str]] = Field( + Binds: list[str] | None = Field( None, description="A list of volume bindings for this container. Each volume binding\nis a string in one of these forms:\n\n- `host-src:container-dest[:options]` to bind-mount a host path\n into the container. Both `host-src`, and `container-dest` must\n be an _absolute_ path.\n- `volume-name:container-dest[:options]` to bind-mount a volume\n managed by a volume driver into the container. `container-dest`\n must be an _absolute_ path.\n\n`options` is an optional, comma-delimited list of:\n\n- `nocopy` disables automatic copying of data from the container\n path to the volume. The `nocopy` flag only applies to named volumes.\n- `[ro|rw]` mounts a volume read-only or read-write, respectively.\n If omitted or set to `rw`, volumes are mounted read-write.\n- `[z|Z]` applies SELinux labels to allow or deny multiple containers\n to read and write to the same volume.\n - `z`: a _shared_ content label is applied to the content. This\n label indicates that multiple containers can share the volume\n content, for both reading and writing.\n - `Z`: a _private unshared_ label is applied to the content.\n This label indicates that only the current container can use\n a private volume. Labeling systems such as SELinux require\n proper labels to be placed on volume content that is mounted\n into a container. Without a label, the security system can\n prevent a container's processes from using the content. By\n default, the labels set by the host operating system are not\n modified.\n- `[[r]shared|[r]slave|[r]private]` specifies mount\n [propagation behavior](https://www.kernel.org/doc/Documentation/filesystems/sharedsubtree.txt).\n This only applies to bind-mounted volumes, not internal volumes\n or named volumes. Mount propagation requires the source mount\n point (the location where the source directory is mounted in the\n host operating system) to have the correct propagation properties.\n For shared volumes, the source mount point must be set to `shared`.\n For slave volumes, the mount must be set to either `shared` or\n `slave`.\n", ) - ContainerIDFile: Optional[str] = Field( + ContainerIDFile: str | None = Field( None, description="Path to a file where the container ID is written" ) - LogConfig: Optional[LogConfig] = Field( + LogConfig: LogConfig | None = Field( None, description="The logging configuration for this container" ) - NetworkMode: Optional[str] = Field( + NetworkMode: str | None = Field( None, description="Network mode to use for this container. Supported standard values\nare: `bridge`, `host`, `none`, and `container:`. Any\nother value is taken as a custom network's name to which this\ncontainer should connect to.\n", ) - PortBindings: Optional[PortMap] = None - RestartPolicy: Optional[RestartPolicy] = None - AutoRemove: Optional[bool] = Field( + PortBindings: PortMap | None = None + RestartPolicy: RestartPolicy | None = None + AutoRemove: bool | None = Field( None, description="Automatically remove the container when the container's process\nexits. This has no effect if `RestartPolicy` is set.\n", ) - VolumeDriver: Optional[str] = Field( + VolumeDriver: str | None = Field( None, description="Driver that this container uses to mount volumes." ) - VolumesFrom: Optional[list[str]] = Field( + VolumesFrom: list[str] | None = Field( None, description="A list of volumes to inherit from another container, specified in\nthe form `[:]`.\n", ) - Mounts: Optional[list[Mount]] = Field( + Mounts: list[Mount] | None = Field( None, description="Specification for mounts to be added to the container.\n" ) - CapAdd: Optional[list[str]] = Field( + CapAdd: list[str] | None = Field( None, description="A list of kernel capabilities to add to the container. Conflicts\nwith option 'Capabilities'.\n", ) - CapDrop: Optional[list[str]] = Field( + CapDrop: list[str] | None = Field( None, description="A list of kernel capabilities to drop from the container. Conflicts\nwith option 'Capabilities'.\n", ) - CgroupnsMode: Optional[CgroupnsMode] = Field( + CgroupnsMode: CgroupnsMode | None = Field( None, description='cgroup namespace mode for the container. Possible values are:\n\n- `"private"`: the container runs in its own private cgroup namespace\n- `"host"`: use the host system\'s cgroup namespace\n\nIf not specified, the daemon default is used, which can either be `"private"`\nor `"host"`, depending on daemon version, kernel support and configuration.\n', ) - Dns: Optional[list[str]] = Field( + Dns: list[str] | None = Field( None, description="A list of DNS servers for the container to use." ) - DnsOptions: Optional[list[str]] = Field(None, description="A list of DNS options.") - DnsSearch: Optional[list[str]] = Field( + DnsOptions: list[str] | None = Field(None, description="A list of DNS options.") + DnsSearch: list[str] | None = Field( None, description="A list of DNS search domains." ) - ExtraHosts: Optional[list[str]] = Field( + ExtraHosts: list[str] | None = Field( None, description='A list of hostnames/IP mappings to add to the container\'s `/etc/hosts`\nfile. Specified in the form `["hostname:IP"]`.\n', ) - GroupAdd: Optional[list[str]] = Field( + GroupAdd: list[str] | None = Field( None, description="A list of additional groups that the container process will run as.\n", ) - IpcMode: Optional[str] = Field( + IpcMode: str | None = Field( None, description='IPC sharing mode for the container. Possible values are:\n\n- `"none"`: own private IPC namespace, with /dev/shm not mounted\n- `"private"`: own private IPC namespace\n- `"shareable"`: own private IPC namespace, with a possibility to share it with other containers\n- `"container:"`: join another (shareable) container\'s IPC namespace\n- `"host"`: use the host system\'s IPC namespace\n\nIf not specified, daemon default is used, which can either be `"private"`\nor `"shareable"`, depending on daemon version and configuration.\n', ) - Cgroup: Optional[str] = Field(None, description="Cgroup to use for the container.") - Links: Optional[list[str]] = Field( + Cgroup: str | None = Field(None, description="Cgroup to use for the container.") + Links: list[str] | None = Field( None, description="A list of links for the container in the form `container_name:alias`.\n", ) - OomScoreAdj: Optional[int] = Field( + OomScoreAdj: int | None = Field( None, description="An integer value containing the score given to the container in\norder to tune OOM killer preferences.\n", example=500, ) - PidMode: Optional[str] = Field( + PidMode: str | None = Field( None, description='Set the PID (Process) Namespace mode for the container. It can be\neither:\n\n- `"container:"`: joins another container\'s PID namespace\n- `"host"`: use the host\'s PID namespace inside the container\n', ) - Privileged: Optional[bool] = Field( + Privileged: bool | None = Field( None, description="Gives the container full access to the host." ) - PublishAllPorts: Optional[bool] = Field( + PublishAllPorts: bool | None = Field( None, description="Allocates an ephemeral host port for all of a container's\nexposed ports.\n\nPorts are de-allocated when the container stops and allocated when\nthe container starts. The allocated port might be changed when\nrestarting the container.\n\nThe port is selected from the ephemeral port range that depends on\nthe kernel. For example, on Linux the range is defined by\n`/proc/sys/net/ipv4/ip_local_port_range`.\n", ) - ReadonlyRootfs: Optional[bool] = Field( + ReadonlyRootfs: bool | None = Field( None, description="Mount the container's root filesystem as read only." ) - SecurityOpt: Optional[list[str]] = Field( + SecurityOpt: list[str] | None = Field( None, description="A list of string values to customize labels for MLS systems, such\nas SELinux.\n", ) - StorageOpt: Optional[dict[str, str]] = Field( + StorageOpt: dict[str, str] | None = Field( None, description='Storage driver options for this container, in the form `{"size": "120G"}`.\n', ) - Tmpfs: Optional[dict[str, str]] = Field( + Tmpfs: dict[str, str] | None = Field( None, description='A map of container directories which should be replaced by tmpfs\nmounts, and their corresponding mount options. For example:\n\n```\n{ "/run": "rw,noexec,nosuid,size=65536k" }\n```\n', ) - UTSMode: Optional[str] = Field( + UTSMode: str | None = Field( None, description="UTS namespace to use for the container." ) - UsernsMode: Optional[str] = Field( + UsernsMode: str | None = Field( None, description="Sets the usernamespace mode for the container when usernamespace\nremapping option is enabled.\n", ) - ShmSize: Optional[int] = Field( + ShmSize: int | None = Field( None, description="Size of `/dev/shm` in bytes. If omitted, the system uses 64MB.\n", ge=0, ) - Sysctls: Optional[dict[str, str]] = Field( + Sysctls: dict[str, str] | None = Field( None, description='A list of kernel parameters (sysctls) to set in the container.\nFor example:\n\n```\n{"net.ipv4.ip_forward": "1"}\n```\n', ) - Runtime: Optional[str] = Field( - None, description="Runtime to use with this container." - ) - ConsoleSize: Optional[list[ConsoleSizeItem]] = Field( + Runtime: str | None = Field(None, description="Runtime to use with this container.") + ConsoleSize: list[ConsoleSizeItem] | None = Field( None, description="Initial console size, as an `[height, width]` array. (Windows only)\n", max_items=2, min_items=2, ) - Isolation: Optional[Isolation] = Field( + Isolation: Isolation | None = Field( None, description="Isolation technology of the container. (Windows only)\n" ) - MaskedPaths: Optional[list[str]] = Field( + MaskedPaths: list[str] | None = Field( None, description="The list of paths to be masked inside the container (this overrides\nthe default set of paths).\n", ) - ReadonlyPaths: Optional[list[str]] = Field( + ReadonlyPaths: list[str] | None = Field( None, description="The list of paths to be set as read-only inside the container\n(this overrides the default set of paths).\n", ) class IPAM(BaseModel): - Driver: Optional[str] = Field( - "default", description="Name of the IPAM driver to use." - ) - Config_: Optional[list[IPAMConfig]] = Field( + Driver: str | None = Field("default", description="Name of the IPAM driver to use.") + Config_: list[IPAMConfig] | None = Field( None, alias="Config", description='List of IPAM configuration options, specified as a map:\n\n```\n{"Subnet": , "IPRange": , "Gateway": , "AuxAddress": }\n```\n', ) - Options: Optional[dict[str, str]] = Field( + Options: dict[str, str] | None = Field( None, description="Driver-specific options, specified as a map." ) class BuildInfo(BaseModel): - id: Optional[str] = None - stream: Optional[str] = None - error: Optional[str] = None - errorDetail: Optional[ErrorDetail] = None - status: Optional[str] = None - progress: Optional[str] = None - progressDetail: Optional[ProgressDetail] = None - aux: Optional[ImageID] = None + id: str | None = None + stream: str | None = None + error: str | None = None + errorDetail: ErrorDetail | None = None + status: str | None = None + progress: str | None = None + progressDetail: ProgressDetail | None = None + aux: ImageID | None = None class CreateImageInfo(BaseModel): - id: Optional[str] = None - error: Optional[str] = None - status: Optional[str] = None - progress: Optional[str] = None - progressDetail: Optional[ProgressDetail] = None + id: str | None = None + error: str | None = None + status: str | None = None + progress: str | None = None + progressDetail: ProgressDetail | None = None class PushImageInfo(BaseModel): - error: Optional[str] = None - status: Optional[str] = None - progress: Optional[str] = None - progressDetail: Optional[ProgressDetail] = None + error: str | None = None + status: str | None = None + progress: str | None = None + progressDetail: ProgressDetail | None = None class EndpointSettings(BaseModel): @@ -3183,43 +3157,43 @@ class EndpointSettings(BaseModel): Configuration for a network endpoint. """ - IPAMConfig: Optional[EndpointIPAMConfig] = None - Links: Optional[list[str]] = Field(None, example=["container_1", "container_2"]) - Aliases: Optional[list[str]] = Field(None, example=["server_x", "server_y"]) - NetworkID: Optional[str] = Field( + IPAMConfig: EndpointIPAMConfig | None = None + Links: list[str] | None = Field(None, example=["container_1", "container_2"]) + Aliases: list[str] | None = Field(None, example=["server_x", "server_y"]) + NetworkID: str | None = Field( None, description="Unique ID of the network.\n", example="08754567f1f40222263eab4102e1c733ae697e8e354aa9cd6e18d7402835292a", ) - EndpointID: Optional[str] = Field( + EndpointID: str | None = Field( None, description="Unique ID for the service endpoint in a Sandbox.\n", example="b88f5b905aabf2893f3cbc4ee42d1ea7980bbc0a92e2c8922b1e1795298afb0b", ) - Gateway: Optional[str] = Field( + Gateway: str | None = Field( None, description="Gateway address for this network.\n", example="172.17.0.1" ) - IPAddress: Optional[str] = Field( + IPAddress: str | None = Field( None, description="IPv4 address.\n", example="172.17.0.4" ) - IPPrefixLen: Optional[int] = Field( + IPPrefixLen: int | None = Field( None, description="Mask length of the IPv4 address.\n", example=16 ) - IPv6Gateway: Optional[str] = Field( + IPv6Gateway: str | None = Field( None, description="IPv6 gateway address.\n", example="2001:db8:2::100" ) - GlobalIPv6Address: Optional[str] = Field( + GlobalIPv6Address: str | None = Field( None, description="Global IPv6 address.\n", example="2001:db8::5689" ) - GlobalIPv6PrefixLen: Optional[int] = Field( + GlobalIPv6PrefixLen: int | None = Field( None, description="Mask length of the global IPv6 address.\n", example=64 ) - MacAddress: Optional[str] = Field( + MacAddress: str | None = Field( None, description="MAC address for the endpoint on this network.\n", example="02:42:ac:11:00:04", ) - DriverOpts: Optional[dict[str, str]] = Field( + DriverOpts: dict[str, str] | None = Field( None, description="DriverOpts is a mapping of driver options and values. These options\nare passed directly to the driver and are driver specific.\n", example={ @@ -3236,11 +3210,11 @@ class NodeDescription(BaseModel): """ - Hostname: Optional[str] = Field(None, example="bf3067039e47") - Platform: Optional[Platform] = None - Resources: Optional[ResourceObject] = None - Engine: Optional[EngineDescription] = None - TLSInfo: Optional[TLSInfo] = None + Hostname: str | None = Field(None, example="bf3067039e47") + Platform: Platform | None = None + Resources: ResourceObject | None = None + Engine: EngineDescription | None = None + TLSInfo: TLSInfo | None = None class NodeStatus(BaseModel): @@ -3251,9 +3225,9 @@ class NodeStatus(BaseModel): """ - State: Optional[NodeState] = None - Message: Optional[str] = Field(None, example="") - Addr: Optional[str] = Field( + State: NodeState | None = None + Message: str | None = Field(None, example="") + Addr: str | None = Field( None, description="IP address of the node.", example="172.17.0.2" ) @@ -3267,9 +3241,9 @@ class ManagerStatus(BaseModel): """ - Leader: Optional[bool] = Field(False, example=True) - Reachability: Optional[Reachability] = None - Addr: Optional[str] = Field( + Leader: bool | None = Field(False, example=True) + Reachability: Reachability | None = None + Addr: str | None = Field( None, description="The IP address and port at which the manager is reachable.\n", example="10.0.0.46:2377", @@ -3283,8 +3257,8 @@ class Resources1(BaseModel): """ - Limits: Optional[Limit] = Field(None, description="Define resources limits.") - Reservations: Optional[ResourceObject] = Field( + Limits: Limit | None = Field(None, description="Define resources limits.") + Reservations: ResourceObject | None = Field( None, description="Define resources reservation." ) @@ -3294,65 +3268,65 @@ class TaskSpec(BaseModel): User modifiable task configuration. """ - PluginSpec: Optional[PluginSpec] = Field( + PluginSpec: PluginSpec | None = Field( None, description="Plugin spec for the service. *(Experimental release only.)*\n\n


\n\n> **Note**: ContainerSpec, NetworkAttachmentSpec, and PluginSpec are\n> mutually exclusive. PluginSpec is only used when the Runtime field\n> is set to `plugin`. NetworkAttachmentSpec is used when the Runtime\n> field is set to `attachment`.\n", ) - ContainerSpec: Optional[ContainerSpec] = Field( + ContainerSpec: ContainerSpec | None = Field( None, description="Container spec for the service.\n\n


\n\n> **Note**: ContainerSpec, NetworkAttachmentSpec, and PluginSpec are\n> mutually exclusive. PluginSpec is only used when the Runtime field\n> is set to `plugin`. NetworkAttachmentSpec is used when the Runtime\n> field is set to `attachment`.\n", ) - NetworkAttachmentSpec: Optional[NetworkAttachmentSpec] = Field( + NetworkAttachmentSpec: NetworkAttachmentSpec | None = Field( None, description="Read-only spec type for non-swarm containers attached to swarm overlay\nnetworks.\n\n


\n\n> **Note**: ContainerSpec, NetworkAttachmentSpec, and PluginSpec are\n> mutually exclusive. PluginSpec is only used when the Runtime field\n> is set to `plugin`. NetworkAttachmentSpec is used when the Runtime\n> field is set to `attachment`.\n", ) - Resources: Optional[Resources1] = Field( + Resources: Resources1 | None = Field( None, description="Resource requirements which apply to each individual container created\nas part of the service.\n", ) - RestartPolicy: Optional[RestartPolicy1] = Field( + RestartPolicy: RestartPolicy1 | None = Field( None, description="Specification for the restart policy which applies to containers\ncreated as part of this service.\n", ) - Placement: Optional[Placement] = None - ForceUpdate: Optional[int] = Field( + Placement: Placement | None = None + ForceUpdate: int | None = Field( None, description="A counter that triggers an update even if no relevant parameters have\nbeen changed.\n", ) - Runtime: Optional[str] = Field( + Runtime: str | None = Field( None, description="Runtime is the type of runtime specified for the task executor.\n", ) - Networks: Optional[list[NetworkAttachmentConfig]] = Field( + Networks: list[NetworkAttachmentConfig] | None = Field( None, description="Specifies which networks the service should attach to." ) - LogDriver: Optional[LogDriver1] = Field( + LogDriver: LogDriver1 | None = Field( None, description="Specifies the log driver to use for tasks created from this spec. If\nnot present, the default one for the swarm will be used, finally\nfalling back to the engine default if not specified.\n", ) class Task(BaseModel): - ID: Optional[str] = Field(None, description="The ID of the task.") - Version: Optional[ObjectVersion] = None - CreatedAt: Optional[str] = None - UpdatedAt: Optional[str] = None - Name: Optional[str] = Field(None, description="Name of the task.") - Labels: Optional[dict[str, str]] = Field( + ID: str | None = Field(None, description="The ID of the task.") + Version: ObjectVersion | None = None + CreatedAt: str | None = None + UpdatedAt: str | None = None + Name: str | None = Field(None, description="Name of the task.") + Labels: dict[str, str] | None = Field( None, description="User-defined key/value metadata." ) - Spec: Optional[TaskSpec] = None - ServiceID: Optional[str] = Field( + Spec: TaskSpec | None = None + ServiceID: str | None = Field( None, description="The ID of the service this task is part of." ) - Slot: Optional[int] = None - NodeID: Optional[str] = Field( + Slot: int | None = None + NodeID: str | None = Field( None, description="The ID of the node that this task is on." ) - AssignedGenericResources: Optional[GenericResources] = None - Status: Optional[Status1] = None - DesiredState: Optional[TaskState] = None - JobIteration: Optional[ObjectVersion] = Field( + AssignedGenericResources: GenericResources | None = None + Status: Status1 | None = None + DesiredState: TaskState | None = None + JobIteration: ObjectVersion | None = Field( None, description="If the Service this Task belongs to is a job-mode service, contains\nthe JobIteration of the Service this Task was created for. Absent if\nthe Task was created for a Replicated or Global Service.\n", ) @@ -3363,39 +3337,39 @@ class ServiceSpec(BaseModel): User modifiable configuration for a service. """ - Name: Optional[str] = Field(None, description="Name of the service.") - Labels: Optional[dict[str, str]] = Field( + Name: str | None = Field(None, description="Name of the service.") + Labels: dict[str, str] | None = Field( None, description="User-defined key/value metadata." ) - TaskTemplate: Optional[TaskSpec] = None - Mode: Optional[Mode] = Field(None, description="Scheduling mode for the service.") - UpdateConfig: Optional[UpdateConfig] = Field( + TaskTemplate: TaskSpec | None = None + Mode: Mode | None = Field(None, description="Scheduling mode for the service.") + UpdateConfig: UpdateConfig | None = Field( None, description="Specification for the update strategy of the service." ) - RollbackConfig: Optional[RollbackConfig] = Field( + RollbackConfig: RollbackConfig | None = Field( None, description="Specification for the rollback strategy of the service." ) - Networks: Optional[list[NetworkAttachmentConfig]] = Field( + Networks: list[NetworkAttachmentConfig] | None = Field( None, description="Specifies which networks the service should attach to." ) - EndpointSpec: Optional[EndpointSpec] = None + EndpointSpec: EndpointSpec | None = None class Service(BaseModel): - ID: Optional[str] = None - Version: Optional[ObjectVersion] = None - CreatedAt: Optional[str] = None - UpdatedAt: Optional[str] = None - Spec: Optional[ServiceSpec] = None - Endpoint: Optional[Endpoint] = None - UpdateStatus: Optional[UpdateStatus] = Field( + ID: str | None = None + Version: ObjectVersion | None = None + CreatedAt: str | None = None + UpdatedAt: str | None = None + Spec: ServiceSpec | None = None + Endpoint: Endpoint | None = None + UpdateStatus: UpdateStatus | None = Field( None, description="The status of a service update." ) - ServiceStatus: Optional[ServiceStatus] = Field( + ServiceStatus: ServiceStatus | None = Field( None, description="The status of the service's tasks. Provided only when requested as\npart of a ServiceList operation.\n", ) - JobStatus: Optional[JobStatus] = Field( + JobStatus: JobStatus | None = Field( None, description="The status of the service when it is in one of ReplicatedJob or\nGlobalJob modes. Absent on Replicated and Global mode services. The\nJobIteration is an ObjectVersion, but unlike the Service's version,\ndoes not need to be sent with an update request.\n", ) @@ -3406,49 +3380,49 @@ class NetworkSettings1(BaseModel): A summary of the container's network settings """ - Networks: Optional[dict[str, EndpointSettings]] = None + Networks: dict[str, EndpointSettings] | None = None class ContainerSummary(BaseModel): - Id: Optional[str] = Field(None, description="The ID of this container") - Names: Optional[list[str]] = Field( + Id: str | None = Field(None, description="The ID of this container") + Names: list[str] | None = Field( None, description="The names that this container has been given" ) - Image: Optional[str] = Field( + Image: str | None = Field( None, description="The name of the image used when creating this container" ) - ImageID: Optional[str] = Field( + ImageID: str | None = Field( None, description="The ID of the image that this container was created from" ) - Command: Optional[str] = Field( + Command: str | None = Field( None, description="Command to run when starting the container" ) - Created: Optional[int] = Field(None, description="When the container was created") - Ports: Optional[list[Port]] = Field( + Created: int | None = Field(None, description="When the container was created") + Ports: list[Port] | None = Field( None, description="The ports exposed by this container" ) - SizeRw: Optional[int] = Field( + SizeRw: int | None = Field( None, description="The size of files that have been created or changed by this container", ) - SizeRootFs: Optional[int] = Field( + SizeRootFs: int | None = Field( None, description="The total size of all the files in this container" ) - Labels: Optional[dict[str, str]] = Field( + Labels: dict[str, str] | None = Field( None, description="User-defined key/value metadata." ) - State: Optional[str] = Field( + State: str | None = Field( None, description="The state of this container (e.g. `Exited`)" ) - Status: Optional[str] = Field( + Status: str | None = Field( None, description="Additional human-readable status of this container (e.g. `Exit 0`)", ) - HostConfig: Optional[HostConfig1] = None - NetworkSettings: Optional[NetworkSettings1] = Field( + HostConfig: HostConfig1 | None = None + NetworkSettings: NetworkSettings1 | None = Field( None, description="A summary of the container's network settings" ) - Mounts: Optional[list[MountPoint]] = None + Mounts: list[MountPoint] | None = None class ContainerState(BaseModel): @@ -3458,46 +3432,46 @@ class ContainerState(BaseModel): """ - Status: Optional[Status2] = Field( + Status: Status2 | None = Field( None, description='String representation of the container state. Can be one of "created",\n"running", "paused", "restarting", "removing", "exited", or "dead".\n', example="running", ) - Running: Optional[bool] = Field( + Running: bool | None = Field( None, description='Whether this container is running.\n\nNote that a running container can be _paused_. The `Running` and `Paused`\nbooleans are not mutually exclusive:\n\nWhen pausing a container (on Linux), the freezer cgroup is used to suspend\nall processes in the container. Freezing the process requires the process to\nbe running. As a result, paused containers are both `Running` _and_ `Paused`.\n\nUse the `Status` field instead to determine if a container\'s state is "running".\n', example=True, ) - Paused: Optional[bool] = Field( + Paused: bool | None = Field( None, description="Whether this container is paused.", example=False ) - Restarting: Optional[bool] = Field( + Restarting: bool | None = Field( None, description="Whether this container is restarting.", example=False ) - OOMKilled: Optional[bool] = Field( + OOMKilled: bool | None = Field( None, description="Whether this container has been killed because it ran out of memory.\n", example=False, ) - Dead: Optional[bool] = Field(None, example=False) - Pid: Optional[int] = Field( + Dead: bool | None = Field(None, example=False) + Pid: int | None = Field( None, description="The process ID of this container", example=1234 ) - ExitCode: Optional[int] = Field( + ExitCode: int | None = Field( None, description="The last exit code of this container", example=0 ) - Error: Optional[str] = None - StartedAt: Optional[str] = Field( + Error: str | None = None + StartedAt: str | None = Field( None, description="The time when this container was last started.", example="2020-01-06T09:06:59.461876391Z", ) - FinishedAt: Optional[str] = Field( + FinishedAt: str | None = Field( None, description="The time when this container last exited.", example="2020-01-06T09:07:59.461876391Z", ) - Health: Optional[Health] = None + Health: Health | None = None class ContainerWaitResponse(BaseModel): @@ -3506,7 +3480,7 @@ class ContainerWaitResponse(BaseModel): """ StatusCode: int = Field(..., description="Exit code of the container") - Error: Optional[ContainerWaitExitError] = None + Error: ContainerWaitExitError | None = None class RegistryServiceConfig(BaseModel): @@ -3515,12 +3489,12 @@ class RegistryServiceConfig(BaseModel): """ - AllowNondistributableArtifactsCIDRs: Optional[list[str]] = Field( + AllowNondistributableArtifactsCIDRs: list[str] | None = Field( None, description="List of IP ranges to which nondistributable artifacts can be pushed,\nusing the CIDR syntax [RFC 4632](https://tools.ietf.org/html/4632).\n\nSome images (for example, Windows base images) contain artifacts\nwhose distribution is restricted by license. When these images are\npushed to a registry, restricted artifacts are not included.\n\nThis configuration override this behavior, and enables the daemon to\npush nondistributable artifacts to all registries whose resolved IP\naddress is within the subnet described by the CIDR syntax.\n\nThis option is useful when pushing images containing\nnondistributable artifacts to a registry on an air-gapped network so\nhosts on that network can pull the images without connecting to\nanother server.\n\n> **Warning**: Nondistributable artifacts typically have restrictions\n> on how and where they can be distributed and shared. Only use this\n> feature to push artifacts to private registries and ensure that you\n> are in compliance with any terms that cover redistributing\n> nondistributable artifacts.\n", example=["::1/128", "127.0.0.0/8"], ) - AllowNondistributableArtifactsHostnames: Optional[list[str]] = Field( + AllowNondistributableArtifactsHostnames: list[str] | None = Field( None, description="List of registry hostnames to which nondistributable artifacts can be\npushed, using the format `[:]` or `[:]`.\n\nSome images (for example, Windows base images) contain artifacts\nwhose distribution is restricted by license. When these images are\npushed to a registry, restricted artifacts are not included.\n\nThis configuration override this behavior for the specified\nregistries.\n\nThis option is useful when pushing images containing\nnondistributable artifacts to a registry on an air-gapped network so\nhosts on that network can pull the images without connecting to\nanother server.\n\n> **Warning**: Nondistributable artifacts typically have restrictions\n> on how and where they can be distributed and shared. Only use this\n> feature to push artifacts to private registries and ensure that you\n> are in compliance with any terms that cover redistributing\n> nondistributable artifacts.\n", example=[ @@ -3528,12 +3502,12 @@ class RegistryServiceConfig(BaseModel): "[2001:db8:a0b:12f0::1]:443", ], ) - InsecureRegistryCIDRs: Optional[list[str]] = Field( + InsecureRegistryCIDRs: list[str] | None = Field( None, description="List of IP ranges of insecure registries, using the CIDR syntax\n([RFC 4632](https://tools.ietf.org/html/4632)). Insecure registries\naccept un-encrypted (HTTP) and/or untrusted (HTTPS with certificates\nfrom unknown CAs) communication.\n\nBy default, local registries (`127.0.0.0/8`) are configured as\ninsecure. All other registries are secure. Communicating with an\ninsecure registry is not possible if the daemon assumes that registry\nis secure.\n\nThis configuration override this behavior, insecure communication with\nregistries whose resolved IP address is within the subnet described by\nthe CIDR syntax.\n\nRegistries can also be marked insecure by hostname. Those registries\nare listed under `IndexConfigs` and have their `Secure` field set to\n`false`.\n\n> **Warning**: Using this option can be useful when running a local\n> registry, but introduces security vulnerabilities. This option\n> should therefore ONLY be used for testing purposes. For increased\n> security, users should add their CA to their system's list of trusted\n> CAs instead of enabling this option.\n", example=["::1/128", "127.0.0.0/8"], ) - IndexConfigs: Optional[dict[str, IndexInfo]] = Field( + IndexConfigs: dict[str, IndexInfo] | None = Field( None, example={ "127.0.0.1:5000": { @@ -3562,7 +3536,7 @@ class RegistryServiceConfig(BaseModel): }, }, ) - Mirrors: Optional[list[str]] = Field( + Mirrors: list[str] | None = Field( None, description="List of registry URLs that act as a mirror for the official\n(`docker.io`) registry.\n", example=[ @@ -3578,20 +3552,20 @@ class SwarmInfo(BaseModel): """ - NodeID: Optional[str] = Field( + NodeID: str | None = Field( "", description="Unique identifier of for this node in the swarm.", example="k67qz4598weg5unwwffg6z1m1", ) - NodeAddr: Optional[str] = Field( + NodeAddr: str | None = Field( "", description="IP address at which this node can be reached by other nodes in the\nswarm.\n", example="10.0.0.46", ) - LocalNodeState: Optional[LocalNodeState] = "" - ControlAvailable: Optional[bool] = Field(False, example=True) - Error: Optional[str] = "" - RemoteManagers: Optional[list[PeerNode]] = Field( + LocalNodeState: LocalNodeState | None = None + ControlAvailable: bool | None = Field(False, example=True) + Error: str | None = "" + RemoteManagers: list[PeerNode] | None = Field( None, description="List of ID's and addresses of other managers in the swarm.\n", example=[ @@ -3600,13 +3574,13 @@ class SwarmInfo(BaseModel): {"NodeID": "k67qz4598weg5unwwffg6z1m1", "Addr": "10.0.0.46:2377"}, ], ) - Nodes: Optional[int] = Field( + Nodes: int | None = Field( None, description="Total number of nodes in the swarm.", example=4 ) - Managers: Optional[int] = Field( + Managers: int | None = Field( None, description="Total number of managers in the swarm.", example=3 ) - Cluster: Optional[ClusterInfo] = None + Cluster: ClusterInfo | None = None class NetworkingConfig(BaseModel): @@ -3618,7 +3592,7 @@ class NetworkingConfig(BaseModel): """ - EndpointsConfig: Optional[dict[str, EndpointSettings]] = Field( + EndpointsConfig: dict[str, EndpointSettings] | None = Field( None, description="A mapping of network name to endpoint configuration for that network.\n", ) @@ -3629,145 +3603,145 @@ class NetworkSettings(BaseModel): NetworkSettings exposes the network settings in the API """ - Bridge: Optional[str] = Field( + Bridge: str | None = Field( None, description="Name of the network'a bridge (for example, `docker0`).", example="docker0", ) - SandboxID: Optional[str] = Field( + SandboxID: str | None = Field( None, description="SandboxID uniquely represents a container's network stack.", example="9d12daf2c33f5959c8bf90aa513e4f65b561738661003029ec84830cd503a0c3", ) - HairpinMode: Optional[bool] = Field( + HairpinMode: bool | None = Field( None, description="Indicates if hairpin NAT should be enabled on the virtual interface.\n", example=False, ) - LinkLocalIPv6Address: Optional[str] = Field( + LinkLocalIPv6Address: str | None = Field( None, description="IPv6 unicast address using the link-local prefix.", example="fe80::42:acff:fe11:1", ) - LinkLocalIPv6PrefixLen: Optional[int] = Field( + LinkLocalIPv6PrefixLen: int | None = Field( None, description="Prefix length of the IPv6 unicast address.", example="64" ) - Ports: Optional[PortMap] = None - SandboxKey: Optional[str] = Field( + Ports: PortMap | None = None + SandboxKey: str | None = Field( None, description="SandboxKey identifies the sandbox", example="/var/run/docker/netns/8ab54b426c38", ) - SecondaryIPAddresses: Optional[list[Address]] = Field(None, description="") - SecondaryIPv6Addresses: Optional[list[Address]] = Field(None, description="") - EndpointID: Optional[str] = Field( + SecondaryIPAddresses: list[Address] | None = Field(None, description="") + SecondaryIPv6Addresses: list[Address] | None = Field(None, description="") + EndpointID: str | None = Field( None, description='EndpointID uniquely represents a service endpoint in a Sandbox.\n\n


\n\n> **Deprecated**: This field is only propagated when attached to the\n> default "bridge" network. Use the information from the "bridge"\n> network inside the `Networks` map instead, which contains the same\n> information. This field was deprecated in Docker 1.9 and is scheduled\n> to be removed in Docker 17.12.0\n', example="b88f5b905aabf2893f3cbc4ee42d1ea7980bbc0a92e2c8922b1e1795298afb0b", ) - Gateway: Optional[str] = Field( + Gateway: str | None = Field( None, description='Gateway address for the default "bridge" network.\n\n


\n\n> **Deprecated**: This field is only propagated when attached to the\n> default "bridge" network. Use the information from the "bridge"\n> network inside the `Networks` map instead, which contains the same\n> information. This field was deprecated in Docker 1.9 and is scheduled\n> to be removed in Docker 17.12.0\n', example="172.17.0.1", ) - GlobalIPv6Address: Optional[str] = Field( + GlobalIPv6Address: str | None = Field( None, description='Global IPv6 address for the default "bridge" network.\n\n


\n\n> **Deprecated**: This field is only propagated when attached to the\n> default "bridge" network. Use the information from the "bridge"\n> network inside the `Networks` map instead, which contains the same\n> information. This field was deprecated in Docker 1.9 and is scheduled\n> to be removed in Docker 17.12.0\n', example="2001:db8::5689", ) - GlobalIPv6PrefixLen: Optional[int] = Field( + GlobalIPv6PrefixLen: int | None = Field( None, description='Mask length of the global IPv6 address.\n\n


\n\n> **Deprecated**: This field is only propagated when attached to the\n> default "bridge" network. Use the information from the "bridge"\n> network inside the `Networks` map instead, which contains the same\n> information. This field was deprecated in Docker 1.9 and is scheduled\n> to be removed in Docker 17.12.0\n', example=64, ) - IPAddress: Optional[str] = Field( + IPAddress: str | None = Field( None, description='IPv4 address for the default "bridge" network.\n\n


\n\n> **Deprecated**: This field is only propagated when attached to the\n> default "bridge" network. Use the information from the "bridge"\n> network inside the `Networks` map instead, which contains the same\n> information. This field was deprecated in Docker 1.9 and is scheduled\n> to be removed in Docker 17.12.0\n', example="172.17.0.4", ) - IPPrefixLen: Optional[int] = Field( + IPPrefixLen: int | None = Field( None, description='Mask length of the IPv4 address.\n\n


\n\n> **Deprecated**: This field is only propagated when attached to the\n> default "bridge" network. Use the information from the "bridge"\n> network inside the `Networks` map instead, which contains the same\n> information. This field was deprecated in Docker 1.9 and is scheduled\n> to be removed in Docker 17.12.0\n', example=16, ) - IPv6Gateway: Optional[str] = Field( + IPv6Gateway: str | None = Field( None, description='IPv6 gateway address for this network.\n\n


\n\n> **Deprecated**: This field is only propagated when attached to the\n> default "bridge" network. Use the information from the "bridge"\n> network inside the `Networks` map instead, which contains the same\n> information. This field was deprecated in Docker 1.9 and is scheduled\n> to be removed in Docker 17.12.0\n', example="2001:db8:2::100", ) - MacAddress: Optional[str] = Field( + MacAddress: str | None = Field( None, description='MAC address for the container on the default "bridge" network.\n\n


\n\n> **Deprecated**: This field is only propagated when attached to the\n> default "bridge" network. Use the information from the "bridge"\n> network inside the `Networks` map instead, which contains the same\n> information. This field was deprecated in Docker 1.9 and is scheduled\n> to be removed in Docker 17.12.0\n', example="02:42:ac:11:00:04", ) - Networks: Optional[dict[str, EndpointSettings]] = Field( + Networks: dict[str, EndpointSettings] | None = Field( None, description="Information about all networks that the container is connected to.\n", ) class Network(BaseModel): - Name: Optional[str] = None - Id: Optional[str] = None - Created: Optional[str] = None - Scope: Optional[str] = None - Driver: Optional[str] = None - EnableIPv6: Optional[bool] = None - IPAM: Optional[IPAM] = None - Internal: Optional[bool] = None - Attachable: Optional[bool] = None - Ingress: Optional[bool] = None - Containers: Optional[dict[str, NetworkContainer]] = None - Options: Optional[dict[str, str]] = None - Labels: Optional[dict[str, str]] = None + Name: str | None = None + Id: str | None = None + Created: str | None = None + Scope: str | None = None + Driver: str | None = None + EnableIPv6: bool | None = None + IPAM: IPAM | None = None + Internal: bool | None = None + Attachable: bool | None = None + Ingress: bool | None = None + Containers: dict[str, NetworkContainer] | None = None + Options: dict[str, str] | None = None + Labels: dict[str, str] | None = None class Node(BaseModel): - ID: Optional[str] = Field(None, example="24ifsmvkjbyhk") - Version: Optional[ObjectVersion] = None - CreatedAt: Optional[str] = Field( + ID: str | None = Field(None, example="24ifsmvkjbyhk") + Version: ObjectVersion | None = None + CreatedAt: str | None = Field( None, description="Date and time at which the node was added to the swarm in\n[RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds.\n", example="2016-08-18T10:44:24.496525531Z", ) - UpdatedAt: Optional[str] = Field( + UpdatedAt: str | None = Field( None, description="Date and time at which the node was last updated in\n[RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds.\n", example="2017-08-09T07:09:37.632105588Z", ) - Spec: Optional[NodeSpec] = None - Description: Optional[NodeDescription] = None - Status: Optional[NodeStatus] = None - ManagerStatus: Optional[ManagerStatus] = None + Spec: NodeSpec | None = None + Description: NodeDescription | None = None + Status: NodeStatus | None = None + ManagerStatus: ManagerStatus | None = None class SystemInfo(BaseModel): - ID: Optional[str] = Field( + ID: str | None = Field( None, description="Unique identifier of the daemon.\n\n


\n\n> **Note**: The format of the ID itself is not part of the API, and\n> should not be considered stable.\n", example="7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS", ) - Containers: Optional[int] = Field( + Containers: int | None = Field( None, description="Total number of containers on the host.", example=14 ) - ContainersRunning: Optional[int] = Field( + ContainersRunning: int | None = Field( None, description='Number of containers with status `"running"`.\n', example=3 ) - ContainersPaused: Optional[int] = Field( + ContainersPaused: int | None = Field( None, description='Number of containers with status `"paused"`.\n', example=1 ) - ContainersStopped: Optional[int] = Field( + ContainersStopped: int | None = Field( None, description='Number of containers with status `"stopped"`.\n', example=10 ) - Images: Optional[int] = Field( + Images: int | None = Field( None, description="Total number of images on the host.\n\nBoth _tagged_ and _untagged_ (dangling) images are counted.\n", example=508, ) - Driver: Optional[str] = Field( + Driver: str | None = Field( None, description="Name of the storage driver in use.", example="overlay2" ) - DriverStatus: Optional[list[list[str]]] = Field( + DriverStatus: list[list[str]] | None = Field( None, description='Information specific to the storage driver, provided as\n"label" / "value" pairs.\n\nThis information is provided by the storage driver, and formatted\nin a way consistent with the output of `docker info` on the command\nline.\n\n


\n\n> **Note**: The information returned in this field, including the\n> formatting of values and labels, should not be considered stable,\n> and may change without notice.\n', example=[ @@ -3776,193 +3750,193 @@ class SystemInfo(BaseModel): ["Native Overlay Diff", "true"], ], ) - DockerRootDir: Optional[str] = Field( + DockerRootDir: str | None = Field( None, description="Root directory of persistent Docker state.\n\nDefaults to `/var/lib/docker` on Linux, and `C:\\ProgramData\\docker`\non Windows.\n", example="/var/lib/docker", ) - Plugins: Optional[PluginsInfo] = None - MemoryLimit: Optional[bool] = Field( + Plugins: PluginsInfo | None = None + MemoryLimit: bool | None = Field( None, description="Indicates if the host has memory limit support enabled.", example=True, ) - SwapLimit: Optional[bool] = Field( + SwapLimit: bool | None = Field( None, description="Indicates if the host has memory swap limit support enabled.", example=True, ) - KernelMemory: Optional[bool] = Field( + KernelMemory: bool | None = Field( None, description="Indicates if the host has kernel memory limit support enabled.\n\n


\n\n> **Deprecated**: This field is deprecated as the kernel 5.4 deprecated\n> `kmem.limit_in_bytes`.\n", example=True, ) - KernelMemoryTCP: Optional[bool] = Field( + KernelMemoryTCP: bool | None = Field( None, description="Indicates if the host has kernel memory TCP limit support enabled.\n\nKernel memory TCP limits are not supported when using cgroups v2, which\ndoes not support the corresponding `memory.kmem.tcp.limit_in_bytes` cgroup.\n", example=True, ) - CpuCfsPeriod: Optional[bool] = Field( + CpuCfsPeriod: bool | None = Field( None, description="Indicates if CPU CFS(Completely Fair Scheduler) period is supported by\nthe host.\n", example=True, ) - CpuCfsQuota: Optional[bool] = Field( + CpuCfsQuota: bool | None = Field( None, description="Indicates if CPU CFS(Completely Fair Scheduler) quota is supported by\nthe host.\n", example=True, ) - CPUShares: Optional[bool] = Field( + CPUShares: bool | None = Field( None, description="Indicates if CPU Shares limiting is supported by the host.\n", example=True, ) - CPUSet: Optional[bool] = Field( + CPUSet: bool | None = Field( None, description="Indicates if CPUsets (cpuset.cpus, cpuset.mems) are supported by the host.\n\nSee [cpuset(7)](https://www.kernel.org/doc/Documentation/cgroup-v1/cpusets.txt)\n", example=True, ) - PidsLimit: Optional[bool] = Field( + PidsLimit: bool | None = Field( None, description="Indicates if the host kernel has PID limit support enabled.", example=True, ) - OomKillDisable: Optional[bool] = Field( + OomKillDisable: bool | None = Field( None, description="Indicates if OOM killer disable is supported on the host." ) - IPv4Forwarding: Optional[bool] = Field( + IPv4Forwarding: bool | None = Field( None, description="Indicates IPv4 forwarding is enabled.", example=True ) - BridgeNfIptables: Optional[bool] = Field( + BridgeNfIptables: bool | None = Field( None, description="Indicates if `bridge-nf-call-iptables` is available on the host.", example=True, ) - BridgeNfIp6tables: Optional[bool] = Field( + BridgeNfIp6tables: bool | None = Field( None, description="Indicates if `bridge-nf-call-ip6tables` is available on the host.", example=True, ) - Debug: Optional[bool] = Field( + Debug: bool | None = Field( None, description="Indicates if the daemon is running in debug-mode / with debug-level\nlogging enabled.\n", example=True, ) - NFd: Optional[int] = Field( + NFd: int | None = Field( None, description="The total number of file Descriptors in use by the daemon process.\n\nThis information is only returned if debug-mode is enabled.\n", example=64, ) - NGoroutines: Optional[int] = Field( + NGoroutines: int | None = Field( None, description="The number of goroutines that currently exist.\n\nThis information is only returned if debug-mode is enabled.\n", example=174, ) - SystemTime: Optional[str] = Field( + SystemTime: str | None = Field( None, description="Current system-time in [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt)\nformat with nano-seconds.\n", example="2017-08-08T20:28:29.06202363Z", ) - LoggingDriver: Optional[str] = Field( + LoggingDriver: str | None = Field( None, description="The logging driver to use as a default for new containers.\n" ) - CgroupDriver: Optional[CgroupDriver] = Field( + CgroupDriver: CgroupDriver | None = Field( CgroupDriver.cgroupfs, description="The driver to use for managing cgroups.\n", example="cgroupfs", ) - CgroupVersion: Optional[CgroupVersion] = Field( + CgroupVersion: CgroupVersion | None = Field( CgroupVersion.field_1, description="The version of the cgroup.\n", example="1" ) - NEventsListener: Optional[int] = Field( + NEventsListener: int | None = Field( None, description="Number of event listeners subscribed.", example=30 ) - KernelVersion: Optional[str] = Field( + KernelVersion: str | None = Field( None, description='Kernel version of the host.\n\nOn Linux, this information obtained from `uname`. On Windows this\ninformation is queried from the HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Windows NT\\\\CurrentVersion\\\\\nregistry value, for example _"10.0 14393 (14393.1198.amd64fre.rs1_release_sec.170427-1353)"_.\n', example="4.9.38-moby", ) - OperatingSystem: Optional[str] = Field( + OperatingSystem: str | None = Field( None, description='Name of the host\'s operating system, for example: "Ubuntu 16.04.2 LTS"\nor "Windows Server 2016 Datacenter"\n', example="Alpine Linux v3.5", ) - OSVersion: Optional[str] = Field( + OSVersion: str | None = Field( None, description="Version of the host's operating system\n\n


\n\n> **Note**: The information returned in this field, including its\n> very existence, and the formatting of values, should not be considered\n> stable, and may change without notice.\n", example="16.04", ) - OSType: Optional[str] = Field( + OSType: str | None = Field( None, description='Generic type of the operating system of the host, as returned by the\nGo runtime (`GOOS`).\n\nCurrently returned values are "linux" and "windows". A full list of\npossible values can be found in the [Go documentation](https://golang.org/doc/install/source#environment).\n', example="linux", ) - Architecture: Optional[str] = Field( + Architecture: str | None = Field( None, description="Hardware architecture of the host, as returned by the Go runtime\n(`GOARCH`).\n\nA full list of possible values can be found in the [Go documentation](https://golang.org/doc/install/source#environment).\n", example="x86_64", ) - NCPU: Optional[int] = Field( + NCPU: int | None = Field( None, description="The number of logical CPUs usable by the daemon.\n\nThe number of available CPUs is checked by querying the operating\nsystem when the daemon starts. Changes to operating system CPU\nallocation after the daemon is started are not reflected.\n", example=4, ) - MemTotal: Optional[int] = Field( + MemTotal: int | None = Field( None, description="Total amount of physical memory available on the host, in bytes.\n", example=2095882240, ) - IndexServerAddress: Optional[str] = Field( + IndexServerAddress: str | None = Field( "https://index.docker.io/v1/", description="Address / URL of the index server that is used for image search,\nand as a default for user authentication for Docker Hub and Docker Cloud.\n", example="https://index.docker.io/v1/", ) - RegistryConfig: Optional[RegistryServiceConfig] = None - GenericResources: Optional[GenericResources] = None - HttpProxy: Optional[str] = Field( + RegistryConfig: RegistryServiceConfig | None = None + GenericResources: GenericResources | None = None + HttpProxy: str | None = Field( None, description="HTTP-proxy configured for the daemon. This value is obtained from the\n[`HTTP_PROXY`](https://www.gnu.org/software/wget/manual/html_node/Proxies.html) environment variable.\nCredentials ([user info component](https://tools.ietf.org/html/rfc3986#section-3.2.1)) in the proxy URL\nare masked in the API response.\n\nContainers do not automatically inherit this configuration.\n", example="http://xxxxx:xxxxx@proxy.corp.example.com:8080", ) - HttpsProxy: Optional[str] = Field( + HttpsProxy: str | None = Field( None, description="HTTPS-proxy configured for the daemon. This value is obtained from the\n[`HTTPS_PROXY`](https://www.gnu.org/software/wget/manual/html_node/Proxies.html) environment variable.\nCredentials ([user info component](https://tools.ietf.org/html/rfc3986#section-3.2.1)) in the proxy URL\nare masked in the API response.\n\nContainers do not automatically inherit this configuration.\n", example="https://xxxxx:xxxxx@proxy.corp.example.com:4443", ) - NoProxy: Optional[str] = Field( + NoProxy: str | None = Field( None, description="Comma-separated list of domain extensions for which no proxy should be\nused. This value is obtained from the [`NO_PROXY`](https://www.gnu.org/software/wget/manual/html_node/Proxies.html)\nenvironment variable.\n\nContainers do not automatically inherit this configuration.\n", example="*.local, 169.254/16", ) - Name: Optional[str] = Field( + Name: str | None = Field( None, description="Hostname of the host.", example="node5.corp.example.com" ) - Labels: Optional[list[str]] = Field( + Labels: list[str] | None = Field( None, description="User-defined labels (key/value metadata) as set on the daemon.\n\n


\n\n> **Note**: When part of a Swarm, nodes can both have _daemon_ labels,\n> set through the daemon configuration, and _node_ labels, set from a\n> manager node in the Swarm. Node labels are not included in this\n> field. Node labels can be retrieved using the `/nodes/(id)` endpoint\n> on a manager node in the Swarm.\n", example=["storage=ssd", "production"], ) - ExperimentalBuild: Optional[bool] = Field( + ExperimentalBuild: bool | None = Field( None, description="Indicates if experimental features are enabled on the daemon.\n", example=True, ) - ServerVersion: Optional[str] = Field( + ServerVersion: str | None = Field( None, description="Version string of the daemon.\n\n> **Note**: the [standalone Swarm API](/swarm/swarm-api/)\n> returns the Swarm version instead of the daemon version, for example\n> `swarm/1.2.8`.\n", example="17.06.0-ce", ) - ClusterStore: Optional[str] = Field( + ClusterStore: str | None = Field( None, description="URL of the distributed storage backend.\n\n\nThe storage backend is used for multihost networking (to store\nnetwork and endpoint information) and by the node discovery mechanism.\n\n


\n\n> **Deprecated**: This field is only propagated when using standalone Swarm\n> mode, and overlay networking using an external k/v store. Overlay\n> networks with Swarm mode enabled use the built-in raft store, and\n> this field will be empty.\n", example="consul://consul.corp.example.com:8600/some/path", ) - ClusterAdvertise: Optional[str] = Field( + ClusterAdvertise: str | None = Field( None, description="The network endpoint that the Engine advertises for the purpose of\nnode discovery. ClusterAdvertise is a `host:port` combination on which\nthe daemon is reachable by other hosts.\n\n


\n\n> **Deprecated**: This field is only propagated when using standalone Swarm\n> mode, and overlay networking using an external k/v store. Overlay\n> networks with Swarm mode enabled use the built-in raft store, and\n> this field will be empty.\n", example="node5.corp.example.com:8000", ) - Runtimes: Optional[dict[str, Runtime]] = Field( + Runtimes: dict[str, Runtime] | None = Field( {"runc": {"path": "runc"}}, description='List of [OCI compliant](https://github.com/opencontainers/runtime-spec)\nruntimes configured on the daemon. Keys hold the "name" used to\nreference the runtime.\n\nThe Docker daemon relies on an OCI compliant runtime (invoked via the\n`containerd` daemon) as its interface to the Linux kernel namespaces,\ncgroups, and SELinux.\n\nThe default runtime is `runc`, and automatically configured. Additional\nruntimes can be configured by the user and will be listed here.\n', example={ @@ -3974,30 +3948,30 @@ class SystemInfo(BaseModel): }, }, ) - DefaultRuntime: Optional[str] = Field( + DefaultRuntime: str | None = Field( "runc", description="Name of the default OCI runtime that is used when starting containers.\n\nThe default can be overridden per-container at create time.\n", example="runc", ) - Swarm: Optional[SwarmInfo] = None - LiveRestoreEnabled: Optional[bool] = Field( + Swarm: SwarmInfo | None = None + LiveRestoreEnabled: bool | None = Field( False, description="Indicates if live restore is enabled.\n\nIf enabled, containers are kept running when the daemon is shutdown\nor upon daemon start if running containers are detected.\n", example=False, ) - Isolation: Optional[Isolation2] = Field( + Isolation: Isolation2 | None = Field( Isolation2.default, description="Represents the isolation technology to use as a default for containers.\nThe supported values are platform-specific.\n\nIf no isolation value is specified on daemon start, on Windows client,\nthe default is `hyperv`, and on Windows server, the default is `process`.\n\nThis option is currently not used on other platforms.\n", ) - InitBinary: Optional[str] = Field( + InitBinary: str | None = Field( None, description="Name and, optional, path of the `docker-init` binary.\n\nIf the path is omitted, the daemon searches the host's `$PATH` for the\nbinary and uses the first result.\n", example="docker-init", ) - ContainerdCommit: Optional[Commit] = None - RuncCommit: Optional[Commit] = None - InitCommit: Optional[Commit] = None - SecurityOptions: Optional[list[str]] = Field( + ContainerdCommit: Commit | None = None + RuncCommit: Commit | None = None + InitCommit: Commit | None = None + SecurityOptions: list[str] | None = Field( None, description="List of security features that are enabled on the daemon, such as\napparmor, seccomp, SELinux, user-namespaces (userns), and rootless.\n\nAdditional configuration options for each security feature may\nbe present, and are included as a comma-separated list of key/value\npairs.\n", example=[ @@ -4008,16 +3982,16 @@ class SystemInfo(BaseModel): "name=rootless", ], ) - ProductLicense: Optional[str] = Field( + ProductLicense: str | None = Field( None, description="Reports a summary of the product license on the daemon.\n\nIf a commercial license has been applied to the daemon, information\nsuch as number of nodes, and expiration are included.\n", example="Community Engine", ) - DefaultAddressPools: Optional[list[DefaultAddressPool]] = Field( + DefaultAddressPools: list[DefaultAddressPool] | None = Field( None, description='List of custom default address pools for local networks, which can be\nspecified in the daemon.json file or dockerd option.\n\nExample: a Base "10.10.0.0/16" with Size 24 will define the set of 256\n10.10.[0-255].0/24 address pools.\n', ) - Warnings: Optional[list[str]] = Field( + Warnings: list[str] | None = Field( None, description="List of warnings / informational messages about missing features, or\nissues related to the daemon configuration.\n\nThese messages can be printed by the client as information to the user.\n", example=[ diff --git a/packages/models-library/src/models_library/generics.py b/packages/models-library/src/models_library/generics.py index 1975fee07ef..07556cb6d27 100644 --- a/packages/models-library/src/models_library/generics.py +++ b/packages/models-library/src/models_library/generics.py @@ -37,7 +37,7 @@ def values(self) -> ValuesView[DictValue]: def update(self, *s: Iterable[tuple[DictKey, DictValue]]) -> None: return self.__root__.update(*s) - def __iter__(self) -> Iterator[DictKey]: + def __iter__(self) -> Iterator[DictKey]: # type: ignore return self.__root__.__iter__() def get(self, key: DictKey, default: DictValue | None = None): diff --git a/packages/models-library/src/models_library/projects.py b/packages/models-library/src/models_library/projects.py index 4dbef6aeb3f..c032cc68877 100644 --- a/packages/models-library/src/models_library/projects.py +++ b/packages/models-library/src/models_library/projects.py @@ -121,13 +121,13 @@ class Project(BaseProjectModel): ) # Timestamps - creation_date: DateTimeStr = Field( + creation_date: DateTimeStr = Field( # type: ignore[assignment] ..., description="project creation date", examples=["2018-07-01T11:13:43Z"], alias="creationDate", ) - last_change_date: DateTimeStr = Field( + last_change_date: DateTimeStr = Field( # type: ignore[assignment] ..., description="last save date", examples=["2018-07-01T11:13:43Z"], diff --git a/packages/models-library/src/models_library/projects_nodes.py b/packages/models-library/src/models_library/projects_nodes.py index 4bc37146d67..74bafc7b579 100644 --- a/packages/models-library/src/models_library/projects_nodes.py +++ b/packages/models-library/src/models_library/projects_nodes.py @@ -225,7 +225,7 @@ def convert_empty_str_to_none(cls, v): def convert_old_enum_name(cls, v) -> RunningState: if v == "FAILURE": return RunningState.FAILED - return v + return RunningState(v) @validator("state", pre=True) @classmethod diff --git a/packages/models-library/src/models_library/projects_pipeline.py b/packages/models-library/src/models_library/projects_pipeline.py index f7375985fa9..1f4e2eefa67 100644 --- a/packages/models-library/src/models_library/projects_pipeline.py +++ b/packages/models-library/src/models_library/projects_pipeline.py @@ -5,7 +5,8 @@ from pydantic import BaseModel, Field, PositiveInt from .clusters import ClusterID -from .projects_nodes import NodeID, NodeState +from .projects_nodes import NodeState +from .projects_nodes_io import NodeID from .projects_state import RunningState diff --git a/packages/models-library/src/models_library/rest_pagination_utils.py b/packages/models-library/src/models_library/rest_pagination_utils.py index 9774349c898..ef6bf4f8522 100644 --- a/packages/models-library/src/models_library/rest_pagination_utils.py +++ b/packages/models-library/src/models_library/rest_pagination_utils.py @@ -1,5 +1,7 @@ from math import ceil -from typing import Any, Dict, List, Protocol, TypedDict, Union, runtime_checkable +from typing import Any, Protocol, TypedDict, Union, runtime_checkable + +from pydantic import AnyHttpUrl from .rest_pagination import PageLinks, PageMetaInfoLimitOffset @@ -29,23 +31,25 @@ def replace_query_params(self, **kwargs: Any) -> "_StarletteURL": _URLType = Union[_YarlURL, _StarletteURL] -def _replace_query(url: _URLType, query: Dict[str, Any]): +def _replace_query(url: _URLType, query: dict[str, Any]) -> AnyHttpUrl: """This helper function ensures query replacement works with both""" + new_url: _URLType | _StarletteURL if isinstance(url, _YarlURL): new_url = url.update_query(query) else: new_url = url.replace_query_params(**query) - return f"{new_url}" + output: AnyHttpUrl = AnyHttpUrl(f"{new_url}") + return output class PageDict(TypedDict): _meta: Any _links: Any - data: List[Any] + data: list[Any] def paginate_data( - chunk: List[Any], + chunk: list[Any], *, request_url: _URLType, total: int, diff --git a/packages/models-library/src/models_library/service_settings_labels.py b/packages/models-library/src/models_library/service_settings_labels.py index 8e5df399288..8dbdef45c59 100644 --- a/packages/models-library/src/models_library/service_settings_labels.py +++ b/packages/models-library/src/models_library/service_settings_labels.py @@ -216,7 +216,7 @@ def validate_volume_limits(cls, v, values) -> str | None: msg = f"path={path!r} not found in inputs_path={inputs_path!r}, outputs_path={outputs_path!r}, state_paths={state_paths!r}" raise ValueError(msg) - return v + return f"{v}" class Config(_BaseConfig): schema_extra: ClassVar[dict[str, Any]] = { @@ -273,10 +273,10 @@ class _PortRange(BaseModel): def lower_less_than_upper(cls, v, values) -> PortInt: upper = v lower: PortInt | None = values.get("lower") - if lower is None or lower >= upper: + if lower is None or lower > upper: msg = f"Condition not satisfied: lower={lower!r} < upper={upper!r}" raise ValueError(msg) - return v + return PortInt(v) class DNSResolver(BaseModel): @@ -310,7 +310,7 @@ class NATRule(BaseModel): def iter_tcp_ports(self) -> Generator[PortInt, None, None]: for port in self.tcp_ports: if isinstance(port, _PortRange): - yield from range(port.lower, port.upper + 1) + yield from (PortInt(i) for i in range(port.lower, port.upper + 1)) else: yield port @@ -387,7 +387,7 @@ def compose_spec_requires_container_http_entry(cls, v, values) -> str | None: if v is not None and values.get("compose_spec") is None: msg = "`container_http_entry` not allowed if `compose_spec` is missing" raise ValueError(msg) - return v + return f"{v}" if v else v @validator("containers_allowed_outgoing_permit_list") @classmethod diff --git a/packages/models-library/src/models_library/services_resources.py b/packages/models-library/src/models_library/services_resources.py index e421acc4f78..26e6d4fb183 100644 --- a/packages/models-library/src/models_library/services_resources.py +++ b/packages/models-library/src/models_library/services_resources.py @@ -134,7 +134,8 @@ def create_from_single_service( def create_jsonable( service_resources: ServiceResourcesDict, ) -> dict[DockerGenericTag, Any]: - return jsonable_encoder(service_resources) + output: dict[DockerGenericTag, Any] = jsonable_encoder(service_resources) + return output class Config: schema_extra = { diff --git a/packages/models-library/src/models_library/utils/database_models_factory.py b/packages/models-library/src/models_library/utils/database_models_factory.py index 3cc74cfe2e6..9390d13a6f5 100644 --- a/packages/models-library/src/models_library/utils/database_models_factory.py +++ b/packages/models-library/src/models_library/utils/database_models_factory.py @@ -57,25 +57,25 @@ def _eval_defaults( default = column.default.arg if include_server_defaults and column.server_default: - assert column.server_default.is_server_default # nosec + assert column.server_default.is_server_default # type: ignore # nosec # # FIXME: Map server's DefaultClauses to correct values # Heuristics based on test against all our tables # if pydantic_type: if issubclass(pydantic_type, list): - assert column.server_default.arg == "{}" # nosec + assert column.server_default.arg == "{}" # type: ignore # nosec default_factory = list elif issubclass(pydantic_type, dict): - assert column.server_default.arg.text.endswith("::jsonb") # nosec + assert column.server_default.arg.text.endswith("::jsonb") # type: ignore # nosec default = json.loads( - column.server_default.arg.text.replace("::jsonb", "").replace( + column.server_default.arg.text.replace("::jsonb", "").replace( # type: ignore "'", "" ) ) elif issubclass(pydantic_type, datetime): assert isinstance( # nosec - column.server_default.arg, + column.server_default.arg, # type: ignore (type(null()), sqlalchemy.sql.functions.now), ) default_factory = datetime.now @@ -110,7 +110,7 @@ def create_pydantic_model_from_sa_table( ) -> type[BaseModel]: fields = {} exclude = exclude or [] - extra_policies = extra_policies or DEFAULT_EXTRA_POLICIES + extra_policies = extra_policies or DEFAULT_EXTRA_POLICIES # type: ignore for column in table.columns: name = str(column.name) @@ -160,10 +160,10 @@ def create_pydantic_model_from_sa_table( if hasattr(column, "doc") and column.doc: field_args["description"] = column.doc - fields[name] = (pydantic_type, Field(**field_args)) + fields[name] = (pydantic_type, Field(**field_args)) # type: ignore # create domain models from db-schemas - pydantic_model = create_model( + pydantic_model: type[BaseModel] = create_model( table.name.capitalize(), __config__=config, **fields # type: ignore ) assert issubclass(pydantic_model, BaseModel) # nosec diff --git a/packages/models-library/src/models_library/utils/docker_compose.py b/packages/models-library/src/models_library/utils/docker_compose.py index b5dadab77fe..d1b61f9adc5 100644 --- a/packages/models-library/src/models_library/utils/docker_compose.py +++ b/packages/models-library/src/models_library/utils/docker_compose.py @@ -1,4 +1,5 @@ import yaml +from models_library.service_settings_labels import ComposeSpecLabelDict from .string_substitution import SubstitutionsDict, TextTemplate @@ -17,7 +18,7 @@ def replace_env_vars_in_compose_spec( - service_spec: "ComposeSpecLabelDict", + service_spec: ComposeSpecLabelDict, *, replace_simcore_registry: str, replace_service_version: str, diff --git a/packages/models-library/src/models_library/utils/fastapi_encoders.py b/packages/models-library/src/models_library/utils/fastapi_encoders.py index a85d845e30c..32924b83615 100644 --- a/packages/models-library/src/models_library/utils/fastapi_encoders.py +++ b/packages/models-library/src/models_library/utils/fastapi_encoders.py @@ -19,3 +19,5 @@ from ._original_fastapi_encoders import jsonable_encoder servicelib_jsonable_encoder = jsonable_encoder # alias + +__all__ = ("jsonable_encoder",) diff --git a/packages/models-library/src/models_library/utils/json_schema.py b/packages/models-library/src/models_library/utils/json_schema.py index f6c381c1f57..9b6d76cf232 100644 --- a/packages/models-library/src/models_library/utils/json_schema.py +++ b/packages/models-library/src/models_library/utils/json_schema.py @@ -11,7 +11,7 @@ from collections.abc import Sequence from contextlib import suppress from copy import deepcopy -from typing import Any, Dict, Tuple +from typing import Any import jsonschema from jsonschema import validators @@ -35,13 +35,12 @@ def set_defaults(validator, properties, instance, schema): if "default" in subschema: instance.setdefault(prop, subschema["default"]) - for error in validate_properties( + yield from validate_properties( validator, properties, instance, schema, - ): - yield error + ) return validators.extend( validator_class, @@ -54,7 +53,7 @@ def set_defaults(validator, properties, instance, schema): def jsonschema_validate_data( - instance: Any, schema: Dict[str, Any], *, return_with_default: bool = False + instance: Any, schema: dict[str, Any], *, return_with_default: bool = False ): """Checks whether data satisfies schema contract @@ -72,13 +71,13 @@ def jsonschema_validate_data( return out -def jsonschema_validate_schema(schema: Dict[str, Any]): +def jsonschema_validate_schema(schema: dict[str, Any]): """Checks whether schema is a valid json-schema :raises InvalidJsonSchema """ with suppress(jsonschema.ValidationError): - dummy_data = {} + dummy_data: dict = {} validators.validate(instance=dummy_data, schema=schema) return schema @@ -93,7 +92,7 @@ def any_ref_key(obj): return False -__all__: Tuple[str, ...] = ( +__all__: tuple[str, ...] = ( "any_ref_key", "InvalidJsonSchema", "jsonschema_validate_data", diff --git a/packages/models-library/src/models_library/utils/nodes.py b/packages/models-library/src/models_library/utils/nodes.py index 1953531a0e3..e000be7bbc0 100644 --- a/packages/models-library/src/models_library/utils/nodes.py +++ b/packages/models-library/src/models_library/utils/nodes.py @@ -2,25 +2,25 @@ import json import logging from copy import deepcopy -from typing import Any, Callable, Coroutine, Dict +from typing import Any, Callable, Coroutine +from models_library.projects_nodes_io import UUIDStr from pydantic import BaseModel from ..projects import Project -from ..projects_nodes import NodeID -from ..projects_nodes_io import PortLink +from ..projects_nodes_io import NodeID, PortLink logger = logging.getLogger(__name__) def project_node_io_payload_cb( project: Project, -) -> Callable[[NodeID], Coroutine[Any, Any, Dict[str, Any]]]: +) -> Callable[[NodeID], Coroutine[Any, Any, dict[str, Any]]]: """callback fct to use together with compute_node_hash when a Project as input""" - async def node_io_payload_cb(node_id: NodeID) -> Dict[str, Any]: - node_io_payload = {"inputs": None, "outputs": None} - node = project.workbench.get(str(node_id)) + async def node_io_payload_cb(node_id: NodeID) -> dict[str, Any]: + node_io_payload: dict[str, Any] = {"inputs": None, "outputs": None} + node = project.workbench.get(UUIDStr(node_id)) if node: node_io_payload = {"inputs": node.inputs, "outputs": node.outputs} @@ -31,13 +31,13 @@ async def node_io_payload_cb(node_id: NodeID) -> Dict[str, Any]: async def compute_node_hash( node_id: NodeID, - get_node_io_payload_cb: Callable[[NodeID], Coroutine[Any, Any, Dict[str, Any]]], + get_node_io_payload_cb: Callable[[NodeID], Coroutine[Any, Any, dict[str, Any]]], ) -> str: # resolve the port links if any and get only the payload node_payload = deepcopy(await get_node_io_payload_cb(node_id)) assert all(k in node_payload for k in ["inputs", "outputs"]) # nosec - resolved_payload = {} + resolved_payload: dict[str, Any] = {} for port_type in ["inputs", "outputs"]: port_type_payloads = node_payload.get(port_type) diff --git a/packages/models-library/src/models_library/utils/specs_substitution.py b/packages/models-library/src/models_library/utils/specs_substitution.py index 413b8799da7..af1fd5ce250 100644 --- a/packages/models-library/src/models_library/utils/specs_substitution.py +++ b/packages/models-library/src/models_library/utils/specs_substitution.py @@ -44,7 +44,8 @@ def _create_text_template( def get_identifiers(self) -> list[str]: """lists identifiers in specs in order of apperance. Can have repetitions""" - return self._template.get_identifiers() + output: list[str] = self._template.get_identifiers() + return output def get_replaced(self) -> set[str]: return self._substitutions.used From 33455f3f6a9e98c3f21f7016fe2cf62375197bf1 Mon Sep 17 00:00:00 2001 From: matusdrobuliak66 Date: Tue, 25 Jul 2023 08:45:05 +0200 Subject: [PATCH 2/5] @pcrespov review --- packages/models-library/src/models_library/aiodocker_api.py | 6 +++--- .../src/models_library/api_schemas_storage.py | 2 +- .../src/models_library/utils/database_models_factory.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/models-library/src/models_library/aiodocker_api.py b/packages/models-library/src/models_library/aiodocker_api.py index 1aab4ba3441..18e52326e42 100644 --- a/packages/models-library/src/models_library/aiodocker_api.py +++ b/packages/models-library/src/models_library/aiodocker_api.py @@ -12,7 +12,7 @@ class AioDockerContainerSpec(ContainerSpec): Env: dict[str, str | None] | None = Field( # type: ignore - None, + default=None, description="aiodocker expects here a dictionary and re-convert it back internally`.\n", ) @@ -37,7 +37,7 @@ class AioDockerResources1(Resources1): None, description="Define resources reservation.", alias="Reservations" ) - class Config: + class Config(Resources1.Config): # type: ignore allow_population_by_field_name = True @@ -55,6 +55,6 @@ class AioDockerTaskSpec(TaskSpec): class AioDockerServiceSpec(ServiceSpec): TaskTemplate: AioDockerTaskSpec | None = None - class Config: + class Config(ServiceSpec.Config): # type: ignore alias_generator = to_snake_case allow_population_by_field_name = True diff --git a/packages/models-library/src/models_library/api_schemas_storage.py b/packages/models-library/src/models_library/api_schemas_storage.py index 594c48e5136..a58f2f348c3 100644 --- a/packages/models-library/src/models_library/api_schemas_storage.py +++ b/packages/models-library/src/models_library/api_schemas_storage.py @@ -132,7 +132,7 @@ class FileMetaDataGet(BaseModel): created_at: datetime last_modified: datetime file_size: ByteSize | int = Field( - -1, description="File size in bytes (-1 means invalid)" + default=-1, description="File size in bytes (-1 means invalid)" ) entity_tag: ETag | None = Field( default=None, diff --git a/packages/models-library/src/models_library/utils/database_models_factory.py b/packages/models-library/src/models_library/utils/database_models_factory.py index 9390d13a6f5..372e70a2534 100644 --- a/packages/models-library/src/models_library/utils/database_models_factory.py +++ b/packages/models-library/src/models_library/utils/database_models_factory.py @@ -57,7 +57,7 @@ def _eval_defaults( default = column.default.arg if include_server_defaults and column.server_default: - assert column.server_default.is_server_default # type: ignore # nosec + assert column.server_default.is_server_default # type: ignore # nosec # # FIXME: Map server's DefaultClauses to correct values # Heuristics based on test against all our tables From cfc5dd0a84dbd7227f4c85afadedfe2b29f71d35 Mon Sep 17 00:00:00 2001 From: matusdrobuliak66 Date: Tue, 25 Jul 2023 09:32:15 +0200 Subject: [PATCH 3/5] fix failing test --- .../models_library/rest_pagination_utils.py | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/packages/models-library/src/models_library/rest_pagination_utils.py b/packages/models-library/src/models_library/rest_pagination_utils.py index ef6bf4f8522..6e4fb792a5f 100644 --- a/packages/models-library/src/models_library/rest_pagination_utils.py +++ b/packages/models-library/src/models_library/rest_pagination_utils.py @@ -31,15 +31,14 @@ def replace_query_params(self, **kwargs: Any) -> "_StarletteURL": _URLType = Union[_YarlURL, _StarletteURL] -def _replace_query(url: _URLType, query: dict[str, Any]) -> AnyHttpUrl: +def _replace_query(url: _URLType, query: dict[str, Any]) -> str: """This helper function ensures query replacement works with both""" new_url: _URLType | _StarletteURL if isinstance(url, _YarlURL): new_url = url.update_query(query) else: new_url = url.replace_query_params(**query) - output: AnyHttpUrl = AnyHttpUrl(f"{new_url}") - return output + return f"{new_url}" class PageDict(TypedDict): @@ -72,21 +71,31 @@ def paginate_data( total=total, count=len(chunk), limit=limit, offset=offset ), _links=PageLinks( - self=_replace_query(request_url, {"offset": offset, "limit": limit}), - first=_replace_query(request_url, {"offset": 0, "limit": limit}), - prev=_replace_query( - request_url, {"offset": max(offset - limit, 0), "limit": limit} + self=AnyHttpUrl( + _replace_query(request_url, {"offset": offset, "limit": limit}) + ), + first=AnyHttpUrl( + _replace_query(request_url, {"offset": 0, "limit": limit}) + ), + prev=AnyHttpUrl( + _replace_query( + request_url, {"offset": max(offset - limit, 0), "limit": limit} + ) ) if offset > 0 else None, - next=_replace_query( - request_url, - {"offset": min(offset + limit, last_page * limit), "limit": limit}, + next=AnyHttpUrl( + _replace_query( + request_url, + {"offset": min(offset + limit, last_page * limit), "limit": limit}, + ) ) if offset < (last_page * limit) else None, - last=_replace_query( - request_url, {"offset": last_page * limit, "limit": limit} + last=AnyHttpUrl( + _replace_query( + request_url, {"offset": last_page * limit, "limit": limit} + ) ), ), data=chunk, From d46932728c5c86b00c4b2fb2cc1a57e61e22738b Mon Sep 17 00:00:00 2001 From: matusdrobuliak66 Date: Tue, 25 Jul 2023 10:22:17 +0200 Subject: [PATCH 4/5] fix failing test --- .../models_library/rest_pagination_utils.py | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/packages/models-library/src/models_library/rest_pagination_utils.py b/packages/models-library/src/models_library/rest_pagination_utils.py index 6e4fb792a5f..ec9cedf0a54 100644 --- a/packages/models-library/src/models_library/rest_pagination_utils.py +++ b/packages/models-library/src/models_library/rest_pagination_utils.py @@ -1,7 +1,7 @@ from math import ceil from typing import Any, Protocol, TypedDict, Union, runtime_checkable -from pydantic import AnyHttpUrl +from pydantic import AnyHttpUrl, parse_obj_as from .rest_pagination import PageLinks, PageMetaInfoLimitOffset @@ -71,31 +71,37 @@ def paginate_data( total=total, count=len(chunk), limit=limit, offset=offset ), _links=PageLinks( - self=AnyHttpUrl( - _replace_query(request_url, {"offset": offset, "limit": limit}) + self=( + parse_obj_as( + AnyHttpUrl, + _replace_query(request_url, {"offset": offset, "limit": limit}), + ) ), - first=AnyHttpUrl( - _replace_query(request_url, {"offset": 0, "limit": limit}) + first=parse_obj_as( + AnyHttpUrl, _replace_query(request_url, {"offset": 0, "limit": limit}) ), - prev=AnyHttpUrl( + prev=parse_obj_as( + AnyHttpUrl, _replace_query( request_url, {"offset": max(offset - limit, 0), "limit": limit} - ) + ), ) if offset > 0 else None, - next=AnyHttpUrl( + next=parse_obj_as( + AnyHttpUrl, _replace_query( request_url, {"offset": min(offset + limit, last_page * limit), "limit": limit}, - ) + ), ) if offset < (last_page * limit) else None, - last=AnyHttpUrl( + last=parse_obj_as( + AnyHttpUrl, _replace_query( request_url, {"offset": last_page * limit, "limit": limit} - ) + ), ), ), data=chunk, From c2d589fab9065e16c491ca4105bb9b3d6bafde15 Mon Sep 17 00:00:00 2001 From: matusdrobuliak66 Date: Tue, 25 Jul 2023 14:31:54 +0200 Subject: [PATCH 5/5] fix failing test --- .../src/models_library/service_settings_labels.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/models-library/src/models_library/service_settings_labels.py b/packages/models-library/src/models_library/service_settings_labels.py index 8dbdef45c59..09704b53b95 100644 --- a/packages/models-library/src/models_library/service_settings_labels.py +++ b/packages/models-library/src/models_library/service_settings_labels.py @@ -215,8 +215,8 @@ def validate_volume_limits(cls, v, values) -> str | None: ): msg = f"path={path!r} not found in inputs_path={inputs_path!r}, outputs_path={outputs_path!r}, state_paths={state_paths!r}" raise ValueError(msg) - - return f"{v}" + output: str | None = v + return output class Config(_BaseConfig): schema_extra: ClassVar[dict[str, Any]] = { @@ -273,7 +273,7 @@ class _PortRange(BaseModel): def lower_less_than_upper(cls, v, values) -> PortInt: upper = v lower: PortInt | None = values.get("lower") - if lower is None or lower > upper: + if lower is None or lower >= upper: msg = f"Condition not satisfied: lower={lower!r} < upper={upper!r}" raise ValueError(msg) return PortInt(v)