Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoPR resources/resource-manager] Move subscriptionId to global #304

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,29 @@ public AzureClient getAzureClient() {
return this.azureClient;
}

/** The ID of the target subscription. */
private String subscriptionId;

/**
* Gets The ID of the target subscription.
*
* @return the subscriptionId value.
*/
public String subscriptionId() {
return this.subscriptionId;
}

/**
* Sets The ID of the target subscription.
*
* @param subscriptionId the subscriptionId value.
* @return the service client itself
*/
public SubscriptionClientImpl withSubscriptionId(String subscriptionId) {
this.subscriptionId = subscriptionId;
return this;
}

/** The API version to use for the operation. */
private String apiVersion;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,39 +79,36 @@ interface SubscriptionsService {
* Gets all available geo-locations.
* This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list.
*
* @param subscriptionId The ID of the target subscription.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws CloudException thrown if the request is rejected by server
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the List<LocationInner> object if successful.
*/
public List<LocationInner> listLocations(String subscriptionId) {
return listLocationsWithServiceResponseAsync(subscriptionId).toBlocking().single().body();
public List<LocationInner> listLocations() {
return listLocationsWithServiceResponseAsync().toBlocking().single().body();
}

/**
* Gets all available geo-locations.
* This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list.
*
* @param subscriptionId The ID of the target subscription.
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceFuture} object
*/
public ServiceFuture<List<LocationInner>> listLocationsAsync(String subscriptionId, final ServiceCallback<List<LocationInner>> serviceCallback) {
return ServiceFuture.fromResponse(listLocationsWithServiceResponseAsync(subscriptionId), serviceCallback);
public ServiceFuture<List<LocationInner>> listLocationsAsync(final ServiceCallback<List<LocationInner>> serviceCallback) {
return ServiceFuture.fromResponse(listLocationsWithServiceResponseAsync(), serviceCallback);
}

/**
* Gets all available geo-locations.
* This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list.
*
* @param subscriptionId The ID of the target subscription.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the List&lt;LocationInner&gt; object
*/
public Observable<List<LocationInner>> listLocationsAsync(String subscriptionId) {
return listLocationsWithServiceResponseAsync(subscriptionId).map(new Func1<ServiceResponse<List<LocationInner>>, List<LocationInner>>() {
public Observable<List<LocationInner>> listLocationsAsync() {
return listLocationsWithServiceResponseAsync().map(new Func1<ServiceResponse<List<LocationInner>>, List<LocationInner>>() {
@Override
public List<LocationInner> call(ServiceResponse<List<LocationInner>> response) {
return response.body();
Expand All @@ -123,18 +120,17 @@ public List<LocationInner> call(ServiceResponse<List<LocationInner>> response) {
* Gets all available geo-locations.
* This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list.
*
* @param subscriptionId The ID of the target subscription.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the List&lt;LocationInner&gt; object
*/
public Observable<ServiceResponse<List<LocationInner>>> listLocationsWithServiceResponseAsync(String subscriptionId) {
if (subscriptionId == null) {
throw new IllegalArgumentException("Parameter subscriptionId is required and cannot be null.");
public Observable<ServiceResponse<List<LocationInner>>> listLocationsWithServiceResponseAsync() {
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.");
}
return service.listLocations(subscriptionId, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
return service.listLocations(this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<List<LocationInner>>>>() {
@Override
public Observable<ServiceResponse<List<LocationInner>>> call(Response<ResponseBody> response) {
Expand All @@ -159,37 +155,34 @@ private ServiceResponse<PageImpl<LocationInner>> listLocationsDelegate(Response<
/**
* Gets details about a specified subscription.
*
* @param subscriptionId The ID of the target subscription.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws CloudException thrown if the request is rejected by server
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the SubscriptionInner object if successful.
*/
public SubscriptionInner get(String subscriptionId) {
return getWithServiceResponseAsync(subscriptionId).toBlocking().single().body();
public SubscriptionInner get() {
return getWithServiceResponseAsync().toBlocking().single().body();
}

/**
* Gets details about a specified subscription.
*
* @param subscriptionId The ID of the target subscription.
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceFuture} object
*/
public ServiceFuture<SubscriptionInner> getAsync(String subscriptionId, final ServiceCallback<SubscriptionInner> serviceCallback) {
return ServiceFuture.fromResponse(getWithServiceResponseAsync(subscriptionId), serviceCallback);
public ServiceFuture<SubscriptionInner> getAsync(final ServiceCallback<SubscriptionInner> serviceCallback) {
return ServiceFuture.fromResponse(getWithServiceResponseAsync(), serviceCallback);
}

/**
* Gets details about a specified subscription.
*
* @param subscriptionId The ID of the target subscription.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the SubscriptionInner object
*/
public Observable<SubscriptionInner> getAsync(String subscriptionId) {
return getWithServiceResponseAsync(subscriptionId).map(new Func1<ServiceResponse<SubscriptionInner>, SubscriptionInner>() {
public Observable<SubscriptionInner> getAsync() {
return getWithServiceResponseAsync().map(new Func1<ServiceResponse<SubscriptionInner>, SubscriptionInner>() {
@Override
public SubscriptionInner call(ServiceResponse<SubscriptionInner> response) {
return response.body();
Expand All @@ -200,18 +193,17 @@ public SubscriptionInner call(ServiceResponse<SubscriptionInner> response) {
/**
* Gets details about a specified subscription.
*
* @param subscriptionId The ID of the target subscription.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the SubscriptionInner object
*/
public Observable<ServiceResponse<SubscriptionInner>> getWithServiceResponseAsync(String subscriptionId) {
if (subscriptionId == null) {
throw new IllegalArgumentException("Parameter subscriptionId is required and cannot be null.");
public Observable<ServiceResponse<SubscriptionInner>> getWithServiceResponseAsync() {
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.");
}
return service.get(subscriptionId, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
return service.get(this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<SubscriptionInner>>>() {
@Override
public Observable<ServiceResponse<SubscriptionInner>> call(Response<ResponseBody> response) {
Expand Down