com.nutanix.vmm.java.client.api.VmDataProtectionApi Maven / Gradle / Ivy
package com.nutanix.vmm.java.client.api;
import com.nutanix.vmm.java.client.ApiClient;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.HashSet;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.util.UriComponentsBuilder;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
@javax.annotation.Generated(value = "com.nutanix.swagger.codegen.generators.JavaClientSDKGenerator", date = "2023-08-18T03:46:19.074Z[Etc/UTC]")@Component("com.nutanix.vmm.java.client.api.VmDataProtectionApi")
public class VmDataProtectionApi {
private ApiClient apiClient;
private final Set headersToSkip;
public VmDataProtectionApi() {
this(new ApiClient());
}
@Autowired
public VmDataProtectionApi(ApiClient apiClient) {
this.apiClient = apiClient;
this.headersToSkip = new HashSet<>(Arrays.asList("authorization", "cookie", "ntnx-request-id", "host", "user-agent"));
}
public ApiClient getApiClient() {
return apiClient;
}
public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}
/**
* Revert VM identified by {extId}. This does an in-place VM restore from a specified VM Recovery Point.
* 202 - Task Id to monitor the progress of VM revert operation.
*
4XX - Client error response
*
5XX - Server error response
* @param extId Globally unique identifier of a VM. It should be of type UUID.
* @param body Specify the VM Recovery Point Id to which the VM would be reverted.
* @param args Additional arguments
* @return com.nutanix.dp1.vmm.vmm.v4.ahv.config.RevertVmResponse
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public com.nutanix.dp1.vmm.vmm.v4.ahv.config.RevertVmResponse revertVm(String extId, com.nutanix.dp1.vmm.vmm.v4.ahv.config.VmRevertParams body, HashMap ... args) throws RestClientException {
// Check for optional argument map
HashMap argMap = args.length > 0 ? args[0] : new HashMap();
Object postBody = body;
// verify the required parameter 'extId' is set
if (extId == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'extId' when calling revertVm");
}
// verify the required parameter 'body' is set
if (body == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling revertVm");
}
// create path and map variables
final Map uriVariables = new HashMap();
uriVariables.put("extId", extId);
String path = UriComponentsBuilder.fromPath("/api/vmm/v4.0.a1/ahv/config/vms/{extId}/$actions/revert").buildAndExpand(uriVariables).toUriString();
final MultiValueMap queryParams = new LinkedMultiValueMap();
final HttpHeaders headerParams = new HttpHeaders();
final MultiValueMap formParams = new LinkedMultiValueMap();
argMap.forEach((key, value) -> {
if (!this.headersToSkip.contains(key.toLowerCase())) {
String stringValue = apiClient.parameterToString(value);
if (stringValue != null && !stringValue.trim().isEmpty()) {
headerParams.add(key, apiClient.parameterToString(value));
}
}
});
final String[] accepts = {
"application/json"
};
final List accept = apiClient.selectHeaderAccept(accepts);
final String[] contentTypes = {
"application/json"
};
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
String[] authNames = new String[] { "basicAuthScheme" };
ParameterizedTypeReference returnType = new ParameterizedTypeReference() {};
return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
}