a 97a@sddlZddlZddlmZmZddlmZddlmZddl m Z ddl m Z ddl m Z ddlmZmZmZmZmZmZdd lmZdd lmZdd lmZdd lmZmZmZmZm Z m!Z!m"Z"m#Z#ddlmZdd lm$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*m+Z+m,Z,ddl-m.Z.ddl-m/Z/e0e1Z2e(Z3Gddde4Z5Gddde4Z6Gddde4Z7Gddde4Z8ddZ9dS)N)waiter xform_name)ClientArgsCreator)AUTH_TYPE_MAPS)prepare_request_dict)ClientMethodDocstring)PaginatorDocstring) ClientErrorDataNotFoundErrorOperationNotPageableErrorUnknownSignatureVersionError*InvalidEndpointDiscoveryConfigurationErrorUnknownFIPSEndpointError)first_non_none_response) ServiceModel) Paginator)CachedPropertyget_service_module_nameS3RegionRedirectorS3ArnParamHandlerS3EndpointSetterensure_booleanS3ControlArnParamHandlerS3ControlEndpointSetter)UNSIGNED)Config)get_global_history_recorder)EndpointDiscoveryHandlerEndpointDiscoveryManager,block_endpoint_discovery_required_operations)standard)adaptivec@seZdZdZd2ddZd3ddZd4dd Zd d Zd5d d ZddZ ddZ ddZ ddZ ddZ ddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1ZdS)6 ClientCreatorz%Creates client objects for a service.Nc Cs:||_||_||_||_||_||_||_||_| |_dSN) _loader_endpoint_resolver _user_agent_event_emitter_retry_handler_factory_retry_config_translator_response_parser_factory_exceptions_factory _config_store) selfloaderendpoint_resolver user_agent event_emitterZretry_handler_factoryZretry_config_translatorZresponse_parser_factoryexceptions_factory config_storer4j/private/var/folders/s6/9n5zrl012gv99k63s4q6ccsd4s6mqz/T/pip-target-f5cq3f2q/lib/python/botocore/client.py__init__7szClientCreator.__init__Tc  Cs|jjd|d} t| |d}|||} ||| } t|j|| | jdd} | | ||||||| | }| fi|}| || || || || || || || ||| |||S)Nzchoose-service-name service_namedefaultZ signingNameservice_signing_name)r'emitr_load_service_model_create_client_classClientEndpointBridger%metadataget_get_client_args_register_retries_register_s3_events_register_s3_control_events_register_endpoint_discovery0_register_lazy_block_unknown_fips_pseudo_regions)r-r8 region_name is_secure endpoint_urlverify credentials scoped_config api_version client_config responses service_modelclsendpoint_bridgeZ client_argsZservice_clientr4r4r5 create_clientIs:       zClientCreator.create_clientcCs|||}|||Sr#)r>r?)r-r8rOrRr4r4r5create_client_classgs z!ClientCreator.create_client_classc Csb||}||}||d<tg}|j}|jjd|||dt|}tt |t ||}|S)N_PY_TO_OP_NAMEzcreating-client-class.%s)class_attributesZ base_classes) _create_methods_create_name_mapping BaseClient service_id hyphenizer'r=rtypestrtuple) r-r8rRrXZpy_name_to_operation_namebasesr\ class_namerSr4r4r5r?ks   z"ClientCreator._create_client_classcCs"|jj|d|d}t||d}|S)Nz service-2)rOr7)r$load_service_modelr)r-r8rOZ json_modelrRr4r4r5r>ys   z!ClientCreator._load_service_modelcCsV|jjjd}|dkr"||n0|dkr@||||n|dkrR||dS)Nmoder r!legacy)metaconfigretries_register_v2_standard_retries_register_v2_adaptive_retries_register_legacy_retries)r-client retry_moder4r4r5rDs   zClientCreator._register_retriescCs<|jjjd}d|i}|dur(||d<tjfi|dS)Ntotal_max_attemptsrl max_attempts)rfrgrhrBr register_retry_handler)r-rlrokwargsr4r4r5ris z+ClientCreator._register_v2_standard_retriescCst|dSr#)r!rp)r-rlr4r4r5rjsz+ClientCreator._register_v2_adaptive_retriesc Cs|jjj}|jjj}|}|jd}|s0dS||jjj }|j || di| di|}t d|jjj|j||}d|} |jjjd||| ddS)NZ_retryretryZ definitionsz*Registering retry handlers for service: %szretry-config-%szneeds-retry.%s) unique_id)rfrRendpoint_prefixr\r]r$Z load_data_transform_legacy_retriesrgrhr)Zbuild_retry_configrBloggerdebugr8r(Zcreate_retry_handlereventsregister) r-rlrtr\Zservice_event_nameZoriginal_configrhZ retry_confighandlerrsr4r4r5rks.     z&ClientCreator._register_legacy_retriescCs:|dur dS|}d|vr6|}|dd|d<|S)Nrnro)copypop)r-rhZ copied_argsr4r4r5rus z'ClientCreator._transform_legacy_retriescCs6|jjj}|dur(|ddur(|dS|dp4dS)Nrdrmre)rfrgrhrBget_config_variable)r-rlr3Zclient_retriesr4r4r5_get_retry_modes   zClientCreator._get_retry_modec Cs|dur dS|jjjdurdS|jj}|jjj}d}|rN|jdurN|j}n|jr`|jd}| |}|r| ||r|du}t ||d}t |} | ||n | dtdS)NFendpoint_discovery_enabledT)Zalways_discoverzbefore-parameter-build)rfrRZendpoint_discovery_operationrxr\r]rr,r~$_normalize_endpoint_discovery_config_requires_endpoint_discoveryrrryr) r-rlrKrgrxr\enabledZdiscovermanagerrzr4r4r5rGs,  z*ClientCreator._register_endpoint_discoverycCsPt|tr4|}|dkr"|S|dvrBt|Snt|trB|St|ddS)z?Config must either be a boolean-string or string-literal 'auto'auto)truefalse)Z config_valueN) isinstancer_lowerstriprboolr )r-rr4r4r5rs    z2ClientCreator._normalize_endpoint_discovery_configcCs|dkr|jjjS|S)Nr)rfrRZendpoint_discovery_required)r-rlrr4r4r5rs z*ClientCreator._requires_endpoint_discoverycsjjjrdvrdSjj}jjj}|jj||dd}|vrffdd}jj d|dS)NZfipsT)Zallow_non_regionalcsjjj}t|ddS)N)rIr8)rfrRr8r)rqr8rlrIr4r5_lazy_fips_exceptions  z\ClientCreator._register_lazy_block_unknown_fips_pseudo_regions.._lazy_fips_exceptionz before-sign) rfrIr partitionrRrtr%get_available_endpointsrxry)r-rlrrtZ known_regionsrr4rr5rHs z>ClientCreator._register_lazy_block_unknown_fips_pseudo_regionscCsp|jjjdkrdSt||t|jjt|j|jj |jj j ||jj d|jj| |j||dS)Ns3r/regionZ s3_configrKr)rfrRr8rryrrxrr%rIrgrr!_set_s3_presign_signature_versionr-rlrTrKrPrNr4r4r5rEs z!ClientCreator._register_s3_eventscCsR|jjjdkrdSt|jjt|j|jj|jj j ||jj d|jjdS)NZ s3controlr) rfrRr8rryrxrr%rIrgrrrr4r4r5rFsz)ClientCreator._register_s3_control_eventscCsxtd||}|durdS|jd|j}|jdkr@|j|vr@dS|jd|j}|d}d|vrddS|jd|jdS)Nr aws-globalsignatureVersionszchoose-signer.s3) !_get_configured_signature_versionr%rrrIconstruct_endpointrxry_default_s3_presign_to_sigv2)r-Z client_metarPrNZprovided_signature_versionZregionsendpointZsignature_versionsr4r4r5r&s* z/ClientCreator._set_s3_presign_signature_versioncKs$dD]}||rd|SqdS)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. :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-queryz -presign-postrN)endswith)r-signature_versionrqsuffixr4r4r5rJs z*ClientCreator._default_s3_presign_to_sigv2c Cs:t|j|j|j|j|j|jd} | ||||||||| S)N)r3)rr'r&r*r$r+r,Zget_client_args) r-rRrIrJrKrLrMrNrPrTZ args_creatorr4r4r5rC\s zClientCreator._get_client_argscCs.i}|jD]}t|}||||||<q |Sr#)operation_namesr_create_api_method)r-rRZop_dictoperation_namepy_operation_namer4r4r5rYgs  zClientCreator._create_methodscCs$i}|jD]}t|}|||<q |Sr#)rr)r-rRmappingrrr4r4r5rZos   z"ClientCreator._create_name_mappingcsHfdd}t|_|}t||j|jddd}||_|S)Ncs|rtd||S)Nz$%s() only accepts keyword arguments.) TypeError_make_api_call)r-argsrqrrr4r5 _api_callzs z3ClientCreator._create_api_method.._api_callzresponse = client.%sF)operation_model method_namer1Zmethod_descriptionZexample_prefixinclude_signature)r___name__rrr'Z documentation__doc__)r-rrrRrr docstringr4rr5rxs  z ClientCreator._create_api_method)NNN)TNNNNNN)N)N)r __module__ __qualname__rr6rUrVr?r>rDrirjrkrurrGrrrHrErFrrrCrYrZrr4r4r4r5r"5s>       $  r"c@seZdZdZdZddgZdddZd d d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdS)!r@aBridges 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.comrz s3-controlNcCs(||_||_||_||_|p |j|_dSr#)r<r/rNrPDEFAULT_ENDPOINTdefault_endpoint)r-r/rNrPrr<r4r4r5r6s zClientEndpointBridge.__init__TcCsZ|||}|j||}|s0|jj||dd}|rF||||||S|||||SdS)NZaws)Zpartition_name)_check_default_regionr/r_create_endpoint_assume_endpoint)r-r8rIrKrJresolvedr4r4r5resolves  zClientEndpointBridge.resolvecCs*|dur |S|jr&|jjdur&|jjSdSr#)rPrI)r-r8rIr4r4r5rsz*ClientEndpointBridge._check_default_regionc Cs|du}||||\}}|durl||rD||||d||}n(|d|d}||||dg}|||} |||} |j|||| ||| dS)NZ dnsSuffixZ sslCommonNamehostnameZ protocols)r8rIsigning_region signing_namerKrAr)_pick_region_values_is_s3_dualstack_mode_create_dualstack_endpointrB _make_url_resolve_signature_version_resolve_signing_name_create_result) r-rr8rIrKrJexplicit_regionrrrrr4r4r5rs0    z%ClientEndpointBridge._create_endpointcCsn||jvrdS|j}|dur:|jdur:d|jvr:|jdS|jdurHdS|jdidd}|dvrjdSdS)NFZuse_dualstack_endpointr)TTruerT)_DUALSTACK_ENABLED_SERVICESrPrrNrB)r-r8rPrr4r4r5rs   z*ClientEndpointBridge._is_s3_dualstack_modecCs2|s|dkrd}dj|||d}|||ddgS)Nrz us-east-1z){service}.dualstack.{region}.{dns_suffix})servicer dns_suffixhttphttps)formatr)r-r8rIrrJrrr4r4r5rs z/ClientEndpointBridge._create_dualstack_endpointc Csr|dur*|jj||d}|||ddg}td|||||ddgi}|j|id}|j||||||idS) N)rrrrz#Assuming an endpoint for %s, %s: %srv4)r)r8rIrrrrKrA)rrrrvrwrrr)r-r8rIrKrJrrrr4r4r5rs( z%ClientEndpointBridge._assume_endpointcCs|||||||dS)N)r8rIrrrKrrAr4)r-r8rIrrrKrrAr4r4r5rsz#ClientEndpointBridge._create_resultcCs"|rd|vrd}nd}d||fS)Nrrz%s://%sr4)r-rrJZsupported_protocolsschemer4r4r5r"s zClientEndpointBridge._make_urlcCs0d|vr d|dvr |ddS|jr,|jS|S)NcredentialScoperr;)r-r8rr4r4r5r)s  z*ClientEndpointBridge._resolve_signing_namecCs@|}|dur8|d}|}d|vr8d|dvr8|dd}||fS)NZ endpointNamerrr4)r-rrIrKrr4r4r5r4s   z(ClientEndpointBridge._pick_region_valuescCsrt||j|j}|dur|Sd|vr^|d}|dkr8dSd|vrDdS|D]}|tvrH|SqHt|dddS)NrrZs3v4r)r)rrPrNrr rB)r-r8rZconfigured_versionZpotential_versionsZknownr4r4r5rHs"  z/ClientEndpointBridge._resolve_signature_version)NNNN)NNT)rrrrrrr6rrrrrrrrrrrr4r4r4r5r@s(     r@c@seZdZiZddZddZddZeddZd d Z d d Z d ddZ ddZ ddZ ddZddZddZeddZeddZddZd S)!r[c Cs\||_||_||_||_i|_||_||_t||j|j||j | |_ | |_ d|_ | dSr#) _serializer _endpointZ_response_parser_request_signer_cacher$_client_config ClientMetahostrWrfr+ _exceptions_register_handlers) r- serializerrZresponse_parserr1request_signerrRr.rPrr2r4r4r5r6hszBaseClient.__init__cCsNd|jj|f}|jjj||d\}}|dur6|Std|jj|fdS)Nz getattr.%s.%s)rlz!'%s' object has no attribute '%s') _service_modelr\r]rfrxemit_until_responseAttributeError __class__r)r-item event_namerzevent_responser4r4r5 __getattr__ys  zBaseClient.__getattr__cCs*|jjj}|jjd||jjdS)Nzrequest-created.%s)rfrRr\r]rxryrrz)r-r\r4r4r5rs zBaseClient._register_handlerscCs|jjSr#)rfrRr-r4r4r5rszBaseClient._service_modelcCs|j|}|jj}td|||d|jr.paginate page_configF)Zpaginator_namer1rRpaginator_configrz%s.Paginator.%srN) can_paginater rWrrrfrxrRrr_rr^rrrgetattr) r-ractual_operation_namerrZpaginator_class_nameZdocumented_paginator_clsrZ paginatorr4r4r5 get_paginators8       zBaseClient.get_paginatorcCsjd|jvrRz*|j|jjd|jjd}||jd<WntyPi|jd<Yn0|j|}||jdvS)aMCheck 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. rz paginators-1Z pagination)rr$rcrr8rOr rW)r-rrrr4r4r5r0s   zBaseClient.can_paginatecCsXd|jvrNz&|j|jjd|jj}||jd<WntyLi|jd<Yn0|jdS)N waiter_configz waiters-2)rr$rcrr8rOr )r-rr4r4r5_get_waiter_configKs  zBaseClient._get_waiter_configcCsd|}|std|t|}i}|jD]}||t|<q,||vrRtd|t||||S)aGReturns 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 zWaiter does not exist: %s)r ValueErrorr WaiterModel waiter_namesrZcreate_waiter_with_client)r-Z waiter_namergrrrr4r4r5 get_waiterWs      zBaseClient.get_waitercCs*|}|sgSt|}dd|jDS)z(Returns a list of all available waiters.cSsg|] }t|qSr4)r).0rr4r4r5 wz+BaseClient.waiter_names..)rrrr)r-rgrr4r4r5rns  zBaseClient.waiter_namescCs|jdur||_|jSr#)r_load_exceptionsrr4r4r5rys  zBaseClient.exceptionscCs|j|jSr#)r+Zcreate_client_exceptionsrrr4r4r5r szBaseClient._load_exceptions)N)rrrrWr6rrpropertyrrrrrrrrrrrrr r4r4r4r5r[^s( 1 9   r[c@s`eZdZdZddZeddZeddZedd Zed d Z ed d Z eddZ dS)ra~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. cCs(||_||_||_||_||_||_dSr#)rxr _endpoint_urlr_method_to_api_mapping _partition)r-rxrPrKrRmethod_to_api_mappingrr4r4r5r6s zClientMeta.__init__cCs|jSr#)rrr4r4r5rRszClientMeta.service_modelcCs|jjSr#)rrIrr4r4r5rIszClientMeta.region_namecCs|jSr#)r rr4r4r5rKszClientMeta.endpoint_urlcCs|jSr#)rrr4r4r5rgszClientMeta.configcCs|jSr#)r rr4r4r5rsz ClientMeta.method_to_api_mappingcCs|jSr#)r rr4r4r5rszClientMeta.partitionN) rrrrr6r rRrIrKrgrrr4r4r4r5rs       rcCs\|r|jdur|jS|durX||}|durXt|trX|d}|rXtd|||SdS)z Gets the manually configured signature version. :returns: the customer configured signature version, or None if no signature version was configured. NrzWSwitching signature version for service %s to version %s based on config file override.)rrBrdictrvrw)r8rPrNZservice_configversionr4r4r5rs   r):logging functoolsZbotocorerrZ botocore.argsrZ botocore.authrZbotocore.awsrequestrZbotocore.docs.docstringrrZbotocore.exceptionsr r r r r rZbotocore.hooksrZbotocore.modelrZbotocore.paginaterZbotocore.utilsrrrrrrrrrZbotocore.configrZbotocore.historyrZbotocore.discoveryrrrZbotocore.retriesr r! getLoggerrrvrobjectr"r@r[rrr4r4r4r5 s>         (       aK(/