Search in sources :

Example 1 with HttpLoggingPolicy

use of com.azure.core.http.policy.HttpLoggingPolicy in project mssql-jdbc by Microsoft.

the class KeyVaultHttpPipelineBuilder method buildPipeline.

/**
 * Builds the HTTP pipeline with all the necessary HTTP policies included in the pipeline.
 *
 * @return A fully built HTTP pipeline including the default HTTP client.
 * @throws SQLServerException If the {@link KeyVaultCustomCredentialPolicy} policy cannot be added to the pipeline.
 */
HttpPipeline buildPipeline() throws SQLServerException {
    // Closest to API goes first, closest to wire goes last.
    final List<HttpPipelinePolicy> policies = new ArrayList<>();
    HttpPolicyProviders.addBeforeRetryPolicies(policies);
    policies.add(retryPolicy);
    policies.add(new KeyVaultCustomCredentialPolicy(credential));
    policies.addAll(this.policies);
    HttpPolicyProviders.addAfterRetryPolicies(policies);
    policies.add(new HttpLoggingPolicy(httpLogOptions));
    return new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])).build();
}
Also used : HttpPipelinePolicy(com.azure.core.http.policy.HttpPipelinePolicy) HttpPipelineBuilder(com.azure.core.http.HttpPipelineBuilder) ArrayList(java.util.ArrayList) HttpLoggingPolicy(com.azure.core.http.policy.HttpLoggingPolicy)

Example 2 with HttpLoggingPolicy

use of com.azure.core.http.policy.HttpLoggingPolicy in project ApplicationInsights-Java by microsoft.

the class LazyHttpClient method newHttpPipeLine.

// pass non-null ikeyRedirectCache if you want to use ikey-specific redirect policy
public static HttpPipeline newHttpPipeLine(@Nullable Configuration.AadAuthentication aadConfiguration, @Nullable Cache<String, String> ikeyRedirectCache) {
    List<HttpPipelinePolicy> policies = new ArrayList<>();
    // Redirect policy to handle v2.1/track redirects (and other redirects too, e.g. profiler)
    policies.add(new RedirectPolicy(ikeyRedirectCache));
    if (aadConfiguration != null && aadConfiguration.enabled) {
        policies.add(getAuthenticationPolicy(aadConfiguration));
    }
    // Add Logging Policy. Can be enabled using AZURE_LOG_LEVEL.
    // TODO set the logging level based on self diagnostic log level set by user
    policies.add(new HttpLoggingPolicy(new HttpLogOptions()));
    HttpPipelineBuilder pipelineBuilder = new HttpPipelineBuilder().httpClient(INSTANCE);
    pipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0]));
    return pipelineBuilder.build();
}
Also used : HttpPipelinePolicy(com.azure.core.http.policy.HttpPipelinePolicy) HttpPipelineBuilder(com.azure.core.http.HttpPipelineBuilder) ArrayList(java.util.ArrayList) HttpLogOptions(com.azure.core.http.policy.HttpLogOptions) HttpLoggingPolicy(com.azure.core.http.policy.HttpLoggingPolicy)

Example 3 with HttpLoggingPolicy

use of com.azure.core.http.policy.HttpLoggingPolicy in project mssql-jdbc by microsoft.

the class KeyVaultHttpPipelineBuilder method buildPipeline.

/**
 * Builds the HTTP pipeline with all the necessary HTTP policies included in the pipeline.
 *
 * @return A fully built HTTP pipeline including the default HTTP client.
 * @throws SQLServerException If the {@link KeyVaultCustomCredentialPolicy} policy cannot be added to the pipeline.
 */
HttpPipeline buildPipeline() throws SQLServerException {
    // Closest to API goes first, closest to wire goes last.
    final List<HttpPipelinePolicy> policies = new ArrayList<>();
    HttpPolicyProviders.addBeforeRetryPolicies(policies);
    policies.add(retryPolicy);
    policies.add(new KeyVaultCustomCredentialPolicy(credential));
    policies.addAll(this.policies);
    HttpPolicyProviders.addAfterRetryPolicies(policies);
    policies.add(new HttpLoggingPolicy(httpLogOptions));
    return new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])).build();
}
Also used : HttpPipelinePolicy(com.azure.core.http.policy.HttpPipelinePolicy) HttpPipelineBuilder(com.azure.core.http.HttpPipelineBuilder) ArrayList(java.util.ArrayList) HttpLoggingPolicy(com.azure.core.http.policy.HttpLoggingPolicy)

Aggregations

HttpPipelineBuilder (com.azure.core.http.HttpPipelineBuilder)3 HttpLoggingPolicy (com.azure.core.http.policy.HttpLoggingPolicy)3 HttpPipelinePolicy (com.azure.core.http.policy.HttpPipelinePolicy)3 ArrayList (java.util.ArrayList)3 HttpLogOptions (com.azure.core.http.policy.HttpLogOptions)1