U
    M8c0                     @   s  d dl Z d dlmZmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZmZmZ d dlmZmZ d d	lmZmZmZmZmZ d d
lmZ d dlmZ d dlmZmZ d dl m!Z! d dl"m#Z# d dl$m%Z%m&Z& d dl'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z- d dlm.Z. d dl'm/Z/ d dl'm0Z0 d dl'm1Z1 d dl'm2Z2 d dl'm3Z3 d dlm4Z4 e5dZ6e 7e8Z9e Z:G dd dZ;G dd dZ<G dd dZ=G dd  d Z>d!d" Z?dS )#    N)waiter
xform_name)ClientArgsCreator)AUTH_TYPE_MAPS)prepare_request_dict)Config)EndpointDiscoveryHandlerEndpointDiscoveryManager,block_endpoint_discovery_required_operations)ClientMethodDocstringPaginatorDocstring)DataNotFoundError*InvalidEndpointDiscoveryConfigurationErrorOperationNotPageableErrorUnknownServiceErrorUnknownSignatureVersionError)get_global_history_recorder)first_non_none_response)apply_request_checksumresolve_checksum_context)ServiceModel)	Paginator)adaptivestandard)CachedPropertyEventbridgeSignerSetterS3ControlArnParamHandlerv2S3RegionRedirectorv2ensure_booleanget_service_module_name)ClientError)S3ArnParamHandler)S3ControlArnParamHandler)S3ControlEndpointSetter)S3EndpointSetter)S3RegionRedirector)UNSIGNED)Zv2Zv3Zv3httpsv4s3s3v4c                   @   s   e Zd ZdZd6ddZd7ddZd8dd	Zd
d Zdd Zd9ddZ	d:ddZ
dd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! Zd"d# Zd$d% Zd&d' Zd;d(d)Zd*d+ Zd,d- Zd.d/ Zd0d1 Zd2d3 Zd4d5 ZdS )<ClientCreatorz%Creates client objects for a service.Nc
           
      C   s:   || _ || _|| _|| _|| _|| _|| _|| _|	| _d S N)	_loader_endpoint_resolver_user_agent_event_emitter_retry_handler_factory_retry_config_translator_response_parser_factory_exceptions_factory_config_store)
selfloaderendpoint_resolver
user_agentevent_emitterZretry_handler_factoryZretry_config_translatorZresponse_parser_factoryexceptions_factoryconfig_store r<   3/tmp/pip-unpacked-wheel-ozje0y8b/botocore/client.py__init__S   s    zClientCreator.__init__Tc                 C   s  | j jd|d}t||d}| ||}z| ||}| jd}W n( tk
rl   d }d }t	d| Y nX | 
||}| ||	\}}	t| j||	|jd| j|jdd}| ||||||||	||
||}|f |}| | | j|d d |	|d	 | j|d
 | |||	 |S )Nzchoose-service-nameservice_namedefaultZ
partitionszSNo endpoints ruleset found for service %s, falling back to legacy endpoint routing.ZsigningNameZsignatureVersion)service_signing_namer;   service_signature_version)clientendpoint_bridgeendpoint_urlclient_configscoped_configrE   )r/   emitr   _load_service_model_load_service_endpoints_rulesetr,   	load_datar   loggerinfo_create_client_class_normalize_fips_regionClientEndpointBridger-   metadatagetr4   _get_client_args_register_retries_register_s3_events_register_s3_control_events_register_endpoint_discovery)r5   r@   region_name	is_securerG   verifycredentialsrI   api_versionrH   
auth_token	responsesservice_modelendpoints_ruleset_datapartition_dataclsrF   Zclient_argsZservice_clientr<   r<   r=   create_clientm   s      
 



  zClientCreator.create_clientc                 C   s   |  ||}| ||S r+   )rL   rQ   )r5   r@   r_   rb   r<   r<   r=   create_client_class   s    z!ClientCreator.create_client_classc           	      C   sb   |  |}| |}||d< tg}|j }| jjd| ||d t|}tt	|t
||}|S )N_PY_TO_OP_NAMEzcreating-client-class.%s)class_attributesZbase_classes)_create_methods_create_name_mapping
BaseClient
service_id	hyphenizer/   rK   r   typestrtuple)	r5   r@   rb   ri   Zpy_name_to_operation_namebasesrm   
class_namere   r<   r<   r=   rQ      s    


