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 search/resource-manager] [WaitForARMFeedback] Add api get_services_by_subscription of Azure Search #2894

Closed
Closed
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 @@ -14,13 +14,14 @@
import com.microsoft.azure.arm.resources.collection.SupportsGettingByResourceGroup;
import rx.Observable;
import com.microsoft.azure.arm.resources.collection.SupportsListingByResourceGroup;
import com.microsoft.azure.arm.collection.SupportsListing;
import com.microsoft.azure.management.searchmanagementclient.v2015_08_19.implementation.ServicesInner;
import com.microsoft.azure.arm.model.HasInner;

/**
* Type representing Services.
*/
public interface Services extends SupportsCreating<SearchService.DefinitionStages.Blank>, SupportsDeletingByResourceGroup, SupportsBatchDeletion, SupportsGettingByResourceGroup<SearchService>, SupportsListingByResourceGroup<SearchService>, HasInner<ServicesInner> {
public interface Services extends SupportsCreating<SearchService.DefinitionStages.Blank>, SupportsDeletingByResourceGroup, SupportsBatchDeletion, SupportsGettingByResourceGroup<SearchService>, SupportsListingByResourceGroup<SearchService>, SupportsListing<SearchService>, HasInner<ServicesInner> {
/**
* Checks whether or not the given Search service name is available for use. Search service names must be globally unique since they are part of the service URI (https://&lt;name&gt;.search.windows.net).
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,30 @@ public SearchService call(SearchServiceInner inner) {
});
}

@Override
public PagedList<SearchService> list() {
ServicesInner client = this.inner();
return this.wrapList(client.list());
}

@Override
public Observable<SearchService> listAsync() {
ServicesInner client = this.inner();
return client.listAsync()
.flatMap(new Func1<Page<SearchServiceInner>, Observable<SearchServiceInner>>() {
@Override
public Observable<SearchServiceInner> call(Page<SearchServiceInner> innerPage) {
return Observable.from(innerPage.items());
}
})
.map(new Func1<SearchServiceInner, SearchService>() {
@Override
public SearchService call(SearchServiceInner inner) {
return wrapModel(inner);
}
});
}

@Override
public SearchServiceImpl define(String name) {
return wrapModel(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import com.microsoft.azure.arm.collection.InnerSupportsGet;
import com.microsoft.azure.arm.collection.InnerSupportsDelete;
import com.microsoft.azure.arm.collection.InnerSupportsListing;
import retrofit2.Retrofit;
import com.google.common.reflect.TypeToken;
import com.microsoft.azure.CloudException;
Expand Down Expand Up @@ -43,7 +44,7 @@
* An instance of this class provides access to all the operations defined
* in Services.
*/
public class ServicesInner implements InnerSupportsGet<SearchServiceInner>, InnerSupportsDelete<Void> {
public class ServicesInner implements InnerSupportsGet<SearchServiceInner>, InnerSupportsDelete<Void>, InnerSupportsListing<SearchServiceInner> {
/** The Retrofit service to perform REST calls. */
private ServicesService service;
/** The service client containing this operation class. */
Expand Down Expand Up @@ -89,6 +90,10 @@ interface ServicesService {
@GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices")
Observable<Response<ResponseBody>> listByResourceGroup(@Path("resourceGroupName") String resourceGroupName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-client-request-id") UUID clientRequestId, @Header("User-Agent") String userAgent);

@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.searchmanagementclient.v2015_08_19.Services list" })
@GET("subscriptions/{subscriptionId}/providers/Microsoft.Search/searchServices")
Observable<Response<ResponseBody>> list(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-client-request-id") UUID clientRequestId, @Header("User-Agent") String userAgent);

@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.searchmanagementclient.v2015_08_19.Services checkNameAvailability" })
@POST("subscriptions/{subscriptionId}/providers/Microsoft.Search/checkNameAvailability")
Observable<Response<ResponseBody>> checkNameAvailability(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-client-request-id") UUID clientRequestId, @Body CheckNameAvailabilityInput checkNameAvailabilityInput, @Header("User-Agent") String userAgent);
Expand Down Expand Up @@ -1176,6 +1181,172 @@ private ServiceResponse<PageImpl<SearchServiceInner>> listByResourceGroupDelegat
.build(response);
}

/**
* Gets a list of all Search services in the given subscription.
*
* @return the PagedList<SearchServiceInner> object if successful.
*/
public PagedList<SearchServiceInner> list() {
PageImpl<SearchServiceInner> page = new PageImpl<>();
page.setItems(listWithServiceResponseAsync().toBlocking().single().body());
page.setNextPageLink(null);
return new PagedList<SearchServiceInner>(page) {
@Override
public Page<SearchServiceInner> nextPage(String nextPageLink) {
return null;
}
};
}

/**
* Gets a list of all Search services in the given subscription.
*
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
* @return the {@link ServiceFuture} object
*/
public ServiceFuture<List<SearchServiceInner>> listAsync(final ServiceCallback<List<SearchServiceInner>> serviceCallback) {
return ServiceFuture.fromResponse(listWithServiceResponseAsync(), serviceCallback);
}

/**
* Gets a list of all Search services in the given subscription.
*
* @return the observable to the List&lt;SearchServiceInner&gt; object
*/
public Observable<Page<SearchServiceInner>> listAsync() {
return listWithServiceResponseAsync().map(new Func1<ServiceResponse<List<SearchServiceInner>>, Page<SearchServiceInner>>() {
@Override
public Page<SearchServiceInner> call(ServiceResponse<List<SearchServiceInner>> response) {
PageImpl<SearchServiceInner> page = new PageImpl<>();
page.setItems(response.body());
return page;
}
});
}

/**
* Gets a list of all Search services in the given subscription.
*
* @return the observable to the List&lt;SearchServiceInner&gt; object
*/
public Observable<ServiceResponse<List<SearchServiceInner>>> listWithServiceResponseAsync() {
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.");
}
final SearchManagementRequestOptions searchManagementRequestOptions = null;
UUID clientRequestId = null;
return service.list(this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), clientRequestId, this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<List<SearchServiceInner>>>>() {
@Override
public Observable<ServiceResponse<List<SearchServiceInner>>> call(Response<ResponseBody> response) {
try {
ServiceResponse<PageImpl<SearchServiceInner>> result = listDelegate(response);
List<SearchServiceInner> items = null;
if (result.body() != null) {
items = result.body().items();
}
ServiceResponse<List<SearchServiceInner>> clientResponse = new ServiceResponse<List<SearchServiceInner>>(items, result.response());
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}

/**
* Gets a list of all Search services in the given subscription.
*
* @param searchManagementRequestOptions Additional parameters for the operation
* @return the PagedList<SearchServiceInner> object if successful.
*/
public PagedList<SearchServiceInner> list(SearchManagementRequestOptions searchManagementRequestOptions) {
PageImpl<SearchServiceInner> page = new PageImpl<>();
page.setItems(listWithServiceResponseAsync(searchManagementRequestOptions).toBlocking().single().body());
page.setNextPageLink(null);
return new PagedList<SearchServiceInner>(page) {
@Override
public Page<SearchServiceInner> nextPage(String nextPageLink) {
return null;
}
};
}

/**
* Gets a list of all Search services in the given subscription.
*
* @param searchManagementRequestOptions Additional parameters for the operation
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
* @return the {@link ServiceFuture} object
*/
public ServiceFuture<List<SearchServiceInner>> listAsync(SearchManagementRequestOptions searchManagementRequestOptions, final ServiceCallback<List<SearchServiceInner>> serviceCallback) {
return ServiceFuture.fromResponse(listWithServiceResponseAsync(searchManagementRequestOptions), serviceCallback);
}

/**
* Gets a list of all Search services in the given subscription.
*
* @param searchManagementRequestOptions Additional parameters for the operation
* @return the observable to the List&lt;SearchServiceInner&gt; object
*/
public Observable<Page<SearchServiceInner>> listAsync(SearchManagementRequestOptions searchManagementRequestOptions) {
return listWithServiceResponseAsync(searchManagementRequestOptions).map(new Func1<ServiceResponse<List<SearchServiceInner>>, Page<SearchServiceInner>>() {
@Override
public Page<SearchServiceInner> call(ServiceResponse<List<SearchServiceInner>> response) {
PageImpl<SearchServiceInner> page = new PageImpl<>();
page.setItems(response.body());
return page;
}
});
}

/**
* Gets a list of all Search services in the given subscription.
*
* @param searchManagementRequestOptions Additional parameters for the operation
* @return the observable to the List&lt;SearchServiceInner&gt; object
*/
public Observable<ServiceResponse<List<SearchServiceInner>>> listWithServiceResponseAsync(SearchManagementRequestOptions searchManagementRequestOptions) {
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.");
}
Validator.validate(searchManagementRequestOptions);
UUID clientRequestId = null;
if (searchManagementRequestOptions != null) {
clientRequestId = searchManagementRequestOptions.clientRequestId();
}
return service.list(this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), clientRequestId, this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<List<SearchServiceInner>>>>() {
@Override
public Observable<ServiceResponse<List<SearchServiceInner>>> call(Response<ResponseBody> response) {
try {
ServiceResponse<PageImpl<SearchServiceInner>> result = listDelegate(response);
List<SearchServiceInner> items = null;
if (result.body() != null) {
items = result.body().items();
}
ServiceResponse<List<SearchServiceInner>> clientResponse = new ServiceResponse<List<SearchServiceInner>>(items, result.response());
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}

private ServiceResponse<PageImpl<SearchServiceInner>> listDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<PageImpl<SearchServiceInner>, CloudException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<PageImpl<SearchServiceInner>>() { }.getType())
.registerError(CloudException.class)
.build(response);
}

/**
* Checks whether or not the given Search service name is available for use. Search service names must be globally unique since they are part of the service URI (https://&lt;name&gt;.search.windows.net).
*
Expand Down