Skip to content

Commit

Permalink
Add docker-py stubs (#11749)
Browse files Browse the repository at this point in the history
  • Loading branch information
kasium authored Apr 12, 2024
1 parent a7e1300 commit bc8fc36
Show file tree
Hide file tree
Showing 69 changed files with 1,935 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"stubs/commonmark",
"stubs/dateparser",
"stubs/defusedxml",
"stubs/docker",
"stubs/docutils",
"stubs/Flask-SocketIO",
"stubs/fpdf2",
Expand Down
7 changes: 7 additions & 0 deletions stubs/docker/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# additional requirements are needed, e.g. win32 apis
docker.transport.NpipeHTTPAdapter
docker.transport.NpipeSocket
docker.transport.SSHHTTPAdapter
docker.transport.npipeconn
docker.transport.npipesocket
docker.transport.sshconn
3 changes: 3 additions & 0 deletions stubs/docker/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version = "7.0.*"
upstream_repository = "https://github.com/docker/docker-py"
requires = ["types-requests", "urllib3>=2"]
7 changes: 7 additions & 0 deletions stubs/docker/docker/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from .api import APIClient as APIClient
from .client import DockerClient as DockerClient, from_env as from_env
from .context import Context as Context, ContextAPI as ContextAPI
from .tls import TLSConfig as TLSConfig
from .version import __version__ as __version__

__title__: str
1 change: 1 addition & 0 deletions stubs/docker/docker/api/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .client import APIClient as APIClient
39 changes: 39 additions & 0 deletions stubs/docker/docker/api/build.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from _typeshed import Incomplete

log: Incomplete

class BuildApiMixin:
def build(
self,
path: Incomplete | None = None,
tag: str | None = None,
quiet: bool = False,
fileobj: Incomplete | None = None,
nocache: bool = False,
rm: bool = False,
timeout: Incomplete | None = None,
custom_context: bool = False,
encoding: Incomplete | None = None,
pull: bool = False,
forcerm: bool = False,
dockerfile: Incomplete | None = None,
container_limits: Incomplete | None = None,
decode: bool = False,
buildargs: Incomplete | None = None,
gzip: bool = False,
shmsize: Incomplete | None = None,
labels: Incomplete | None = None,
cache_from: Incomplete | None = None,
target: Incomplete | None = None,
network_mode: Incomplete | None = None,
squash: Incomplete | None = None,
extra_hosts: Incomplete | None = None,
platform: Incomplete | None = None,
isolation: Incomplete | None = None,
use_config_proxy: bool = True,
): ...
def prune_builds(
self, filters: Incomplete | None = None, keep_storage: Incomplete | None = None, all: Incomplete | None = None
): ...

def process_dockerfile(dockerfile, path): ...
55 changes: 55 additions & 0 deletions stubs/docker/docker/api/client.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from _typeshed import Incomplete
from collections.abc import Mapping, Sequence

import requests
from docker.tls import TLSConfig
from requests.adapters import BaseAdapter

from .build import BuildApiMixin
from .config import ConfigApiMixin
from .container import ContainerApiMixin
from .daemon import DaemonApiMixin
from .exec_api import ExecApiMixin
from .image import ImageApiMixin
from .network import NetworkApiMixin
from .plugin import PluginApiMixin
from .secret import SecretApiMixin
from .service import ServiceApiMixin
from .swarm import SwarmApiMixin
from .volume import VolumeApiMixin

class APIClient(
requests.Session,
BuildApiMixin,
ConfigApiMixin,
ContainerApiMixin,
DaemonApiMixin,
ExecApiMixin,
ImageApiMixin,
NetworkApiMixin,
PluginApiMixin,
SecretApiMixin,
ServiceApiMixin,
SwarmApiMixin,
VolumeApiMixin,
):
__attrs__: Sequence[str]
base_url: str
timeout: int
credstore_env: Mapping[Incomplete, Incomplete] | None
def __init__(
self,
base_url: str | None = None,
version: str | None = None,
timeout: int = 60,
tls: bool | TLSConfig = False,
user_agent: str = "docker-sdk-python/7.0.0",
num_pools: int | None = None,
credstore_env: Mapping[Incomplete, Incomplete] | None = None,
use_ssh_client: bool = False,
max_pool_size: int = 10,
) -> None: ...
def get_adapter(self, url: str) -> BaseAdapter: ...
@property
def api_version(self) -> str: ...
def reload_config(self, dockercfg_path: str | None = None) -> None: ...
7 changes: 7 additions & 0 deletions stubs/docker/docker/api/config.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from _typeshed import Incomplete

class ConfigApiMixin:
def create_config(self, name, data, labels: Incomplete | None = None, templating: Incomplete | None = None): ...
def inspect_config(self, id): ...
def remove_config(self, id): ...
def configs(self, filters: Incomplete | None = None): ...
109 changes: 109 additions & 0 deletions stubs/docker/docker/api/container.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
from _typeshed import Incomplete

class ContainerApiMixin:
def attach(
self, container, stdout: bool = True, stderr: bool = True, stream: bool = False, logs: bool = False, demux: bool = False
): ...
def attach_socket(self, container, params: Incomplete | None = None, ws: bool = False): ...
def commit(
self,
container,
repository: str | None = None,
tag: str | None = None,
message: Incomplete | None = None,
author: Incomplete | None = None,
pause: bool = True,
changes: Incomplete | None = None,
conf: Incomplete | None = None,
): ...
def containers(
self,
quiet: bool = False,
all: bool = False,
trunc: bool = False,
latest: bool = False,
since: Incomplete | None = None,
before: Incomplete | None = None,
limit: int = -1,
size: bool = False,
filters: Incomplete | None = None,
): ...
def create_container(
self,
image,
command: Incomplete | None = None,
hostname: Incomplete | None = None,
user: Incomplete | None = None,
detach: bool = False,
stdin_open: bool = False,
tty: bool = False,
ports: Incomplete | None = None,
environment: Incomplete | None = None,
volumes: Incomplete | None = None,
network_disabled: bool = False,
name: Incomplete | None = None,
entrypoint: Incomplete | None = None,
working_dir: Incomplete | None = None,
domainname: Incomplete | None = None,
host_config: Incomplete | None = None,
mac_address: Incomplete | None = None,
labels: Incomplete | None = None,
stop_signal: Incomplete | None = None,
networking_config: Incomplete | None = None,
healthcheck: Incomplete | None = None,
stop_timeout: Incomplete | None = None,
runtime: Incomplete | None = None,
use_config_proxy: bool = True,
platform: Incomplete | None = None,
): ...
def create_container_config(self, *args, **kwargs): ...
def create_container_from_config(self, config, name: Incomplete | None = None, platform: Incomplete | None = None): ...
def create_host_config(self, *args, **kwargs): ...
def create_networking_config(self, *args, **kwargs): ...
def create_endpoint_config(self, *args, **kwargs): ...
def diff(self, container): ...
def export(self, container, chunk_size=2097152): ...
def get_archive(self, container, path, chunk_size=2097152, encode_stream: bool = False): ...
def inspect_container(self, container): ...
def kill(self, container, signal: Incomplete | None = None) -> None: ...
def logs(
self,
container,
stdout: bool = True,
stderr: bool = True,
stream: bool = False,
timestamps: bool = False,
tail: str = "all",
since: Incomplete | None = None,
follow: Incomplete | None = None,
until: Incomplete | None = None,
): ...
def pause(self, container) -> None: ...
def port(self, container, private_port): ...
def put_archive(self, container, path, data): ...
def prune_containers(self, filters: Incomplete | None = None): ...
def remove_container(self, container, v: bool = False, link: bool = False, force: bool = False) -> None: ...
def rename(self, container, name) -> None: ...
def resize(self, container, height, width) -> None: ...
def restart(self, container, timeout: int = 10) -> None: ...
def start(self, container, *args, **kwargs) -> None: ...
def stats(self, container, decode: Incomplete | None = None, stream: bool = True, one_shot: Incomplete | None = None): ...
def stop(self, container, timeout: Incomplete | None = None) -> None: ...
def top(self, container, ps_args: Incomplete | None = None): ...
def unpause(self, container) -> None: ...
def update_container(
self,
container,
blkio_weight: Incomplete | None = None,
cpu_period: Incomplete | None = None,
cpu_quota: Incomplete | None = None,
cpu_shares: Incomplete | None = None,
cpuset_cpus: Incomplete | None = None,
cpuset_mems: Incomplete | None = None,
mem_limit: Incomplete | None = None,
mem_reservation: Incomplete | None = None,
memswap_limit: Incomplete | None = None,
kernel_memory: Incomplete | None = None,
restart_policy: Incomplete | None = None,
): ...
def wait(self, container, timeout: Incomplete | None = None, condition: Incomplete | None = None): ...
23 changes: 23 additions & 0 deletions stubs/docker/docker/api/daemon.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from _typeshed import Incomplete

class DaemonApiMixin:
def df(self): ...
def events(
self,
since: Incomplete | None = None,
until: Incomplete | None = None,
filters: Incomplete | None = None,
decode: Incomplete | None = None,
): ...
def info(self): ...
def login(
self,
username,
password: Incomplete | None = None,
email: Incomplete | None = None,
registry: Incomplete | None = None,
reauth: bool = False,
dockercfg_path: Incomplete | None = None,
): ...
def ping(self): ...
def version(self, api_version: bool = True): ...
22 changes: 22 additions & 0 deletions stubs/docker/docker/api/exec_api.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from _typeshed import Incomplete

class ExecApiMixin:
def exec_create(
self,
container,
cmd,
stdout: bool = True,
stderr: bool = True,
stdin: bool = False,
tty: bool = False,
privileged: bool = False,
user: str = "",
environment: Incomplete | None = None,
workdir: Incomplete | None = None,
detach_keys: Incomplete | None = None,
): ...
def exec_inspect(self, exec_id): ...
def exec_resize(self, exec_id, height: Incomplete | None = None, width: Incomplete | None = None) -> None: ...
def exec_start(
self, exec_id, detach: bool = False, tty: bool = False, stream: bool = False, socket: bool = False, demux: bool = False
): ...
59 changes: 59 additions & 0 deletions stubs/docker/docker/api/image.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from _typeshed import Incomplete

log: Incomplete

class ImageApiMixin:
def get_image(self, image: str, chunk_size: int = 2097152): ...
def history(self, image): ...
def images(self, name: str | None = None, quiet: bool = False, all: bool = False, filters: Incomplete | None = None): ...
def import_image(
self,
src: Incomplete | None = None,
repository: str | None = None,
tag: str | None = None,
image: str | None = None,
changes: Incomplete | None = None,
stream_src: bool = False,
): ...
def import_image_from_data(
self, data, repository: str | None = None, tag: str | None = None, changes: Incomplete | None = None
): ...
def import_image_from_file(
self, filename: str, repository: str | None = None, tag: str | None = None, changes: Incomplete | None = None
): ...
def import_image_from_stream(
self, stream, repository: str | None = None, tag: str | None = None, changes: Incomplete | None = None
): ...
def import_image_from_url(
self, url, repository: str | None = None, tag: str | None = None, changes: Incomplete | None = None
): ...
def import_image_from_image(
self, image, repository: str | None = None, tag: str | None = None, changes: Incomplete | None = None
): ...
def inspect_image(self, image): ...
def inspect_distribution(self, image, auth_config: Incomplete | None = None): ...
def load_image(self, data, quiet: Incomplete | None = None): ...
def prune_images(self, filters: Incomplete | None = None): ...
def pull(
self,
repository: str,
tag: str | None = None,
stream: bool = False,
auth_config: Incomplete | None = None,
decode: bool = False,
platform: Incomplete | None = None,
all_tags: bool = False,
): ...
def push(
self,
repository: str,
tag: str | None = None,
stream: bool = False,
auth_config: Incomplete | None = None,
decode: bool = False,
): ...
def remove_image(self, image: str, force: bool = False, noprune: bool = False): ...
def search(self, term: str, limit: int | None = None): ...
def tag(self, image, repository, tag: str | None = None, force: bool = False): ...

def is_file(src: str) -> bool: ...
34 changes: 34 additions & 0 deletions stubs/docker/docker/api/network.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from _typeshed import Incomplete

class NetworkApiMixin:
def networks(self, names: Incomplete | None = None, ids: Incomplete | None = None, filters: Incomplete | None = None): ...
def create_network(
self,
name,
driver: Incomplete | None = None,
options: Incomplete | None = None,
ipam: Incomplete | None = None,
check_duplicate: Incomplete | None = None,
internal: bool = False,
labels: Incomplete | None = None,
enable_ipv6: bool = False,
attachable: Incomplete | None = None,
scope: Incomplete | None = None,
ingress: Incomplete | None = None,
): ...
def prune_networks(self, filters: Incomplete | None = None): ...
def remove_network(self, net_id) -> None: ...
def inspect_network(self, net_id, verbose: Incomplete | None = None, scope: Incomplete | None = None): ...
def connect_container_to_network(
self,
container,
net_id,
ipv4_address: Incomplete | None = None,
ipv6_address: Incomplete | None = None,
aliases: Incomplete | None = None,
links: Incomplete | None = None,
link_local_ips: Incomplete | None = None,
driver_opt: Incomplete | None = None,
mac_address: Incomplete | None = None,
) -> None: ...
def disconnect_container_from_network(self, container, net_id, force: bool = False) -> None: ...
Loading

0 comments on commit bc8fc36

Please sign in to comment.