z"ClientCreator._create_client_classc                 C   s`   |d k	rX| dd dd}||krXtdd}|r>||}n|}td||f  |}||fS )Nzfips- z-fipsT)use_fips_endpointztransforming region from %s to %s and setting use_fips_endpoint to true. client should not be configured with a fips psuedo region.)replacer   mergerO   warning)r5   r[   rH   Znormalized_region_nameZconfig_use_fips_endpointr<   r<   r=   rR      s&     
z$ClientCreator._normalize_fips_regionc                 C   s"   | j j|d|d}t||d}|S )Nz	service-2r_   r?   )r,   load_service_modelr   )r5   r@   r_   Z
json_modelrb   r<   r<   r=   rL      s      z!ClientCreator._load_service_modelc                 C   s   | j j|d|dS )Nzendpoint-rule-set-1ry   )r,   rz   )r5   r@   r_   r<   r<   r=   rM      s
      z-ClientCreator._load_service_endpoints_rulesetc                 C   sV   |j jjd }|dkr"| | n0|dkr@| | | | n|dkrR| | d S )Nmoder   r   legacy)metaconfigretries_register_v2_standard_retries_register_v2_adaptive_retries_register_legacy_retries)r5   rE   
retry_moder<   r<   r=   rW      s    
zClientCreator._register_retriesc                 C   s8   |j jjd}d|i}|d k	r(||d< tjf | d S )Ntotal_max_attemptsrE   max_attempts)r}   r~   r   rU   r   register_retry_handler)r5   rE   r   kwargsr<   r<   r=   r      s
    z+ClientCreator._register_v2_standard_retriesc                 C   s   t | d S r+   )r   r   )r5   rE   r<   r<   r=   r      s    z+ClientCreator._register_v2_adaptive_retriesc           
      C   s   |j jj}|j jj}| }| jd}|s0d S | |j jj	}| j
||di |di |}td|j jj | j||}d| }	|j jjd| ||	d d S )NZ_retryretryZdefinitionsz*Registering retry handlers for service: %szretry-config-%szneeds-retry.)	unique_id)r}   rb   endpoint_prefixrm   rn   r,   rN   _transform_legacy_retriesr~   r   r1   Zbuild_retry_configrU   rO   debugr@   r0   Zcreate_retry_handlereventsregister)
r5   rE   r   rm   Zservice_event_nameZoriginal_configr   Zretry_confighandlerr   r<   r<   r=   r     s6    



   z&ClientCreator._register_legacy_retriesc                 C   s:   |d krd S |  }d|kr6|  }|dd |d< |S )Nr      r   )copypop)r5   r   Zcopied_argsr<   r<   r=   r   "  s    z'ClientCreator._transform_legacy_retriesc                 C   s6   |j jj}|d k	r(|dd k	r(|d S |dp4dS )Nr{   r   r|   )r}   r~   r   rU   get_config_variable)r5   rE   r;   Zclient_retriesr<   r<   r=   _get_retry_mode-  s    
