B 劇cQ@srddlZddlZddlZddlmZddlmZmZddl Z ddl Z ddl m Z m Z ddlmZGdddZdS) N)Config)DataNotFoundErrorUnknownServiceError)ResourceNotExistsErrorUnknownAPIVersionError)ResourceFactoryc @seZdZdZd&ddZddZeddZed d Zed d Z ed dZ ddZ ddZ ddZ ddZd'ddZddZddZd(d d!Zd)d"d#Zd$d%ZdS)*Sessiona/ A session stores configuration state and allows you to create service clients and resources. :type aws_access_key_id: string :param aws_access_key_id: AWS access key ID :type aws_secret_access_key: string :param aws_secret_access_key: AWS secret access key :type aws_session_token: string :param aws_session_token: AWS temporary session token :type region_name: string :param region_name: Default region when creating new connections :type botocore_session: botocore.session.Session :param botocore_session: Use this Botocore session instead of creating a new default one. :type profile_name: string :param profile_name: The name of a profile to use. If not given, then the default profile is used. NcCs|dk r||_n tj|_|jjdkrnd|jj}|jjrT|jjd|7_n||j_d|j_tj |j_|dk r|j d||s|s|r|j ||||dk r|j d|t |j d|_||dS)NZBotocorez Botocore/{} ZBoto3profileregion event_emitter)_sessionbotocoresessionZ get_sessionZuser_agent_nameformatZuser_agent_versionuser_agent_extraboto3 __version__Zset_config_variableZset_credentialsr get_componentresource_factory _setup_loader_register_default_handlers)selfaws_access_key_idaws_secret_access_keyaws_session_token region_nameZbotocore_session profile_nameZ botocore_inforh/private/var/folders/8c/hx9_v10d5x38qmnzt13b7b8j1k3n5b/T/pip-target-x6xd5gna/lib/python/boto3/session.py__init__1s,       zSession.__init__cCsd|jjt|jdS)Nz{}(region_name={})r )r __class____name__reprrget_config_variable)rrrr __repr__]szSession.__repr__cCs |jjp dS)z1 The **read-only** profile name. default)rr )rrrr rcszSession.profile_namecCs |jdS)z0 The **read-only** region name. r )rr%)rrrr rjszSession.region_namecCs |jdS)z1 The event emitter for a session r )rr)rrrr eventsqszSession.eventscCs|jjS)zC The profiles available to the session credentials )ravailable_profiles)rrrr r)xszSession.available_profilescCs2|jd|_|jjtjtjt ddS)zC Setup loader paths so that we can load resources. Z data_loaderdataN) rr_loaderZ search_pathsappendospathjoindirname__file__)rrrr rszSession._setup_loadercCs |jS)z Get a list of available services that can be loaded as low-level clients via :py:meth:`Session.client`. :rtype: list :return: List of service names )rget_available_services)rrrr r2szSession.get_available_servicescCs|jjddS)z Get a list of available services that can be loaded as resource clients via :py:meth:`Session.resource`. :rtype: list :return: List of service names z resources-1)Z type_name)r+Zlist_available_services)rrrr get_available_resourcesszSession.get_available_resourcescCs |jS)zLists the available partitions :rtype: list :return: Returns a list of partition names (e.g., ["aws", "aws-cn"]) )rget_available_partitions)rrrr r4sz Session.get_available_partitionsawsFcCs|jj|||dS)aLists the region and endpoint names of a particular partition. The list of regions returned by this method are regions that are explicitly known by the client to exist and is not comprehensive. A region not returned in this list may still be available for the provided service. :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"]). ) service_namepartition_nameallow_non_regional)rget_available_regions)rr6r7r8rrr r9szSession.get_available_regionscCs |jS)a% Return the :class:`botocore.credentials.Credentials` object associated with this session. If the credentials have not yet been loaded, this will attempt to load them. If they have already been loaded, this will return the cached credentials. )rget_credentials)rrrr r:szSession.get_credentialscCs |j|S)aLists the partition name of a particular region. :type region_name: string :param region_name: Name of the region to list partition for (e.g., us-east-1). :rtype: string :return: Returns the respective partition name (e.g., aws). )rget_partition_for_region)rrrrr r;s z Session.get_partition_for_regionTc Cs |jj||||||||| | d S)a Create a low-level service client by name. :type service_name: string :param service_name: The name of a service, e.g. 's3' or 'ec2'. You can get a list of available services via :py:meth:`get_available_services`. :type region_name: string :param region_name: The name of the region associated with the client. A client is associated with a single region. :type api_version: string :param api_version: The API version to use. By default, botocore will use the latest API version when creating a client. You only need to specify this parameter if you want to use a previous API version of the client. :type use_ssl: boolean :param use_ssl: Whether or not to use SSL. By default, SSL is used. Note that not all services support non-ssl connections. :type verify: boolean/string :param verify: Whether or not to verify SSL certificates. By default SSL certificates are verified. You can provide the following values: * False - do not validate SSL certificates. SSL will still be used (unless use_ssl is False), but SSL certificates will not be verified. * path/to/cert/bundle.pem - A filename of the CA cert bundle to uses. You can specify this argument if you want to use a different CA cert bundle than the one used by botocore. :type endpoint_url: string :param endpoint_url: The complete URL to use for the constructed client. Normally, botocore will automatically construct the appropriate URL to use when communicating with a service. You can specify a complete URL (including the "http/https" scheme) to override this behavior. If this value is provided, then ``use_ssl`` is ignored. :type aws_access_key_id: string :param aws_access_key_id: The access key to use when creating the client. This is entirely optional, and if not provided, the credentials configured for the session will automatically be used. You only need to provide this argument if you want to override the credentials used for this specific client. :type aws_secret_access_key: string :param aws_secret_access_key: The secret key to use when creating the client. Same semantics as aws_access_key_id above. :type aws_session_token: string :param aws_session_token: The session token to use when creating the client. Same semantics as aws_access_key_id above. :type config: botocore.client.Config :param config: Advanced client configuration options. If region_name is specified in the client config, its value will take precedence over environment variables and configuration values, but not over a region_name value passed explicitly to the method. See `botocore config documentation `_ for more details. :return: Service client instance ) r api_versionuse_sslverify endpoint_urlrrrconfig)rZ create_client) rr6rr<r=r>r?rrrr@rrr clientsRzSession.clientc  Cs,y|j|d|} Wnftk rH|} ||k} t|| | Yn4tk rz|j|d}t||d |YnX|dkr|j |d}| dk r| j dkrt | } d| _ n tdd} |j||||||||| | d }|jj}tjj||| dtj|j||d}|jj|| d |d }||d S) a Create a resource service client by name. :type service_name: string :param service_name: The name of a service, e.g. 's3' or 'ec2'. You can get a list of available services via :py:meth:`get_available_resources`. :type region_name: string :param region_name: The name of the region associated with the client. A client is associated with a single region. :type api_version: string :param api_version: The API version to use. By default, botocore will use the latest API version when creating a client. You only need to specify this parameter if you want to use a previous API version of the client. :type use_ssl: boolean :param use_ssl: Whether or not to use SSL. By default, SSL is used. Note that not all services support non-ssl connections. :type verify: boolean/string :param verify: Whether or not to verify SSL certificates. By default SSL certificates are verified. You can provide the following values: * False - do not validate SSL certificates. SSL will still be used (unless use_ssl is False), but SSL certificates will not be verified. * path/to/cert/bundle.pem - A filename of the CA cert bundle to uses. You can specify this argument if you want to use a different CA cert bundle than the one used by botocore. :type endpoint_url: string :param endpoint_url: The complete URL to use for the constructed client. Normally, botocore will automatically construct the appropriate URL to use when communicating with a service. You can specify a complete URL (including the "http/https" scheme) to override this behavior. If this value is provided, then ``use_ssl`` is ignored. :type aws_access_key_id: string :param aws_access_key_id: The access key to use when creating the client. This is entirely optional, and if not provided, the credentials configured for the session will automatically be used. You only need to provide this argument if you want to override the credentials used for this specific client. :type aws_secret_access_key: string :param aws_secret_access_key: The secret key to use when creating the client. Same semantics as aws_access_key_id above. :type aws_session_token: string :param aws_session_token: The session token to use when creating the client. Same semantics as aws_access_key_id above. :type config: botocore.client.Config :param config: Advanced client configuration options. If region_name is specified in the client config, its value will take precedence over environment variables and configuration values, but not over a region_name value passed explicitly to the method. If user_agent_extra is specified in the client config, it overrides the default user_agent_extra provided by the resource API. See `botocore config documentation `_ for more details. :return: Subclass of :py:class:`~boto3.resources.base.ServiceResource` z resources-1z, NResource)r) rr<r=r>r?rrrr@ resources)r6 service_modelZresource_json_definitionsZservice_waiter_modelservice) resource_nameZsingle_resource_json_definitionservice_context)rA)r+Zload_service_modelrr3r2rrZlist_api_versionsrr/Zdetermine_latest_versionrcopydeepcopyrrAmetarDrutilsZServiceContextZLazyLoadedWaiterModelrrZload_from_definition)rr6rr<r=r>r?rrrr@Zresource_model availableZhas_low_level_clientZavailable_api_versionsrArDrGclsrrr resource8sXS    zSession.resourcecCs|jdtjd|jdtjd|jdtjd|jdtjd|jjd tjd d d |jjd tjddd |jdtjd|jdtjjd|jddS)Nzcreating-client-class.s3z*boto3.s3.inject.inject_s3_transfer_methodsz!creating-resource-class.s3.Bucketz%boto3.s3.inject.inject_bucket_methodsz!creating-resource-class.s3.Objectz%boto3.s3.inject.inject_object_methodsz(creating-resource-class.s3.ObjectSummaryz-boto3.s3.inject.inject_object_summary_methodsz creating-resource-class.dynamodbz6boto3.dynamodb.transform.register_high_level_interfacezhigh-level-dynamodb) unique_idz&creating-resource-class.dynamodb.Tablez+boto3.dynamodb.table.register_table_methodszhigh-level-dynamodb-tablez+creating-resource-class.ec2.ServiceResourcez'boto3.ec2.createtags.inject_create_tagsz$creating-resource-class.ec2.Instancez'boto3.ec2.deletetags.inject_delete_tags)r )rregisterrrKZ lazy_callr()rrrr rs@z"Session._register_default_handlers)NNNNNN)r5F) NNTNNNNNN) NNTNNNNNN)r# __module__ __qualname____doc__r!r&propertyrrr(r)rr2r3r4r9r:r;rArNrrrrr r sN %          W r )rHr-Zbotocore.sessionrZbotocore.clientrZbotocore.exceptionsrrrZ boto3.utilsZboto3.exceptionsrrZresources.factoryrr rrrr s