private void initializeFunctionService() { if (functionService == null) { HttpUrl defaultHostName = HttpUrl.parse(defaultHostName()); if (defaultHostName == null) { defaultHostName = new HttpUrl.Builder().host(defaultHostName()).scheme("http").build(); } functionService = manager().restClient().newBuilder() .withBaseUrl(defaultHostName.toString()) .withCredentials(new FunctionCredentials(this)) .withLogLevel(LogLevel.BODY_AND_HEADERS) .build() .retrofit().create(FunctionService.class); } }
VaultImpl(String key, VaultInner innerObject, KeyVaultManager manager, GraphRbacManager graphRbacManager) { super(key, innerObject, manager); this.graphRbacManager = graphRbacManager; this.accessPolicies = new ArrayList<>(); if (innerObject != null && innerObject.properties() != null && innerObject.properties().accessPolicies() != null) { for (AccessPolicyEntry entry : innerObject.properties().accessPolicies()) { this.accessPolicies.add(new AccessPolicyImpl(entry, this)); } } this.client = new KeyVaultClient( manager.inner().restClient().newBuilder().withBaseUrl("https://{vaultBaseUrl}").build()); }
VaultImpl(String key, VaultInner innerObject, KeyVaultManager manager, GraphRbacManager graphRbacManager) { super(key, innerObject, manager); this.graphRbacManager = graphRbacManager; this.accessPolicies = new ArrayList<>(); if (innerObject != null && innerObject.properties() != null && innerObject.properties().accessPolicies() != null) { for (AccessPolicyEntry entry : innerObject.properties().accessPolicies()) { this.accessPolicies.add(new AccessPolicyImpl(entry, this)); } } this.client = new KeyVaultClient( manager.inner().restClient().newBuilder().withBaseUrl("https://{vaultBaseUrl}").build()); }
/** * Creates an instance of MonitorManager that exposes Monitor API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription UUID * @return the MonitorManager */ public static MonitorManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new MonitorManager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withInterceptor(new ProviderRegistrationInterceptor(credentials)) .build(), subscriptionId); } /**
/** * Creates an instance of ServiceBusManager that exposes servicebus management API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription UUID * @return the ServiceBusManager */ public static ServiceBusManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new ServiceBusManager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withInterceptor(new ProviderRegistrationInterceptor(credentials)) .withInterceptor(new ResourceManagerThrottlingInterceptor()) .build(), subscriptionId); }
/** * Creates an instance of ContainerRegistryManager that exposes Registry resource management API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription * @return the SearchServiceManager */ public static SearchServiceManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new SearchServiceManager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withInterceptor(new ProviderRegistrationInterceptor(credentials)) .withInterceptor(new ResourceManagerThrottlingInterceptor()) .build(), subscriptionId); }
/** * Creates an instance of DnsZoneManager that exposes DNS zone management API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription UUID * @return the DnsZoneManager */ public static DnsZoneManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new DnsZoneManager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withInterceptor(new ProviderRegistrationInterceptor(credentials)) .withInterceptor(new ResourceManagerThrottlingInterceptor()) .build(), subscriptionId); }
/** * Creates an instance of ComputeManager that exposes Compute resource management API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription * @return the ComputeManager */ public static ComputeManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new ComputeManager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withInterceptor(new ProviderRegistrationInterceptor(credentials)) .withInterceptor(new ResourceManagerThrottlingInterceptor()) .build(), subscriptionId); }
/** * Creates an instance of NetworkManager that exposes network resource management API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription UUID * @return the NetworkManager */ public static NetworkManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new NetworkManager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withInterceptor(new ProviderRegistrationInterceptor(credentials)) .withInterceptor(new ResourceManagerThrottlingInterceptor()) .build(), subscriptionId); }
/** * Creates an instance of LocksManager that exposes Authorization resource management API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription UUID * @return the LocksManager */ public static LocksManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new LocksManager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .build(), subscriptionId); } /**
/** * Creates an instance of AuthorizationManager that exposes Authorization resource management API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription UUID * @return the AuthorizationManager */ public static AuthorizationManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new AuthorizationManager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .build(), subscriptionId); } /**
/** * Creates an instance of AppServiceManager that exposes Web resource management API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription UUID * @return the AppServiceManager */ public static AppServiceManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new AppServiceManager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .build(), subscriptionId); } /**
@Bean @ConditionalOnMissingBean public Azure azure(AzureProperties azureProperties) throws IOException { CredentialsProvider credentialsProvider = new DefaultCredentialsProvider(azureProperties); ApplicationTokenCredentials credentials = credentialsProvider.getCredentials(); TelemetryCollector.getInstance().setSubscription(credentials.defaultSubscriptionId()); RestClient restClient = new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials).withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withInterceptor(new ProviderRegistrationInterceptor(credentials)) .withInterceptor(new ResourceManagerThrottlingInterceptor()).withUserAgent(SPRING_CLOUD_USER_AGENT) .build(); return Azure.authenticate(restClient, credentials.domain()).withDefaultSubscription(); }
@Bean @ConditionalOnMissingBean public Azure azure(AzureProperties azureProperties) throws IOException { CredentialsProvider credentialsProvider = new DefaultCredentialsProvider(azureProperties); ApplicationTokenCredentials credentials = credentialsProvider.getCredentials(); TelemetryCollector.getInstance().setSubscription(credentials.defaultSubscriptionId()); RestClient restClient = new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials).withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withInterceptor(new ProviderRegistrationInterceptor(credentials)) .withInterceptor(new ResourceManagerThrottlingInterceptor()).withUserAgent(SPRING_CLOUD_USER_AGENT) .build(); return Azure.authenticate(restClient, credentials.domain()).withDefaultSubscription(); }
/** * Creates an instance of ResourcesManager that exposes Resources resource management API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription UUID * @return the ResourcesManager */ public static ResourcesManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new ResourcesManager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .build(), subscriptionId); } /**
/** * Initializes a new instance of the ServiceClient class. * * @param baseUrl the service base uri * @param clientBuilder the http client builder * @param restBuilder the retrofit rest client builder */ protected ServiceClient(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder restBuilder) { this(new RestClient.Builder(clientBuilder, restBuilder) .withBaseUrl(baseUrl) .withResponseBuilderFactory(new ServiceResponseBuilder.Factory()) .withSerializerAdapter(new JacksonAdapter()) .build()); }
private GraphRbacManager(RestClient restClient, String tenantId) { String graphEndpoint = AzureEnvironment.AZURE.graphEndpoint(); if (restClient.credentials() instanceof AzureTokenCredentials) { graphEndpoint = ((AzureTokenCredentials) restClient.credentials()).environment().graphEndpoint(); } this.graphRbacManagementClient = new GraphRbacManagementClientImpl( restClient.newBuilder().withBaseUrl(graphEndpoint).build()).withTenantID(tenantId); this.authorizationManagementClient = new AuthorizationManagementClientImpl(restClient); this.tenantId = tenantId; }
protected RestClient buildRestClient(AzureTokenCredentials credentials, AzureEnvironment.Endpoint endpoint) { RestClient client = restClientBuilder .withBaseUrl(credentials.environment(), endpoint) .withCredentials(credentials) .withInterceptor(new ProviderRegistrationInterceptor(credentials)) .withInterceptor(new ResourceManagerThrottlingInterceptor()) .build(); if (client.httpClient().proxy() != null) { credentials.withProxy(client.httpClient().proxy()); } return client; }
protected RestClient buildRestClient(AzureTokenCredentials credentials, AzureEnvironment.Endpoint endpoint) { RestClient client = restClientBuilder .withBaseUrl(credentials.environment(), endpoint) .withCredentials(credentials) .withInterceptor(new ResourceManagerThrottlingInterceptor()) .build(); if (client.httpClient().proxy() != null) { credentials.withProxy(client.httpClient().proxy()); } return client; }
protected RestClient buildRestClient(AzureTokenCredentials credentials, AzureEnvironment.Endpoint endpoint) { RestClient client = restClientBuilder .withBaseUrl(credentials.environment(), endpoint) .withCredentials(credentials) .withInterceptor(new ProviderRegistrationInterceptor(credentials)) .withInterceptor(new ResourceManagerThrottlingInterceptor()) .build(); if (client.httpClient().proxy() != null) { credentials.withProxy(client.httpClient().proxy()); } return client; }