zClientCreator._get_retry_modec           
      C   s   |d k	rd S |j jjd krd S |j j}|j jj }d}|rN|jd k	rN|j}n| jr`| jd}| 	|}|r| 
||r|dk}t||d}t|}	|	|| n|dt d S )NFendpoint_discovery_enabledT)Zalways_discoverzbefore-parameter-build)r}   rb   Zendpoint_discovery_operationr   rm   rn   r   r4   r   $_normalize_endpoint_discovery_config_requires_endpoint_discoveryr	   r   r   r
   )
r5   rE   rG   r~   r   rm   enabledZdiscovermanagerr   r<   r<   r=   rZ   6  s4    
 z*ClientCreator._register_endpoint_discoveryc                 C   sP   t |tr4|  }|dkr"|S |dkrBt|S nt |trB|S t|ddS )z?Config must either be a boolean-string or string-literal 'auto'auto)truefalse)Zconfig_valueN)
isinstancerp   lowerstripr   boolr   )r5   r   r<   r<   r=   r   U  s    


z2ClientCreator._normalize_endpoint_discovery_configc                 C   s   |dkr|j jjS |S )Nr   )r}   rb   Zendpoint_discovery_required)r5   rE   r   r<   r<   r=   r   b  s    
z*ClientCreator._requires_endpoint_discoveryc                 C   s4   |j jjdkrd S t| j|j j|d|j j d S )Nr   )r7   regionrG   )r}   rb   r@   r   r-   r[   r   r   )r5   rE   rF   rG   r<   r<   r=   _register_eventbridge_eventsg  s    z*ClientCreator._register_eventbridge_eventsc                 C   s4   |j jjdkrd S td |  | |j || d S )Nr(   )r}   rb   r@   r   r   !_set_s3_presign_signature_versionr5   rE   rF   rG   rH   rI   r<   r<   r=   rX   r  s      z!ClientCreator._register_s3_eventsc                 C   s&   |j jjdkrd S t |j j d S )NZ	s3control)r}   rb   r@   r   r   r   r   r<   r<   r=   rY     s    z)ClientCreator._register_s3_control_eventsc                 C   sx   t d||}|d k	rd S | jd|j}|jdkr@|j|kr@d S | jd|j}|d }d|krdd S |jd| j d S )Nr(   z
aws-globalsignatureVersionszchoose-signer.s3)	!_get_configured_signature_versionr-   Zget_available_endpoints	partitionr[   construct_endpointr   r   _default_s3_presign_to_sigv2)r5   Zclient_metarH   rI   Zprovided_signature_versionZregionsendpointZsignature_versionsr<   r<   r=   r     s6         z/ClientCreator._set_s3_presign_signature_versionc                 K   s4   | drdS dD ]}||rd|   S qdS )a@  
        Returns the 's3' (sigv2) signer if presigning an s3 request. This is
        intended to be used to set the default signature version for the signer
        to sigv2. Situations where an asymmetric signature is required are the
        exception, for example MRAP needs v4a.

        :type signature_version: str
        :param signature_version: The current client signature version.

        :type signing_name: str
        :param signing_name: The signing name of the service.

        :return: 's3' if the request is an s3 presign request, None otherwise
        Zv4aN)z-queryz-presign-postr(   )
startswithendswith)r5   signature_versionr   suffixr<   r<   r=   r     s
    

z*ClientCreator._default_s3_presign_to_sigv2c                 C   s@   t | j| j| j| j| j| jd}||||||||||	|
||S )N)r;   )r   r/   r.   r2   r,   r3   r4   Zget_client_args)r5   rb   r[   r\   rG   r]   r^   rI   rH   rF   r`   rc   rd   Zargs_creatorr<   r<   r=   rV     s,    zClientCreator._get_client_argsc                 C   s.   i }|j D ]}t|}| |||||< q
|S r+   )operation_namesr   _create_api_method)r5   rb   Zop_dictoperation_namepy_operation_namer<   r<   r=   rj     s    
  
zClientCreator._create_methodsc                 C   s$   i }|j D ]}t|}|||< q
|S r+   )r   r   )r5   rb   mappingr   r   r<   r<   r=   rk     s
    

z"ClientCreator._create_name_mappingc                    sH    fdd}t |_| }t| | j|jd dd}||_|S )Nc                    s   |rt  d|  |S )Nz"() only accepts keyword arguments.)	TypeError_make_api_call)r5   argsr   r   r   r<   r=   	_api_call	  s
    z3ClientCreator._create_api_method.<locals>._api_callzresponse = client.%sF)operation_modelmethod_namer9   Zmethod_descriptionZexample_prefixinclude_signature)rp   __name__r   r   r/   Zdocumentation__doc__)r5   r   r   rb   r   r   Z	docstringr<   r   r=   r     s    

