Skip to content

Commit

Permalink
Making relative paths work in composite swagger docs (Azure#1396)
Browse files Browse the repository at this point in the history
* remove stale token from tokencache for sp auth as adal does not remove it.

* more improvements

* jshint fixes

* application token creds update

* update version

* auth updates to node azure clientruntime

* fix to make nodejs tests work for 6.x as well as 4.x

* Making relative paths work in composite swagger docs

* made modification in all the composite test specs to represent relative documents accurately

* regenerated code
  • Loading branch information
amarzavery authored and tbombach committed Sep 2, 2016
1 parent a7dda4e commit 64bf663
Show file tree
Hide file tree
Showing 30 changed files with 1,768 additions and 1,742 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
import com.microsoft.rest.ServiceCall;
import com.microsoft.rest.ServiceCallback;
import com.microsoft.rest.ServiceResponse;
import com.microsoft.rest.ServiceResponseCallback;
import java.io.IOException;
import java.util.List;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.Path;
import retrofit2.http.Query;
import retrofit2.Response;
import rx.functions.Func1;
import rx.Observable;

/**
* An instance of this class provides access to all the operations defined
Expand Down Expand Up @@ -50,7 +50,7 @@ public UsagesInner(Retrofit retrofit, StorageManagementClientImpl client) {
interface UsagesService {
@Headers("Content-Type: application/json; charset=utf-8")
@GET("subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages")
Call<ResponseBody> list(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
Observable<Response<ResponseBody>> list(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

}

Expand All @@ -63,48 +63,44 @@ interface UsagesService {
* @return the List&lt;UsageInner&gt; object wrapped in {@link ServiceResponse} if successful.
*/
public ServiceResponse<List<UsageInner>> list() throws CloudException, IOException, IllegalArgumentException {
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
if (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
Call<ResponseBody> call = service.list(this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent());
ServiceResponse<PageImpl<UsageInner>> response = listDelegate(call.execute());
List<UsageInner> result = response.getBody().getItems();
return new ServiceResponse<>(result, response.getResponse());
return listAsync().toBlocking().single();
}

/**
* Gets the current usage count and the limit for the resources under the subscription.
*
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
* @return the {@link Call} object
* @return the {@link ServiceCall} object
*/
public ServiceCall<List<UsageInner>> listAsync(final ServiceCallback<List<UsageInner>> serviceCallback) {
return ServiceCall.create(listAsync(), serviceCallback);
}

/**
* Gets the current usage count and the limit for the resources under the subscription.
*
* @return the observable to the List&lt;UsageInner&gt; object
*/
public Observable<ServiceResponse<List<UsageInner>>> listAsync() {
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
if (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
Call<ResponseBody> call = service.list(this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent());
final ServiceCall<List<UsageInner>> serviceCall = new ServiceCall<>(call);
call.enqueue(new ServiceResponseCallback<List<UsageInner>>(serviceCall, serviceCallback) {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
try {
ServiceResponse<PageImpl<UsageInner>> result = listDelegate(response);
serviceCallback.success(new ServiceResponse<>(result.getBody().getItems(), result.getResponse()));
} catch (CloudException | IOException exception) {
if (serviceCallback != null) {
serviceCallback.failure(exception);
return service.list(this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<List<UsageInner>>>>() {
@Override
public Observable<ServiceResponse<List<UsageInner>>> call(Response<ResponseBody> response) {
try {
ServiceResponse<PageImpl<UsageInner>> result = listDelegate(response);
ServiceResponse<List<UsageInner>> clientResponse = new ServiceResponse<List<UsageInner>>(result.getBody().getItems(), result.getResponse());
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
serviceCall.failure(exception);
}
}
});
return serviceCall;
});
}

private ServiceResponse<PageImpl<UsageInner>> listDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
Expand Down
Loading

0 comments on commit 64bf663

Please sign in to comment.