예제 #1
0
 def _create_config(**kwargs):
     # type: (Mapping[str, Any]) -> Configuration
     config = Configuration(**kwargs)
     config.logging_policy = NetworkTraceLoggingPolicy(**kwargs)
     config.retry_policy = RetryPolicy(**kwargs)
     config.proxy_policy = ProxyPolicy(**kwargs)
     return config
예제 #2
0
 def create_config(**kwargs):
     # type: (Mapping[str, Any]) -> Configuration
     config = Configuration(**kwargs)
     config.logging_policy = NetworkTraceLoggingPolicy(**kwargs)
     config.retry_policy = RetryPolicy(retry_on_status_codes=[404, 429] +
                                       list(range(500, 600)),
                                       **kwargs)
     return config
예제 #3
0
 def create_config(**kwargs: Dict[str, Any]) -> Configuration:
     timeout = kwargs.pop("connection_timeout", 2)
     config = Configuration(connection_timeout=timeout, **kwargs)
     config.logging_policy = NetworkTraceLoggingPolicy(**kwargs)
     retries = kwargs.pop("retry_total", 5)
     config.retry_policy = AsyncRetryPolicy(
         retry_total=retries,
         retry_on_status_codes=[404, 429] + list(range(500, 600)),
         **kwargs)
     return config
예제 #4
0
 def create_config(**kwargs):
     # type: (Dict[str, str]) -> Configuration
     timeout = kwargs.pop("connection_timeout", 2)
     config = Configuration(connection_timeout=timeout, **kwargs)
     config.header_policy = HeadersPolicy(base_headers={"Metadata": "true"},
                                          **kwargs)
     config.logging_policy = NetworkTraceLoggingPolicy(**kwargs)
     retries = kwargs.pop("retry_total", 5)
     config.retry_policy = RetryPolicy(retry_total=retries,
                                       retry_on_status_codes=[404, 429] +
                                       list(range(500, 600)),
                                       **kwargs)
     return config
예제 #5
0
 def create_config(credential, scopes, **kwargs):
     # Here the SDK developer would define the default
     # config to interact with the service
     config = Configuration(**kwargs)
     config.headers_policy = HeadersPolicy({"CustomHeader": "Value"}, **kwargs)
     config.authentication_policy = BearerTokenCredentialPolicy(credential, scopes, **kwargs)
     config.user_agent_policy = UserAgentPolicy("ServiceUserAgentValue", **kwargs)
     config.retry_policy = RetryPolicy(**kwargs)
     config.redirect_policy = RedirectPolicy(**kwargs)
     config.logging_policy = NetworkTraceLoggingPolicy(**kwargs)
     config.proxy_policy = ProxyPolicy(**kwargs)
예제 #6
0
def create_configuration(**kwargs):
    # type: (**Any) -> Configuration
    config = Configuration(**kwargs)
    config.headers_policy = StorageHeadersPolicy(**kwargs)
    config.user_agent_policy = StorageUserAgentPolicy(**kwargs)
    config.retry_policy = kwargs.get('retry_policy') or ExponentialRetry(
        **kwargs)
    config.redirect_policy = RedirectPolicy(**kwargs)
    config.logging_policy = StorageLoggingPolicy(**kwargs)
    config.proxy_policy = ProxyPolicy(**kwargs)
    config.data_settings = StorageDataSettings(**kwargs)
    return config
예제 #7
0
    def create_config(**kwargs: Dict[str, Any]) -> Configuration:
        """
        Build a default configuration for the credential's HTTP pipeline.

        :rtype: :class:`azure.core.configuration`
        """
        return Configuration(**kwargs)
예제 #8
0
def create_configuration(**kwargs):
    # type: (**Any) -> Configuration
    if 'connection_timeout' not in kwargs:
        kwargs['connection_timeout'] = DEFAULT_SOCKET_TIMEOUT
    config = Configuration(**kwargs)
    config.headers_policy = StorageHeadersPolicy(**kwargs)
    config.user_agent_policy = StorageUserAgentPolicy(**kwargs)
    config.retry_policy = kwargs.get('retry_policy') or ExponentialRetry(
        **kwargs)
    config.redirect_policy = RedirectPolicy(**kwargs)
    config.logging_policy = StorageLoggingPolicy(**kwargs)
    config.proxy_policy = ProxyPolicy(**kwargs)
    config.blob_settings = StorageBlobSettings(**kwargs)
    return config