z ClientCreator._create_api_method)NNN)TNNNNNNN)N)N)N)NNNN)r   
__module____qualname__r   r>   rf   rg   rQ   rR   rL   rM   rW   r   r   r   r   r   rZ   r   r   r   rX   rY   r   r   rV   rj   rk   r   r<   r<   r<   r=   r*   P   sR   
   
        
K



	    
+&		r*   c                   @   s   e Zd ZdZdZddgZd#ddZd$d	d
Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" ZdS )%rS   a  Bridges endpoint data and client creation

    This class handles taking out the relevant arguments from the endpoint
    resolver and determining which values to use, taking into account any
    client configuration options and scope configuration options.

    This class also handles determining what, if any, region to use if no
    explicit region setting is provided. For example, Amazon S3 client will
    utilize "us-east-1" by default if no region can be resolved.z {service}.{region}.amazonaws.comr(   z
s3-controlNc                 C   s4   || _ || _|| _|| _|p | j| _|| _|| _d S r+   )rC   r7   rI   rH   DEFAULT_ENDPOINTdefault_endpointr;   rD   )r5   r7   rI   rH   r   rC   r;   rD   r<   r<   r=   r>   2  s    
zClientEndpointBridge.__init__Tc                 C   sx   |  ||}| |}| d}| jj||||d}|sN| jj||d||d}|rd| |||||S | ||||S d S )Nru   )use_dualstack_endpointru   Zaws)Zpartition_namer   ru   )_check_default_region_resolve_use_dualstack_endpoint$_resolve_endpoint_variant_config_varr7   r   _create_endpoint_assume_endpoint)r5   r@   r[   rG   r\   r   ru   resolvedr<   r<   r=   resolveD  sF    	       zClientEndpointBridge.resolvec                 C   s   | j jS r+   )r7   Zuses_builtin_datar5   r<   r<   r=   resolver_uses_builtin_datak  s    z/ClientEndpointBridge.resolver_uses_builtin_datac                 C   s*   |d k	r|S | j r&| j jd k	r&| j jS d S r+   )rH   r[   )r5   r@   r[   r<   r<   r=   r   n  s    z*ClientEndpointBridge._check_default_regionc           	   	   C   sf   |  |||\}}|d kr6| |d||dg }| ||}| ||}| j|||||||dS )NhostnameZ	protocols)r@   r[   signing_regionsigning_namerG   rT   r   )_pick_region_values	_make_urlrU   _resolve_signature_version_resolve_signing_name_create_result)	r5   r   r@   r[   rG   r\   r   r   r   r<   r<   r=   r   u  s2      
 z%ClientEndpointBridge._create_endpointc                 C   s@   | j }d}|r&t||d k	r&t||S | jd k	r<| j|}|S )NF)rH   getattrr;   r   )r5   Z
config_varrH   Z
config_valr<   r<   r=   r     s    

z9ClientEndpointBridge._resolve_endpoint_variant_config_varc                 C   s    |  |}|d k	r|S | dS )Nr   )_is_s3_dualstack_moder   )r5   r@   Zs3_dualstack_moder<   r<   r=   r     s    
z4ClientEndpointBridge._resolve_use_dualstack_endpointc                 C   sh   || j krd S | j}|d k	r:|jd k	r:d|jkr:|jd S | jd k	rd| jdi d}|dkrddS d S )Nr   r(   )TTruer   T)_DUALSTACK_CUSTOMIZED_SERVICESrH   r(   rI   rU   )r5   r@   rH   r   r<   r<   r=   r     s     


