com.nutanix.dat.java.client.api.ProtectedResourcesApi Maven / Gradle / Ivy
Show all versions of dataprotection-java-client Show documentation
package com.nutanix.dat.java.client.api;
import com.nutanix.dat.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.core.io.InputStreamResource;
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.*;
@lombok.extern.slf4j.Slf4j
@javax.annotation.Generated(value = "com.nutanix.swagger.codegen.generators.JavaClientSDKGenerator", date = "2024-05-07T04:20:38.805Z[Etc/UTC]")@Component("com.nutanix.dat.java.client.api.ProtectedResourcesApi")
public class ProtectedResourcesApi {
private ApiClient apiClient;
private final Set headersToSkip;
public ProtectedResourcesApi() {
this(new ApiClient());
}
@Autowired
public ProtectedResourcesApi(ApiClient apiClient) {
this.apiClient = apiClient;
this.headersToSkip = new HashSet<>(Arrays.asList("authorization", "cookie", "host", "user-agent"));
}
public ApiClient getApiClient() {
return apiClient;
}
public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}
/**
* Get the details of the specified protected resource such as the restorable time ranges available on the local Prism Central and the state of replication to the targets specified in the applied protection policies. This applies only if the entity is protected in a minutely or synchronous schedule. Other protection schedules are not served by this endpoint yet, and are considered not protected.
* 200 - Details of the queried protected resource.
*
4XX - Client error response
*
5XX - Server error response
* @param extId The external identifier of a protected VM or volume group that can be used to retrieve the protected resource.
* @param args Additional arguments
* @return com.nutanix.dp1.dat.dataprotection.v4.config.GetProtectedResourceApiResponse
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public com.nutanix.dp1.dat.dataprotection.v4.config.GetProtectedResourceApiResponse getProtectedResourceById(String extId, Map ... args) throws RestClientException {
// Check for optional argument map
Map argMap = args.length > 0 ? args[0] : new HashMap();
Object postBody = null;
// verify the required parameter 'extId' is set
if (extId == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'extId' when calling getProtectedResourceById");
}
// create path and map variables
final Map uriVariables = new HashMap();
uriVariables.put("extId", extId);
String path = UriComponentsBuilder.fromPath("/api/dataprotection/v4.0.b1/config/protected-resources/{extId}").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 = { };
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
String[] authNames = new String[] { "basicAuthScheme" };
ParameterizedTypeReference returnType = new ParameterizedTypeReference() {};
return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
/**
* Promotes the specified synced entity at the target site. This is only relevant if the synced entity is protected in a synchronous schedule.
* 202 - Task Id to monitor the protected resource promotion progress.
*
4XX - Client error response
*
5XX - Server error response
* @param extId The external identifier of a protected VM or volume group that can be used to retrieve the protected resource.
* @param args Additional arguments
* @return com.nutanix.dp1.dat.dataprotection.v4.config.ProtectedResourcePromoteApiResponse
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public com.nutanix.dp1.dat.dataprotection.v4.config.ProtectedResourcePromoteApiResponse promoteProtectedResource(String extId, Map ... args) throws RestClientException {
// Check for optional argument map
Map argMap = args.length > 0 ? args[0] : new HashMap();
Object postBody = null;
// verify the required parameter 'extId' is set
if (extId == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'extId' when calling promoteProtectedResource");
}
// create path and map variables
final Map uriVariables = new HashMap();
uriVariables.put("extId", extId);
String path = UriComponentsBuilder.fromPath("/api/dataprotection/v4.0.b1/config/protected-resources/{extId}/$actions/promote").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 = { };
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);
}
/**
* Restore the specified protected resource from its state at the given timestamp on the given cluster. This is only relevant if the entity is protected in a minutely schedule at the given timestamp.
* 202 - Task Id to monitor the protected resource restoration progress.
*
4XX - Client error response
*
5XX - Server error response
* @param extId The external identifier of a protected VM or volume group that can be used to retrieve the protected resource.
* @param body Restore action specifications for a minutely scheduled protected resource.
* @param args Additional arguments
* @return com.nutanix.dp1.dat.dataprotection.v4.config.ProtectedResourceRestoreApiResponse
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public com.nutanix.dp1.dat.dataprotection.v4.config.ProtectedResourceRestoreApiResponse restoreProtectedResource(String extId, com.nutanix.dp1.dat.dataprotection.v4.config.ProtectedResourceRestoreSpec body, Map ... args) throws RestClientException {
// Check for optional argument map
Map 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 restoreProtectedResource");
}
// verify the required parameter 'body' is set
if (body == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling restoreProtectedResource");
}
// create path and map variables
final Map uriVariables = new HashMap();
uriVariables.put("extId", extId);
String path = UriComponentsBuilder.fromPath("/api/dataprotection/v4.0.b1/config/protected-resources/{extId}/$actions/restore").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);
}
}