Search in sources :

Example 1 with TelemetryInterceptor

use of com.microsoft.azuretools.telemetry.TelemetryInterceptor in project azure-tools-for-java by Microsoft.

the class AzureManagerBase method authApplicationInsights.

protected InsightsManager authApplicationInsights(String subscriptionId, String tenantId) {
    final AzureTokenCredentials credentials = getCredentials(tenantId);
    final InsightsManager.Configurable configurable = buildAzureManager(InsightsManager.configure()).withInterceptor(new TelemetryInterceptor());
    Optional.ofNullable(createProxyFromConfig()).ifPresent(proxy -> {
        configurable.withProxy(proxy);
        Optional.ofNullable(createProxyAuthenticatorFromConfig()).ifPresent(configurable::withProxyAuthenticator);
    });
    return configurable.authenticate(credentials, subscriptionId);
}
Also used : InsightsManager(com.microsoft.azure.management.applicationinsights.v2015_05_01.implementation.InsightsManager) TelemetryInterceptor(com.microsoft.azuretools.telemetry.TelemetryInterceptor) AzureTokenCredentials(com.microsoft.azure.credentials.AzureTokenCredentials)

Example 2 with TelemetryInterceptor

use of com.microsoft.azuretools.telemetry.TelemetryInterceptor in project azure-tools-for-java by Microsoft.

the class AzureManagerBase method authTenant.

@AzureOperation(name = "account|tenant.auth", params = { "tenantId" }, type = AzureOperation.Type.TASK)
protected Azure.Authenticated authTenant(String tenantId) {
    final AzureTokenCredentials credentials = getCredentials(tenantId);
    final Azure.Configurable configurable = Azure.configure().withInterceptor(new TelemetryInterceptor()).withUserAgent(CommonSettings.USER_AGENT);
    Optional.ofNullable(createProxyFromConfig()).ifPresent(proxy -> {
        configurable.withProxy(proxy);
        Optional.ofNullable(createProxyAuthenticatorFromConfig()).ifPresent(configurable::withProxyAuthenticator);
    });
    return configurable.authenticate(credentials);
}
Also used : Azure(com.microsoft.azure.management.Azure) TelemetryInterceptor(com.microsoft.azuretools.telemetry.TelemetryInterceptor) AzureTokenCredentials(com.microsoft.azure.credentials.AzureTokenCredentials) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Aggregations

AzureTokenCredentials (com.microsoft.azure.credentials.AzureTokenCredentials)2 TelemetryInterceptor (com.microsoft.azuretools.telemetry.TelemetryInterceptor)2 Azure (com.microsoft.azure.management.Azure)1 InsightsManager (com.microsoft.azure.management.applicationinsights.v2015_05_01.implementation.InsightsManager)1 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)1