com.microsoft.azure.serializer.AzureJacksonAdapter Java Examples

The following examples show how to use com.microsoft.azure.serializer.AzureJacksonAdapter. 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: ManageSqlVirtualNetworkRules.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * 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 #2
Source File: ManageSqlImportExportDatabase.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * 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 #3
Source File: GettingSqlServerMetrics.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * 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 #4
Source File: ManageSqlServerDnsAliases.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * 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: ManageSqlServerKeysWithAzureKeyVaultKey.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * 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, credentials.clientId());
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #6
Source File: ManageSqlDatabaseInElasticPool.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * 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: ManageSqlDatabase.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * 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 #8
Source File: ManageSqlServerSecurityAlertPolicy.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * 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: ManageSqlWithRecoveredOrRestoredDatabase.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * 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: ManageSqlFirewallRules.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * 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 #11
Source File: ManageSqlDatabasesAcrossDifferentDataCenters.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * 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 #12
Source File: ManageSqlFailoverGroups.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * 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 #13
Source File: SerializationTests.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
@Test
public void test1() throws IOException {
    AzureJacksonAdapter jacksonAdapter = new AzureJacksonAdapter();

    Map<String, VirtualMachineIdentityUserAssignedIdentitiesValue> userAssignedIdentities = new HashMap<>();
    userAssignedIdentities.put("af.B/C", new VirtualMachineIdentityUserAssignedIdentitiesValue());
    userAssignedIdentities.put("af.B/D", new VirtualMachineIdentityUserAssignedIdentitiesValue());

    VirtualMachineIdentity identity = new VirtualMachineIdentity();
    identity.withUserAssignedIdentities(userAssignedIdentities);

    VirtualMachineInner virtualMachine = new VirtualMachineInner();
    virtualMachine.withIdentity(identity);

    virtualMachine.withLicenseType("abs");

    String serialized = jacksonAdapter.serialize(virtualMachine);

    System.out.println(serialized);
}
 
Example #14
Source File: CdnManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * 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 #15
Source File: NetworkManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * 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);
}
 
Example #16
Source File: AppServiceMSICredentials.java    From autorest-clientruntime-for-java with MIT License 5 votes vote down vote up
/**
 * Creates an MSI credential for app services.
 * @param environment the environment this application is running in
 * @param endpoint the MSI endpoint
 * @param secret the MSI secret
 */
public AppServiceMSICredentials(AzureEnvironment environment, String endpoint, String secret) {
    super(environment, null);
    if (endpoint == null) {
        throw new IllegalArgumentException("endpoint == null");
    }
    if (secret == null) {
        throw new IllegalArgumentException("secret == null");
    }
    this.endpoint = endpoint;
    this.secret = secret;
    this.adapter = new AzureJacksonAdapter();
}
 
Example #17
Source File: DnsZoneManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * 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 #18
Source File: KeyVaultManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Creates an instance of KeyVaultManager that exposes KeyVault resource management API entry points.
 *
 * @param credentials the credentials to use
 * @param subscriptionId the subscription UUID
 * @return the KeyVaultManager
 */
public static KeyVaultManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
    return new KeyVaultManager(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 #19
Source File: CosmosDBManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * 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 CosmosDBManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
    return new CosmosDBManager(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 #20
Source File: BatchAIManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
* Creates an instance of BatchAIManager that exposes BatchAI resource management API entry points.
*
* @param credentials the credentials to use
* @param subscriptionId the subscription UUID
* @return the BatchAIManager
*/
public static BatchAIManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
    return new BatchAIManager(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);
}
 
Example #21
Source File: GraphRbacManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Creates an instance of GraphRbacManager that exposes Graph RBAC management API entry points.
 *
 * @param credentials the credentials to use
 * @return the GraphRbacManager instance
 */
public static GraphRbacManager authenticate(AzureTokenCredentials credentials) {
    return new GraphRbacManager(new RestClient.Builder()
            .withBaseUrl(credentials.environment().graphEndpoint())
            .withInterceptor(new RequestIdHeaderInterceptor())
            .withCredentials(credentials)
            .withSerializerAdapter(new AzureJacksonAdapter())
            .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
            .withInterceptor(new ProviderRegistrationInterceptor(credentials))
            .withInterceptor(new ResourceManagerThrottlingInterceptor())
            .build(), credentials.domain());
}
 
Example #22
Source File: AppServiceManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * 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 #23
Source File: ServiceBusManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * 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);
}
 
