Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
docker-py
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
docker-py
Commits
d33e9ad0
Kaydet (Commit)
d33e9ad0
authored
Haz 16, 2017
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Update check_resource decorator to account for new resource names
Signed-off-by:
Joffrey F
<
joffrey@docker.com
>
üst
8fc6540f
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
66 additions
and
65 deletions
+66
-65
client.py
docker/api/client.py
+1
-1
container.py
docker/api/container.py
+24
-24
exec_api.py
docker/api/exec_api.py
+2
-2
image.py
docker/api/image.py
+6
-6
network.py
docker/api/network.py
+4
-2
plugin.py
docker/api/plugin.py
+4
-4
secret.py
docker/api/secret.py
+2
-2
service.py
docker/api/service.py
+5
-5
swarm.py
docker/api/swarm.py
+2
-2
services.py
docker/types/services.py
+1
-1
decorators.py
docker/utils/decorators.py
+15
-16
No files found.
docker/api/client.py
Dosyayı görüntüle @
d33e9ad0
...
@@ -248,7 +248,7 @@ class APIClient(
...
@@ -248,7 +248,7 @@ class APIClient(
'stream'
:
1
'stream'
:
1
}
}
@check_resource
@check_resource
(
'container'
)
def
_attach_websocket
(
self
,
container
,
params
=
None
):
def
_attach_websocket
(
self
,
container
,
params
=
None
):
url
=
self
.
_url
(
"/containers/{0}/attach/ws"
,
container
)
url
=
self
.
_url
(
"/containers/{0}/attach/ws"
,
container
)
req
=
requests
.
Request
(
"POST"
,
url
,
params
=
self
.
_attach_params
(
params
))
req
=
requests
.
Request
(
"POST"
,
url
,
params
=
self
.
_attach_params
(
params
))
...
...
docker/api/container.py
Dosyayı görüntüle @
d33e9ad0
...
@@ -10,7 +10,7 @@ from ..types import (
...
@@ -10,7 +10,7 @@ from ..types import (
class
ContainerApiMixin
(
object
):
class
ContainerApiMixin
(
object
):
@utils.check_resource
@utils.check_resource
(
'container'
)
def
attach
(
self
,
container
,
stdout
=
True
,
stderr
=
True
,
def
attach
(
self
,
container
,
stdout
=
True
,
stderr
=
True
,
stream
=
False
,
logs
=
False
):
stream
=
False
,
logs
=
False
):
"""
"""
...
@@ -54,7 +54,7 @@ class ContainerApiMixin(object):
...
@@ -54,7 +54,7 @@ class ContainerApiMixin(object):
return
self
.
_read_from_socket
(
response
,
stream
)
return
self
.
_read_from_socket
(
response
,
stream
)
@utils.check_resource
@utils.check_resource
(
'container'
)
def
attach_socket
(
self
,
container
,
params
=
None
,
ws
=
False
):
def
attach_socket
(
self
,
container
,
params
=
None
,
ws
=
False
):
"""
"""
Like ``attach``, but returns the underlying socket-like object for the
Like ``attach``, but returns the underlying socket-like object for the
...
@@ -93,7 +93,7 @@ class ContainerApiMixin(object):
...
@@ -93,7 +93,7 @@ class ContainerApiMixin(object):
)
)
)
)
@utils.check_resource
@utils.check_resource
(
'container'
)
def
commit
(
self
,
container
,
repository
=
None
,
tag
=
None
,
message
=
None
,
def
commit
(
self
,
container
,
repository
=
None
,
tag
=
None
,
message
=
None
,
author
=
None
,
changes
=
None
,
conf
=
None
):
author
=
None
,
changes
=
None
,
conf
=
None
):
"""
"""
...
@@ -195,7 +195,7 @@ class ContainerApiMixin(object):
...
@@ -195,7 +195,7 @@ class ContainerApiMixin(object):
x
[
'Id'
]
=
x
[
'Id'
][:
12
]
x
[
'Id'
]
=
x
[
'Id'
][:
12
]
return
res
return
res
@utils.check_resource
@utils.check_resource
(
'container'
)
def
copy
(
self
,
container
,
resource
):
def
copy
(
self
,
container
,
resource
):
"""
"""
Identical to the ``docker cp`` command. Get files/folders from the
Identical to the ``docker cp`` command. Get files/folders from the
...
@@ -659,7 +659,7 @@ class ContainerApiMixin(object):
...
@@ -659,7 +659,7 @@ class ContainerApiMixin(object):
"""
"""
return
EndpointConfig
(
self
.
_version
,
*
args
,
**
kwargs
)
return
EndpointConfig
(
self
.
_version
,
*
args
,
**
kwargs
)
@utils.check_resource
@utils.check_resource
(
'container'
)
def
diff
(
self
,
container
):
def
diff
(
self
,
container
):
"""
"""
Inspect changes on a container's filesystem.
Inspect changes on a container's filesystem.
...
@@ -678,7 +678,7 @@ class ContainerApiMixin(object):
...
@@ -678,7 +678,7 @@ class ContainerApiMixin(object):
self
.
_get
(
self
.
_url
(
"/containers/{0}/changes"
,
container
)),
True
self
.
_get
(
self
.
_url
(
"/containers/{0}/changes"
,
container
)),
True
)
)
@utils.check_resource
@utils.check_resource
(
'container'
)
def
export
(
self
,
container
):
def
export
(
self
,
container
):
"""
"""
Export the contents of a filesystem as a tar archive.
Export the contents of a filesystem as a tar archive.
...
@@ -699,7 +699,7 @@ class ContainerApiMixin(object):
...
@@ -699,7 +699,7 @@ class ContainerApiMixin(object):
self
.
_raise_for_status
(
res
)
self
.
_raise_for_status
(
res
)
return
res
.
raw
return
res
.
raw
@utils.check_resource
@utils.check_resource
(
'container'
)
@utils.minimum_version
(
'1.20'
)
@utils.minimum_version
(
'1.20'
)
def
get_archive
(
self
,
container
,
path
):
def
get_archive
(
self
,
container
,
path
):
"""
"""
...
@@ -730,7 +730,7 @@ class ContainerApiMixin(object):
...
@@ -730,7 +730,7 @@ class ContainerApiMixin(object):
utils
.
decode_json_header
(
encoded_stat
)
if
encoded_stat
else
None
utils
.
decode_json_header
(
encoded_stat
)
if
encoded_stat
else
None
)
)
@utils.check_resource
@utils.check_resource
(
'container'
)
def
inspect_container
(
self
,
container
):
def
inspect_container
(
self
,
container
):
"""
"""
Identical to the `docker inspect` command, but only for containers.
Identical to the `docker inspect` command, but only for containers.
...
@@ -750,7 +750,7 @@ class ContainerApiMixin(object):
...
@@ -750,7 +750,7 @@ class ContainerApiMixin(object):
self
.
_get
(
self
.
_url
(
"/containers/{0}/json"
,
container
)),
True
self
.
_get
(
self
.
_url
(
"/containers/{0}/json"
,
container
)),
True
)
)
@utils.check_resource
@utils.check_resource
(
'container'
)
def
kill
(
self
,
container
,
signal
=
None
):
def
kill
(
self
,
container
,
signal
=
None
):
"""
"""
Kill a container or send a signal to a container.
Kill a container or send a signal to a container.
...
@@ -773,7 +773,7 @@ class ContainerApiMixin(object):
...
@@ -773,7 +773,7 @@ class ContainerApiMixin(object):
self
.
_raise_for_status
(
res
)
self
.
_raise_for_status
(
res
)
@utils.check_resource
@utils.check_resource
(
'container'
)
def
logs
(
self
,
container
,
stdout
=
True
,
stderr
=
True
,
stream
=
False
,
def
logs
(
self
,
container
,
stdout
=
True
,
stderr
=
True
,
stream
=
False
,
timestamps
=
False
,
tail
=
'all'
,
since
=
None
,
follow
=
None
):
timestamps
=
False
,
tail
=
'all'
,
since
=
None
,
follow
=
None
):
"""
"""
...
@@ -836,7 +836,7 @@ class ContainerApiMixin(object):
...
@@ -836,7 +836,7 @@ class ContainerApiMixin(object):
logs
=
True
logs
=
True
)
)
@utils.check_resource
@utils.check_resource
(
'container'
)
def
pause
(
self
,
container
):
def
pause
(
self
,
container
):
"""
"""
Pauses all processes within a container.
Pauses all processes within a container.
...
@@ -852,7 +852,7 @@ class ContainerApiMixin(object):
...
@@ -852,7 +852,7 @@ class ContainerApiMixin(object):
res
=
self
.
_post
(
url
)
res
=
self
.
_post
(
url
)
self
.
_raise_for_status
(
res
)
self
.
_raise_for_status
(
res
)
@utils.check_resource
@utils.check_resource
(
'container'
)
def
port
(
self
,
container
,
private_port
):
def
port
(
self
,
container
,
private_port
):
"""
"""
Lookup the public-facing port that is NAT-ed to ``private_port``.
Lookup the public-facing port that is NAT-ed to ``private_port``.
...
@@ -901,7 +901,7 @@ class ContainerApiMixin(object):
...
@@ -901,7 +901,7 @@ class ContainerApiMixin(object):
return
h_ports
return
h_ports
@utils.check_resource
@utils.check_resource
(
'container'
)
@utils.minimum_version
(
'1.20'
)
@utils.minimum_version
(
'1.20'
)
def
put_archive
(
self
,
container
,
path
,
data
):
def
put_archive
(
self
,
container
,
path
,
data
):
"""
"""
...
@@ -949,7 +949,7 @@ class ContainerApiMixin(object):
...
@@ -949,7 +949,7 @@ class ContainerApiMixin(object):
url
=
self
.
_url
(
'/containers/prune'
)
url
=
self
.
_url
(
'/containers/prune'
)
return
self
.
_result
(
self
.
_post
(
url
,
params
=
params
),
True
)
return
self
.
_result
(
self
.
_post
(
url
,
params
=
params
),
True
)
@utils.check_resource
@utils.check_resource
(
'container'
)
def
remove_container
(
self
,
container
,
v
=
False
,
link
=
False
,
force
=
False
):
def
remove_container
(
self
,
container
,
v
=
False
,
link
=
False
,
force
=
False
):
"""
"""
Remove a container. Similar to the ``docker rm`` command.
Remove a container. Similar to the ``docker rm`` command.
...
@@ -973,7 +973,7 @@ class ContainerApiMixin(object):
...
@@ -973,7 +973,7 @@ class ContainerApiMixin(object):
self
.
_raise_for_status
(
res
)
self
.
_raise_for_status
(
res
)
@utils.minimum_version
(
'1.17'
)
@utils.minimum_version
(
'1.17'
)
@utils.check_resource
@utils.check_resource
(
'container'
)
def
rename
(
self
,
container
,
name
):
def
rename
(
self
,
container
,
name
):
"""
"""
Rename a container. Similar to the ``docker rename`` command.
Rename a container. Similar to the ``docker rename`` command.
...
@@ -991,7 +991,7 @@ class ContainerApiMixin(object):
...
@@ -991,7 +991,7 @@ class ContainerApiMixin(object):
res
=
self
.
_post
(
url
,
params
=
params
)
res
=
self
.
_post
(
url
,
params
=
params
)
self
.
_raise_for_status
(
res
)
self
.
_raise_for_status
(
res
)
@utils.check_resource
@utils.check_resource
(
'container'
)
def
resize
(
self
,
container
,
height
,
width
):
def
resize
(
self
,
container
,
height
,
width
):
"""
"""
Resize the tty session.
Resize the tty session.
...
@@ -1010,7 +1010,7 @@ class ContainerApiMixin(object):
...
@@ -1010,7 +1010,7 @@ class ContainerApiMixin(object):
res
=
self
.
_post
(
url
,
params
=
params
)
res
=
self
.
_post
(
url
,
params
=
params
)
self
.
_raise_for_status
(
res
)
self
.
_raise_for_status
(
res
)
@utils.check_resource
@utils.check_resource
(
'container'
)
def
restart
(
self
,
container
,
timeout
=
10
):
def
restart
(
self
,
container
,
timeout
=
10
):
"""
"""
Restart a container. Similar to the ``docker restart`` command.
Restart a container. Similar to the ``docker restart`` command.
...
@@ -1031,7 +1031,7 @@ class ContainerApiMixin(object):
...
@@ -1031,7 +1031,7 @@ class ContainerApiMixin(object):
res
=
self
.
_post
(
url
,
params
=
params
)
res
=
self
.
_post
(
url
,
params
=
params
)
self
.
_raise_for_status
(
res
)
self
.
_raise_for_status
(
res
)
@utils.check_resource
@utils.check_resource
(
'container'
)
def
start
(
self
,
container
,
*
args
,
**
kwargs
):
def
start
(
self
,
container
,
*
args
,
**
kwargs
):
"""
"""
Start a container. Similar to the ``docker start`` command, but
Start a container. Similar to the ``docker start`` command, but
...
@@ -1070,7 +1070,7 @@ class ContainerApiMixin(object):
...
@@ -1070,7 +1070,7 @@ class ContainerApiMixin(object):
self
.
_raise_for_status
(
res
)
self
.
_raise_for_status
(
res
)
@utils.minimum_version
(
'1.17'
)
@utils.minimum_version
(
'1.17'
)
@utils.check_resource
@utils.check_resource
(
'container'
)
def
stats
(
self
,
container
,
decode
=
None
,
stream
=
True
):
def
stats
(
self
,
container
,
decode
=
None
,
stream
=
True
):
"""
"""
Stream statistics for a specific container. Similar to the
Stream statistics for a specific container. Similar to the
...
@@ -1096,7 +1096,7 @@ class ContainerApiMixin(object):
...
@@ -1096,7 +1096,7 @@ class ContainerApiMixin(object):
return
self
.
_result
(
self
.
_get
(
url
,
params
=
{
'stream'
:
False
}),
return
self
.
_result
(
self
.
_get
(
url
,
params
=
{
'stream'
:
False
}),
json
=
True
)
json
=
True
)
@utils.check_resource
@utils.check_resource
(
'container'
)
def
stop
(
self
,
container
,
timeout
=
10
):
def
stop
(
self
,
container
,
timeout
=
10
):
"""
"""
Stops a container. Similar to the ``docker stop`` command.
Stops a container. Similar to the ``docker stop`` command.
...
@@ -1117,7 +1117,7 @@ class ContainerApiMixin(object):
...
@@ -1117,7 +1117,7 @@ class ContainerApiMixin(object):
timeout
=
(
timeout
+
(
self
.
timeout
or
0
)))
timeout
=
(
timeout
+
(
self
.
timeout
or
0
)))
self
.
_raise_for_status
(
res
)
self
.
_raise_for_status
(
res
)
@utils.check_resource
@utils.check_resource
(
'container'
)
def
top
(
self
,
container
,
ps_args
=
None
):
def
top
(
self
,
container
,
ps_args
=
None
):
"""
"""
Display the running processes of a container.
Display the running processes of a container.
...
@@ -1139,7 +1139,7 @@ class ContainerApiMixin(object):
...
@@ -1139,7 +1139,7 @@ class ContainerApiMixin(object):
params
[
'ps_args'
]
=
ps_args
params
[
'ps_args'
]
=
ps_args
return
self
.
_result
(
self
.
_get
(
u
,
params
=
params
),
True
)
return
self
.
_result
(
self
.
_get
(
u
,
params
=
params
),
True
)
@utils.check_resource
@utils.check_resource
(
'container'
)
def
unpause
(
self
,
container
):
def
unpause
(
self
,
container
):
"""
"""
Unpause all processes within a container.
Unpause all processes within a container.
...
@@ -1152,7 +1152,7 @@ class ContainerApiMixin(object):
...
@@ -1152,7 +1152,7 @@ class ContainerApiMixin(object):
self
.
_raise_for_status
(
res
)
self
.
_raise_for_status
(
res
)
@utils.minimum_version
(
'1.22'
)
@utils.minimum_version
(
'1.22'
)
@utils.check_resource
@utils.check_resource
(
'container'
)
def
update_container
(
def
update_container
(
self
,
container
,
blkio_weight
=
None
,
cpu_period
=
None
,
cpu_quota
=
None
,
self
,
container
,
blkio_weight
=
None
,
cpu_period
=
None
,
cpu_quota
=
None
,
cpu_shares
=
None
,
cpuset_cpus
=
None
,
cpuset_mems
=
None
,
mem_limit
=
None
,
cpu_shares
=
None
,
cpuset_cpus
=
None
,
cpuset_mems
=
None
,
mem_limit
=
None
,
...
@@ -1217,7 +1217,7 @@ class ContainerApiMixin(object):
...
@@ -1217,7 +1217,7 @@ class ContainerApiMixin(object):
res
=
self
.
_post_json
(
url
,
data
=
data
)
res
=
self
.
_post_json
(
url
,
data
=
data
)
return
self
.
_result
(
res
,
True
)
return
self
.
_result
(
res
,
True
)
@utils.check_resource
@utils.check_resource
(
'container'
)
def
wait
(
self
,
container
,
timeout
=
None
):
def
wait
(
self
,
container
,
timeout
=
None
):
"""
"""
Block until a container stops, then return its exit code. Similar to
Block until a container stops, then return its exit code. Similar to
...
...
docker/api/exec_api.py
Dosyayı görüntüle @
d33e9ad0
...
@@ -6,7 +6,7 @@ from .. import utils
...
@@ -6,7 +6,7 @@ from .. import utils
class
ExecApiMixin
(
object
):
class
ExecApiMixin
(
object
):
@utils.minimum_version
(
'1.15'
)
@utils.minimum_version
(
'1.15'
)
@utils.check_resource
@utils.check_resource
(
'container'
)
def
exec_create
(
self
,
container
,
cmd
,
stdout
=
True
,
stderr
=
True
,
def
exec_create
(
self
,
container
,
cmd
,
stdout
=
True
,
stderr
=
True
,
stdin
=
False
,
tty
=
False
,
privileged
=
False
,
user
=
''
,
stdin
=
False
,
tty
=
False
,
privileged
=
False
,
user
=
''
,
environment
=
None
):
environment
=
None
):
...
@@ -110,7 +110,7 @@ class ExecApiMixin(object):
...
@@ -110,7 +110,7 @@ class ExecApiMixin(object):
self
.
_raise_for_status
(
res
)
self
.
_raise_for_status
(
res
)
@utils.minimum_version
(
'1.15'
)
@utils.minimum_version
(
'1.15'
)
@utils.check_resource
@utils.check_resource
(
'exec_id'
)
def
exec_start
(
self
,
exec_id
,
detach
=
False
,
tty
=
False
,
stream
=
False
,
def
exec_start
(
self
,
exec_id
,
detach
=
False
,
tty
=
False
,
stream
=
False
,
socket
=
False
):
socket
=
False
):
"""
"""
...
...
docker/api/image.py
Dosyayı görüntüle @
d33e9ad0
...
@@ -12,7 +12,7 @@ log = logging.getLogger(__name__)
...
@@ -12,7 +12,7 @@ log = logging.getLogger(__name__)
class
ImageApiMixin
(
object
):
class
ImageApiMixin
(
object
):
@utils.check_resource
@utils.check_resource
(
'image'
)
def
get_image
(
self
,
image
):
def
get_image
(
self
,
image
):
"""
"""
Get a tarball of an image. Similar to the ``docker save`` command.
Get a tarball of an image. Similar to the ``docker save`` command.
...
@@ -39,7 +39,7 @@ class ImageApiMixin(object):
...
@@ -39,7 +39,7 @@ class ImageApiMixin(object):
self
.
_raise_for_status
(
res
)
self
.
_raise_for_status
(
res
)
return
res
.
raw
return
res
.
raw
@utils.check_resource
@utils.check_resource
(
'image'
)
def
history
(
self
,
image
):
def
history
(
self
,
image
):
"""
"""
Show the history of an image.
Show the history of an image.
...
@@ -228,7 +228,7 @@ class ImageApiMixin(object):
...
@@ -228,7 +228,7 @@ class ImageApiMixin(object):
image
=
image
,
repository
=
repository
,
tag
=
tag
,
changes
=
changes
image
=
image
,
repository
=
repository
,
tag
=
tag
,
changes
=
changes
)
)
@utils.check_resource
@utils.check_resource
(
'image'
)
def
insert
(
self
,
image
,
url
,
path
):
def
insert
(
self
,
image
,
url
,
path
):
if
utils
.
compare_version
(
'1.12'
,
self
.
_version
)
>=
0
:
if
utils
.
compare_version
(
'1.12'
,
self
.
_version
)
>=
0
:
raise
errors
.
DeprecatedMethod
(
raise
errors
.
DeprecatedMethod
(
...
@@ -241,7 +241,7 @@ class ImageApiMixin(object):
...
@@ -241,7 +241,7 @@ class ImageApiMixin(object):
}
}
return
self
.
_result
(
self
.
_post
(
api_url
,
params
=
params
))
return
self
.
_result
(
self
.
_post
(
api_url
,
params
=
params
))
@utils.check_resource
@utils.check_resource
(
'image'
)
def
inspect_image
(
self
,
image
):
def
inspect_image
(
self
,
image
):
"""
"""
Get detailed information about an image. Similar to the ``docker
Get detailed information about an image. Similar to the ``docker
...
@@ -443,7 +443,7 @@ class ImageApiMixin(object):
...
@@ -443,7 +443,7 @@ class ImageApiMixin(object):
return
self
.
_result
(
response
)
return
self
.
_result
(
response
)
@utils.check_resource
@utils.check_resource
(
'image'
)
def
remove_image
(
self
,
image
,
force
=
False
,
noprune
=
False
):
def
remove_image
(
self
,
image
,
force
=
False
,
noprune
=
False
):
"""
"""
Remove an image. Similar to the ``docker rmi`` command.
Remove an image. Similar to the ``docker rmi`` command.
...
@@ -477,7 +477,7 @@ class ImageApiMixin(object):
...
@@ -477,7 +477,7 @@ class ImageApiMixin(object):
True
True
)
)
@utils.check_resource
@utils.check_resource
(
'image'
)
def
tag
(
self
,
image
,
repository
,
tag
=
None
,
force
=
False
):
def
tag
(
self
,
image
,
repository
,
tag
=
None
,
force
=
False
):
"""
"""
Tag an image into a repository. Similar to the ``docker tag`` command.
Tag an image into a repository. Similar to the ``docker tag`` command.
...
...
docker/api/network.py
Dosyayı görüntüle @
d33e9ad0
...
@@ -156,6 +156,7 @@ class NetworkApiMixin(object):
...
@@ -156,6 +156,7 @@ class NetworkApiMixin(object):
return
self
.
_result
(
self
.
_post
(
url
,
params
=
params
),
True
)
return
self
.
_result
(
self
.
_post
(
url
,
params
=
params
),
True
)
@minimum_version
(
'1.21'
)
@minimum_version
(
'1.21'
)
@check_resource
(
'net_id'
)
def
remove_network
(
self
,
net_id
):
def
remove_network
(
self
,
net_id
):
"""
"""
Remove a network. Similar to the ``docker network rm`` command.
Remove a network. Similar to the ``docker network rm`` command.
...
@@ -168,6 +169,7 @@ class NetworkApiMixin(object):
...
@@ -168,6 +169,7 @@ class NetworkApiMixin(object):
self
.
_raise_for_status
(
res
)
self
.
_raise_for_status
(
res
)
@minimum_version
(
'1.21'
)
@minimum_version
(
'1.21'
)
@check_resource
(
'net_id'
)
def
inspect_network
(
self
,
net_id
,
verbose
=
None
):
def
inspect_network
(
self
,
net_id
,
verbose
=
None
):
"""
"""
Get detailed information about a network.
Get detailed information about a network.
...
@@ -187,7 +189,7 @@ class NetworkApiMixin(object):
...
@@ -187,7 +189,7 @@ class NetworkApiMixin(object):
res
=
self
.
_get
(
url
,
params
=
params
)
res
=
self
.
_get
(
url
,
params
=
params
)
return
self
.
_result
(
res
,
json
=
True
)
return
self
.
_result
(
res
,
json
=
True
)
@check_resource
@check_resource
(
'image'
)
@minimum_version
(
'1.21'
)
@minimum_version
(
'1.21'
)
def
connect_container_to_network
(
self
,
container
,
net_id
,
def
connect_container_to_network
(
self
,
container
,
net_id
,
ipv4_address
=
None
,
ipv6_address
=
None
,
ipv4_address
=
None
,
ipv6_address
=
None
,
...
@@ -224,7 +226,7 @@ class NetworkApiMixin(object):
...
@@ -224,7 +226,7 @@ class NetworkApiMixin(object):
res
=
self
.
_post_json
(
url
,
data
=
data
)
res
=
self
.
_post_json
(
url
,
data
=
data
)
self
.
_raise_for_status
(
res
)
self
.
_raise_for_status
(
res
)
@check_resource
@check_resource
(
'image'
)
@minimum_version
(
'1.21'
)
@minimum_version
(
'1.21'
)
def
disconnect_container_from_network
(
self
,
container
,
net_id
,
def
disconnect_container_from_network
(
self
,
container
,
net_id
,
force
=
False
):
force
=
False
):
...
...
docker/api/plugin.py
Dosyayı görüntüle @
d33e9ad0
...
@@ -5,7 +5,7 @@ from .. import auth, utils
...
@@ -5,7 +5,7 @@ from .. import auth, utils
class
PluginApiMixin
(
object
):
class
PluginApiMixin
(
object
):
@utils.minimum_version
(
'1.25'
)
@utils.minimum_version
(
'1.25'
)
@utils.check_resource
@utils.check_resource
(
'name'
)
def
configure_plugin
(
self
,
name
,
options
):
def
configure_plugin
(
self
,
name
,
options
):
"""
"""
Configure a plugin.
Configure a plugin.
...
@@ -171,7 +171,7 @@ class PluginApiMixin(object):
...
@@ -171,7 +171,7 @@ class PluginApiMixin(object):
return
self
.
_result
(
self
.
_get
(
url
,
params
=
params
),
True
)
return
self
.
_result
(
self
.
_get
(
url
,
params
=
params
),
True
)
@utils.minimum_version
(
'1.25'
)
@utils.minimum_version
(
'1.25'
)
@utils.check_resource
@utils.check_resource
(
'name'
)
def
push_plugin
(
self
,
name
):
def
push_plugin
(
self
,
name
):
"""
"""
Push a plugin to the registry.
Push a plugin to the registry.
...
@@ -195,7 +195,7 @@ class PluginApiMixin(object):
...
@@ -195,7 +195,7 @@ class PluginApiMixin(object):
return
self
.
_stream_helper
(
res
,
decode
=
True
)
return
self
.
_stream_helper
(
res
,
decode
=
True
)
@utils.minimum_version
(
'1.25'
)
@utils.minimum_version
(
'1.25'
)
@utils.check_resource
@utils.check_resource
(
'name'
)
def
remove_plugin
(
self
,
name
,
force
=
False
):
def
remove_plugin
(
self
,
name
,
force
=
False
):
"""
"""
Remove an installed plugin.
Remove an installed plugin.
...
@@ -215,7 +215,7 @@ class PluginApiMixin(object):
...
@@ -215,7 +215,7 @@ class PluginApiMixin(object):
return
True
return
True
@utils.minimum_version
(
'1.26'
)
@utils.minimum_version
(
'1.26'
)
@utils.check_resource
@utils.check_resource
(
'name'
)
def
upgrade_plugin
(
self
,
name
,
remote
,
privileges
):
def
upgrade_plugin
(
self
,
name
,
remote
,
privileges
):
"""
"""
Upgrade an installed plugin.
Upgrade an installed plugin.
...
...
docker/api/secret.py
Dosyayı görüntüle @
d33e9ad0
...
@@ -36,7 +36,7 @@ class SecretApiMixin(object):
...
@@ -36,7 +36,7 @@ class SecretApiMixin(object):
)
)
@utils.minimum_version
(
'1.25'
)
@utils.minimum_version
(
'1.25'
)
@utils.check_resource
@utils.check_resource
(
'id'
)
def
inspect_secret
(
self
,
id
):
def
inspect_secret
(
self
,
id
):
"""
"""
Retrieve secret metadata
Retrieve secret metadata
...
@@ -54,7 +54,7 @@ class SecretApiMixin(object):
...
@@ -54,7 +54,7 @@ class SecretApiMixin(object):
return
self
.
_result
(
self
.
_get
(
url
),
True
)
return
self
.
_result
(
self
.
_get
(
url
),
True
)
@utils.minimum_version
(
'1.25'
)
@utils.minimum_version
(
'1.25'
)
@utils.check_resource
@utils.check_resource
(
'id'
)
def
remove_secret
(
self
,
id
):
def
remove_secret
(
self
,
id
):
"""
"""
Remove a secret
Remove a secret
...
...
docker/api/service.py
Dosyayı görüntüle @
d33e9ad0
...
@@ -113,7 +113,7 @@ class ServiceApiMixin(object):
...
@@ -113,7 +113,7 @@ class ServiceApiMixin(object):
)
)
@utils.minimum_version
(
'1.24'
)
@utils.minimum_version
(
'1.24'
)
@utils.check_resource
@utils.check_resource
(
'service'
)
def
inspect_service
(
self
,
service
):
def
inspect_service
(
self
,
service
):
"""
"""
Return information about a service.
Return information about a service.
...
@@ -132,7 +132,7 @@ class ServiceApiMixin(object):
...
@@ -132,7 +132,7 @@ class ServiceApiMixin(object):
return
self
.
_result
(
self
.
_get
(
url
),
True
)
return
self
.
_result
(
self
.
_get
(
url
),
True
)
@utils.minimum_version
(
'1.24'
)
@utils.minimum_version
(
'1.24'
)
@utils.check_resource
@utils.check_resource
(
'task'
)
def
inspect_task
(
self
,
task
):
def
inspect_task
(
self
,
task
):
"""
"""
Retrieve information about a task.
Retrieve information about a task.
...
@@ -151,7 +151,7 @@ class ServiceApiMixin(object):
...
@@ -151,7 +151,7 @@ class ServiceApiMixin(object):
return
self
.
_result
(
self
.
_get
(
url
),
True
)
return
self
.
_result
(
self
.
_get
(
url
),
True
)
@utils.minimum_version
(
'1.24'
)
@utils.minimum_version
(
'1.24'
)
@utils.check_resource
@utils.check_resource
(
'service'
)
def
remove_service
(
self
,
service
):
def
remove_service
(
self
,
service
):
"""
"""
Stop and remove a service.
Stop and remove a service.
...
@@ -195,7 +195,7 @@ class ServiceApiMixin(object):
...
@@ -195,7 +195,7 @@ class ServiceApiMixin(object):
return
self
.
_result
(
self
.
_get
(
url
,
params
=
params
),
True
)
return
self
.
_result
(
self
.
_get
(
url
,
params
=
params
),
True
)
@utils.minimum_version
(
'1.25'
)
@utils.minimum_version
(
'1.25'
)
@utils.check_resource
@utils.check_resource
(
'service'
)
def
service_logs
(
self
,
service
,
details
=
False
,
follow
=
False
,
stdout
=
False
,
def
service_logs
(
self
,
service
,
details
=
False
,
follow
=
False
,
stdout
=
False
,
stderr
=
False
,
since
=
0
,
timestamps
=
False
,
tail
=
'all'
,
stderr
=
False
,
since
=
0
,
timestamps
=
False
,
tail
=
'all'
,
is_tty
=
None
):
is_tty
=
None
):
...
@@ -269,7 +269,7 @@ class ServiceApiMixin(object):
...
@@ -269,7 +269,7 @@ class ServiceApiMixin(object):
return
self
.
_result
(
self
.
_get
(
url
,
params
=
params
),
True
)
return
self
.
_result
(
self
.
_get
(
url
,
params
=
params
),
True
)
@utils.minimum_version
(
'1.24'
)
@utils.minimum_version
(
'1.24'
)
@utils.check_resource
@utils.check_resource
(
'service'
)
def
update_service
(
self
,
service
,
version
,
task_template
=
None
,
name
=
None
,
def
update_service
(
self
,
service
,
version
,
task_template
=
None
,
name
=
None
,
labels
=
None
,
mode
=
None
,
update_config
=
None
,
labels
=
None
,
mode
=
None
,
update_config
=
None
,
networks
=
None
,
endpoint_config
=
None
,
networks
=
None
,
endpoint_config
=
None
,
...
...
docker/api/swarm.py
Dosyayı görüntüle @
d33e9ad0
...
@@ -117,7 +117,7 @@ class SwarmApiMixin(object):
...
@@ -117,7 +117,7 @@ class SwarmApiMixin(object):
url
=
self
.
_url
(
'/swarm'
)
url
=
self
.
_url
(
'/swarm'
)
return
self
.
_result
(
self
.
_get
(
url
),
True
)
return
self
.
_result
(
self
.
_get
(
url
),
True
)
@utils.check_resource
@utils.check_resource
(
'node_id'
)
@utils.minimum_version
(
'1.24'
)
@utils.minimum_version
(
'1.24'
)
def
inspect_node
(
self
,
node_id
):
def
inspect_node
(
self
,
node_id
):
"""
"""
...
@@ -228,7 +228,7 @@ class SwarmApiMixin(object):
...
@@ -228,7 +228,7 @@ class SwarmApiMixin(object):
return
self
.
_result
(
self
.
_get
(
url
,
params
=
params
),
True
)
return
self
.
_result
(
self
.
_get
(
url
,
params
=
params
),
True
)
@utils.check_resource
@utils.check_resource
(
'node_id'
)
@utils.minimum_version
(
'1.24'
)
@utils.minimum_version
(
'1.24'
)
def
remove_node
(
self
,
node_id
,
force
=
False
):
def
remove_node
(
self
,
node_id
,
force
=
False
):
"""
"""
...
...
docker/types/services.py
Dosyayı görüntüle @
d33e9ad0
...
@@ -443,7 +443,7 @@ class SecretReference(dict):
...
@@ -443,7 +443,7 @@ class SecretReference(dict):
gid (string): GID of the secret file's group. Default: 0
gid (string): GID of the secret file's group. Default: 0
mode (int): File access mode inside the container. Default: 0o444
mode (int): File access mode inside the container. Default: 0o444
"""
"""
@check_resource
@check_resource
(
'secret_id'
)
def
__init__
(
self
,
secret_id
,
secret_name
,
filename
=
None
,
uid
=
None
,
def
__init__
(
self
,
secret_id
,
secret_name
,
filename
=
None
,
uid
=
None
,
gid
=
None
,
mode
=
0
o444
):
gid
=
None
,
mode
=
0
o444
):
self
[
'SecretName'
]
=
secret_name
self
[
'SecretName'
]
=
secret_name
...
...
docker/utils/decorators.py
Dosyayı görüntüle @
d33e9ad0
...
@@ -4,22 +4,21 @@ from .. import errors
...
@@ -4,22 +4,21 @@ from .. import errors
from
.
import
utils
from
.
import
utils
def
check_resource
(
f
):
def
check_resource
(
resource_name
):
@functools.wraps
(
f
)
def
decorator
(
f
):
def
wrapped
(
self
,
resource_id
=
None
,
*
args
,
**
kwargs
):
@functools.wraps
(
f
)
if
resource_id
is
None
:
def
wrapped
(
self
,
resource_id
=
None
,
*
args
,
**
kwargs
):
if
kwargs
.
get
(
'container'
):
if
resource_id
is
None
and
kwargs
.
get
(
resource_name
):
resource_id
=
kwargs
.
pop
(
'container'
)
resource_id
=
kwargs
.
pop
(
resource_name
)
elif
kwargs
.
get
(
'image'
):
if
isinstance
(
resource_id
,
dict
):
resource_id
=
kwargs
.
pop
(
'image'
)
resource_id
=
resource_id
.
get
(
'Id'
,
resource_id
.
get
(
'ID'
))
if
isinstance
(
resource_id
,
dict
):
if
not
resource_id
:
resource_id
=
resource_id
.
get
(
'Id'
,
resource_id
.
get
(
'ID'
))
raise
errors
.
NullResource
(
if
not
resource_id
:
'Resource ID was not provided'
raise
errors
.
NullResource
(
)
'Resource ID was not provided'
return
f
(
self
,
resource_id
,
*
args
,
**
kwargs
)
)
return
wrapped
return
f
(
self
,
resource_id
,
*
args
,
**
kwargs
)
return
decorator
return
wrapped
def
minimum_version
(
version
):
def
minimum_version
(
version
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment