Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.spotinst.sdkjava.model.repo.oceanCD.OceanCDRepo Maven / Gradle / Ivy
package com.spotinst.sdkjava.model.repo.oceanCD;
import com.spotinst.sdkjava.exception.ExceptionHelper;
import com.spotinst.sdkjava.exception.SpotinstHttpException;
import com.spotinst.sdkjava.model.*;
import com.spotinst.sdkjava.model.api.oceanCD.ApiRolloutSpec;
import com.spotinst.sdkjava.model.api.oceanCD.ApiStrategy;
import com.spotinst.sdkjava.model.api.oceanCD.ApiVerificationProvider;
import com.spotinst.sdkjava.model.api.oceanCD.ApiVerificationTemplate;
import com.spotinst.sdkjava.model.api.oceanCD.response.ApiCluster;
import com.spotinst.sdkjava.model.api.oceanCD.response.ApiClusterNotification;
import com.spotinst.sdkjava.model.api.oceanCD.response.ApiRolloutStatus;
import com.spotinst.sdkjava.model.api.oceanCD.response.ApiRolloutsDetails;
import com.spotinst.sdkjava.model.bl.oceanCD.RolloutSpec;
import com.spotinst.sdkjava.model.bl.oceanCD.Strategy;
import com.spotinst.sdkjava.model.bl.oceanCD.VerificationProvider;
import com.spotinst.sdkjava.model.bl.oceanCD.VerificationTemplate;
import com.spotinst.sdkjava.model.bl.oceanCD.response.Cluster;
import com.spotinst.sdkjava.model.bl.oceanCD.response.ClusterNotification;
import com.spotinst.sdkjava.model.bl.oceanCD.response.RolloutStatus;
import com.spotinst.sdkjava.model.bl.oceanCD.response.RolloutsDetails;
import com.spotinst.sdkjava.model.converters.oceanCD.*;
import com.spotinst.sdkjava.model.requests.oceanCD.RolloutActions;
import com.spotinst.sdkjava.model.service.oceanCD.OceanCDService;
import java.util.List;
import java.util.stream.Collectors;
/**
* Created by Janetlin Kiruba on 11/08/2022.
*/
public class OceanCDRepo implements IOceanCDRepo {
@Override
public RepoGenericResponse createStrategy(Strategy createStrategyReq, String authToken) {
RepoGenericResponse retVal;
try {
ApiStrategy apiCreateStrategyReq = OceanCDStrategyConverter.toDal(createStrategyReq);
ApiStrategy apiCreateStrategyRes = OceanCDService.createStrategy(apiCreateStrategyReq, authToken);
Strategy createStrategyRes = OceanCDStrategyConverter.toBl(apiCreateStrategyRes);
retVal = new RepoGenericResponse<>(createStrategyRes);
}
catch (SpotinstHttpException ex) {
retVal = ExceptionHelper.handleHttpException(ex);
}
return retVal;
}
@Override
public RepoGenericResponse getStrategy(String strategyName, String authToken) {
RepoGenericResponse retVal;
try {
ApiStrategy apiCreateStrategy = OceanCDService.getStrategy(strategyName, authToken);
Strategy strategy = OceanCDStrategyConverter.toBl(apiCreateStrategy);
retVal = new RepoGenericResponse<>(strategy);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse> getAllStrategies(String authToken) {
RepoGenericResponse> retVal;
try {
List apiCreateStrategy = OceanCDService.getAllStrategies(authToken);
List strategies = apiCreateStrategy.stream().map(OceanCDStrategyConverter::toBl).collect(Collectors.toList());
retVal = new RepoGenericResponse<>(strategies);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse updateStrategy(Strategy strategyUpdateReq, String strategyName, String authToken) {
RepoGenericResponse retVal;
ApiStrategy apiStrategy = OceanCDStrategyConverter.toDal(strategyUpdateReq);
try {
Boolean success = OceanCDService.updateStrategy(apiStrategy, strategyName, authToken);
retVal = new RepoGenericResponse<>(success);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse patchStrategy(Strategy strategyUpdateReq, String strategyName, String authToken) {
RepoGenericResponse retVal;
ApiStrategy apiStrategy = OceanCDStrategyConverter.toDal(strategyUpdateReq);
try {
Boolean success = OceanCDService.patchStrategy(apiStrategy, strategyName, authToken);
retVal = new RepoGenericResponse<>(success);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse deleteStrategy(String strategyName, String authToken) {
RepoGenericResponse retVal;
try {
Boolean success = OceanCDService.deleteStrategy(strategyName, authToken);
retVal = new RepoGenericResponse<>(success);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse createRolloutSpec(RolloutSpec rolloutSpecReq, String authToken) {
RepoGenericResponse retVal;
try {
ApiRolloutSpec apiRolloutSpecReq = OceanCDRolloutSpecConverter.toDal(rolloutSpecReq);
ApiRolloutSpec apiRolloutSpecRes = OceanCDService.createRolloutSpec(apiRolloutSpecReq, authToken);
RolloutSpec createStrategyRes = OceanCDRolloutSpecConverter.toBl(apiRolloutSpecRes);
retVal = new RepoGenericResponse<>(createStrategyRes);
}
catch (SpotinstHttpException ex) {
retVal = ExceptionHelper.handleHttpException(ex);
}
return retVal;
}
@Override
public RepoGenericResponse getRolloutSpec(String rolloutSpecName, String authToken) {
RepoGenericResponse retVal;
try {
ApiRolloutSpec apiCreateStrategy = OceanCDService.getRolloutSpec(rolloutSpecName, authToken);
RolloutSpec strategy = OceanCDRolloutSpecConverter.toBl(apiCreateStrategy);
retVal = new RepoGenericResponse<>(strategy);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse> getAllRolloutSpecs(String authToken) {
RepoGenericResponse> retVal;
try {
List apiCreateStrategy = OceanCDService.getAllRolloutSpecs(authToken);
List strategies = apiCreateStrategy.stream().map(OceanCDRolloutSpecConverter::toBl).collect(Collectors.toList());
retVal = new RepoGenericResponse<>(strategies);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse updateRolloutSpec(RolloutSpec rolloutSpecReq, String rolloutSpecName, String authToken) {
RepoGenericResponse retVal;
ApiRolloutSpec apiRolloutSpec = OceanCDRolloutSpecConverter.toDal(rolloutSpecReq);
try {
Boolean success = OceanCDService.updateRolloutSpec(apiRolloutSpec, rolloutSpecName, authToken);
retVal = new RepoGenericResponse<>(success);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse patchRolloutSpec(RolloutSpec rolloutSpecReq, String rolloutSpecName, String authToken) {
RepoGenericResponse retVal;
ApiRolloutSpec apiRolloutSpec = OceanCDRolloutSpecConverter.toDal(rolloutSpecReq);
try {
Boolean success = OceanCDService.patchRolloutSpec(apiRolloutSpec, rolloutSpecName, authToken);
retVal = new RepoGenericResponse<>(success);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse deleteRolloutSpec(String rolloutSpecName, String authToken) {
RepoGenericResponse retVal;
try {
Boolean success = OceanCDService.deleteRolloutSpec(rolloutSpecName, authToken);
retVal = new RepoGenericResponse<>(success);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse getRolloutStatus(String rolloutId, String authToken) {
RepoGenericResponse retVal;
try {
ApiRolloutStatus apiRolloutStatus = OceanCDService.getRolloutStatus(rolloutId, authToken);
RolloutStatus rolloutStatus = OceanCDRolloutConverter.toBl(apiRolloutStatus);
retVal = new RepoGenericResponse<>(rolloutStatus);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse> getAllRollouts(String fromDate, String authToken) {
RepoGenericResponse> retVal;
try {
List apiRolloutStatus = OceanCDService.getAllRollouts(fromDate, authToken);
List rolloutStatus = apiRolloutStatus.stream().map(OceanCDRolloutConverter::toBl).collect(Collectors.toList());
retVal = new RepoGenericResponse<>(rolloutStatus);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse rolloutAction(RolloutActions rolloutActionsReq, String rolloutId, String authToken) {
RepoGenericResponse retVal;
try {
Boolean success = OceanCDService.rolloutAction(rolloutActionsReq, rolloutId, authToken);
retVal = new RepoGenericResponse<>(success);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse createVerificationProvider(VerificationProvider verificationProviderReq, String authToken) {
RepoGenericResponse retVal;
try {
ApiVerificationProvider apiverificationProviderReq = OceanCDVerificationProviderConverter.toDal(verificationProviderReq);
ApiVerificationProvider apiverificationProviderRes = OceanCDService.createVerificationProvider(apiverificationProviderReq, authToken);
VerificationProvider verificationProviderRes = OceanCDVerificationProviderConverter.toBl(apiverificationProviderRes);
retVal = new RepoGenericResponse<>(verificationProviderRes);
}
catch (SpotinstHttpException ex) {
retVal = ExceptionHelper.handleHttpException(ex);
}
return retVal;
}
@Override
public RepoGenericResponse getVerificationProvider(String verificationProviderName, String authToken) {
RepoGenericResponse retVal;
try {
ApiVerificationProvider apiVerificationProvider = OceanCDService.getVerificationProvider(verificationProviderName, authToken);
VerificationProvider verificationProvider = OceanCDVerificationProviderConverter.toBl(apiVerificationProvider);
retVal = new RepoGenericResponse<>(verificationProvider);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse> getAllVerificationProviders(String authToken) {
RepoGenericResponse> retVal;
try {
List apiVerificationProvider = OceanCDService.getAllVerificationProviders(authToken);
List strategies = apiVerificationProvider.stream().map(OceanCDVerificationProviderConverter::toBl).collect(Collectors.toList());
retVal = new RepoGenericResponse<>(strategies);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse updateVerificationProvider(VerificationProvider verificationProviderReq, String verificationProviderName, String authToken) {
RepoGenericResponse retVal;
ApiVerificationProvider apiVerificationProvider = OceanCDVerificationProviderConverter.toDal(verificationProviderReq);
try {
Boolean success = OceanCDService.updateVerificationProvider(apiVerificationProvider, verificationProviderName, authToken);
retVal = new RepoGenericResponse<>(success);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse patchVerificationProvider(VerificationProvider verificationProviderReq, String verificationProviderName, String authToken) {
RepoGenericResponse retVal;
ApiVerificationProvider apiVerificationProvider = OceanCDVerificationProviderConverter.toDal(verificationProviderReq);
try {
Boolean success = OceanCDService.patchVerificationProvider(apiVerificationProvider, verificationProviderName, authToken);
retVal = new RepoGenericResponse<>(success);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse deleteVerificationProvider(String verificationProviderName, String authToken) {
RepoGenericResponse retVal;
try {
Boolean success = OceanCDService.deleteVerificationProvider(verificationProviderName, authToken);
retVal = new RepoGenericResponse<>(success);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse createVerificationTemplate(VerificationTemplate verificationTemplateReq, String authToken) {
RepoGenericResponse retVal;
try {
ApiVerificationTemplate apiverificationTemplateReq = OceanCDVerificationTemplateConverter.toDal(verificationTemplateReq);
ApiVerificationTemplate apiverificationTemplateRes = OceanCDService.createVerificationTemplate(apiverificationTemplateReq, authToken);
VerificationTemplate verificationTemplateRes = OceanCDVerificationTemplateConverter.toBl(apiverificationTemplateRes);
retVal = new RepoGenericResponse<>(verificationTemplateRes);
}
catch (SpotinstHttpException ex) {
retVal = ExceptionHelper.handleHttpException(ex);
}
return retVal;
}
@Override
public RepoGenericResponse getVerificationTemplate(String verificationTemplateName, String authToken) {
RepoGenericResponse retVal;
try {
ApiVerificationTemplate apiVerificationTemplate = OceanCDService.getVerificationTemplate(verificationTemplateName, authToken);
VerificationTemplate verificationTemplate = OceanCDVerificationTemplateConverter.toBl(apiVerificationTemplate);
retVal = new RepoGenericResponse<>(verificationTemplate);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse> getAllVerificationTemplates(String authToken) {
RepoGenericResponse> retVal;
try {
List apiVerificationTemplate = OceanCDService.getAllVerificationTemplates(authToken);
List strategies = apiVerificationTemplate.stream().map(OceanCDVerificationTemplateConverter::toBl).collect(Collectors.toList());
retVal = new RepoGenericResponse<>(strategies);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse updateVerificationTemplate(VerificationTemplate verificationTemplateReq, String verificationTemplateName, String authToken) {
RepoGenericResponse retVal;
ApiVerificationTemplate apiVerificationTemplate = OceanCDVerificationTemplateConverter.toDal(verificationTemplateReq);
try {
Boolean success = OceanCDService.updateVerificationTemplate(apiVerificationTemplate, verificationTemplateName, authToken);
retVal = new RepoGenericResponse<>(success);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse patchVerificationTemplate(VerificationTemplate verificationTemplateReq, String verificationTemplateName, String authToken) {
RepoGenericResponse retVal;
ApiVerificationTemplate apiVerificationTemplate = OceanCDVerificationTemplateConverter.toDal(verificationTemplateReq);
try {
Boolean success = OceanCDService.patchVerificationTemplate(apiVerificationTemplate, verificationTemplateName, authToken);
retVal = new RepoGenericResponse<>(success);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse deleteVerificationTemplate(String verificationTemplateName, String authToken) {
RepoGenericResponse retVal;
try {
Boolean success = OceanCDService.deleteVerificationTemplate(verificationTemplateName, authToken);
retVal = new RepoGenericResponse<>(success);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse getCluster(String clusterId, String authToken) {
RepoGenericResponse retVal;
try {
ApiCluster apiCluster = OceanCDService.getCluster(clusterId, authToken);
Cluster cluster = OceanCDClusterConverter.toBl(apiCluster);
retVal = new RepoGenericResponse<>(cluster);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse> getAllClusters(String authToken) {
RepoGenericResponse> retVal;
try {
List apiCluster = OceanCDService.getAllClusters(authToken);
List clusters = apiCluster.stream().map(OceanCDClusterConverter::toBl).collect(Collectors.toList());
retVal = new RepoGenericResponse<>(clusters);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse updateCluster(ClusterNotification clusterNotificationReq, String clusterId, String authToken) {
RepoGenericResponse retVal;
ApiClusterNotification apiClusterNotification = OceanCDClusterConverter.toDal(clusterNotificationReq);
try {
Boolean success = OceanCDService.updateCluster(apiClusterNotification, clusterId, authToken);
retVal = new RepoGenericResponse<>(success);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
@Override
public RepoGenericResponse deleteCluster(String clusterId, String authToken) {
RepoGenericResponse retVal;
try {
Boolean success = OceanCDService.deleteCluster(clusterId, authToken);
retVal = new RepoGenericResponse<>(success);
}
catch (SpotinstHttpException e) {
retVal = ExceptionHelper.handleHttpException(e);
}
return retVal;
}
}