Example #24
Source File: KeyVaultClientIntegrationTestBase.java    From azure-keyvault-java with MIT License 5 votes vote down vote up
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 #25
Source File: ITManagedStorageAccountKey.java    From azure-keyvault-java with MIT License 5 votes vote down vote up
protected RestClient buildPlaybackRestClient(ServiceClientCredentials credentials, String baseUrl)
        throws IOException {
    return 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()).build();
}
 
Example #26
Source File: KeyVaultClientIntegrationTestBase.java    From azure-keyvault-java with MIT License 5 votes vote down vote up
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 #27
Source File: AzureServiceClient.java    From autorest-clientruntime-for-java with MIT License 5 votes vote down vote up
/**
 * Initializes a new instance of the ServiceClient class.
 *
 * @param baseUrl the service base uri
 * @param credentials the credentials
 * @param clientBuilder the http client builder
 * @param restBuilder the retrofit rest client builder
 */
protected AzureServiceClient(String baseUrl, ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder restBuilder) {
    this(new RestClient.Builder(clientBuilder, restBuilder)
            .withBaseUrl(baseUrl)
            .withCredentials(credentials)
            .withSerializerAdapter(new AzureJacksonAdapter())
            .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
            .build());
}
 
Example #28
Source File: CloudErrorDeserializerTests.java    From autorest-clientruntime-for-java with MIT License 5 votes vote down vote up
@Test
public void cloudErrorDeserialization() throws Exception {
    SerializerAdapter<ObjectMapper> serializerAdapter = new AzureJacksonAdapter();
    String bodyString =
        "{" +
        "    \"error\": {" +
        "        \"code\": \"BadArgument\"," +
        "        \"message\": \"The provided database ‘foo’ has an invalid username.\"," +
        "        \"target\": \"query\"," +
        "        \"details\": [" +
        "            {" +
        "                \"code\": \"301\"," +
        "                \"target\": \"$search\"," +
        "                \"message\": \"$search query option not supported\"" +
        "            }" +
        "        ]," +
        "        \"additionalInfo\": [" +
        "            {" +
        "                \"type\": \"SomeErrorType\"," +
        "                \"info\": {" +
        "                    \"someProperty\": \"SomeValue\"" +
        "                }" +
        "            }" +
        "        ]" +
        "    }" +
        "}";
    
    CloudError cloudError = serializerAdapter.deserialize(bodyString, CloudError.class);

    Assert.assertEquals("BadArgument", cloudError.code());
    Assert.assertEquals("The provided database ‘foo’ has an invalid username.", cloudError.message());
    Assert.assertEquals("query", cloudError.target());
    Assert.assertEquals(1, cloudError.details().size());
    Assert.assertEquals("301", cloudError.details().get(0).code());
    Assert.assertEquals(1, cloudError.additionalInfo().size());
    Assert.assertEquals("SomeErrorType", cloudError.additionalInfo().get(0).type());
    Assert.assertEquals("SomeValue", cloudError.additionalInfo().get(0).info().get("someProperty").asText());
}
 
Example #29
Source File: MSIManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Creates an instance of MSIManager that exposes Managed Service Identity (MSI) resource management API entry points.
 *
 * @param credentials the credentials to use
 * @param subscriptionId the subscription UUID
 * @return the MSIManager
 */
public static MSIManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
    return new MSIManager(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 #30
Source File: RedisManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * 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);
}