z*ClientEndpointBridge._is_s3_dualstack_modec              	   C   s~   |d kr*| j j||d}| ||ddg}td| d| d|  | |ddgi}| j|i d	}| j||||||i d
S )N)servicer   httphttpszAssuming an endpoint for z, z: r   r'   )r   )r@   r[   r   r   r   rG   rT   )r   formatr   rO   r   r   r   r   )r5   r@   r[   rG   r\   r   r   r   r<   r<   r=   r     s6        z%ClientEndpointBridge._assume_endpointc                 C   s   |||||||dS )N)r@   r[   r   r   rG   r   rT   r<   )r5   r@   r[   r   r   rG   r   rT   r<   r<   r=   r     s    z#ClientEndpointBridge._create_resultc                 C   s$   |rd|krd}nd}| d| S )Nr   r   z://r<   )r5   r   r\   Zsupported_protocolsschemer<   r<   r=   r     s    zClientEndpointBridge._make_urlc                 C   s0   d|kr d|d kr |d d S | j r,| j S |S )NcredentialScoper   )rC   )r5   r@   r   r<   r<   r=   r     s    
z*ClientEndpointBridge._resolve_signing_namec                 C   s@   |}|d kr8|d }|}d|kr8d|d kr8|d d }||fS )NZendpointNamer   r   r<   )r5   r   r[   rG   r   r<   r<   r=   r     s    
z(ClientEndpointBridge._pick_region_valuesc                 C   s   t || j| j}|d k	r|S |dg }| jd k	rD| jtkrD| jg}d|kr~|dkrXdS d|krddS |D ]}|tkrh|  S qht|dd S )Nr   r(   r)   r'   )r   )r   rH   rI   rU   rD   _LEGACY_SIGNATURE_VERSIONSr   r   )r5   r@   r   Zconfigured_versionZpotential_versionsZknownr<   r<   r=   r     s4      
z/ClientEndpointBridge._resolve_signature_version)NNNNNN)NNT)r   r   r   r   r   r   r>   r   r   r   r   r   r   r   r   r   r   r   r   r   r<   r<   r<   r=   rS   $  s4   
      
     
'rS   c                   @   s   e Zd Zi Zd&ddZdd Zdd Zdd	 Zed
d Z	dd Z
dd Zd'ddZdd Zd(ddZdd Zdd Zdd Zdd Zed d! Zed"d# Zd$d% ZdS ))rl   Nc                 C   sb   || _ || _|| _|| _|| _i | _|| _|| _t|| j|j	|| j
|	| _|
| _d | _|   d S r+   )_serializer	_endpoint_ruleset_resolverZ_response_parser_request_signer_cacher,   _client_config
ClientMetahostrh   r}   r3   _exceptions_register_handlers)r5   
serializerr   Zresponse_parserr9   request_signerrb   r6   rH   r   r:   Zendpoint_ruleset_resolverr<   r<   r=   r>   ?  s&    zBaseClient.__init__c                 C   s\   | j j }d| d| }| jjj|| d\}}|d k	r>|S td| jj d| dd S )Nzgetattr..rJ   'z' object has no attribute ')	_service_modelrm   rn   r}   r   emit_until_responseAttributeError	__class__r   )r5   itemrm   Z
event_namer   event_responser<   r<   r=   __getattr__a  s     
zBaseClient.__getattr__c                 C   s   | j   dS )z'Closes underlying endpoint connections.N)r   closer   r<   r<   r=   r   p  s    zBaseClient.closec                 C   s,   | j jj }| j jd| | jj d S )Nzrequest-created.)r}   rb   rm   rn   r   r   r   r   )r5   rm   r<   r<   r=   r   t  s
     zBaseClient._register_handlersc                 C   s   | j jS r+   )r}   rb   r   r<   r<   r=   r   {  s    zBaseClient._service_modelc                 C   sH  | j |}| j j}td|||d |jr<td|| | jj	| jj
|j|jd}| |||\}}| j|||||d}t||| | j j }	| jjjdj|	|d||| j|d\}
}|d k	r|\}}nt| | |||\}}| jjjd	j|	|d||||d
 |jdkr@|di d}| j|}|||n|S d S )NZAPI_CALL)r   Z	operationparamszWarning: %s.%s() is deprecated)Zclient_regionrH   has_streaming_input	auth_type)
api_paramsr   rG   contextheadersz)before-call.{service_id}.{operation_name}rm   r   )modelr   r   r   z(after-call.{service_id}.{operation_name})http_responseparsedr   r   i,  ErrorZCode)r   r   r@   history_recorderrecord
deprecatedrO   r   r}   r[   r~   r   r   _resolve_endpoint_ruleset_convert_to_request_dictr   rm   rn   r   r   r   r   r   _make_requestrK   status_coderU   
exceptionsZ	from_code)r5   r   r   r   r@   request_contextrG   additional_headersrequest_dictrm   r   r   r   Zparsed_responseZ
error_codeZerror_classr<   r<   r=   r     s         


   
zBaseClient._make_api_callc              
   C   sb   z| j ||W S  tk
r\ } z.| jjjdj| jj	 |j
d||d  W 5 d }~X Y nX d S )Nz.after-call-error.{service_id}.{operation_name}r   )	exceptionr   )r   Zmake_request	Exceptionr}   r   rK   r   r   rm   rn   name)r5   r   r
  r  er<   r<   r=   r    s    