예제 #9
0
    def create_config(**kwargs):
        # type: (Mapping[str, Any]) -> Configuration
        timeout = kwargs.pop("connection_timeout", 2)
        config = Configuration(connection_timeout=timeout, **kwargs)

        # retry is the only IO policy, so its class is a kwarg to increase async code sharing
        retry_policy = kwargs.pop("retry_policy", RetryPolicy)  # type: ignore
        args = kwargs.copy(
        )  # combine kwargs and default retry settings in a Python 2-compatible way
        args.update(_ManagedIdentityBase._retry_settings)  # type: ignore
        config.retry_policy = retry_policy(**args)  # type: ignore

        # Metadata header is required by IMDS and in Cloud Shell; App Service ignores it
        config.headers_policy = HeadersPolicy(
            base_headers={"Metadata": "true"}, **kwargs)
        config.logging_policy = NetworkTraceLoggingPolicy(**kwargs)

        return config
예제 #10
0
    def test_basic_requests(self):

        conf = Configuration()
        request = HttpRequest("GET", "https://bing.com")
        policies = [UserAgentPolicy("myusergant"), RedirectPolicy()]
        with Pipeline(RequestsTransport(conf), policies=policies) as pipeline:
            response = pipeline.run(request)

        assert pipeline._transport.session is None
        assert response.http_response.status_code == 200
예제 #11
0
 def test_requests_socket_timeout(self):
     conf = Configuration()
     request = HttpRequest("GET", "https://bing.com")
     policies = [
         UserAgentPolicy("myusergant"),
         RedirectPolicy()
     ]
     # Sometimes this will raise a read timeout, sometimes a socket timeout depending on timing.
     # Either way, the error should always be wrapped as an AzureError to ensure it's caught
     # by the retry policy.
     with pytest.raises(AzureError):
         with Pipeline(RequestsTransport(), policies=policies) as pipeline:
             response = pipeline.run(request, connection_timeout=0.000001)
예제 #12
0
def example_connection_config():

    # [START connection_configuration]
    from azure.core import Configuration

    config = Configuration(connection_timeout=100,
                           connection_verify=True,
                           connection_cert=None,
                           connection_data_block_size=4096)

    # Or parameters can be tweaked later:
    config.connection.timeout = 100
    config.connection.verify = True
    config.connection.cert = None
    config.connection.data_block_size = 4096
예제 #13
0
    def test_basic_requests_separate_session(self):

        conf = Configuration()
        session = requests.Session()
        request = HttpRequest("GET", "https://bing.com")
        policies = [UserAgentPolicy("myusergant"), RedirectPolicy()]
        transport = RequestsTransport(conf,
                                      session=session,
                                      session_owner=False)
        with Pipeline(transport, policies=policies) as pipeline:
            response = pipeline.run(request)

        assert transport.session
        assert response.http_response.status_code == 200
        transport.close()
        assert transport.session
        transport.session.close()
예제 #14
0
 def _create_config(**kwargs: Mapping[str, Any]) -> Configuration:
     config = Configuration(**kwargs)
     config.logging_policy = NetworkTraceLoggingPolicy(**kwargs)
     config.retry_policy = AsyncRetryPolicy(**kwargs)
     return config
예제 #15
0
 def _create_config(**kwargs: "Any") -> Configuration:
     config = Configuration(**kwargs)
     config.logging_policy = NetworkTraceLoggingPolicy(**kwargs)
     config.retry_policy = AsyncRetryPolicy(**kwargs)
     config.proxy_policy = ProxyPolicy(**kwargs)
     return config
예제 #16
0
 def create_config(**kwargs: Dict[str, Any]) -> Configuration:
     return Configuration()
예제 #17
0
def create_configuration(**kwargs):
    # type: (**Any) -> Configuration
    config = Configuration(**kwargs)
    config.headers_policy = StorageHeadersPolicy(**kwargs)
    config.user_agent_policy = StorageUserAgentPolicy(**kwargs)
    config.retry_policy = kwargs.get("retry_policy") or ExponentialRetry(**kwargs)
    config.logging_policy = StorageLoggingPolicy(**kwargs)
    config.proxy_policy = ProxyPolicy(**kwargs)

    # Storage settings
    config.max_single_put_size = kwargs.get("max_single_put_size", 64 * 1024 * 1024)
    config.copy_polling_interval = 15

    # Block blob uploads
    config.max_block_size = kwargs.get("max_block_size", 4 * 1024 * 1024)
    config.min_large_block_upload_threshold = kwargs.get("min_large_block_upload_threshold", 4 * 1024 * 1024 + 1)
    config.use_byte_buffer = kwargs.get("use_byte_buffer", False)

    # Page blob uploads
    config.max_page_size = kwargs.get("max_page_size", 4 * 1024 * 1024)

    # Blob downloads
    config.max_single_get_size = kwargs.get("max_single_get_size", 32 * 1024 * 1024)
    config.max_chunk_get_size = kwargs.get("max_chunk_get_size", 4 * 1024 * 1024)

    # File uploads
    config.max_range_size = kwargs.get("max_range_size", 4 * 1024 * 1024)
    return config
예제 #18
0
 def create_config(**kwargs):
     # type: (Dict[str, str]) -> Configuration
     return Configuration()