Skip to content

Commit

Permalink
ComputeManager, rename region->location, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
jianghaolu committed May 12, 2016
1 parent 5e2de11 commit 41224f8
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 14 deletions.
2 changes: 1 addition & 1 deletion azure-client-authentication/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ checkstyle {

dependencies {
compile 'com.microsoft.azure:adal4j:1.1.2'
compile 'com.microsoft.rest:client-runtime:1.0.0-beta1'
compile 'com.microsoft.azure:azure-client-runtime:1.0.0-beta1'
testCompile 'junit:junit:4.12'
testCompile 'junit:junit-dep:4.11'
deployerJars "org.apache.maven.wagon:wagon-ftp:2.10"
Expand Down
6 changes: 3 additions & 3 deletions azure-client-authentication/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@

<dependencies>
<dependency>
<groupId>com.microsoft.rest</groupId>
<artifactId>client-runtime</artifactId>
<version>${parent.version}</version>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-client-runtime</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.microsoft.aad.adal4j.AuthenticationContext;
import com.microsoft.aad.adal4j.AuthenticationResult;
import com.microsoft.aad.adal4j.ClientCredential;
import com.microsoft.azure.AzureEnvironment;
import com.microsoft.rest.credentials.TokenCredentials;

import java.io.File;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import com.microsoft.aad.adal4j.AuthenticationContext;
import com.microsoft.aad.adal4j.AuthenticationResult;
import com.microsoft.azure.AzureEnvironment;
import com.microsoft.rest.credentials.TokenCredentials;

import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
package com.microsoft.azure.credentials;

import com.microsoft.aad.adal4j.AuthenticationResult;

import com.microsoft.azure.AzureEnvironment;
import org.junit.Assert;

import org.junit.Test;

import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
*
*/

package com.microsoft.azure.credentials;
package com.microsoft.azure;

import com.microsoft.azure.serializer.AzureJacksonMapperAdapter;
import com.microsoft.rest.RestClient;

/**
* An instance of this class describes an environment in Azure.
Expand Down Expand Up @@ -74,6 +77,15 @@ public AzureEnvironment(
public String getBaseUrl() {
return this.baseURL;
}

/**
* Gets a builder for {@link RestClient}.
*
* @return a builder for the rest client.
*/
public RestClient.Builder newRestClientBuilder() {
return new RestClient.Builder(baseURL).withMapperAdapter(new AzureJacksonMapperAdapter());
}

/**
* Gets the ActiveDirectory Endpoint for the Azure Environment.
Expand Down
17 changes: 10 additions & 7 deletions client-runtime/src/main/java/com/microsoft/rest/RestClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public static class Builder {
/**
* Creates an instance of the builder with a base URL to the service.
*
* @param baseUrl the dynamic base URL with varialbes wrapped in "{" and "}".
* @param baseUrl the dynamic base URL with variables wrapped in "{" and "}".
*/
public Builder(String baseUrl) {
this(baseUrl, new OkHttpClient.Builder(), new Retrofit.Builder());
Expand All @@ -147,7 +147,7 @@ public Builder(String baseUrl) {
/**
* Creates an instance of the builder with a base URL and 2 custom builders.
*
* @param baseUrl the dynamic base URL with varialbes wrapped in "{" and "}".
* @param baseUrl the dynamic base URL with variables wrapped in "{" and "}".
* @param httpClientBuilder the builder to build an {@link OkHttpClient}.
* @param retrofitBuilder the builder to build a {@link Retrofit}.
*/
Expand Down Expand Up @@ -204,10 +204,7 @@ public Builder withUserAgent(String userAgent) {
* @return the builder itself for chaining.
*/
public Builder withMapperAdapter(JacksonMapperAdapter mapperAdapter) {
if (mapperAdapter != null) {
this.mapperAdapter = mapperAdapter;
this.retrofitBuilder = retrofitBuilder.addConverterFactory(mapperAdapter.getConverterFactory());
}
this.mapperAdapter = mapperAdapter;
return this;
}

Expand Down Expand Up @@ -253,12 +250,18 @@ public Builder withInterceptor(Interceptor interceptor) {
* @return a {@link RestClient}.
*/
public RestClient build() {
if (mapperAdapter == null) {
throw new IllegalArgumentException("Please set mapper adapter.");
}
OkHttpClient httpClient = httpClientBuilder
.addInterceptor(baseUrlHandler)
.addInterceptor(customHeadersInterceptor)
.build();
return new RestClient(httpClient,
retrofitBuilder.client(httpClient).build(),
retrofitBuilder
.client(httpClient)
.addConverterFactory(mapperAdapter.getConverterFactory())
.build(),
credentials,
customHeadersInterceptor,
baseUrlHandler,
Expand Down

0 comments on commit 41224f8

Please sign in to comment.