ó
è?F[c           @   s€   d  Z  d d l Z d d l Z d d l m Z e j e ƒ Z d Z i i  d 6Z	 d e
 f d „  ƒ  YZ d e f d	 „  ƒ  YZ d S(
   sÛ   Resolves regions and endpoints.

This module implements endpoint resolution, including resolving endpoints for a
given service and region and resolving the available endpoints for a service
in a specific AWS partition.
iÿÿÿÿN(   t   NoRegionErrors   {service}.{region}.{dnsSuffix}t	   endpointst   BaseEndpointResolverc           B   s2   e  Z d  Z d d „ Z d „  Z d e d „ Z RS(   s3   Resolves regions and endpoints. Must be subclassed.c         C   s
   t  ‚ d S(   s7  Resolves an endpoint for a service and region combination.

        :type service_name: string
        :param service_name: Name of the service to resolve an endpoint for
            (e.g., s3)

        :type region_name: string
        :param region_name: Region/endpoint name to resolve (e.g., us-east-1)
            if no region is provided, the first found partition-wide endpoint
            will be used if available.

        :rtype: dict
        :return: Returns a dict containing the following keys:
            - partition: (string, required) Resolved partition name
            - endpointName: (string, required) Resolved endpoint name
            - hostname: (string, required) Hostname to use for this endpoint
            - sslCommonName: (string) sslCommonName to use for this endpoint.
            - credentialScope: (dict) Signature version 4 credential scope
              - region: (string) region name override when signing.
              - service: (string) service name override when signing.
            - signatureVersions: (list<string>) A list of possible signature
              versions, including s3, v4, v2, and s3v4
            - protocols: (list<string>) A list of supported protocols
              (e.g., http, https)
            - ...: Other keys may be included as well based on the metadata
        N(   t   NotImplementedError(   t   selft   service_namet   region_name(    (    s<   lib/python2.7/site-packages/boto/vendored/regions/regions.pyt   construct_endpoint   s    c         C   s
   t  ‚ d S(   s   Lists the partitions available to the endpoint resolver.

        :return: Returns a list of partition names (e.g., ["aws", "aws-cn"]).
        N(   R   (   R   (    (    s<   lib/python2.7/site-packages/boto/vendored/regions/regions.pyt   get_available_partitions<   s    t   awsc         C   s
   t  ‚ d S(   sÒ  Lists the endpoint names of a particular partition.

        :type service_name: string
        :param service_name: Name of a service to list endpoint for (e.g., s3)

        :type partition_name: string
        :param partition_name: Name of the partition to limit endpoints to.
            (e.g., aws for the public AWS endpoints, aws-cn for AWS China
            endpoints, aws-us-gov for AWS GovCloud (US) Endpoints, etc.

        :type allow_non_regional: bool
        :param allow_non_regional: Set to True to include endpoints that are
             not regional endpoints (e.g., s3-external-1,
             fips-us-gov-west-1, etc).
        :return: Returns a list of endpoint names (e.g., ["us-east-1"]).
        N(   R   (   R   R   t   partition_namet   allow_non_regional(    (    s<   lib/python2.7/site-packages/boto/vendored/regions/regions.pyt   get_available_endpointsC   s    N(   t   __name__t
   __module__t   __doc__t   NoneR   R   t   FalseR   (    (    (    s<   lib/python2.7/site-packages/boto/vendored/regions/regions.pyR      s
   	t   EndpointResolverc           B   sh   e  Z d  Z d „  Z d „  Z d e d „ Z d d „ Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z RS(   s7   Resolves endpoints based on partition endpoint metadatac         C   s(   d | k r t  d ƒ ‚ n  | |  _ d S(   sA   
        :param endpoint_data: A dict of partition data.
        t
   partitionss%   Missing "partitions" in endpoint dataN(   t
   ValueErrort   _endpoint_data(   R   t   endpoint_data(    (    s<   lib/python2.7/site-packages/boto/vendored/regions/regions.pyt   __init__Z   s    c         C   s3   g  } x& |  j  d D] } | j | d ƒ q W| S(   NR   t	   partition(   R   t   append(   R   t   resultR   (    (    s<   lib/python2.7/site-packages/boto/vendored/regions/regions.pyR   b   s    R	   c         C   s“   g  } x† |  j  d D]w } | d | k r0 q n  | d } | | k rL q n  x< | | d D], } | sw | | d k r[ | j | ƒ q[ q[ Wq W| S(   NR   R   t   servicesR   t   regions(   R   R   (   R   R   R
   R   R   R   R   t   endpoint_name(    (    s<   lib/python2.7/site-packages/boto/vendored/regions/regions.pyR   h   s    
c         C   s;   x4 |  j  d D]% } |  j | | | ƒ } | r | Sq Wd  S(   NR   (   R   t   _endpoint_for_partition(   R   R   R   R   R   (    (    s<   lib/python2.7/site-packages/boto/vendored/regions/regions.pyR   v   s
    c         C   s  | d j  | t ƒ } | d  k rG d | k r; | d } qG t ƒ  ‚ n  | | d k rm |  j | | | | ƒ S|  j | | ƒ r| j  d ƒ } | j  d t ƒ } | rÙ | rÙ t j d | | | ƒ |  j | | | | ƒ St j d | | ƒ |  j | | | | ƒ Sd  S(   NR   t   partitionEndpointR   t   isRegionalizeds'   Using partition endpoint for %s, %s: %ss*   Creating a regex based endpoint for %s, %s(	   t   gett   DEFAULT_SERVICE_DATAR   R    t   _resolvet   _region_matcht   Truet   LOGt   debug(   R   R   R   R   t   service_datat   partition_endpointt   is_regionalized(    (    s<   lib/python2.7/site-packages/boto/vendored/regions/regions.pyR   ~   s*    
		
c         C   s>   | | d k r t  Sd | k r: t j | d ƒ j | ƒ St S(   NR   t   regionRegex(   R%   t   ret   compilet   matchR   (   R   R   R   (    (    s<   lib/python2.7/site-packages/boto/vendored/regions/regions.pyR$   ›   s
    c         C   sÙ   | d j  | i  ƒ } | d | d <| | d <|  j | j  d i  ƒ | ƒ |  j | j  d i  ƒ | ƒ | j  d t ƒ } |  j | | d | | ƒ | d <d | k rÇ |  j | | d | | ƒ | d <n  | d | d <| S(   NR   R   t   endpointNamet   defaultst   hostnamet   sslCommonNamet	   dnsSuffix(   R!   t   _merge_keyst   DEFAULT_URI_TEMPLATEt   _expand_template(   R   R   R   R(   R   R   R1   (    (    s<   lib/python2.7/site-packages/boto/vendored/regions/regions.pyR#   ¢   s    
c         C   s2   x+ | D]# } | | k r | | | | <q q Wd  S(   N(    (   R   t	   from_dataR   t   key(    (    s<   lib/python2.7/site-packages/boto/vendored/regions/regions.pyR4   ³   s    c         C   s    | j  d | d | d | d ƒ S(   Nt   servicet   regionR3   (   t   format(   R   R   t   templateR   R   (    (    s<   lib/python2.7/site-packages/boto/vendored/regions/regions.pyR6   ¸   s    	N(   R   R   R   R   R   R   R   R   R   R   R$   R#   R4   R6   (    (    (    s<   lib/python2.7/site-packages/boto/vendored/regions/regions.pyR   X   s   						(   R   t   loggingR,   t    boto.vendored.regions.exceptionsR    t	   getLoggerR   R&   R5   R"   t   objectR   R   (    (    (    s<   lib/python2.7/site-packages/boto/vendored/regions/regions.pyt   <module>   s   ;