com.spotinst.sdkjava.model.repo.ocean.kubernetes.K8sVngRepo Maven / Gradle / Ivy
package com.spotinst.sdkjava.model.repo.ocean.kubernetes;
import com.spotinst.sdkjava.exception.ExceptionHelper;
import com.spotinst.sdkjava.exception.SpotinstHttpException;
import com.spotinst.sdkjava.model.ISpotK8sVngRepo;
import com.spotinst.sdkjava.model.api.ocean.kubernetes.*;
import com.spotinst.sdkjava.model.bl.ocean.kubernetes.*;
import com.spotinst.sdkjava.model.requests.ocean.kubernetes.K8sImportClusterVngToOceanVngRequest;
import com.spotinst.sdkjava.model.requests.ocean.kubernetes.K8sVngDeleteRequest;
import com.spotinst.sdkjava.model.service.ocean.kubernetes.K8sVngSpecService;
import com.spotinst.sdkjava.model.RepoGenericResponse;
import com.spotinst.sdkjava.model.converters.K8sVngConverter;
import java.util.List;
import java.util.stream.Collectors;
public class K8sVngRepo implements ISpotK8sVngRepo {
@Override
public RepoGenericResponse create(K8sVngSpec vngToCreate, String authToken, String account) {
RepoGenericResponse retVal;
try {
ApiK8sVngSpec apiK8sVngSpecToCreate = K8sVngConverter.toDal(vngToCreate);
ApiK8sVngSpec apiCreatedVng = K8sVngSpecService.createK8sVng(apiK8sVngSpecToCreate, authToken, account);
K8sVngSpec createdK8sVngSpec = K8sVngConverter.toBl(apiCreatedVng);
retVal = new RepoGenericResponse<>(createdK8sVngSpec);
}
catch (SpotinstHttpException ex) {
retVal = ExceptionHelper.handleHttpException(ex);
}
return retVal;
}
@Override
public RepoGenericResponse deleteK8sVngSpec(K8sVngDeleteRequest vngDeletionRequest, String authToken, String account) {
RepoGenericResponse retVal;
try {
Boolean deleted = K8sVngSpecService.deleteK8sVng(vngDeletionRequest, authToken, account);
retVal = new RepoGenericResponse<>(deleted);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse update(String identifier, K8sVngSpec vngToUpdate, String authToken,String account) {
RepoGenericResponse retVal;
ApiK8sVngSpec apiK8sVngSpec = K8sVngConverter.toDal(vngToUpdate);
try {
Boolean success = K8sVngSpecService.updateK8sVng(identifier, apiK8sVngSpec, authToken, account);
retVal = new RepoGenericResponse<>(success);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse get(String identifier, String authToken, String account) {
RepoGenericResponse retVal;
try {
ApiK8sVngSpec apiK8sVngSpec = K8sVngSpecService.getK8sVng(identifier, authToken, account);
K8sVngSpec k8sVngSpec = K8sVngConverter.toBl(apiK8sVngSpec);
retVal = new RepoGenericResponse<>(k8sVngSpec);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse> list(String authToken, String account, String oceanId) {
RepoGenericResponse> retVal;
try {
List apiGetAllVng = K8sVngSpecService.listK8sVng(authToken, account, oceanId);
List k8sVngSpec = apiGetAllVng.stream().map(K8sVngConverter::toBl).collect(Collectors.toList());
retVal = new RepoGenericResponse<>(k8sVngSpec);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse importASGToVng(K8sVngSpec importASGRequest, String autoScalingGroupName, String oceanId, String authToken, String account) {
RepoGenericResponse retVal;
try {
ApiK8sVngSpec apiImportASGToVng = K8sVngConverter.toDal(importASGRequest);
ApiK8sVngSpec apiImportASG = K8sVngSpecService.importASGToVng(apiImportASGToVng, autoScalingGroupName, oceanId, authToken, account);
K8sVngSpec ImportedK8sVngSpec = K8sVngConverter.toBl(apiImportASG);
retVal = new RepoGenericResponse<>(ImportedK8sVngSpec);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse importCluterVngToOceanVng(K8sImportClusterVngToOceanVngRequest importClusterVngRequest, String authToken) {
RepoGenericResponse retVal;
try {
ApiK8sVngSpec apiImportClusterVngToVng = K8sVngSpecService.importClusterVngToOceanVng(importClusterVngRequest, authToken);
K8sVngSpec ImportedK8sVngSpec = K8sVngConverter.toBl(apiImportClusterVngToVng);
retVal = new RepoGenericResponse<>(ImportedK8sVngSpec);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse> launchNodesInVNG(LaunchNodesInVNG lauchNodes, String vngId, String authToken, String account) {
RepoGenericResponse> retVal;
try {
List apiLaunchNodesInVNG = K8sVngSpecService
.launchNodesInVNG(lauchNodes, vngId, authToken, account);
List launchNodesInVNG = apiLaunchNodesInVNG.stream().map(K8sVngConverter::toBl)
.collect(Collectors.toList());
retVal = new RepoGenericResponse<>(launchNodesInVNG);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy