
                          x    S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKr " S S	\	5      r
   SS
 jrS rg)z<This package facilitates HTTP/REST requests to the registry.    )absolute_import)division)print_function)docker_creds)docker_nameNc                   \   ^  \ rS rSrSrU 4S jr\S 5       r\S 5       r\S 5       r	Sr
U =r$ )BadStatusException   z6Exceptions when an unexpected HTTP status is returned.c                 b   > SR                  XS9n[        [        U ]  U5        Xl        X l        g )Nz#Response:
{resp}
Content:
{content})respcontent)formatsuperr	   __init___resp_content)selfr   r   message	__class__s       ;lib/third_party/containerregistry/client/v1/docker_http_.pyr   BadStatusException.__init__   s5    6== > $G	
d,W5JM    c                     U R                   $ N)r   r   s    r   r   BadStatusException.resp#   s    ::r   c                 .    U R                   R                  $ r   )r   statusr   s    r   r   BadStatusException.status'   s    ::r   c                     U R                   $ r   )r   r   s    r   r   BadStatusException.content+   s    ==r   )r   r   )__name__
__module____qualname____firstlineno____doc__r   propertyr   r   r   __static_attributes____classcell__)r   s   @r   r	   r	      sG    >      r   r	   c                     U(       a  UOSUR                  5       S[        R                  S.nU R                  X(       a  SOSXFS9u  pxUR                  U;  a  [        Xx5      eXx4$ )a-  Wrapper containing much of the boilerplate REST logic for Registry calls.

Args:
  transport: the HTTP transport to use for requesting url
  url: the URL to which to talk
  credentials: the source of the Authorization header
  accepted_codes: the list of acceptable http status codes
  body: the body to pass into the PUT request (or None for GET)
  content_type: the mime-type of the request (or None for JSON)

Raises:
  BadStatusException: the status codes wasn't among the acceptable set.

Returns:
  The response of the HTTP request, and its contents.
zapplication/jsontrue)zcontent-typeAuthorizationzX-Docker-Tokenz
user-agentPUTGET)bodyheaders)Getr   
USER_AGENTrequestr   r	   )		transporturlcredentialsaccepted_codesr/   content_typer0   r   r   s	            r   Requestr9   1   so    . '3l8J"(**	' ##	D5e$ $ A-$ 
[[&
T
++	r   c                 2    U R                  S5      (       a  gg)z<Returns https scheme for all the endpoints except localhost.z
localhost:httphttps)
startswith)endpoints    r   Schemer?   W   s    &&r   )NNN)r&   
__future__r   r   r   containerregistry.clientr   r   httplib2	Exceptionr	   r9   r?    r   r   <module>rE      s?    C &  % 1 0  6 "#Lr   