API client for Docker Registries
Project description
A Python REST client for Docker Registries. Pronounced dee-redge client.
It’s useful for automating image tagging and untagging
Usage
Most people will primarily use the Registry class:
from dreg_client import Registry
registry = Registry.build_with_manual_client("https://registry.example.com/v2/")
namespaces = registry.namespaces() # a sequence of strings
repositories = registry.repositories() # a mapping of repository names to Repository objects
ns_repositories = registry.repositories("testns") # a mapping of repository names to Repository objects,
# but only for those repositories in the "testns" namespace
test_repo = registry.repository("testrepo", "testns") # a Repository object
test_repo = registry.repository("testns/testrepo") # an identical repository object
The Repository class has several methods for interacting with individual repositories:
from dreg_client import Repository, Manifest
assert isinstance(test_repo, Repository)
assert test_repo.name == "testns/testrepo"
tags = test_repo.tags() # a sequence of strings
manifest = test_repo.get_manifest(tags[0]) # a Manifest object
assert isinstance(manifest, Manifest)
test_repo.delete_manifest(manifest.digest) # manifests can only be deleted by digest, not by tag
# At the moment, retrieving and deleting blobs returns a requests Response object directly
get_blob_response = test_repo.get_blob("sha256:ce17d456b9373523c40fe294e8918a10059f63c54edd2c8ead1f3079f7fbb22a")
delete_blob_response = test_repo.delete_blob("sha256:ce17d456b9373523c40fe294e8918a10059f63c54edd2c8ead1f3079f7fbb22a")
However, you’re probably going to want to use the high-level get_image() method, which returns an Image object:
from dreg_client import Image, Platform
test_image = test_repo.get_image(tags[0])
assert isinstance(test_image, Image)
assert test_image.repo == "testns/testrepo"
assert test_image.tag == tags[0]
assert test_image.platforms == {
Platform.from_name("linux/amd64"),
Platform.from_name("linux/arm64"),
Platform.from_name("linux/arm/v7"),
}
platform_image = test_image.get_platform_image(Platform.from_name("linux/amd64"))
History
dreg-client is a fork of a project named docker-registry-client. While it looked good, development has stalled, with approved PRs remaining unmerged. The code design was also hostile to strict type checking. I forked it to make some improvements, add type hints, and to resolve several outstanding problems at the time.
This fork is not a drop-in replacement for docker-registry-client. Major changes from upstream include:
Complete removal of python2 support
Complete removal of support for v1 registries
A re-work of class names
A re-work of the requests integration and registry auth service
More higher-level abstractions, to avoid needing to dive into manifest dictionaries
Alternatives
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dreg-client-1.2.0.tar.gz
.
File metadata
- Download URL: dreg-client-1.2.0.tar.gz
- Upload date:
- Size: 29.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81c179eab9846ae4873668b6a68a76579e39a7bcdc325c37a4392c0c83a0f021 |
|
MD5 | cd998bb142d955b5edfb1f2439beb008 |
|
BLAKE2b-256 | 2e77dc0627e4e49b2e93f343b97da3d2b7bae62758df3a767fac1432b690cb78 |
File details
Details for the file dreg_client-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: dreg_client-1.2.0-py3-none-any.whl
- Upload date:
- Size: 17.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7ef54ac7e99da639ef729f576f0064aa06a467057df2080e640b74c5a1dad13 |
|
MD5 | 2afee832c36fb29a1b7c08c20145e796 |
|
BLAKE2b-256 | e333716789d53977284ed8167318371aafe121d40fbb68d473196006dda97a67 |