![JAR search and dependency download from the Maven repository](/logo.png)
com.microsoft.azure.management.monitor.implementation.ActionGroupsInner Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-mgmt-monitor Show documentation
Show all versions of azure-mgmt-monitor Show documentation
This package contains Microsoft Azure Monitor SDK.
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
*/
package com.microsoft.azure.management.monitor.implementation;
import com.microsoft.azure.management.resources.fluentcore.collection.InnerSupportsGet;
import com.microsoft.azure.management.resources.fluentcore.collection.InnerSupportsDelete;
import com.microsoft.azure.management.resources.fluentcore.collection.InnerSupportsListing;
import retrofit2.Retrofit;
import com.google.common.reflect.TypeToken;
import com.microsoft.azure.management.monitor.ActionGroupPatchBody;
import com.microsoft.azure.management.monitor.EnableRequest;
import com.microsoft.azure.management.monitor.ErrorResponseException;
import com.microsoft.azure.Page;
import com.microsoft.azure.PagedList;
import com.microsoft.rest.ServiceCallback;
import com.microsoft.rest.ServiceFuture;
import com.microsoft.rest.ServiceResponse;
import com.microsoft.rest.Validator;
import java.io.IOException;
import java.util.List;
import okhttp3.ResponseBody;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.HTTP;
import retrofit2.http.PATCH;
import retrofit2.http.Path;
import retrofit2.http.POST;
import retrofit2.http.PUT;
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
* in ActionGroups.
*/
public class ActionGroupsInner implements InnerSupportsGet, InnerSupportsDelete, InnerSupportsListing {
/** The Retrofit service to perform REST calls. */
private ActionGroupsService service;
/** The service client containing this operation class. */
private MonitorManagementClientImpl client;
/**
* Initializes an instance of ActionGroupsInner.
*
* @param retrofit the Retrofit instance built from a Retrofit Builder.
* @param client the instance of the service client containing this operation class.
*/
public ActionGroupsInner(Retrofit retrofit, MonitorManagementClientImpl client) {
this.service = retrofit.create(ActionGroupsService.class);
this.client = client;
}
/**
* The interface defining all the services for ActionGroups to be
* used by Retrofit to perform actually REST calls.
*/
interface ActionGroupsService {
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.monitor.ActionGroups createOrUpdate" })
@PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}")
Observable> createOrUpdate(@Path("resourceGroupName") String resourceGroupName, @Path("actionGroupName") String actionGroupName, @Path("subscriptionId") String subscriptionId, @Body ActionGroupResourceInner actionGroup, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.monitor.ActionGroups getByResourceGroup" })
@GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}")
Observable> getByResourceGroup(@Path("resourceGroupName") String resourceGroupName, @Path("actionGroupName") String actionGroupName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.monitor.ActionGroups delete" })
@HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", method = "DELETE", hasBody = true)
Observable> delete(@Path("resourceGroupName") String resourceGroupName, @Path("actionGroupName") String actionGroupName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.monitor.ActionGroups update" })
@PATCH("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}")
Observable> update(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("actionGroupName") String actionGroupName, @Query("api-version") String apiVersion, @Body ActionGroupPatchBody actionGroupPatch, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.monitor.ActionGroups list" })
@GET("subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups")
Observable> list(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.monitor.ActionGroups listByResourceGroup" })
@GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups")
Observable> listByResourceGroup(@Path("resourceGroupName") String resourceGroupName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.monitor.ActionGroups enableReceiver" })
@POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe")
Observable> enableReceiver(@Path("resourceGroupName") String resourceGroupName, @Path("actionGroupName") String actionGroupName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body EnableRequest enableRequest, @Header("User-Agent") String userAgent);
}
/**
* Create a new action group or update an existing one.
*
* @param resourceGroupName The name of the resource group.
* @param actionGroupName The name of the action group.
* @param actionGroup The action group to create or use for the update.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws ErrorResponseException thrown if the request is rejected by server
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the ActionGroupResourceInner object if successful.
*/
public ActionGroupResourceInner createOrUpdate(String resourceGroupName, String actionGroupName, ActionGroupResourceInner actionGroup) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, actionGroupName, actionGroup).toBlocking().single().body();
}
/**
* Create a new action group or update an existing one.
*
* @param resourceGroupName The name of the resource group.
* @param actionGroupName The name of the action group.
* @param actionGroup The action group to create or use for the update.
* @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 createOrUpdateAsync(String resourceGroupName, String actionGroupName, ActionGroupResourceInner actionGroup, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(createOrUpdateWithServiceResponseAsync(resourceGroupName, actionGroupName, actionGroup), serviceCallback);
}
/**
* Create a new action group or update an existing one.
*
* @param resourceGroupName The name of the resource group.
* @param actionGroupName The name of the action group.
* @param actionGroup The action group to create or use for the update.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the ActionGroupResourceInner object
*/
public Observable createOrUpdateAsync(String resourceGroupName, String actionGroupName, ActionGroupResourceInner actionGroup) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, actionGroupName, actionGroup).map(new Func1, ActionGroupResourceInner>() {
@Override
public ActionGroupResourceInner call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Create a new action group or update an existing one.
*
* @param resourceGroupName The name of the resource group.
* @param actionGroupName The name of the action group.
* @param actionGroup The action group to create or use for the update.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the ActionGroupResourceInner object
*/
public Observable> createOrUpdateWithServiceResponseAsync(String resourceGroupName, String actionGroupName, ActionGroupResourceInner actionGroup) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (actionGroupName == null) {
throw new IllegalArgumentException("Parameter actionGroupName is required and cannot be null.");
}
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
if (actionGroup == null) {
throw new IllegalArgumentException("Parameter actionGroup is required and cannot be null.");
}
Validator.validate(actionGroup);
final String apiVersion = "2019-06-01";
return service.createOrUpdate(resourceGroupName, actionGroupName, this.client.subscriptionId(), actionGroup, apiVersion, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1, Observable>>() {
@Override
public Observable> call(Response response) {
try {
ServiceResponse clientResponse = createOrUpdateDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse createOrUpdateDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter())
.register(200, new TypeToken() { }.getType())
.register(201, new TypeToken() { }.getType())
.registerError(ErrorResponseException.class)
.build(response);
}
/**
* Get an action group.
*
* @param resourceGroupName The name of the resource group.
* @param actionGroupName The name of the action group.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws ErrorResponseException thrown if the request is rejected by server
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the ActionGroupResourceInner object if successful.
*/
public ActionGroupResourceInner getByResourceGroup(String resourceGroupName, String actionGroupName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, actionGroupName).toBlocking().single().body();
}
/**
* Get an action group.
*
* @param resourceGroupName The name of the resource group.
* @param actionGroupName The name of the action group.
* @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 getByResourceGroupAsync(String resourceGroupName, String actionGroupName, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(getByResourceGroupWithServiceResponseAsync(resourceGroupName, actionGroupName), serviceCallback);
}
/**
* Get an action group.
*
* @param resourceGroupName The name of the resource group.
* @param actionGroupName The name of the action group.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the ActionGroupResourceInner object
*/
public Observable getByResourceGroupAsync(String resourceGroupName, String actionGroupName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, actionGroupName).map(new Func1, ActionGroupResourceInner>() {
@Override
public ActionGroupResourceInner call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Get an action group.
*
* @param resourceGroupName The name of the resource group.
* @param actionGroupName The name of the action group.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the ActionGroupResourceInner object
*/
public Observable> getByResourceGroupWithServiceResponseAsync(String resourceGroupName, String actionGroupName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (actionGroupName == null) {
throw new IllegalArgumentException("Parameter actionGroupName is required and cannot be null.");
}
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
final String apiVersion = "2019-06-01";
return service.getByResourceGroup(resourceGroupName, actionGroupName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1, Observable>>() {
@Override
public Observable> call(Response response) {
try {
ServiceResponse clientResponse = getByResourceGroupDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse getByResourceGroupDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter())
.register(200, new TypeToken() { }.getType())
.registerError(ErrorResponseException.class)
.build(response);
}
/**
* Delete an action group.
*
* @param resourceGroupName The name of the resource group.
* @param actionGroupName The name of the action group.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws ErrorResponseException thrown if the request is rejected by server
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
*/
public void delete(String resourceGroupName, String actionGroupName) {
deleteWithServiceResponseAsync(resourceGroupName, actionGroupName).toBlocking().single().body();
}
/**
* Delete an action group.
*
* @param resourceGroupName The name of the resource group.
* @param actionGroupName The name of the action group.
* @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 deleteAsync(String resourceGroupName, String actionGroupName, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(resourceGroupName, actionGroupName), serviceCallback);
}
/**
* Delete an action group.
*
* @param resourceGroupName The name of the resource group.
* @param actionGroupName The name of the action group.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable deleteAsync(String resourceGroupName, String actionGroupName) {
return deleteWithServiceResponseAsync(resourceGroupName, actionGroupName).map(new Func1, Void>() {
@Override
public Void call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Delete an action group.
*
* @param resourceGroupName The name of the resource group.
* @param actionGroupName The name of the action group.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable> deleteWithServiceResponseAsync(String resourceGroupName, String actionGroupName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (actionGroupName == null) {
throw new IllegalArgumentException("Parameter actionGroupName is required and cannot be null.");
}
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
final String apiVersion = "2019-06-01";
return service.delete(resourceGroupName, actionGroupName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1, Observable>>() {
@Override
public Observable> call(Response response) {
try {
ServiceResponse clientResponse = deleteDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse deleteDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter())
.register(200, new TypeToken() { }.getType())
.register(204, new TypeToken() { }.getType())
.registerError(ErrorResponseException.class)
.build(response);
}
/**
* Updates an existing action group's tags. To update other fields use the CreateOrUpdate method.
*
* @param resourceGroupName The name of the resource group.
* @param actionGroupName The name of the action group.
* @param actionGroupPatch Parameters supplied to the operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws ErrorResponseException thrown if the request is rejected by server
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the ActionGroupResourceInner object if successful.
*/
public ActionGroupResourceInner update(String resourceGroupName, String actionGroupName, ActionGroupPatchBody actionGroupPatch) {
return updateWithServiceResponseAsync(resourceGroupName, actionGroupName, actionGroupPatch).toBlocking().single().body();
}
/**
* Updates an existing action group's tags. To update other fields use the CreateOrUpdate method.
*
* @param resourceGroupName The name of the resource group.
* @param actionGroupName The name of the action group.
* @param actionGroupPatch Parameters supplied to the operation.
* @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 updateAsync(String resourceGroupName, String actionGroupName, ActionGroupPatchBody actionGroupPatch, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(updateWithServiceResponseAsync(resourceGroupName, actionGroupName, actionGroupPatch), serviceCallback);
}
/**
* Updates an existing action group's tags. To update other fields use the CreateOrUpdate method.
*
* @param resourceGroupName The name of the resource group.
* @param actionGroupName The name of the action group.
* @param actionGroupPatch Parameters supplied to the operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the ActionGroupResourceInner object
*/
public Observable updateAsync(String resourceGroupName, String actionGroupName, ActionGroupPatchBody actionGroupPatch) {
return updateWithServiceResponseAsync(resourceGroupName, actionGroupName, actionGroupPatch).map(new Func1, ActionGroupResourceInner>() {
@Override
public ActionGroupResourceInner call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Updates an existing action group's tags. To update other fields use the CreateOrUpdate method.
*
* @param resourceGroupName The name of the resource group.
* @param actionGroupName The name of the action group.
* @param actionGroupPatch Parameters supplied to the operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the ActionGroupResourceInner object
*/
public Observable> updateWithServiceResponseAsync(String resourceGroupName, String actionGroupName, ActionGroupPatchBody actionGroupPatch) {
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (actionGroupName == null) {
throw new IllegalArgumentException("Parameter actionGroupName is required and cannot be null.");
}
if (actionGroupPatch == null) {
throw new IllegalArgumentException("Parameter actionGroupPatch is required and cannot be null.");
}
Validator.validate(actionGroupPatch);
final String apiVersion = "2019-06-01";
return service.update(this.client.subscriptionId(), resourceGroupName, actionGroupName, apiVersion, actionGroupPatch, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1, Observable>>() {
@Override
public Observable> call(Response response) {
try {
ServiceResponse clientResponse = updateDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse updateDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter())
.register(200, new TypeToken() { }.getType())
.registerError(ErrorResponseException.class)
.build(response);
}
/**
* Get a list of all action groups in a subscription.
*
* @return the PagedList object if successful.
*/
public PagedList list() {
PageImpl1 page = new PageImpl1<>();
page.setItems(listWithServiceResponseAsync().toBlocking().single().body());
page.setNextPageLink(null);
return new PagedList(page) {
@Override
public Page nextPage(String nextPageLink) {
return null;
}
};
}
/**
* Get a list of all action groups in a subscription.
*
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
* @return the {@link ServiceFuture} object
*/
public ServiceFuture> listAsync(final ServiceCallback> serviceCallback) {
return ServiceFuture.fromResponse(listWithServiceResponseAsync(), serviceCallback);
}
/**
* Get a list of all action groups in a subscription.
*
* @return the observable to the List<ActionGroupResourceInner> object
*/
public Observable> listAsync() {
return listWithServiceResponseAsync().map(new Func1>, Page>() {
@Override
public Page call(ServiceResponse> response) {
PageImpl1 page = new PageImpl1<>();
page.setItems(response.body());
return page;
}
});
}
/**
* Get a list of all action groups in a subscription.
*
* @return the observable to the List<ActionGroupResourceInner> object
*/
public Observable>> listWithServiceResponseAsync() {
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
final String apiVersion = "2019-06-01";
return service.list(this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1, Observable>>>() {
@Override
public Observable>> call(Response response) {
try {
ServiceResponse> result = listDelegate(response);
List items = null;
if (result.body() != null) {
items = result.body().items();
}
ServiceResponse> clientResponse = new ServiceResponse>(items, result.response());
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse> listDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken>() { }.getType())
.registerError(ErrorResponseException.class)
.build(response);
}
/**
* Get a list of all action groups in a resource group.
*
* @param resourceGroupName The name of the resource group.
* @return the PagedList object if successful.
*/
public PagedList listByResourceGroup(String resourceGroupName) {
PageImpl1 page = new PageImpl1<>();
page.setItems(listByResourceGroupWithServiceResponseAsync(resourceGroupName).toBlocking().single().body());
page.setNextPageLink(null);
return new PagedList(page) {
@Override
public Page nextPage(String nextPageLink) {
return null;
}
};
}
/**
* Get a list of all action groups in a resource group.
*
* @param resourceGroupName The name of the resource group.
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
* @return the {@link ServiceFuture} object
*/
public ServiceFuture> listByResourceGroupAsync(String resourceGroupName, final ServiceCallback> serviceCallback) {
return ServiceFuture.fromResponse(listByResourceGroupWithServiceResponseAsync(resourceGroupName), serviceCallback);
}
/**
* Get a list of all action groups in a resource group.
*
* @param resourceGroupName The name of the resource group.
* @return the observable to the List<ActionGroupResourceInner> object
*/
public Observable> listByResourceGroupAsync(String resourceGroupName) {
return listByResourceGroupWithServiceResponseAsync(resourceGroupName).map(new Func1>, Page>() {
@Override
public Page call(ServiceResponse> response) {
PageImpl1 page = new PageImpl1<>();
page.setItems(response.body());
return page;
}
});
}
/**
* Get a list of all action groups in a resource group.
*
* @param resourceGroupName The name of the resource group.
* @return the observable to the List<ActionGroupResourceInner> object
*/
public Observable>> listByResourceGroupWithServiceResponseAsync(String resourceGroupName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
final String apiVersion = "2019-06-01";
return service.listByResourceGroup(resourceGroupName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1, Observable>>>() {
@Override
public Observable>> call(Response response) {
try {
ServiceResponse> result = listByResourceGroupDelegate(response);
List items = null;
if (result.body() != null) {
items = result.body().items();
}
ServiceResponse> clientResponse = new ServiceResponse>(items, result.response());
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse> listByResourceGroupDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken>() { }.getType())
.registerError(ErrorResponseException.class)
.build(response);
}
/**
* Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers.
*
* @param resourceGroupName The name of the resource group.
* @param actionGroupName The name of the action group.
* @param receiverName The name of the receiver to resubscribe.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws ErrorResponseException thrown if the request is rejected by server
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
*/
public void enableReceiver(String resourceGroupName, String actionGroupName, String receiverName) {
enableReceiverWithServiceResponseAsync(resourceGroupName, actionGroupName, receiverName).toBlocking().single().body();
}
/**
* Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers.
*
* @param resourceGroupName The name of the resource group.
* @param actionGroupName The name of the action group.
* @param receiverName The name of the receiver to resubscribe.
* @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 enableReceiverAsync(String resourceGroupName, String actionGroupName, String receiverName, final ServiceCallback serviceCallback) {
return ServiceFuture.fromResponse(enableReceiverWithServiceResponseAsync(resourceGroupName, actionGroupName, receiverName), serviceCallback);
}
/**
* Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers.
*
* @param resourceGroupName The name of the resource group.
* @param actionGroupName The name of the action group.
* @param receiverName The name of the receiver to resubscribe.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable enableReceiverAsync(String resourceGroupName, String actionGroupName, String receiverName) {
return enableReceiverWithServiceResponseAsync(resourceGroupName, actionGroupName, receiverName).map(new Func1, Void>() {
@Override
public Void call(ServiceResponse response) {
return response.body();
}
});
}
/**
* Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers.
*
* @param resourceGroupName The name of the resource group.
* @param actionGroupName The name of the action group.
* @param receiverName The name of the receiver to resubscribe.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable> enableReceiverWithServiceResponseAsync(String resourceGroupName, String actionGroupName, String receiverName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (actionGroupName == null) {
throw new IllegalArgumentException("Parameter actionGroupName is required and cannot be null.");
}
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
if (receiverName == null) {
throw new IllegalArgumentException("Parameter receiverName is required and cannot be null.");
}
final String apiVersion = "2019-06-01";
EnableRequest enableRequest = new EnableRequest();
enableRequest.withReceiverName(receiverName);
return service.enableReceiver(resourceGroupName, actionGroupName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), enableRequest, this.client.userAgent())
.flatMap(new Func1, Observable>>() {
@Override
public Observable> call(Response response) {
try {
ServiceResponse clientResponse = enableReceiverDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse enableReceiverDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter())
.register(200, new TypeToken() { }.getType())
.register(409, new TypeToken() { }.getType())
.registerError(ErrorResponseException.class)
.build(response);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy