com.microsoft.rest.RestClient Java Examples
The following examples show how to use
com.microsoft.rest.RestClient.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RedisManagementTest.java From azure-libraries-for-java with MIT License | 6 votes |
@Override protected void initializeClients(RestClient restClient, String defaultSubscription, String domain) { RG_NAME = generateRandomResourceName("javacsmrg", 15); RR_NAME = generateRandomResourceName("javacsmrc", 15); RG_NAME_SECOND = RG_NAME + "Second"; RR_NAME_SECOND = RR_NAME + "Second"; RR_NAME_THIRD = RR_NAME + "Third"; SA_NAME = generateRandomResourceName("javacsmsa", 15); resourceManager = ResourceManager .authenticate(restClient) .withSubscription(defaultSubscription); redisManager = RedisManager .authenticate(restClient, defaultSubscription); storageManager = StorageManager .authenticate(restClient, defaultSubscription); }
Example #2
Source File: ContainerServiceManagementTest.java From azure-libraries-for-java with MIT License | 6 votes |
@Override protected void initializeClients(RestClient restClient, String defaultSubscription, String domain) { RG_NAME = generateRandomResourceName("javaacsrg", 15); resourceManager = ResourceManager .authenticate(restClient) .withSubscription(defaultSubscription); containerServiceManager = ContainerServiceManager .authenticate(restClient, defaultSubscription); resourceManager.resourceGroups() .define(RG_NAME) .withRegion(Region.US_EAST) .create(); }
Example #3
Source File: ManageSqlWithRecoveredOrRestoredDatabase.java From azure-libraries-for-java with MIT License | 6 votes |
/** * Main entry point. * @param args the parameters */ public static void main(String[] args) { try { final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION")); ApplicationTokenCredentials credentials = ApplicationTokenCredentials.fromFile(credFile); RestClient restClient = new RestClient.Builder() .withBaseUrl(AzureEnvironment.AZURE, AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withSerializerAdapter(new AzureJacksonAdapter()) .withReadTimeout(150, TimeUnit.SECONDS) .withLogLevel(LogLevel.BODY) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withCredentials(credentials).build(); Azure azure = Azure.authenticate(restClient, credentials.domain(), credentials.defaultSubscriptionId()).withDefaultSubscription(); // Print selected subscription System.out.println("Selected subscription: " + azure.subscriptionId()); runSample(azure); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } }
Example #4
Source File: GettingSqlServerMetrics.java From azure-libraries-for-java with MIT License | 6 votes |
/** * Main entry point. * @param args the parameters */ public static void main(String[] args) { try { final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION")); ApplicationTokenCredentials credentials = ApplicationTokenCredentials.fromFile(credFile); RestClient restClient = new RestClient.Builder() .withBaseUrl(AzureEnvironment.AZURE, AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withReadTimeout(150, TimeUnit.SECONDS) .withLogLevel(LogLevel.BODY) .withCredentials(credentials).build(); Azure azure = Azure.authenticate(restClient, credentials.domain(), credentials.defaultSubscriptionId()).withDefaultSubscription(); // Print selected subscription System.out.println("Selected subscription: " + azure.subscriptionId()); runSample(azure); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } }
Example #5
Source File: ManageSqlServerDnsAliases.java From azure-libraries-for-java with MIT License | 6 votes |
/** * Main entry point. * @param args the parameters */ public static void main(String[] args) { try { final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION")); ApplicationTokenCredentials credentials = ApplicationTokenCredentials.fromFile(credFile); RestClient restClient = new RestClient.Builder() .withBaseUrl(AzureEnvironment.AZURE, AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withReadTimeout(150, TimeUnit.SECONDS) .withLogLevel(LogLevel.BODY) .withCredentials(credentials).build(); Azure azure = Azure.authenticate(restClient, credentials.domain(), credentials.defaultSubscriptionId()).withDefaultSubscription(); // Print selected subscription System.out.println("Selected subscription: " + azure.subscriptionId()); runSample(azure); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } }
Example #6
Source File: ManageSqlDatabasesAcrossDifferentDataCenters.java From azure-libraries-for-java with MIT License | 6 votes |
/** * Main entry point. * @param args the parameters */ public static void main(String[] args) { try { final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION")); ApplicationTokenCredentials credentials = ApplicationTokenCredentials.fromFile(credFile); RestClient restClient = new RestClient.Builder() .withBaseUrl(AzureEnvironment.AZURE, AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withSerializerAdapter(new AzureJacksonAdapter()) .withReadTimeout(150, TimeUnit.SECONDS) .withLogLevel(LogLevel.BODY) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withCredentials(credentials).build(); Azure azure = Azure.authenticate(restClient, credentials.domain(), credentials.defaultSubscriptionId()).withDefaultSubscription(); // Print selected subscription System.out.println("Selected subscription: " + azure.subscriptionId()); runSample(azure); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } }
Example #7
Source File: ManageSqlVirtualNetworkRules.java From azure-libraries-for-java with MIT License | 6 votes |
/** * Main entry point. * @param args the parameters */ public static void main(String[] args) { try { final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION")); ApplicationTokenCredentials credentials = ApplicationTokenCredentials.fromFile(credFile); RestClient restClient = new RestClient.Builder() .withBaseUrl(AzureEnvironment.AZURE, AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withReadTimeout(150, TimeUnit.SECONDS) .withLogLevel(LogLevel.BODY) .withCredentials(credentials).build(); Azure azure = Azure.authenticate(restClient, credentials.domain(), credentials.defaultSubscriptionId()).withDefaultSubscription(); // Print selected subscription System.out.println("Selected subscription: " + azure.subscriptionId()); runSample(azure); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } }
Example #8
Source File: ManageSqlFailoverGroups.java From azure-libraries-for-java with MIT License | 6 votes |
/** * Main entry point. * @param args the parameters */ public static void main(String[] args) { try { final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION")); ApplicationTokenCredentials credentials = ApplicationTokenCredentials.fromFile(credFile); RestClient restClient = new RestClient.Builder() .withBaseUrl(AzureEnvironment.AZURE, AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withReadTimeout(150, TimeUnit.SECONDS) .withLogLevel(LogLevel.BODY) .withCredentials(credentials).build(); Azure azure = Azure.authenticate(restClient, credentials.domain(), credentials.defaultSubscriptionId()).withDefaultSubscription(); // Print selected subscription System.out.println("Selected subscription: " + azure.subscriptionId()); runSample(azure); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } }
Example #9
Source File: ManageSqlImportExportDatabase.java From azure-libraries-for-java with MIT License | 6 votes |
/** * Main entry point. * @param args the parameters */ public static void main(String[] args) { try { final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION")); ApplicationTokenCredentials credentials = ApplicationTokenCredentials.fromFile(credFile); RestClient restClient = new RestClient.Builder() .withBaseUrl(AzureEnvironment.AZURE, AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withSerializerAdapter(new AzureJacksonAdapter()) .withReadTimeout(150, TimeUnit.SECONDS) .withLogLevel(LogLevel.BODY) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withCredentials(credentials).build(); Azure azure = Azure.authenticate(restClient, credentials.domain(), credentials.defaultSubscriptionId()).withDefaultSubscription(); // Print selected subscription System.out.println("Selected subscription: " + azure.subscriptionId()); runSample(azure); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } }
Example #10
Source File: Utils.java From azure-libraries-for-java with MIT License | 6 votes |
/** * Get the Azure storage account connection string. * @param accountName storage account name * @param accountKey storage account key * @param restClient rest client * @return the storage account connection string. */ public static String getStorageConnectionString(String accountName, String accountKey, RestClient restClient) { AzureEnvironment environment = AzureEnvironment.AZURE; if (restClient != null) { try { AzureEnvironment environment1 = extractAzureEnvironment(restClient); if (environment1 != null && environment1.storageEndpointSuffix() != null) { environment = environment1; } } catch (IllegalArgumentException e) { // ignored } } String suffix = environment.storageEndpointSuffix().replaceAll("^\\.*", ""); return String.format("DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s;EndpointSuffix=%s", accountName, accountKey, suffix); }
Example #11
Source File: FunctionDeploymentSlotsTests.java From azure-libraries-for-java with MIT License | 5 votes |
@Override protected void initializeClients(RestClient restClient, String defaultSubscription, String domain) { WEBAPP_NAME_1 = generateRandomResourceName("java-funcapp-", 20); RG_NAME_1 = generateRandomResourceName("javacsmrg", 20); SLOT_NAME_1 = generateRandomResourceName("java-slot-", 20); SLOT_NAME_2 = generateRandomResourceName("java-slot-", 20); SLOT_NAME_3 = generateRandomResourceName("java-slot-", 20); super.initializeClients(restClient, defaultSubscription, domain); }
Example #12
Source File: KeyVaultClientIntegrationTestBase.java From azure-keyvault-java with MIT License | 5 votes |
protected RestClient buildPlaybackRestClient(ServiceClientCredentials credentials, String baseUrl) throws IOException { return buildRestClient(new RestClient.Builder().withBaseUrl(baseUrl) .withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()).withCredentials(credentials) .withLogLevel(LogLevel.NONE) .withNetworkInterceptor(new LoggingInterceptor(LogLevel.BODY_AND_HEADERS)) .withNetworkInterceptor(interceptorManager.initInterceptor()) .withInterceptor(new ResourceManagerThrottlingInterceptor())); }
Example #13
Source File: AppServiceManager.java From azure-libraries-for-java with MIT License | 5 votes |
private AppServiceManager(RestClient restClient, String tenantId, String subscriptionId) { super( restClient, subscriptionId, new WebSiteManagementClientImpl(restClient).withSubscriptionId(subscriptionId)); keyVaultManager = KeyVaultManager.authenticate(restClient, tenantId, subscriptionId); storageManager = StorageManager.authenticate(restClient, subscriptionId); rbacManager = GraphRbacManager.authenticate(restClient, tenantId); dnsZoneManager = DnsZoneManager.authenticate(restClient, subscriptionId); this.restClient = restClient; }
Example #14
Source File: AppServiceManager.java From azure-libraries-for-java with MIT License | 5 votes |
/** * Creates an instance of StorageManager that exposes storage resource management API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription UUID * @return the StorageManager */ 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()) .withInterceptor(new ProviderRegistrationInterceptor(credentials)) .withInterceptor(new ResourceManagerThrottlingInterceptor()) .build(), credentials.domain(), subscriptionId); }
Example #15
Source File: VirtualMachineEMSILMSIOperationsTests.java From azure-libraries-for-java with MIT License | 5 votes |
@Override protected void initializeClients(RestClient restClient, String defaultSubscription, String domain) throws IOException { this.msiManager = MSIManager.authenticate(restClient, defaultSubscription); this.resourceManager = msiManager.resourceManager(); this.computeManager = ComputeManager.authenticate(restClient, defaultSubscription); this.networkManager = NetworkManager.authenticate(restClient, defaultSubscription); }
Example #16
Source File: GraphRbacManager.java From azure-libraries-for-java with MIT License | 5 votes |
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; }
Example #17
Source File: SqlServerTest.java From azure-libraries-for-java with MIT License | 5 votes |
@Override protected RestClient buildRestClient(RestClient.Builder builder, boolean isMocked) { if (!isMocked) { return super.buildRestClient(builder.withReadTimeout(150, TimeUnit.SECONDS) , isMocked); } return super.buildRestClient(builder, isMocked); }
Example #18
Source File: DnsZoneRecordSetETagTests.java From azure-libraries-for-java with MIT License | 5 votes |
@Override protected void initializeClients(RestClient restClient, String defaultSubscription, String domain) { resourceManager = ResourceManager .authenticate(restClient) .withSubscription(defaultSubscription); zoneManager = DnsZoneManager .authenticate(restClient, defaultSubscription); RG_NAME = generateRandomResourceName("dnsetagtest", 15); }
Example #19
Source File: SqlServerTest.java From azure-libraries-for-java with MIT License | 5 votes |
@Override protected void initializeClients(RestClient restClient, String defaultSubscription, String domain) { RG_NAME = generateRandomResourceName("rgsql", 20); SQL_SERVER_NAME = generateRandomResourceName("javasqlserver", 20); resourceManager = ResourceManager .authenticate(restClient) .withSubscription(defaultSubscription); sqlServerManager = SqlServerManager .authenticate(restClient, domain, defaultSubscription); storageManager = StorageManager .authenticate(restClient, defaultSubscription); }
Example #20
Source File: RedisManager.java From azure-libraries-for-java with MIT License | 5 votes |
/** * Creates an instance of RedisManager that exposes Redis resource management API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription UUID * @return the RedisManager */ public static RedisManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new RedisManager(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); }
Example #21
Source File: DiagnosticLogsTests.java From azure-libraries-for-java with MIT License | 5 votes |
@Override protected void initializeClients(RestClient restClient, String defaultSubscription, String domain) { WEBAPP_NAME_1 = generateRandomResourceName("java-webapp-", 20); RG_NAME_1 = generateRandomResourceName("javacsmrg", 20); super.initializeClients(restClient, defaultSubscription, domain); }
Example #22
Source File: DnsZoneManager.java From azure-libraries-for-java with MIT License | 5 votes |
/** * 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); }
Example #23
Source File: TooManyRequestsRetryInterceptorTests.java From azure-libraries-for-java with MIT License | 5 votes |
@Override protected void initializeClients(RestClient restClient, String defaultSubscription, String domain) { testId = SdkContext.randomResourceName("", 9); rgName = "rg429" + testId; super.initializeClients(restClient, defaultSubscription, domain); resourceGroups = resourceClient.resourceGroups(); rg = resourceGroups.define(rgName) .withRegion(Region.US_EAST) .create(); }
Example #24
Source File: Azure.java From azure-libraries-for-java with MIT License | 5 votes |
/** * Authenticate to Azure using an Azure credentials object. * * @param credentials the credentials object * @return the authenticated Azure client */ public static Authenticated authenticate(AzureTokenCredentials credentials) { return new AuthenticatedImpl(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(), credentials.domain()); }
Example #25
Source File: CdnManager.java From azure-libraries-for-java with MIT License | 5 votes |
/** * Creates an instance of CDN Manager that exposes CDN manager management API entry points. * * @param credentials the credentials to use * @param subscriptionId the subscription UUID * @return the CDN Manager */ public static CdnManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new CdnManager(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); }
Example #26
Source File: AlertsTests.java From azure-libraries-for-java with MIT License | 5 votes |
@Override protected void initializeClients(RestClient restClient, String defaultSubscription, String domain) { RG_NAME = generateRandomResourceName("jMonitor_", 18); SA_NAME = generateRandomResourceName("jMonitorSA", 18); super.initializeClients(restClient, defaultSubscription, domain); }
Example #27
Source File: AuthenticationTests.java From azure-libraries-for-java with MIT License | 5 votes |
@Override protected void initializeClients(RestClient restClient, String defaultSubscription, String domain) { WEBAPP_NAME_1 = generateRandomResourceName("java-webapp-", 20); RG_NAME_1 = generateRandomResourceName("javacsmrg", 20); super.initializeClients(restClient, defaultSubscription, domain); }
Example #28
Source File: BatchManager.java From azure-libraries-for-java with MIT License | 5 votes |
protected BatchManager(RestClient restClient, String subscriptionId) { super( restClient, subscriptionId, new BatchManagementClientImpl(restClient).withSubscriptionId(subscriptionId)); storageManager = StorageManager.authenticate(restClient, subscriptionId); }
Example #29
Source File: KeyVaultClientIntegrationTestBase.java From azure-keyvault-java with MIT License | 5 votes |
protected void initializeClients(RestClient restClient, String s, String s1) throws IOException { try { RestClient restClientWithTimeout = buildRestClient(new RestClient.Builder() .withBaseUrl("https://{vaultBaseUrl}").withSerializerAdapter(new AzureJacksonAdapter()) .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .withCredentials(createTestCredentials()).withLogLevel(LogLevel.BODY_AND_HEADERS) .withNetworkInterceptor(interceptorManager.initInterceptor())); createTestCredentials(); keyVaultClient = new KeyVaultClient(restClientWithTimeout); // keyVaultClient = new KeyVaultClient(restClient); } catch (Exception e) { e.printStackTrace(); } }
Example #30
Source File: ServiceBusOperationsTests.java From azure-libraries-for-java with MIT License | 5 votes |
@Override protected RestClient buildRestClient(RestClient.Builder builder, boolean isMocked) { if (!isMocked) { return super.buildRestClient(builder, isMocked); } return super.buildRestClient(builder.withReadTimeout(100, TimeUnit.SECONDS), isMocked); }