
                         0    S SK Jr  S SK Jr   " S S5      rg)   )errors)utilsc                   p    \ rS rSrS
S jr  SS jrS r\R                  " S5      S
S j5       r	SS jr
S	rg)VolumeApiMixin   Nc                     SU(       a  [         R                  " U5      OS0nU R                  S5      nU R                  U R	                  X2S9S5      $ )a|  
List volumes currently registered by the docker daemon. Similar to the
``docker volume ls`` command.

Args:
    filters (dict): Server-side list filtering options.

Returns:
    (dict): Dictionary with list of volume objects as value of the
    ``Volumes`` key.

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.

Example:

    >>> client.api.volumes()
    {u'Volumes': [{u'Driver': u'local',
       u'Mountpoint': u'/var/lib/docker/volumes/foobar/_data',
       u'Name': u'foobar'},
      {u'Driver': u'local',
       u'Mountpoint': u'/var/lib/docker/volumes/baz/_data',
       u'Name': u'baz'}]}
filtersNz/volumesparamsT)r   convert_filters_url_result_getselfr	   r   urls       $lib/third_party/docker/api/volume.pyvolumesVolumeApiMixin.volumes   sK    8 u,,W5d
 ii
#||DIIcI94@@    c                 x   U R                  S5      nUb   [        U[        5      (       d  [        S5      eUUUS.nUb_  [        R
                  " SU R                  5      S:  a  [        R                  " S5      e[        U[        5      (       d  [        S5      eXFS'   U R                  U R                  XVS	9S
5      $ )a#  
Create and register a named volume

Args:
    name (str): Name of the volume
    driver (str): Name of the driver used to create the volume
    driver_opts (dict): Driver options as a key-value dictionary
    labels (dict): Labels to set on the volume

Returns:
    (dict): The created volume reference object

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.

Example:

    >>> volume = client.api.create_volume(
    ...     name='foobar',
    ...     driver='local',
    ...     driver_opts={'foo': 'bar', 'baz': 'false'},
    ...     labels={"key": "value"},
    ... )
    ... print(volume)
    {u'Driver': u'local',
    u'Labels': {u'key': u'value'},
    u'Mountpoint': u'/var/lib/docker/volumes/foobar/_data',
    u'Name': u'foobar',
    u'Scope': u'local'}

z/volumes/createz driver_opts must be a dictionary)NameDriver
DriverOptsz1.23    z)volume labels were introduced in API 1.23zlabels must be a dictionaryLabels)dataT)r   
isinstancedict	TypeErrorr   compare_version_versionr   InvalidVersionr   
_post_json)r   namedriverdriver_optslabelsr   r   s          r   create_volumeVolumeApiMixin.create_volume'   s    D ii)*":k4+H+H>?? %
 $$VT]];a?++?  fd++ =>>#N||DOOCO;TBBr   c                 h    U R                  SU5      nU R                  U R                  U5      S5      $ )av  
Retrieve volume info by name.

Args:
    name (str): volume name

Returns:
    (dict): Volume information dictionary

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.

Example:

    >>> client.api.inspect_volume('foobar')
    {u'Driver': u'local',
     u'Mountpoint': u'/var/lib/docker/volumes/foobar/_data',
     u'Name': u'foobar'}

/volumes/{0}T)r   r   r   )r   r%   r   s      r   inspect_volumeVolumeApiMixin.inspect_volume^   s-    , ii-||DIIcND11r   1.25c                     0 nU(       a  [         R                  " U5      US'   U R                  S5      nU R                  U R	                  X2S9S5      $ )a0  
Delete unused volumes

Args:
    filters (dict): Filters to process on the prune list.

Returns:
    (dict): A dict containing a list of deleted volume names and
        the amount of disk space reclaimed in bytes.

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.
r	   z/volumes/pruner
   T)r   r   r   r   _postr   s       r   prune_volumesVolumeApiMixin.prune_volumesw   sL       % 5 5g >F9ii()||DJJsJ:DAAr   c                     0 nU(       a@  [         R                  " U R                  S5      (       a  [        R                  " S5      eSU0nU R                  SXS9nU R                  U5      nU R                  U5        g)a2  
Remove a volume. Similar to the ``docker volume rm`` command.

Args:
    name (str): The volume's name
    force (bool): Force removal of volumes that were already removed
        out of band by the volume driver plugin.

Raises:
    :py:class:`docker.errors.APIError`
        If volume failed to remove.
r/   z(force removal was introduced in API 1.25forcer,   r
   N)r   
version_ltr"   r   r#   r   _delete_raise_for_status)r   r%   r5   r   r   resps         r   remove_volumeVolumeApiMixin.remove_volume   ss     v66++>  u%Fiii<||C t$r    )N)NNNN)F)__name__
__module____qualname____firstlineno__r   r)   r-   r   minimum_versionr2   r:   __static_attributes__r<   r   r   r   r      sE    AB AE!5Cn22 6"B #B*%r   r   N) r   r   r   r<   r   r   <module>rD      s     _% _%r   