Search in sources :

Example 1 with IAccount

use of com.microsoft.azure.toolkit.lib.account.IAccount in project azure-maven-plugins by microsoft.

the class IAzureBaseResource method portalUrl.

default String portalUrl() {
    final IAccount account = Azure.az(IAzureAccount.class).account();
    Subscription subscription = account.getSubscription(this.subscriptionId());
    return account.portalUrl() + REST_SEGMENT_JOB_MANAGEMENT_TENANTID + subscription.getTenantId() + REST_SEGMENT_JOB_MANAGEMENT_RESOURCE + this.id();
}
Also used : IAccount(com.microsoft.azure.toolkit.lib.account.IAccount) IAzureAccount(com.microsoft.azure.toolkit.lib.account.IAzureAccount) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription)

Example 2 with IAccount

use of com.microsoft.azure.toolkit.lib.account.IAccount in project azure-maven-plugins by microsoft.

the class AzureService method getResourceManager.

@Cacheable(cacheName = "resource/{}/manager", key = "$subscriptionId")
default ResourceManager getResourceManager(String subscriptionId) {
    // make sure it is signed in.
    final IAccount account = az(IAzureAccount.class).account();
    final AzureConfiguration config = Azure.az().config();
    final String userAgent = config.getUserAgent();
    final HttpLogDetailLevel logDetailLevel = config.getLogLevel() == null ? HttpLogDetailLevel.NONE : HttpLogDetailLevel.valueOf(config.getLogLevel());
    final AzureProfile azureProfile = new AzureProfile(account.getEnvironment());
    final Providers providers = ResourceManager.configure().withHttpClient(getDefaultHttpClient()).withPolicy(getUserAgentPolicy(userAgent)).authenticate(account.getTokenCredential(subscriptionId), azureProfile).withSubscription(subscriptionId).providers();
    return ResourceManager.configure().withHttpClient(getDefaultHttpClient()).withLogLevel(logDetailLevel).withPolicy(// set user agent with policy
    getUserAgentPolicy(userAgent)).withPolicy(// add policy to auto register resource providers
    new ProviderRegistrationPolicy(providers)).authenticate(account.getTokenCredential(subscriptionId), azureProfile).withSubscription(subscriptionId);
}
Also used : IAccount(com.microsoft.azure.toolkit.lib.account.IAccount) IAzureAccount(com.microsoft.azure.toolkit.lib.account.IAzureAccount) HttpLogDetailLevel(com.azure.core.http.policy.HttpLogDetailLevel) ProviderRegistrationPolicy(com.azure.resourcemanager.resources.fluentcore.policy.ProviderRegistrationPolicy) AzureProfile(com.azure.core.management.profile.AzureProfile) Providers(com.azure.resourcemanager.resources.models.Providers) Cacheable(com.microsoft.azure.toolkit.lib.common.cache.Cacheable)

Aggregations

IAccount (com.microsoft.azure.toolkit.lib.account.IAccount)2 IAzureAccount (com.microsoft.azure.toolkit.lib.account.IAzureAccount)2 HttpLogDetailLevel (com.azure.core.http.policy.HttpLogDetailLevel)1 AzureProfile (com.azure.core.management.profile.AzureProfile)1 ProviderRegistrationPolicy (com.azure.resourcemanager.resources.fluentcore.policy.ProviderRegistrationPolicy)1 Providers (com.azure.resourcemanager.resources.models.Providers)1 Cacheable (com.microsoft.azure.toolkit.lib.common.cache.Cacheable)1 Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)1