U!\c@s-ddlZddlZddlmZmZddlmZddlmZddl m Z ddl m Z ddl m Z mZddl mZdd l mZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddl!m"Z"ddlm#Z#ddl$m%Z%ddl&m'Z'ddl(m)Z)m*Z*m+Z+ej,e-Z.e'Z/de0fdYZ1de0fdYZ2de0fdYZ3d e0fd!YZ4d"Z5dS(#iN(twaitert xform_name(tAUTH_TYPE_MAPS(tprepare_request_dict(tClientMethodDocstring(tPaginatorDocstring(t ClientErrortDataNotFoundError(tOperationNotPageableError(tUnknownSignatureVersionError(tfirst_non_none_response(t ServiceModel(t Paginator(tCachedProperty(tget_service_module_name(tswitch_host_s3_accelerate(tS3RegionRedirector(t fix_s3_host(tswitch_to_virtual_host_style(tS3_ACCELERATE_WHITELIST(tClientArgsCreator(turlsplit(tUNSIGNED(tConfig(tget_global_history_recorder(tEndpointDiscoveryHandlertEndpointDiscoveryManagert,block_endpoint_discovery_required_operationst ClientCreatorcBseZdZddddZedddddddZddZdZddZ dZ dZ dZ d Z d Zd Zd Zd ZdZdZdZdZdZRS(s%Creates client objects for a service.c CsU||_||_||_||_||_||_||_||_| |_dS(N( t_loadert_endpoint_resolvert _user_agentt_event_emittert_retry_handler_factoryt_retry_config_translatort_response_parser_factoryt_exceptions_factoryt _config_store( tselftloadertendpoint_resolvert user_agentt event_emittertretry_handler_factorytretry_config_translatortresponse_parser_factorytexceptions_factoryt config_store((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyt__init__5s        c  Cs|jjdd|} t| d|}|j||} |j|| } t|j|| d| jjd} |j | ||||||| | }| |}|j ||j || || ||j ||| |S(Nschoose-service-namet service_nametdefaulttservice_signing_namet signingName( R temitR t_load_service_modelt_create_client_classtClientEndpointBridgeRtmetadatatgett_get_client_argst_register_retriest_register_s3_eventst_register_endpoint_discovery(R&R1t region_namet is_securet endpoint_urltverifyt credentialst scoped_configt api_versiont client_configt responsest service_modeltclstendpoint_bridget client_argstservice_client((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyt create_clientGs&      cCs"|j||}|j||S(N(R6R7(R&R1RERH((s3/tmp/pip-install-usGedi/botocore/botocore/client.pytcreate_client_classasc Cs|j|}|j|}||ds$         cCs|jjjdkrdSt||j|j||jjj|jj|jj |j ||jjjr|jjj dt n|j |j||dS(Nts3sbefore-sign.s3(RcRHR1RRmt_set_s3_addressing_styleRgRzRlt partitiont_is_s3_acceleratetregister_firstRt!_set_s3_presign_signature_version(R&RnRJRARFRD((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyR=s   cCsb|dkri}n|j||}|j||||}|dk r^|jd|ndS(Nsbefore-sign.s3(Rtt_get_s3_addressing_stylet_get_s3_addressing_handlerRm(R&RAt s3_configR*R|taddressing_styleRr((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyR{s    cCsK|jdt}|s*|j||r.dS|jd}|rG|SdS(Ntuse_accelerate_endpointtvirtualR(R:RvR}(R&RARt acceleratetconfigured_addressing_style((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyRs cCsW|dkrtjdtS|dks5|dk rFtjddStjdtS(NRs'Using S3 virtual host style addressing.tpathsUsing S3 path style addressing.sSDefaulting to S3 virtual host style addressing with path style addressing fallback.(RiRjRRtR(R&RARRR|((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyRs    cCs|dk r|jdrtS|dkr/tSt|j}|jdsQtS|jd}|ddkrttS|dd!}t|tt |krtSt d|DS( NRs amazonaws.comt.is s3-accelerateiicss|]}|tkVqdS(N(R(t.0tp((s3/tmp/pip-install-usGedi/botocore/botocore/client.pys s( RtR:tTrueRvRtnetloctendswithtsplittlentsettall(R&RARRtpartst feature_parts((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyR}s  cCstd||}|dk r"dS|jjd|j}|j|krMdS|jjd|j}|d}d|krdS|jjd|j dS(NRztsignatureVersionsschoose-signer.s3( t!_get_configured_signature_versionRtRtget_available_endpointsR|R?tconstruct_endpointRlRmt_default_s3_presign_to_sigv2(R&t client_metaRFRDtprovided_signature_versiontregionstendpointtsignature_versions((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyR s      cKs2x+ddgD]}|j|r d|Sq WdS(s 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. :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 s-querys -presign-postRzN(R(R&tsignature_versiontkwargstsuffix((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyR-sc CsLt|j|j|j|j|j} | j||||||||| S(N(RR RR#RR$tget_client_args( R&RHR?R@RARBRCRDRFRJt args_creator((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyR;?s    cCsCi}x6|jD]+}t|}|j|||||R=R{RRR}RRR;RRRSR(((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyR3s0             R8cBseZdZdZddgZdddddZddedZdZ dZ dZ d Z d Z d Zd Zd ZdZdZRS(sBridges 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.s {service}.{region}.amazonaws.comRzs s3-controlcCs:||_||_||_||_|p0|j|_dS(N(R3R(RDRFtDEFAULT_ENDPOINTtdefault_endpoint(R&R(RDRFRR3((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyR0s     cCs`|j||}|jj||}|rF|j|||||S|j||||SdS(N(t_check_default_regionR(Rt_create_endpointt_assume_endpoint(R&R1R?RAR@tresolved((s3/tmp/pip-install-usGedi/botocore/botocore/client.pytresolves   cCs9|dk r|S|jr5|jjdk r5|jjSdS(N(RtRFR?(R&R1R?((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyRs c Cs|j|||\}}|dkr|j|rU|j|||d|}q|jd|jd}|j|||jdg}n|j||}|j||} |jd|d|d|d| d |d |d |S( Nt dnsSuffixt sslCommonNamethostnamet protocolsR1R?tsigning_regiont signing_nameRAR9R( t_pick_region_valuesRtt_is_s3_dualstack_modet_create_dualstack_endpointR:t _make_urlt_resolve_signature_versiont_resolve_signing_namet_create_result( R&RR1R?RAR@RRRR((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyRs$       cCs||jkrtS|j}|dk rQ|jdk rQd|jkrQ|jdS|jdkrdtS|jjdijdt}|tddgkrtStS(Ntuse_dualstack_endpointRzRttrue(t_DUALSTACK_ENABLED_SERVICESRvRFRtRzRDR:R(R&R1RFRx((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyRs   cCs7djd|d|d|}|j||ddgS(Ns){service}.dualstack.{region}.{dns_suffix}tservicetregiont dns_suffixthttpthttps(tformatR(R&R1R?RR@R((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyRs   cCs|dkrE|jjd|d|}|j||ddg}ntjd||||j|idgd6}|j|di}|jd |d |d |d |d |d|diS(NRRRRs#Assuming an endpoint for %s, %s: %stv4RRR1R?RRRRAR9( RtRRRRiRjRRR(R&R1R?RAR@RRR((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyRs         cCs5i|d6|d6|d6|d6|d6|d6|d6S(NR1R?RRRARR9((R&R1R?RRRARR9((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyRscCs/|rd|krd}nd}d||fS(NRRs%s://%s((R&RR@tsupported_protocolstscheme((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyRs cCs<d|kr(d|dkr(|ddS|jr8|jS|S(NtcredentialScopeR(R3(R&R1R((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyRs    cCs\|}|dkrR|d}|}d|krRd|dkrR|dd}qRn||fS(Nt endpointNameRR(Rt(R&RR?RAR((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyRs  cCst||j|j}|dk r(|Sd|kr|d}|dkrNdSd|kr^dSx!|D]}|tkre|SqeWntd|jddS(NRRzts3v4RR(RRFRDRtRR R:(R&R1Rtconfigured_versiontpotential_versionstknown((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyRs        N(RRRRRRtR0RRRRRRRRRRRR(((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyR8ws$         RTcBseZiZdZdZdZedZdZdZ ddZ dZ dZ d Zd Zd Zed Zed ZdZRS(c Cs||_||_||_||_i|_||_||_t||j|j||j | |_ | |_ d|_ |jdS(N(t _serializert _endpointt_response_parsert_request_signert_cacheRt_client_configt ClientMetathostRORcR$Rtt _exceptionst_register_handlers( R&t serializerRtresponse_parserR*trequest_signerRHR'RFR|R.((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyR0<s           cCsmd|jjj|f}|jjj|d|\}}|dk rM|Std|jj |fdS(Ns getattr.%s.%sRns!'%s' object has no attribute '%s'( t_service_modelRURVRcRltemit_until_responseRttAttributeErrort __class__R(R&titemt event_nameRrtevent_response((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyt __getattr__Ms  cCs9|jjjj}|jjjd||jjdS(Nsrequest-created.%s(RcRHRURVRlRmRRr(R&RU((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyR\s cCs |jjS(N(RcRH(R&((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyRdsc Cs|jj|}|jj}tjdi|d6|d6|d6|jrbtjd||ni|jj d6|jj d6|j d6|j d 6}|j ||d |}|jjj}|jjjd jd |d |d|d|d|jd |\}} | dk r#| \} } n|j|||\} } |jjjdjd |d |d| d| d|d || jdkr| jdijd} |jj| } | | |n| SdS(NtAPI_CALLRt operationtparamssWarning: %s.%s() is deprecatedt client_regionRFthas_streaming_inputt auth_typetcontexts)before-call.{service_id}.{operation_name}RURtmodelRs(after-call.{service_id}.{operation_name}t http_responsetparsedi,tErrortCode(RRR1thistory_recordertrecordt deprecatedRiRjRcR?RgRRt_convert_to_request_dictRURVRlRRRRtt _make_requestR5t status_codeR:t exceptionst from_code(R&Rt api_paramsRR1trequest_contextt request_dictRURrRRtparsed_responset error_codet error_class((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyRhsL                    cCsty|jj||SWnVtk ro}|jjjdjd|jjj d|j d|d|nXdS(Ns.after-call-error.{service_id}.{operation_name}RURt exceptionR( Rt make_requestt ExceptionRcRlR5RRRURVtname(R&RR Rte((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyRs    cCsu|j|||}|jj||}|jjsI|jddnt|d|jj d|jj d||S(Nt host_prefixRAR)R( t_emit_api_paramsRtserialize_to_requestRtinject_host_prefixtpopRtRRRR)(R&RRRR ((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyRs    cCs|j}|jjj}|jjjdjd|d|d|d|d|}t|d|}d}|jjj|jd|d|d|d|d||S( Ns3provide-client-params.{service_id}.{operation_name}RURRRRR2s4before-parameter-build.{service_id}.{operation_name}( RRRURVRcRlR5RR (R&RRRRRURGR((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyRs       c Cs|j|s!td|n|j|}d}|jd|}td|d|jjd|jjd|dt|_ t d t |jj|f}t |t fi|d 6}|jj|}|t||||}|Sd S( sCreate 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. Rc[stj||S(N(R tpaginate(R&R((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyRst page_configtpaginator_nameR*RHtpaginator_configRs%s.Paginator.%sRN(t can_paginateRRORRRcRlRHRvRRXRRWR RRtgetattr( R&Rtactual_operation_nameRRtpaginator_class_nametdocumented_paginator_clsRt paginator((s3/tmp/pip-install-usGedi/botocore/botocore/client.pyt get_paginators.         cCsd|jkrly9|jj|jjd|jjd}||jd sD   E'/