zBaseClient._make_requestTc           	      C   sl   |  |||}| j||}| jjs0|dd  |d k	rF|d | |rT| jj}nd }t||||d |S )Nhost_prefixr   )rG   r8   r   )	_emit_api_paramsr   Zserialize_to_requestr   Zinject_host_prefixr   updater8   r   )	r5   r   r   rG   r   r   Zset_user_agent_headerr
  r8   r<   r<   r=   r    s.    	   
z#BaseClient._convert_to_request_dictc                 C   sf   |j }| jj }| jjjd| d| |||d}t||d}| jjjd| d| |||d |S )Nzprovide-client-params.r   )r   r   r   rA   zbefore-parameter-build.)r  r   rm   rn   r}   r   rK   r   )r5   r   r   r   r   rm   ra   r<   r<   r=   r    s     zBaseClient._emit_api_paramsFc                 C   s   | j dkr| jj}i }n| j j|||d}|j}|j}|jd}|dk	r| j |}	|	\}
}|
|d< d|krx|rx|d= d|kr|d 	| n||d< ||fS )a  Returns endpoint URL and list of additional headers returned from
        EndpointRulesetResolver for the given operation and params. If the
        ruleset resolver is not available, for example because the service has
        no endpoints ruleset file, the legacy endpoint resolver's value is
        returned.

        Use ignore_signing_region for generating presigned URLs or any other
        situtation where the signing region information from the ruleset
        resolver should be ignored.

        Returns tuple of URL and headers dictionary. Additionally, the
        request_context dict is modified in place with any signing information
        returned from the ruleset resolver.
        N)r   Z	call_argsr  ZauthSchemesr   r   Zsigning)
r   r}   rG   r   urlr   Z
propertiesrU   Zauth_schemes_to_signing_ctxr  )r5   r   r   r  Zignore_signing_regionrG   r	  Zendpoint_infoZauth_schemesZ	auth_infor   Zsigning_contextr<   r<   r=   r  
  s.    
z$BaseClient._resolve_endpoint_rulesetc           
      C   s   |  |st|dn| j| }dd }| jd | }t|| jj| jj|dd|_t	| jj}| d| }t
|tfd|i}| j|}|t| |||}	|	S d	S )
a  Create a paginator for an operation.

        :type operation_name: string
        :param operation_name: The operation name.  This is the same name
            as the method name on the client.  For example, if the
            method name is ``create_foo``, and you'd normally invoke the
            operation as ``client.create_foo(**kwargs)``, if the
            ``create_foo`` operation can be paginated, you can use the
            call ``client.get_paginator("create_foo")``.

        :raise OperationNotPageableError: Raised if the operation is not
            pageable.  You can use the ``client.can_paginate`` method to
            check if an operation is pageable.

        :rtype: L{botocore.paginate.Paginator}
        :return: A paginator object.

        )r   c                 [   s   t j| f|S r+   )r   paginate)r5   r   r<   r<   r=   r  W  s    z*BaseClient.get_paginator.<locals>.paginatepage_configF)Zpaginator_namer9   rb   paginator_configr   z.Paginator.r  N)can_paginater   rh   r   r   r}   r   rb   r   r   ro   r   r   r   r   )
r5   r   actual_operation_namer  r  Zservice_module_nameZpaginator_class_nameZdocumented_paginator_clsr   Z	paginatorr<   r<   r=   get_paginator<  sB    

	  zBaseClient.get_paginatorc                 C   sl   d| j krTz*| j| jjd| jjd }|| j d< W n tk
rR   i | j d< Y nX | j| }|| j d kS )aM  Check if an operation can be paginated.

        :type operation_name: string
        :param operation_name: The operation name.  This is the same name
            as the method name on the client.  For example, if the
            method name is ``create_foo``, and you'd normally invoke the
            operation as ``client.create_foo(**kwargs)``, if the
            ``create_foo`` operation can be paginated, you can use the
            call ``client.get_paginator("create_foo")``.

        :return: ``True`` if the operation can be paginated,
            ``False`` otherwise.

        r  zpaginators-1Z
pagination)r   r,   rz   r   r@   r_   r   rh   )r5   r   r  r  r<   r<   r=   r  }  s    

zBaseClient.can_paginatec                 C   sZ   d| j krPz&| j| jjd| jj}|| j d< W n tk
rN   i | j d< Y nX | j d S )Nwaiter_configz	waiters-2)r   r,   rz   r   r@   r_   r   )r5   r  r<   r<   r=   _get_waiter_config  s    
zBaseClient._get_waiter_configc                 C   sd   |   }|std| t|}i }|jD ]}||t|< q,||krRtd| t|| || S )aG  Returns an object that can wait for some condition.

        :type waiter_name: str
        :param waiter_name: The name of the waiter to get. See the waiters
            section of the service docs for a list of available waiters.

        :returns: The specified waiter object.
        :rtype: botocore.waiter.Waiter
        zWaiter does not exist: %s)r  
ValueErrorr   WaiterModelwaiter_namesr   Zcreate_waiter_with_client)r5   Zwaiter_namer~   r   r   r  r<   r<   r=   
get_waiter  s    


  zBaseClient.get_waiterc                 C   s*   |   }|sg S t|}dd |jD S )z(Returns a list of all available waiters.c                 S   s   g | ]}t |qS r<   )r   ).0r  r<   r<   r=   
<listcomp>  s     z+BaseClient.waiter_names.<locals>.<listcomp>)r  r   r  r  )r5   r~   r   r<   r<   r=   r    s
    
zBaseClient.waiter_namesc                 C   s   | j d kr|  | _ | j S r+   )r   _load_exceptionsr   r<   r<   r=   r    s    

zBaseClient.exceptionsc                 C   s   | j | jS r+   )r3   Zcreate_client_exceptionsr   r   r<   r<   r=   r!    s    zBaseClient._load_exceptions)N)NNT)F)r   r   r   rh   r>   r   r   r   propertyr   r   r  r  r  r  r  r  r  r  r   r  r  r!  r<   r<   r<   r=   rl   5  s4    
"
E   
 
2A


rl   c                   @   s`   e Zd ZdZdd Zedd Zedd Zedd	 Zed
d Z	edd Z
edd ZdS )r   a~  Holds additional client methods.

    This class holds additional information for clients.  It exists for
    two reasons:

        * To give advanced functionality to clients
        * To namespace additional client attributes from the operation
          names which are mapped to methods at runtime.  This avoids
          ever running into collisions with operation names.

    c                 C   s(   || _ || _|| _|| _|| _|| _d S r+   )r   r   _endpoint_urlr   _method_to_api_mapping
_partition)r5   r   rH   rG   rb   method_to_api_mappingr   r<   r<   r=   r>     s    	zClientMeta.__init__c                 C   s   | j S r+   )r   r   r<   r<   r=   rb     s    zClientMeta.service_modelc                 C   s   | j jS r+   )r   r[   r   r<   r<   r=   r[     s    zClientMeta.region_namec                 C   s   | j S r+   )r#  r   r<   r<   r=   rG     s    zClientMeta.endpoint_urlc                 C   s   | j S r+   )r   r   r<   r<   r=   r~     s    zClientMeta.configc                 C   s   | j S r+   )r$  r   r<   r<   r=   r&    s    z ClientMeta.method_to_api_mappingc                 C   s   | j S r+   )r%  r   r<   r<   r=   r     s    zClientMeta.partitionN)r   r   r   r   r>   r"  rb   r[   rG   r~   r&  r   r<   r<   r<   r=   r     s   




r   c                 C   s\   |r|j dk	r|j S |dk	rX|| }|dk	rXt|trX|d}|rXtd| | |S dS )z
    Gets the manually configured signature version.

    :returns: the customer configured signature version, or None if no
        signature version was configured.
    Nr   zWSwitching signature version for service %s to version %s based on config file override.)r   rU   r   dictrO   r   )r@   rH   rI   Zservice_configversionr<   r<   r=   r     s    


r   )@loggingZbotocorer   r   Zbotocore.argsr   Zbotocore.authr   Zbotocore.awsrequestr   Zbotocore.configr   Zbotocore.discoveryr   r	   r
   Zbotocore.docs.docstringr   r   Zbotocore.exceptionsr   r   r   r   r   Zbotocore.historyr   Zbotocore.hooksr   Zbotocore.httpchecksumr   r   Zbotocore.modelr   Zbotocore.paginater   Zbotocore.retriesr   r   Zbotocore.utilsr   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   	frozensetr   	getLoggerr   rO   r   r*   rS   rl   r   r   r<   r<   r<   r=   <module>   sP    
   W     #6