
    2.aC                     8    d dl Z ddlmZ ddlmZ  G d d      Zy)    N   )errors)utilsc                   $   e Zd Z ej                  d      dd       Z ej                  d       ej                  d      d               Z ej                  d       ej                  d      d               Z ej                  d      d	d       Z	y)
SecretApiMixinz1.25Nc                 |   t        |t              s|j                  d      }t        j                  |      }|j                  d      }|||d}|:t        j                  | j                  d      rt        j                  d      ||d<   | j                  d      }| j                  | j                  ||      d	      S )
a  
            Create a secret

            Args:
                name (string): Name of the secret
                data (bytes): Secret data to be stored
                labels (dict): A mapping of labels to assign to the secret
                driver (DriverConfig): A custom driver configuration. If
                    unspecified, the default ``internal`` driver will be used

            Returns (dict): ID of the newly created secret
        zutf-8ascii)DataNameLabelsz1.31z6Secret driver is only available for API version > 1.31Driverz/secrets/create)dataT)
isinstancebytesencodebase64	b64encodedecoder   
version_lt_versionr   InvalidVersion_url_result
_post_json)selfnamer   labelsdriverbodyurls          3/usr/lib/python3/dist-packages/docker/api/secret.pycreate_secretzSecretApiMixin.create_secret   s     $&;;w'D%{{7#
 v6++L  $DNii)*||OOCdO+T
 	
    idc                 h    | j                  d|      }| j                  | j                  |      d      S )a2  
            Retrieve secret metadata

            Args:
                id (string): Full ID of the secret to inspect

            Returns (dict): A dictionary of metadata

            Raises:
                :py:class:`docker.errors.NotFound`
                    if no secret with that ID exists
        /secrets/{0}T)r   r   _get)r   r$   r    s      r!   inspect_secretzSecretApiMixin.inspect_secret.   s-     ii+||DIIcND11r#   c                 l    | j                  d|      }| j                  |      }| j                  |       y)a%  
            Remove a secret

            Args:
                id (string): Full ID of the secret to remove

            Returns (boolean): True if successful

            Raises:
                :py:class:`docker.errors.NotFound`
                    if no secret with that ID exists
        r&   T)r   _delete_raise_for_status)r   r$   r    ress       r!   remove_secretzSecretApiMixin.remove_secret@   s3     ii+ll3s#r#   c                     | j                  d      }i }|rt        j                  |      |d<   | j                  | j	                  ||      d      S )z
            List secrets

            Args:
                filters (dict): A map of filters to process on the secrets
                list. Available filters: ``names``

            Returns (list): A list of secrets
        z/secretsfilters)paramsT)r   r   convert_filtersr   r'   )r   r/   r    r0   s       r!   secretszSecretApiMixin.secretsT   sM     ii
# % 5 5g >F9||DIIc&I94@@r#   )NN)N)
__name__
__module____qualname__r   minimum_versionr"   check_resourcer(   r-   r2    r#   r!   r   r      s    U6"#
 ##
J U6"U$2   #2  U6"U$   #$ U6"A #Ar#   r   )r    r   r   r   r8   r#   r!   <module>r:      s      \A \Ar#   