/**
* 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.compute.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.AzureServiceFuture;
import com.microsoft.azure.CloudException;
import com.microsoft.azure.ListOperationCallback;
import com.microsoft.azure.management.compute.InstanceViewTypes;
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.Path;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Query;
import retrofit2.http.Url;
import retrofit2.Response;
import rx.functions.Func1;
import rx.Observable;
/**
* An instance of this class provides access to all the operations defined
* in VirtualMachines.
*/
public class VirtualMachinesInner implements InnerSupportsGet<VirtualMachineInner>, InnerSupportsDelete<OperationStatusResponseInner>, InnerSupportsListing<VirtualMachineInner> {
/** The Retrofit service to perform REST calls. */
private VirtualMachinesService service;
/** The service client containing this operation class. */
private ComputeManagementClientImpl client;
/**
* Initializes an instance of VirtualMachinesInner.
*
* @param retrofit the Retrofit instance built from a Retrofit Builder.
* @param client the instance of the service client containing this operation class.
*/
public VirtualMachinesInner(Retrofit retrofit, ComputeManagementClientImpl client) {
this.service = retrofit.create(VirtualMachinesService.class);
this.client = client;
}
/**
* The interface defining all the services for VirtualMachines to be
* used by Retrofit to perform actually REST calls.
*/
interface VirtualMachinesService {
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.compute.VirtualMachines capture" })
@POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture")
Observable<Response<ResponseBody>> capture(@Path("resourceGroupName") String resourceGroupName, @Path("vmName") String vmName, @Path("subscriptionId") String subscriptionId, @Body VirtualMachineCaptureParametersInner parameters, @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.compute.VirtualMachines beginCapture" })
@POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture")
Observable<Response<ResponseBody>> beginCapture(@Path("resourceGroupName") String resourceGroupName, @Path("vmName") String vmName, @Path("subscriptionId") String subscriptionId, @Body VirtualMachineCaptureParametersInner parameters, @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.compute.VirtualMachines createOrUpdate" })
@PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}")
Observable<Response<ResponseBody>> createOrUpdate(@Path("resourceGroupName") String resourceGroupName, @Path("vmName") String vmName, @Path("subscriptionId") String subscriptionId, @Body VirtualMachineInner parameters, @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.compute.VirtualMachines beginCreateOrUpdate" })
@PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}")
Observable<Response<ResponseBody>> beginCreateOrUpdate(@Path("resourceGroupName") String resourceGroupName, @Path("vmName") String vmName, @Path("subscriptionId") String subscriptionId, @Body VirtualMachineInner parameters, @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.compute.VirtualMachines delete" })
@HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", method = "DELETE", hasBody = true)
Observable<Response<ResponseBody>> delete(@Path("resourceGroupName") String resourceGroupName, @Path("vmName") String vmName, @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.compute.VirtualMachines beginDelete" })
@HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", method = "DELETE", hasBody = true)
Observable<Response<ResponseBody>> beginDelete(@Path("resourceGroupName") String resourceGroupName, @Path("vmName") String vmName, @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.compute.VirtualMachines getByResourceGroup" })
@GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}")
Observable<Response<ResponseBody>> getByResourceGroup(@Path("resourceGroupName") String resourceGroupName, @Path("vmName") String vmName, @Path("subscriptionId") String subscriptionId, @Query("$expand") InstanceViewTypes expand, @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.compute.VirtualMachines convertToManagedDisks" })
@POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks")
Observable<Response<ResponseBody>> convertToManagedDisks(@Path("resourceGroupName") String resourceGroupName, @Path("vmName") String vmName, @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.compute.VirtualMachines beginConvertToManagedDisks" })
@POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks")
Observable<Response<ResponseBody>> beginConvertToManagedDisks(@Path("resourceGroupName") String resourceGroupName, @Path("vmName") String vmName, @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.compute.VirtualMachines deallocate" })
@POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate")
Observable<Response<ResponseBody>> deallocate(@Path("resourceGroupName") String resourceGroupName, @Path("vmName") String vmName, @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.compute.VirtualMachines beginDeallocate" })
@POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate")
Observable<Response<ResponseBody>> beginDeallocate(@Path("resourceGroupName") String resourceGroupName, @Path("vmName") String vmName, @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.compute.VirtualMachines generalize" })
@POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize")
Observable<Response<ResponseBody>> generalize(@Path("resourceGroupName") String resourceGroupName, @Path("vmName") String vmName, @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.compute.VirtualMachines listByResourceGroup" })
@GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines")
Observable<Response<ResponseBody>> 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.compute.VirtualMachines list" })
@GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines")
Observable<Response<ResponseBody>> 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.compute.VirtualMachines listAvailableSizes" })
@GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes")
Observable<Response<ResponseBody>> listAvailableSizes(@Path("resourceGroupName") String resourceGroupName, @Path("vmName") String vmName, @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.compute.VirtualMachines powerOff" })
@POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff")
Observable<Response<ResponseBody>> powerOff(@Path("resourceGroupName") String resourceGroupName, @Path("vmName") String vmName, @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.compute.VirtualMachines beginPowerOff" })
@POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff")
Observable<Response<ResponseBody>> beginPowerOff(@Path("resourceGroupName") String resourceGroupName, @Path("vmName") String vmName, @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.compute.VirtualMachines restart" })
@POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart")
Observable<Response<ResponseBody>> restart(@Path("resourceGroupName") String resourceGroupName, @Path("vmName") String vmName, @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.compute.VirtualMachines beginRestart" })
@POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart")
Observable<Response<ResponseBody>> beginRestart(@Path("resourceGroupName") String resourceGroupName, @Path("vmName") String vmName, @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.compute.VirtualMachines start" })
@POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start")
Observable<Response<ResponseBody>> start(@Path("resourceGroupName") String resourceGroupName, @Path("vmName") String vmName, @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.compute.VirtualMachines beginStart" })
@POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start")
Observable<Response<ResponseBody>> beginStart(@Path("resourceGroupName") String resourceGroupName, @Path("vmName") String vmName, @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.compute.VirtualMachines redeploy" })
@POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy")
Observable<Response<ResponseBody>> redeploy(@Path("resourceGroupName") String resourceGroupName, @Path("vmName") String vmName, @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.compute.VirtualMachines beginRedeploy" })
@POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy")
Observable<Response<ResponseBody>> beginRedeploy(@Path("resourceGroupName") String resourceGroupName, @Path("vmName") String vmName, @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.compute.VirtualMachines listByResourceGroupNext" })
@GET
Observable<Response<ResponseBody>> listByResourceGroupNext(@Url String nextUrl, @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.compute.VirtualMachines listNext" })
@GET
Observable<Response<ResponseBody>> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
}
/**
* Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @param parameters Parameters supplied to the Capture Virtual Machine operation.
* @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 VirtualMachineCaptureResultInner object if successful.
*/
public VirtualMachineCaptureResultInner capture(String resourceGroupName, String vmName, VirtualMachineCaptureParametersInner parameters) {
return captureWithServiceResponseAsync(resourceGroupName, vmName, parameters).toBlocking().last().body();
}
/**
* Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @param parameters Parameters supplied to the Capture Virtual Machine 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<VirtualMachineCaptureResultInner> captureAsync(String resourceGroupName, String vmName, VirtualMachineCaptureParametersInner parameters, final ServiceCallback<VirtualMachineCaptureResultInner> serviceCallback) {
return ServiceFuture.fromResponse(captureWithServiceResponseAsync(resourceGroupName, vmName, parameters), serviceCallback);
}
/**
* Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @param parameters Parameters supplied to the Capture Virtual Machine operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<VirtualMachineCaptureResultInner> captureAsync(String resourceGroupName, String vmName, VirtualMachineCaptureParametersInner parameters) {
return captureWithServiceResponseAsync(resourceGroupName, vmName, parameters).map(new Func1<ServiceResponse<VirtualMachineCaptureResultInner>, VirtualMachineCaptureResultInner>() {
@Override
public VirtualMachineCaptureResultInner call(ServiceResponse<VirtualMachineCaptureResultInner> response) {
return response.body();
}
});
}
/**
* Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @param parameters Parameters supplied to the Capture Virtual Machine operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<ServiceResponse<VirtualMachineCaptureResultInner>> captureWithServiceResponseAsync(String resourceGroupName, String vmName, VirtualMachineCaptureParametersInner parameters) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (vmName == null) {
throw new IllegalArgumentException("Parameter vmName 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 (parameters == null) {
throw new IllegalArgumentException("Parameter parameters is required and cannot be null.");
}
Validator.validate(parameters);
final String apiVersion = "2016-04-30-preview";
Observable<Response<ResponseBody>> observable = service.capture(resourceGroupName, vmName, this.client.subscriptionId(), parameters, apiVersion, this.client.acceptLanguage(), this.client.userAgent());
return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken<VirtualMachineCaptureResultInner>() { }.getType());
}
/**
* Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @param parameters Parameters supplied to the Capture Virtual Machine operation.
* @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 VirtualMachineCaptureResultInner object if successful.
*/
public VirtualMachineCaptureResultInner beginCapture(String resourceGroupName, String vmName, VirtualMachineCaptureParametersInner parameters) {
return beginCaptureWithServiceResponseAsync(resourceGroupName, vmName, parameters).toBlocking().single().body();
}
/**
* Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @param parameters Parameters supplied to the Capture Virtual Machine 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<VirtualMachineCaptureResultInner> beginCaptureAsync(String resourceGroupName, String vmName, VirtualMachineCaptureParametersInner parameters, final ServiceCallback<VirtualMachineCaptureResultInner> serviceCallback) {
return ServiceFuture.fromResponse(beginCaptureWithServiceResponseAsync(resourceGroupName, vmName, parameters), serviceCallback);
}
/**
* Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @param parameters Parameters supplied to the Capture Virtual Machine operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the VirtualMachineCaptureResultInner object
*/
public Observable<VirtualMachineCaptureResultInner> beginCaptureAsync(String resourceGroupName, String vmName, VirtualMachineCaptureParametersInner parameters) {
return beginCaptureWithServiceResponseAsync(resourceGroupName, vmName, parameters).map(new Func1<ServiceResponse<VirtualMachineCaptureResultInner>, VirtualMachineCaptureResultInner>() {
@Override
public VirtualMachineCaptureResultInner call(ServiceResponse<VirtualMachineCaptureResultInner> response) {
return response.body();
}
});
}
/**
* Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @param parameters Parameters supplied to the Capture Virtual Machine operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the VirtualMachineCaptureResultInner object
*/
public Observable<ServiceResponse<VirtualMachineCaptureResultInner>> beginCaptureWithServiceResponseAsync(String resourceGroupName, String vmName, VirtualMachineCaptureParametersInner parameters) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (vmName == null) {
throw new IllegalArgumentException("Parameter vmName 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 (parameters == null) {
throw new IllegalArgumentException("Parameter parameters is required and cannot be null.");
}
Validator.validate(parameters);
final String apiVersion = "2016-04-30-preview";
return service.beginCapture(resourceGroupName, vmName, this.client.subscriptionId(), parameters, apiVersion, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<VirtualMachineCaptureResultInner>>>() {
@Override
public Observable<ServiceResponse<VirtualMachineCaptureResultInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<VirtualMachineCaptureResultInner> clientResponse = beginCaptureDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse<VirtualMachineCaptureResultInner> beginCaptureDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<VirtualMachineCaptureResultInner, CloudException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<VirtualMachineCaptureResultInner>() { }.getType())
.register(202, new TypeToken<Void>() { }.getType())
.registerError(CloudException.class)
.build(response);
}
/**
* The operation to create or update a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @param parameters Parameters supplied to the Create Virtual Machine operation.
* @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 VirtualMachineInner object if successful.
*/
public VirtualMachineInner createOrUpdate(String resourceGroupName, String vmName, VirtualMachineInner parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, vmName, parameters).toBlocking().last().body();
}
/**
* The operation to create or update a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @param parameters Parameters supplied to the Create Virtual Machine 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<VirtualMachineInner> createOrUpdateAsync(String resourceGroupName, String vmName, VirtualMachineInner parameters, final ServiceCallback<VirtualMachineInner> serviceCallback) {
return ServiceFuture.fromResponse(createOrUpdateWithServiceResponseAsync(resourceGroupName, vmName, parameters), serviceCallback);
}
/**
* The operation to create or update a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @param parameters Parameters supplied to the Create Virtual Machine operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<VirtualMachineInner> createOrUpdateAsync(String resourceGroupName, String vmName, VirtualMachineInner parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, vmName, parameters).map(new Func1<ServiceResponse<VirtualMachineInner>, VirtualMachineInner>() {
@Override
public VirtualMachineInner call(ServiceResponse<VirtualMachineInner> response) {
return response.body();
}
});
}
/**
* The operation to create or update a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @param parameters Parameters supplied to the Create Virtual Machine operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<ServiceResponse<VirtualMachineInner>> createOrUpdateWithServiceResponseAsync(String resourceGroupName, String vmName, VirtualMachineInner parameters) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (vmName == null) {
throw new IllegalArgumentException("Parameter vmName 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 (parameters == null) {
throw new IllegalArgumentException("Parameter parameters is required and cannot be null.");
}
Validator.validate(parameters);
final String apiVersion = "2016-04-30-preview";
Observable<Response<ResponseBody>> observable = service.createOrUpdate(resourceGroupName, vmName, this.client.subscriptionId(), parameters, apiVersion, this.client.acceptLanguage(), this.client.userAgent());
return client.getAzureClient().getPutOrPatchResultAsync(observable, new TypeToken<VirtualMachineInner>() { }.getType());
}
/**
* The operation to create or update a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @param parameters Parameters supplied to the Create Virtual Machine operation.
* @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 VirtualMachineInner object if successful.
*/
public VirtualMachineInner beginCreateOrUpdate(String resourceGroupName, String vmName, VirtualMachineInner parameters) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, vmName, parameters).toBlocking().single().body();
}
/**
* The operation to create or update a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @param parameters Parameters supplied to the Create Virtual Machine 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<VirtualMachineInner> beginCreateOrUpdateAsync(String resourceGroupName, String vmName, VirtualMachineInner parameters, final ServiceCallback<VirtualMachineInner> serviceCallback) {
return ServiceFuture.fromResponse(beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, vmName, parameters), serviceCallback);
}
/**
* The operation to create or update a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @param parameters Parameters supplied to the Create Virtual Machine operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the VirtualMachineInner object
*/
public Observable<VirtualMachineInner> beginCreateOrUpdateAsync(String resourceGroupName, String vmName, VirtualMachineInner parameters) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, vmName, parameters).map(new Func1<ServiceResponse<VirtualMachineInner>, VirtualMachineInner>() {
@Override
public VirtualMachineInner call(ServiceResponse<VirtualMachineInner> response) {
return response.body();
}
});
}
/**
* The operation to create or update a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @param parameters Parameters supplied to the Create Virtual Machine operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the VirtualMachineInner object
*/
public Observable<ServiceResponse<VirtualMachineInner>> beginCreateOrUpdateWithServiceResponseAsync(String resourceGroupName, String vmName, VirtualMachineInner parameters) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (vmName == null) {
throw new IllegalArgumentException("Parameter vmName 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 (parameters == null) {
throw new IllegalArgumentException("Parameter parameters is required and cannot be null.");
}
Validator.validate(parameters);
final String apiVersion = "2016-04-30-preview";
return service.beginCreateOrUpdate(resourceGroupName, vmName, this.client.subscriptionId(), parameters, apiVersion, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<VirtualMachineInner>>>() {
@Override
public Observable<ServiceResponse<VirtualMachineInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<VirtualMachineInner> clientResponse = beginCreateOrUpdateDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse<VirtualMachineInner> beginCreateOrUpdateDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<VirtualMachineInner, CloudException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<VirtualMachineInner>() { }.getType())
.register(201, new TypeToken<VirtualMachineInner>() { }.getType())
.registerError(CloudException.class)
.build(response);
}
/**
* The operation to delete a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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 OperationStatusResponseInner object if successful.
*/
public OperationStatusResponseInner delete(String resourceGroupName, String vmName) {
return deleteWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().last().body();
}
/**
* The operation to delete a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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<OperationStatusResponseInner> deleteAsync(String resourceGroupName, String vmName, final ServiceCallback<OperationStatusResponseInner> serviceCallback) {
return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(resourceGroupName, vmName), serviceCallback);
}
/**
* The operation to delete a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<OperationStatusResponseInner> deleteAsync(String resourceGroupName, String vmName) {
return deleteWithServiceResponseAsync(resourceGroupName, vmName).map(new Func1<ServiceResponse<OperationStatusResponseInner>, OperationStatusResponseInner>() {
@Override
public OperationStatusResponseInner call(ServiceResponse<OperationStatusResponseInner> response) {
return response.body();
}
});
}
/**
* The operation to delete a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<ServiceResponse<OperationStatusResponseInner>> deleteWithServiceResponseAsync(String resourceGroupName, String vmName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (vmName == null) {
throw new IllegalArgumentException("Parameter vmName 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 = "2016-04-30-preview";
Observable<Response<ResponseBody>> observable = service.delete(resourceGroupName, vmName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent());
return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken<OperationStatusResponseInner>() { }.getType());
}
/**
* The operation to delete a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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 OperationStatusResponseInner object if successful.
*/
public OperationStatusResponseInner beginDelete(String resourceGroupName, String vmName) {
return beginDeleteWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().single().body();
}
/**
* The operation to delete a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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<OperationStatusResponseInner> beginDeleteAsync(String resourceGroupName, String vmName, final ServiceCallback<OperationStatusResponseInner> serviceCallback) {
return ServiceFuture.fromResponse(beginDeleteWithServiceResponseAsync(resourceGroupName, vmName), serviceCallback);
}
/**
* The operation to delete a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the OperationStatusResponseInner object
*/
public Observable<OperationStatusResponseInner> beginDeleteAsync(String resourceGroupName, String vmName) {
return beginDeleteWithServiceResponseAsync(resourceGroupName, vmName).map(new Func1<ServiceResponse<OperationStatusResponseInner>, OperationStatusResponseInner>() {
@Override
public OperationStatusResponseInner call(ServiceResponse<OperationStatusResponseInner> response) {
return response.body();
}
});
}
/**
* The operation to delete a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the OperationStatusResponseInner object
*/
public Observable<ServiceResponse<OperationStatusResponseInner>> beginDeleteWithServiceResponseAsync(String resourceGroupName, String vmName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (vmName == null) {
throw new IllegalArgumentException("Parameter vmName 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 = "2016-04-30-preview";
return service.beginDelete(resourceGroupName, vmName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<OperationStatusResponseInner>>>() {
@Override
public Observable<ServiceResponse<OperationStatusResponseInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<OperationStatusResponseInner> clientResponse = beginDeleteDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse<OperationStatusResponseInner> beginDeleteDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<OperationStatusResponseInner, CloudException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<OperationStatusResponseInner>() { }.getType())
.register(202, new TypeToken<Void>() { }.getType())
.register(204, new TypeToken<Void>() { }.getType())
.registerError(CloudException.class)
.build(response);
}
/**
* Retrieves information about the model view or the instance view of a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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 VirtualMachineInner object if successful.
*/
public VirtualMachineInner getByResourceGroup(String resourceGroupName, String vmName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().single().body();
}
/**
* Retrieves information about the model view or the instance view of a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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<VirtualMachineInner> getByResourceGroupAsync(String resourceGroupName, String vmName, final ServiceCallback<VirtualMachineInner> serviceCallback) {
return ServiceFuture.fromResponse(getByResourceGroupWithServiceResponseAsync(resourceGroupName, vmName), serviceCallback);
}
/**
* Retrieves information about the model view or the instance view of a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the VirtualMachineInner object
*/
public Observable<VirtualMachineInner> getByResourceGroupAsync(String resourceGroupName, String vmName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, vmName).map(new Func1<ServiceResponse<VirtualMachineInner>, VirtualMachineInner>() {
@Override
public VirtualMachineInner call(ServiceResponse<VirtualMachineInner> response) {
return response.body();
}
});
}
/**
* Retrieves information about the model view or the instance view of a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the VirtualMachineInner object
*/
public Observable<ServiceResponse<VirtualMachineInner>> getByResourceGroupWithServiceResponseAsync(String resourceGroupName, String vmName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (vmName == null) {
throw new IllegalArgumentException("Parameter vmName 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 = "2016-04-30-preview";
final InstanceViewTypes expand = null;
return service.getByResourceGroup(resourceGroupName, vmName, this.client.subscriptionId(), expand, apiVersion, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<VirtualMachineInner>>>() {
@Override
public Observable<ServiceResponse<VirtualMachineInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<VirtualMachineInner> clientResponse = getByResourceGroupDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
/**
* Retrieves information about the model view or the instance view of a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @param expand The expand expression to apply on the operation. Possible values include: 'instanceView'
* @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 VirtualMachineInner object if successful.
*/
public VirtualMachineInner getByResourceGroup(String resourceGroupName, String vmName, InstanceViewTypes expand) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, vmName, expand).toBlocking().single().body();
}
/**
* Retrieves information about the model view or the instance view of a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @param expand The expand expression to apply on the operation. Possible values include: 'instanceView'
* @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<VirtualMachineInner> getByResourceGroupAsync(String resourceGroupName, String vmName, InstanceViewTypes expand, final ServiceCallback<VirtualMachineInner> serviceCallback) {
return ServiceFuture.fromResponse(getByResourceGroupWithServiceResponseAsync(resourceGroupName, vmName, expand), serviceCallback);
}
/**
* Retrieves information about the model view or the instance view of a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @param expand The expand expression to apply on the operation. Possible values include: 'instanceView'
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the VirtualMachineInner object
*/
public Observable<VirtualMachineInner> getByResourceGroupAsync(String resourceGroupName, String vmName, InstanceViewTypes expand) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, vmName, expand).map(new Func1<ServiceResponse<VirtualMachineInner>, VirtualMachineInner>() {
@Override
public VirtualMachineInner call(ServiceResponse<VirtualMachineInner> response) {
return response.body();
}
});
}
/**
* Retrieves information about the model view or the instance view of a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @param expand The expand expression to apply on the operation. Possible values include: 'instanceView'
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the VirtualMachineInner object
*/
public Observable<ServiceResponse<VirtualMachineInner>> getByResourceGroupWithServiceResponseAsync(String resourceGroupName, String vmName, InstanceViewTypes expand) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (vmName == null) {
throw new IllegalArgumentException("Parameter vmName 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 = "2016-04-30-preview";
return service.getByResourceGroup(resourceGroupName, vmName, this.client.subscriptionId(), expand, apiVersion, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<VirtualMachineInner>>>() {
@Override
public Observable<ServiceResponse<VirtualMachineInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<VirtualMachineInner> clientResponse = getByResourceGroupDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse<VirtualMachineInner> getByResourceGroupDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<VirtualMachineInner, CloudException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<VirtualMachineInner>() { }.getType())
.registerError(CloudException.class)
.build(response);
}
/**
* Converts virtual machine disks from blob-based to managed disks. Virtual machine must be stop-deallocated before invoking this operation.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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 OperationStatusResponseInner object if successful.
*/
public OperationStatusResponseInner convertToManagedDisks(String resourceGroupName, String vmName) {
return convertToManagedDisksWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().last().body();
}
/**
* Converts virtual machine disks from blob-based to managed disks. Virtual machine must be stop-deallocated before invoking this operation.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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<OperationStatusResponseInner> convertToManagedDisksAsync(String resourceGroupName, String vmName, final ServiceCallback<OperationStatusResponseInner> serviceCallback) {
return ServiceFuture.fromResponse(convertToManagedDisksWithServiceResponseAsync(resourceGroupName, vmName), serviceCallback);
}
/**
* Converts virtual machine disks from blob-based to managed disks. Virtual machine must be stop-deallocated before invoking this operation.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<OperationStatusResponseInner> convertToManagedDisksAsync(String resourceGroupName, String vmName) {
return convertToManagedDisksWithServiceResponseAsync(resourceGroupName, vmName).map(new Func1<ServiceResponse<OperationStatusResponseInner>, OperationStatusResponseInner>() {
@Override
public OperationStatusResponseInner call(ServiceResponse<OperationStatusResponseInner> response) {
return response.body();
}
});
}
/**
* Converts virtual machine disks from blob-based to managed disks. Virtual machine must be stop-deallocated before invoking this operation.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<ServiceResponse<OperationStatusResponseInner>> convertToManagedDisksWithServiceResponseAsync(String resourceGroupName, String vmName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (vmName == null) {
throw new IllegalArgumentException("Parameter vmName 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 = "2016-04-30-preview";
Observable<Response<ResponseBody>> observable = service.convertToManagedDisks(resourceGroupName, vmName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent());
return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken<OperationStatusResponseInner>() { }.getType());
}
/**
* Converts virtual machine disks from blob-based to managed disks. Virtual machine must be stop-deallocated before invoking this operation.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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 OperationStatusResponseInner object if successful.
*/
public OperationStatusResponseInner beginConvertToManagedDisks(String resourceGroupName, String vmName) {
return beginConvertToManagedDisksWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().single().body();
}
/**
* Converts virtual machine disks from blob-based to managed disks. Virtual machine must be stop-deallocated before invoking this operation.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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<OperationStatusResponseInner> beginConvertToManagedDisksAsync(String resourceGroupName, String vmName, final ServiceCallback<OperationStatusResponseInner> serviceCallback) {
return ServiceFuture.fromResponse(beginConvertToManagedDisksWithServiceResponseAsync(resourceGroupName, vmName), serviceCallback);
}
/**
* Converts virtual machine disks from blob-based to managed disks. Virtual machine must be stop-deallocated before invoking this operation.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the OperationStatusResponseInner object
*/
public Observable<OperationStatusResponseInner> beginConvertToManagedDisksAsync(String resourceGroupName, String vmName) {
return beginConvertToManagedDisksWithServiceResponseAsync(resourceGroupName, vmName).map(new Func1<ServiceResponse<OperationStatusResponseInner>, OperationStatusResponseInner>() {
@Override
public OperationStatusResponseInner call(ServiceResponse<OperationStatusResponseInner> response) {
return response.body();
}
});
}
/**
* Converts virtual machine disks from blob-based to managed disks. Virtual machine must be stop-deallocated before invoking this operation.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the OperationStatusResponseInner object
*/
public Observable<ServiceResponse<OperationStatusResponseInner>> beginConvertToManagedDisksWithServiceResponseAsync(String resourceGroupName, String vmName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (vmName == null) {
throw new IllegalArgumentException("Parameter vmName 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 = "2016-04-30-preview";
return service.beginConvertToManagedDisks(resourceGroupName, vmName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<OperationStatusResponseInner>>>() {
@Override
public Observable<ServiceResponse<OperationStatusResponseInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<OperationStatusResponseInner> clientResponse = beginConvertToManagedDisksDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse<OperationStatusResponseInner> beginConvertToManagedDisksDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<OperationStatusResponseInner, CloudException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<OperationStatusResponseInner>() { }.getType())
.register(202, new TypeToken<Void>() { }.getType())
.registerError(CloudException.class)
.build(response);
}
/**
* Shuts down the virtual machine and releases the compute resources. You are not billed for the compute resources that this virtual machine uses.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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 OperationStatusResponseInner object if successful.
*/
public OperationStatusResponseInner deallocate(String resourceGroupName, String vmName) {
return deallocateWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().last().body();
}
/**
* Shuts down the virtual machine and releases the compute resources. You are not billed for the compute resources that this virtual machine uses.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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<OperationStatusResponseInner> deallocateAsync(String resourceGroupName, String vmName, final ServiceCallback<OperationStatusResponseInner> serviceCallback) {
return ServiceFuture.fromResponse(deallocateWithServiceResponseAsync(resourceGroupName, vmName), serviceCallback);
}
/**
* Shuts down the virtual machine and releases the compute resources. You are not billed for the compute resources that this virtual machine uses.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<OperationStatusResponseInner> deallocateAsync(String resourceGroupName, String vmName) {
return deallocateWithServiceResponseAsync(resourceGroupName, vmName).map(new Func1<ServiceResponse<OperationStatusResponseInner>, OperationStatusResponseInner>() {
@Override
public OperationStatusResponseInner call(ServiceResponse<OperationStatusResponseInner> response) {
return response.body();
}
});
}
/**
* Shuts down the virtual machine and releases the compute resources. You are not billed for the compute resources that this virtual machine uses.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<ServiceResponse<OperationStatusResponseInner>> deallocateWithServiceResponseAsync(String resourceGroupName, String vmName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (vmName == null) {
throw new IllegalArgumentException("Parameter vmName 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 = "2016-04-30-preview";
Observable<Response<ResponseBody>> observable = service.deallocate(resourceGroupName, vmName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent());
return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken<OperationStatusResponseInner>() { }.getType());
}
/**
* Shuts down the virtual machine and releases the compute resources. You are not billed for the compute resources that this virtual machine uses.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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 OperationStatusResponseInner object if successful.
*/
public OperationStatusResponseInner beginDeallocate(String resourceGroupName, String vmName) {
return beginDeallocateWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().single().body();
}
/**
* Shuts down the virtual machine and releases the compute resources. You are not billed for the compute resources that this virtual machine uses.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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<OperationStatusResponseInner> beginDeallocateAsync(String resourceGroupName, String vmName, final ServiceCallback<OperationStatusResponseInner> serviceCallback) {
return ServiceFuture.fromResponse(beginDeallocateWithServiceResponseAsync(resourceGroupName, vmName), serviceCallback);
}
/**
* Shuts down the virtual machine and releases the compute resources. You are not billed for the compute resources that this virtual machine uses.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the OperationStatusResponseInner object
*/
public Observable<OperationStatusResponseInner> beginDeallocateAsync(String resourceGroupName, String vmName) {
return beginDeallocateWithServiceResponseAsync(resourceGroupName, vmName).map(new Func1<ServiceResponse<OperationStatusResponseInner>, OperationStatusResponseInner>() {
@Override
public OperationStatusResponseInner call(ServiceResponse<OperationStatusResponseInner> response) {
return response.body();
}
});
}
/**
* Shuts down the virtual machine and releases the compute resources. You are not billed for the compute resources that this virtual machine uses.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the OperationStatusResponseInner object
*/
public Observable<ServiceResponse<OperationStatusResponseInner>> beginDeallocateWithServiceResponseAsync(String resourceGroupName, String vmName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (vmName == null) {
throw new IllegalArgumentException("Parameter vmName 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 = "2016-04-30-preview";
return service.beginDeallocate(resourceGroupName, vmName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<OperationStatusResponseInner>>>() {
@Override
public Observable<ServiceResponse<OperationStatusResponseInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<OperationStatusResponseInner> clientResponse = beginDeallocateDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse<OperationStatusResponseInner> beginDeallocateDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<OperationStatusResponseInner, CloudException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<OperationStatusResponseInner>() { }.getType())
.register(202, new TypeToken<Void>() { }.getType())
.registerError(CloudException.class)
.build(response);
}
/**
* Sets the state of the virtual machine to generalized.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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 OperationStatusResponseInner object if successful.
*/
public OperationStatusResponseInner generalize(String resourceGroupName, String vmName) {
return generalizeWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().single().body();
}
/**
* Sets the state of the virtual machine to generalized.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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<OperationStatusResponseInner> generalizeAsync(String resourceGroupName, String vmName, final ServiceCallback<OperationStatusResponseInner> serviceCallback) {
return ServiceFuture.fromResponse(generalizeWithServiceResponseAsync(resourceGroupName, vmName), serviceCallback);
}
/**
* Sets the state of the virtual machine to generalized.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the OperationStatusResponseInner object
*/
public Observable<OperationStatusResponseInner> generalizeAsync(String resourceGroupName, String vmName) {
return generalizeWithServiceResponseAsync(resourceGroupName, vmName).map(new Func1<ServiceResponse<OperationStatusResponseInner>, OperationStatusResponseInner>() {
@Override
public OperationStatusResponseInner call(ServiceResponse<OperationStatusResponseInner> response) {
return response.body();
}
});
}
/**
* Sets the state of the virtual machine to generalized.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the OperationStatusResponseInner object
*/
public Observable<ServiceResponse<OperationStatusResponseInner>> generalizeWithServiceResponseAsync(String resourceGroupName, String vmName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (vmName == null) {
throw new IllegalArgumentException("Parameter vmName 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 = "2016-04-30-preview";
return service.generalize(resourceGroupName, vmName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<OperationStatusResponseInner>>>() {
@Override
public Observable<ServiceResponse<OperationStatusResponseInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<OperationStatusResponseInner> clientResponse = generalizeDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse<OperationStatusResponseInner> generalizeDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<OperationStatusResponseInner, CloudException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<OperationStatusResponseInner>() { }.getType())
.registerError(CloudException.class)
.build(response);
}
/**
* Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines.
*
* @param resourceGroupName The name of the resource group.
* @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 PagedList<VirtualMachineInner> object if successful.
*/
public PagedList<VirtualMachineInner> listByResourceGroup(final String resourceGroupName) {
ServiceResponse<Page<VirtualMachineInner>> response = listByResourceGroupSinglePageAsync(resourceGroupName).toBlocking().single();
return new PagedList<VirtualMachineInner>(response.body()) {
@Override
public Page<VirtualMachineInner> nextPage(String nextPageLink) {
return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body();
}
};
}
/**
* Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines.
*
* @param resourceGroupName The name of the resource 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<List<VirtualMachineInner>> listByResourceGroupAsync(final String resourceGroupName, final ListOperationCallback<VirtualMachineInner> serviceCallback) {
return AzureServiceFuture.fromPageResponse(
listByResourceGroupSinglePageAsync(resourceGroupName),
new Func1<String, Observable<ServiceResponse<Page<VirtualMachineInner>>>>() {
@Override
public Observable<ServiceResponse<Page<VirtualMachineInner>>> call(String nextPageLink) {
return listByResourceGroupNextSinglePageAsync(nextPageLink);
}
},
serviceCallback);
}
/**
* Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines.
*
* @param resourceGroupName The name of the resource group.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the PagedList<VirtualMachineInner> object
*/
public Observable<Page<VirtualMachineInner>> listByResourceGroupAsync(final String resourceGroupName) {
return listByResourceGroupWithServiceResponseAsync(resourceGroupName)
.map(new Func1<ServiceResponse<Page<VirtualMachineInner>>, Page<VirtualMachineInner>>() {
@Override
public Page<VirtualMachineInner> call(ServiceResponse<Page<VirtualMachineInner>> response) {
return response.body();
}
});
}
/**
* Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines.
*
* @param resourceGroupName The name of the resource group.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the PagedList<VirtualMachineInner> object
*/
public Observable<ServiceResponse<Page<VirtualMachineInner>>> listByResourceGroupWithServiceResponseAsync(final String resourceGroupName) {
return listByResourceGroupSinglePageAsync(resourceGroupName)
.concatMap(new Func1<ServiceResponse<Page<VirtualMachineInner>>, Observable<ServiceResponse<Page<VirtualMachineInner>>>>() {
@Override
public Observable<ServiceResponse<Page<VirtualMachineInner>>> call(ServiceResponse<Page<VirtualMachineInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listByResourceGroupNextWithServiceResponseAsync(nextPageLink));
}
});
}
/**
* Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines.
*
ServiceResponse<PageImpl1<VirtualMachineInner>> * @param resourceGroupName The name of the resource group.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the PagedList<VirtualMachineInner> object wrapped in {@link ServiceResponse} if successful.
*/
public Observable<ServiceResponse<Page<VirtualMachineInner>>> listByResourceGroupSinglePageAsync(final 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 = "2016-04-30-preview";
return service.listByResourceGroup(resourceGroupName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Page<VirtualMachineInner>>>>() {
@Override
public Observable<ServiceResponse<Page<VirtualMachineInner>>> call(Response<ResponseBody> response) {
try {
ServiceResponse<PageImpl1<VirtualMachineInner>> result = listByResourceGroupDelegate(response);
return Observable.just(new ServiceResponse<Page<VirtualMachineInner>>(result.body(), result.response()));
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse<PageImpl1<VirtualMachineInner>> listByResourceGroupDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<PageImpl1<VirtualMachineInner>, CloudException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<PageImpl1<VirtualMachineInner>>() { }.getType())
.registerError(CloudException.class)
.build(response);
}
/**
* Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines.
*
* @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 PagedList<VirtualMachineInner> object if successful.
*/
public PagedList<VirtualMachineInner> list() {
ServiceResponse<Page<VirtualMachineInner>> response = listSinglePageAsync().toBlocking().single();
return new PagedList<VirtualMachineInner>(response.body()) {
@Override
public Page<VirtualMachineInner> nextPage(String nextPageLink) {
return listNextSinglePageAsync(nextPageLink).toBlocking().single().body();
}
};
}
/**
* Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines.
*
* @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<VirtualMachineInner>> listAsync(final ListOperationCallback<VirtualMachineInner> serviceCallback) {
return AzureServiceFuture.fromPageResponse(
listSinglePageAsync(),
new Func1<String, Observable<ServiceResponse<Page<VirtualMachineInner>>>>() {
@Override
public Observable<ServiceResponse<Page<VirtualMachineInner>>> call(String nextPageLink) {
return listNextSinglePageAsync(nextPageLink);
}
},
serviceCallback);
}
/**
* Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the PagedList<VirtualMachineInner> object
*/
public Observable<Page<VirtualMachineInner>> listAsync() {
return listWithServiceResponseAsync()
.map(new Func1<ServiceResponse<Page<VirtualMachineInner>>, Page<VirtualMachineInner>>() {
@Override
public Page<VirtualMachineInner> call(ServiceResponse<Page<VirtualMachineInner>> response) {
return response.body();
}
});
}
/**
* Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the PagedList<VirtualMachineInner> object
*/
public Observable<ServiceResponse<Page<VirtualMachineInner>>> listWithServiceResponseAsync() {
return listSinglePageAsync()
.concatMap(new Func1<ServiceResponse<Page<VirtualMachineInner>>, Observable<ServiceResponse<Page<VirtualMachineInner>>>>() {
@Override
public Observable<ServiceResponse<Page<VirtualMachineInner>>> call(ServiceResponse<Page<VirtualMachineInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink));
}
});
}
/**
* Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the PagedList<VirtualMachineInner> object wrapped in {@link ServiceResponse} if successful.
*/
public Observable<ServiceResponse<Page<VirtualMachineInner>>> listSinglePageAsync() {
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
final String apiVersion = "2016-04-30-preview";
return service.list(this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Page<VirtualMachineInner>>>>() {
@Override
public Observable<ServiceResponse<Page<VirtualMachineInner>>> call(Response<ResponseBody> response) {
try {
ServiceResponse<PageImpl1<VirtualMachineInner>> result = listDelegate(response);
return Observable.just(new ServiceResponse<Page<VirtualMachineInner>>(result.body(), result.response()));
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse<PageImpl1<VirtualMachineInner>> listDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<PageImpl1<VirtualMachineInner>, CloudException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<PageImpl1<VirtualMachineInner>>() { }.getType())
.registerError(CloudException.class)
.build(response);
}
/**
* Lists all available virtual machine sizes to which the specified virtual machine can be resized.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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<VirtualMachineSizeInner> object if successful.
*/
public List<VirtualMachineSizeInner> listAvailableSizes(String resourceGroupName, String vmName) {
return listAvailableSizesWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().single().body();
}
/**
* Lists all available virtual machine sizes to which the specified virtual machine can be resized.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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<VirtualMachineSizeInner>> listAvailableSizesAsync(String resourceGroupName, String vmName, final ServiceCallback<List<VirtualMachineSizeInner>> serviceCallback) {
return ServiceFuture.fromResponse(listAvailableSizesWithServiceResponseAsync(resourceGroupName, vmName), serviceCallback);
}
/**
* Lists all available virtual machine sizes to which the specified virtual machine can be resized.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the List<VirtualMachineSizeInner> object
*/
public Observable<List<VirtualMachineSizeInner>> listAvailableSizesAsync(String resourceGroupName, String vmName) {
return listAvailableSizesWithServiceResponseAsync(resourceGroupName, vmName).map(new Func1<ServiceResponse<List<VirtualMachineSizeInner>>, List<VirtualMachineSizeInner>>() {
@Override
public List<VirtualMachineSizeInner> call(ServiceResponse<List<VirtualMachineSizeInner>> response) {
return response.body();
}
});
}
/**
* Lists all available virtual machine sizes to which the specified virtual machine can be resized.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the List<VirtualMachineSizeInner> object
*/
public Observable<ServiceResponse<List<VirtualMachineSizeInner>>> listAvailableSizesWithServiceResponseAsync(String resourceGroupName, String vmName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (vmName == null) {
throw new IllegalArgumentException("Parameter vmName 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 = "2016-04-30-preview";
return service.listAvailableSizes(resourceGroupName, vmName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<List<VirtualMachineSizeInner>>>>() {
@Override
public Observable<ServiceResponse<List<VirtualMachineSizeInner>>> call(Response<ResponseBody> response) {
try {
ServiceResponse<PageImpl<VirtualMachineSizeInner>> result = listAvailableSizesDelegate(response);
ServiceResponse<List<VirtualMachineSizeInner>> clientResponse = new ServiceResponse<List<VirtualMachineSizeInner>>(result.body().items(), result.response());
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse<PageImpl<VirtualMachineSizeInner>> listAvailableSizesDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<PageImpl<VirtualMachineSizeInner>, CloudException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<PageImpl<VirtualMachineSizeInner>>() { }.getType())
.registerError(CloudException.class)
.build(response);
}
/**
* The operation to power off (stop) a virtual machine. The virtual machine can be restarted with the same provisioned resources. You are still charged for this virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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 OperationStatusResponseInner object if successful.
*/
public OperationStatusResponseInner powerOff(String resourceGroupName, String vmName) {
return powerOffWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().last().body();
}
/**
* The operation to power off (stop) a virtual machine. The virtual machine can be restarted with the same provisioned resources. You are still charged for this virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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<OperationStatusResponseInner> powerOffAsync(String resourceGroupName, String vmName, final ServiceCallback<OperationStatusResponseInner> serviceCallback) {
return ServiceFuture.fromResponse(powerOffWithServiceResponseAsync(resourceGroupName, vmName), serviceCallback);
}
/**
* The operation to power off (stop) a virtual machine. The virtual machine can be restarted with the same provisioned resources. You are still charged for this virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<OperationStatusResponseInner> powerOffAsync(String resourceGroupName, String vmName) {
return powerOffWithServiceResponseAsync(resourceGroupName, vmName).map(new Func1<ServiceResponse<OperationStatusResponseInner>, OperationStatusResponseInner>() {
@Override
public OperationStatusResponseInner call(ServiceResponse<OperationStatusResponseInner> response) {
return response.body();
}
});
}
/**
* The operation to power off (stop) a virtual machine. The virtual machine can be restarted with the same provisioned resources. You are still charged for this virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<ServiceResponse<OperationStatusResponseInner>> powerOffWithServiceResponseAsync(String resourceGroupName, String vmName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (vmName == null) {
throw new IllegalArgumentException("Parameter vmName 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 = "2016-04-30-preview";
Observable<Response<ResponseBody>> observable = service.powerOff(resourceGroupName, vmName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent());
return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken<OperationStatusResponseInner>() { }.getType());
}
/**
* The operation to power off (stop) a virtual machine. The virtual machine can be restarted with the same provisioned resources. You are still charged for this virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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 OperationStatusResponseInner object if successful.
*/
public OperationStatusResponseInner beginPowerOff(String resourceGroupName, String vmName) {
return beginPowerOffWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().single().body();
}
/**
* The operation to power off (stop) a virtual machine. The virtual machine can be restarted with the same provisioned resources. You are still charged for this virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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<OperationStatusResponseInner> beginPowerOffAsync(String resourceGroupName, String vmName, final ServiceCallback<OperationStatusResponseInner> serviceCallback) {
return ServiceFuture.fromResponse(beginPowerOffWithServiceResponseAsync(resourceGroupName, vmName), serviceCallback);
}
/**
* The operation to power off (stop) a virtual machine. The virtual machine can be restarted with the same provisioned resources. You are still charged for this virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the OperationStatusResponseInner object
*/
public Observable<OperationStatusResponseInner> beginPowerOffAsync(String resourceGroupName, String vmName) {
return beginPowerOffWithServiceResponseAsync(resourceGroupName, vmName).map(new Func1<ServiceResponse<OperationStatusResponseInner>, OperationStatusResponseInner>() {
@Override
public OperationStatusResponseInner call(ServiceResponse<OperationStatusResponseInner> response) {
return response.body();
}
});
}
/**
* The operation to power off (stop) a virtual machine. The virtual machine can be restarted with the same provisioned resources. You are still charged for this virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the OperationStatusResponseInner object
*/
public Observable<ServiceResponse<OperationStatusResponseInner>> beginPowerOffWithServiceResponseAsync(String resourceGroupName, String vmName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (vmName == null) {
throw new IllegalArgumentException("Parameter vmName 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 = "2016-04-30-preview";
return service.beginPowerOff(resourceGroupName, vmName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<OperationStatusResponseInner>>>() {
@Override
public Observable<ServiceResponse<OperationStatusResponseInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<OperationStatusResponseInner> clientResponse = beginPowerOffDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse<OperationStatusResponseInner> beginPowerOffDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<OperationStatusResponseInner, CloudException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<OperationStatusResponseInner>() { }.getType())
.register(202, new TypeToken<Void>() { }.getType())
.registerError(CloudException.class)
.build(response);
}
/**
* The operation to restart a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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 OperationStatusResponseInner object if successful.
*/
public OperationStatusResponseInner restart(String resourceGroupName, String vmName) {
return restartWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().last().body();
}
/**
* The operation to restart a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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<OperationStatusResponseInner> restartAsync(String resourceGroupName, String vmName, final ServiceCallback<OperationStatusResponseInner> serviceCallback) {
return ServiceFuture.fromResponse(restartWithServiceResponseAsync(resourceGroupName, vmName), serviceCallback);
}
/**
* The operation to restart a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<OperationStatusResponseInner> restartAsync(String resourceGroupName, String vmName) {
return restartWithServiceResponseAsync(resourceGroupName, vmName).map(new Func1<ServiceResponse<OperationStatusResponseInner>, OperationStatusResponseInner>() {
@Override
public OperationStatusResponseInner call(ServiceResponse<OperationStatusResponseInner> response) {
return response.body();
}
});
}
/**
* The operation to restart a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<ServiceResponse<OperationStatusResponseInner>> restartWithServiceResponseAsync(String resourceGroupName, String vmName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (vmName == null) {
throw new IllegalArgumentException("Parameter vmName 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 = "2016-04-30-preview";
Observable<Response<ResponseBody>> observable = service.restart(resourceGroupName, vmName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent());
return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken<OperationStatusResponseInner>() { }.getType());
}
/**
* The operation to restart a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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 OperationStatusResponseInner object if successful.
*/
public OperationStatusResponseInner beginRestart(String resourceGroupName, String vmName) {
return beginRestartWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().single().body();
}
/**
* The operation to restart a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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<OperationStatusResponseInner> beginRestartAsync(String resourceGroupName, String vmName, final ServiceCallback<OperationStatusResponseInner> serviceCallback) {
return ServiceFuture.fromResponse(beginRestartWithServiceResponseAsync(resourceGroupName, vmName), serviceCallback);
}
/**
* The operation to restart a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the OperationStatusResponseInner object
*/
public Observable<OperationStatusResponseInner> beginRestartAsync(String resourceGroupName, String vmName) {
return beginRestartWithServiceResponseAsync(resourceGroupName, vmName).map(new Func1<ServiceResponse<OperationStatusResponseInner>, OperationStatusResponseInner>() {
@Override
public OperationStatusResponseInner call(ServiceResponse<OperationStatusResponseInner> response) {
return response.body();
}
});
}
/**
* The operation to restart a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the OperationStatusResponseInner object
*/
public Observable<ServiceResponse<OperationStatusResponseInner>> beginRestartWithServiceResponseAsync(String resourceGroupName, String vmName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (vmName == null) {
throw new IllegalArgumentException("Parameter vmName 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 = "2016-04-30-preview";
return service.beginRestart(resourceGroupName, vmName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<OperationStatusResponseInner>>>() {
@Override
public Observable<ServiceResponse<OperationStatusResponseInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<OperationStatusResponseInner> clientResponse = beginRestartDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse<OperationStatusResponseInner> beginRestartDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<OperationStatusResponseInner, CloudException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<OperationStatusResponseInner>() { }.getType())
.register(202, new TypeToken<Void>() { }.getType())
.registerError(CloudException.class)
.build(response);
}
/**
* The operation to start a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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 OperationStatusResponseInner object if successful.
*/
public OperationStatusResponseInner start(String resourceGroupName, String vmName) {
return startWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().last().body();
}
/**
* The operation to start a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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<OperationStatusResponseInner> startAsync(String resourceGroupName, String vmName, final ServiceCallback<OperationStatusResponseInner> serviceCallback) {
return ServiceFuture.fromResponse(startWithServiceResponseAsync(resourceGroupName, vmName), serviceCallback);
}
/**
* The operation to start a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<OperationStatusResponseInner> startAsync(String resourceGroupName, String vmName) {
return startWithServiceResponseAsync(resourceGroupName, vmName).map(new Func1<ServiceResponse<OperationStatusResponseInner>, OperationStatusResponseInner>() {
@Override
public OperationStatusResponseInner call(ServiceResponse<OperationStatusResponseInner> response) {
return response.body();
}
});
}
/**
* The operation to start a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<ServiceResponse<OperationStatusResponseInner>> startWithServiceResponseAsync(String resourceGroupName, String vmName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (vmName == null) {
throw new IllegalArgumentException("Parameter vmName 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 = "2016-04-30-preview";
Observable<Response<ResponseBody>> observable = service.start(resourceGroupName, vmName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent());
return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken<OperationStatusResponseInner>() { }.getType());
}
/**
* The operation to start a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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 OperationStatusResponseInner object if successful.
*/
public OperationStatusResponseInner beginStart(String resourceGroupName, String vmName) {
return beginStartWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().single().body();
}
/**
* The operation to start a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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<OperationStatusResponseInner> beginStartAsync(String resourceGroupName, String vmName, final ServiceCallback<OperationStatusResponseInner> serviceCallback) {
return ServiceFuture.fromResponse(beginStartWithServiceResponseAsync(resourceGroupName, vmName), serviceCallback);
}
/**
* The operation to start a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the OperationStatusResponseInner object
*/
public Observable<OperationStatusResponseInner> beginStartAsync(String resourceGroupName, String vmName) {
return beginStartWithServiceResponseAsync(resourceGroupName, vmName).map(new Func1<ServiceResponse<OperationStatusResponseInner>, OperationStatusResponseInner>() {
@Override
public OperationStatusResponseInner call(ServiceResponse<OperationStatusResponseInner> response) {
return response.body();
}
});
}
/**
* The operation to start a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the OperationStatusResponseInner object
*/
public Observable<ServiceResponse<OperationStatusResponseInner>> beginStartWithServiceResponseAsync(String resourceGroupName, String vmName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (vmName == null) {
throw new IllegalArgumentException("Parameter vmName 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 = "2016-04-30-preview";
return service.beginStart(resourceGroupName, vmName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<OperationStatusResponseInner>>>() {
@Override
public Observable<ServiceResponse<OperationStatusResponseInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<OperationStatusResponseInner> clientResponse = beginStartDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse<OperationStatusResponseInner> beginStartDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<OperationStatusResponseInner, CloudException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<OperationStatusResponseInner>() { }.getType())
.register(202, new TypeToken<Void>() { }.getType())
.registerError(CloudException.class)
.build(response);
}
/**
* The operation to redeploy a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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 OperationStatusResponseInner object if successful.
*/
public OperationStatusResponseInner redeploy(String resourceGroupName, String vmName) {
return redeployWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().last().body();
}
/**
* The operation to redeploy a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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<OperationStatusResponseInner> redeployAsync(String resourceGroupName, String vmName, final ServiceCallback<OperationStatusResponseInner> serviceCallback) {
return ServiceFuture.fromResponse(redeployWithServiceResponseAsync(resourceGroupName, vmName), serviceCallback);
}
/**
* The operation to redeploy a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<OperationStatusResponseInner> redeployAsync(String resourceGroupName, String vmName) {
return redeployWithServiceResponseAsync(resourceGroupName, vmName).map(new Func1<ServiceResponse<OperationStatusResponseInner>, OperationStatusResponseInner>() {
@Override
public OperationStatusResponseInner call(ServiceResponse<OperationStatusResponseInner> response) {
return response.body();
}
});
}
/**
* The operation to redeploy a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<ServiceResponse<OperationStatusResponseInner>> redeployWithServiceResponseAsync(String resourceGroupName, String vmName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (vmName == null) {
throw new IllegalArgumentException("Parameter vmName 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 = "2016-04-30-preview";
Observable<Response<ResponseBody>> observable = service.redeploy(resourceGroupName, vmName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent());
return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken<OperationStatusResponseInner>() { }.getType());
}
/**
* The operation to redeploy a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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 OperationStatusResponseInner object if successful.
*/
public OperationStatusResponseInner beginRedeploy(String resourceGroupName, String vmName) {
return beginRedeployWithServiceResponseAsync(resourceGroupName, vmName).toBlocking().single().body();
}
/**
* The operation to redeploy a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @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<OperationStatusResponseInner> beginRedeployAsync(String resourceGroupName, String vmName, final ServiceCallback<OperationStatusResponseInner> serviceCallback) {
return ServiceFuture.fromResponse(beginRedeployWithServiceResponseAsync(resourceGroupName, vmName), serviceCallback);
}
/**
* The operation to redeploy a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the OperationStatusResponseInner object
*/
public Observable<OperationStatusResponseInner> beginRedeployAsync(String resourceGroupName, String vmName) {
return beginRedeployWithServiceResponseAsync(resourceGroupName, vmName).map(new Func1<ServiceResponse<OperationStatusResponseInner>, OperationStatusResponseInner>() {
@Override
public OperationStatusResponseInner call(ServiceResponse<OperationStatusResponseInner> response) {
return response.body();
}
});
}
/**
* The operation to redeploy a virtual machine.
*
* @param resourceGroupName The name of the resource group.
* @param vmName The name of the virtual machine.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the OperationStatusResponseInner object
*/
public Observable<ServiceResponse<OperationStatusResponseInner>> beginRedeployWithServiceResponseAsync(String resourceGroupName, String vmName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (vmName == null) {
throw new IllegalArgumentException("Parameter vmName 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 = "2016-04-30-preview";
return service.beginRedeploy(resourceGroupName, vmName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<OperationStatusResponseInner>>>() {
@Override
public Observable<ServiceResponse<OperationStatusResponseInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<OperationStatusResponseInner> clientResponse = beginRedeployDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse<OperationStatusResponseInner> beginRedeployDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<OperationStatusResponseInner, CloudException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<OperationStatusResponseInner>() { }.getType())
.register(202, new TypeToken<Void>() { }.getType())
.registerError(CloudException.class)
.build(response);
}
/**
* Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines.
*
* @param nextPageLink The NextLink from the previous successful call to List operation.
* @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 PagedList<VirtualMachineInner> object if successful.
*/
public PagedList<VirtualMachineInner> listByResourceGroupNext(final String nextPageLink) {
ServiceResponse<Page<VirtualMachineInner>> response = listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single();
return new PagedList<VirtualMachineInner>(response.body()) {
@Override
public Page<VirtualMachineInner> nextPage(String nextPageLink) {
return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body();
}
};
}
/**
* Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines.
*
* @param nextPageLink The NextLink from the previous successful call to List operation.
* @param serviceFuture the ServiceFuture object tracking the Retrofit calls
* @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<VirtualMachineInner>> listByResourceGroupNextAsync(final String nextPageLink, final ServiceFuture<List<VirtualMachineInner>> serviceFuture, final ListOperationCallback<VirtualMachineInner> serviceCallback) {
return AzureServiceFuture.fromPageResponse(
listByResourceGroupNextSinglePageAsync(nextPageLink),
new Func1<String, Observable<ServiceResponse<Page<VirtualMachineInner>>>>() {
@Override
public Observable<ServiceResponse<Page<VirtualMachineInner>>> call(String nextPageLink) {
return listByResourceGroupNextSinglePageAsync(nextPageLink);
}
},
serviceCallback);
}
/**
* Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines.
*
* @param nextPageLink The NextLink from the previous successful call to List operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the PagedList<VirtualMachineInner> object
*/
public Observable<Page<VirtualMachineInner>> listByResourceGroupNextAsync(final String nextPageLink) {
return listByResourceGroupNextWithServiceResponseAsync(nextPageLink)
.map(new Func1<ServiceResponse<Page<VirtualMachineInner>>, Page<VirtualMachineInner>>() {
@Override
public Page<VirtualMachineInner> call(ServiceResponse<Page<VirtualMachineInner>> response) {
return response.body();
}
});
}
/**
* Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines.
*
* @param nextPageLink The NextLink from the previous successful call to List operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the PagedList<VirtualMachineInner> object
*/
public Observable<ServiceResponse<Page<VirtualMachineInner>>> listByResourceGroupNextWithServiceResponseAsync(final String nextPageLink) {
return listByResourceGroupNextSinglePageAsync(nextPageLink)
.concatMap(new Func1<ServiceResponse<Page<VirtualMachineInner>>, Observable<ServiceResponse<Page<VirtualMachineInner>>>>() {
@Override
public Observable<ServiceResponse<Page<VirtualMachineInner>>> call(ServiceResponse<Page<VirtualMachineInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listByResourceGroupNextWithServiceResponseAsync(nextPageLink));
}
});
}
/**
* Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines.
*
ServiceResponse<PageImpl1<VirtualMachineInner>> * @param nextPageLink The NextLink from the previous successful call to List operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the PagedList<VirtualMachineInner> object wrapped in {@link ServiceResponse} if successful.
*/
public Observable<ServiceResponse<Page<VirtualMachineInner>>> listByResourceGroupNextSinglePageAsync(final String nextPageLink) {
if (nextPageLink == null) {
throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.");
}
String nextUrl = String.format("%s", nextPageLink);
return service.listByResourceGroupNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Page<VirtualMachineInner>>>>() {
@Override
public Observable<ServiceResponse<Page<VirtualMachineInner>>> call(Response<ResponseBody> response) {
try {
ServiceResponse<PageImpl1<VirtualMachineInner>> result = listByResourceGroupNextDelegate(response);
return Observable.just(new ServiceResponse<Page<VirtualMachineInner>>(result.body(), result.response()));
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse<PageImpl1<VirtualMachineInner>> listByResourceGroupNextDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<PageImpl1<VirtualMachineInner>, CloudException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<PageImpl1<VirtualMachineInner>>() { }.getType())
.registerError(CloudException.class)
.build(response);
}
/**
* Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines.
*
* @param nextPageLink The NextLink from the previous successful call to List operation.
* @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 PagedList<VirtualMachineInner> object if successful.
*/
public PagedList<VirtualMachineInner> listNext(final String nextPageLink) {
ServiceResponse<Page<VirtualMachineInner>> response = listNextSinglePageAsync(nextPageLink).toBlocking().single();
return new PagedList<VirtualMachineInner>(response.body()) {
@Override
public Page<VirtualMachineInner> nextPage(String nextPageLink) {
return listNextSinglePageAsync(nextPageLink).toBlocking().single().body();
}
};
}
/**
* Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines.
*
* @param nextPageLink The NextLink from the previous successful call to List operation.
* @param serviceFuture the ServiceFuture object tracking the Retrofit calls
* @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<VirtualMachineInner>> listNextAsync(final String nextPageLink, final ServiceFuture<List<VirtualMachineInner>> serviceFuture, final ListOperationCallback<VirtualMachineInner> serviceCallback) {
return AzureServiceFuture.fromPageResponse(
listNextSinglePageAsync(nextPageLink),
new Func1<String, Observable<ServiceResponse<Page<VirtualMachineInner>>>>() {
@Override
public Observable<ServiceResponse<Page<VirtualMachineInner>>> call(String nextPageLink) {
return listNextSinglePageAsync(nextPageLink);
}
},
serviceCallback);
}
/**
* Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines.
*
* @param nextPageLink The NextLink from the previous successful call to List operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the PagedList<VirtualMachineInner> object
*/
public Observable<Page<VirtualMachineInner>> listNextAsync(final String nextPageLink) {
return listNextWithServiceResponseAsync(nextPageLink)
.map(new Func1<ServiceResponse<Page<VirtualMachineInner>>, Page<VirtualMachineInner>>() {
@Override
public Page<VirtualMachineInner> call(ServiceResponse<Page<VirtualMachineInner>> response) {
return response.body();
}
});
}
/**
* Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines.
*
* @param nextPageLink The NextLink from the previous successful call to List operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the PagedList<VirtualMachineInner> object
*/
public Observable<ServiceResponse<Page<VirtualMachineInner>>> listNextWithServiceResponseAsync(final String nextPageLink) {
return listNextSinglePageAsync(nextPageLink)
.concatMap(new Func1<ServiceResponse<Page<VirtualMachineInner>>, Observable<ServiceResponse<Page<VirtualMachineInner>>>>() {
@Override
public Observable<ServiceResponse<Page<VirtualMachineInner>>> call(ServiceResponse<Page<VirtualMachineInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink));
}
});
}
/**
* Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines.
*
ServiceResponse<PageImpl1<VirtualMachineInner>> * @param nextPageLink The NextLink from the previous successful call to List operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the PagedList<VirtualMachineInner> object wrapped in {@link ServiceResponse} if successful.
*/
public Observable<ServiceResponse<Page<VirtualMachineInner>>> listNextSinglePageAsync(final String nextPageLink) {
if (nextPageLink == null) {
throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.");
}
String nextUrl = String.format("%s", nextPageLink);
return service.listNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Page<VirtualMachineInner>>>>() {
@Override
public Observable<ServiceResponse<Page<VirtualMachineInner>>> call(Response<ResponseBody> response) {
try {
ServiceResponse<PageImpl1<VirtualMachineInner>> result = listNextDelegate(response);
return Observable.just(new ServiceResponse<Page<VirtualMachineInner>>(result.body(), result.response()));
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
private ServiceResponse<PageImpl1<VirtualMachineInner>> listNextDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<PageImpl1<VirtualMachineInner>, CloudException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<PageImpl1<VirtualMachineInner>>() { }.getType())
.registerError(CloudException.class)
.build(response);
}
}