diff --git a/src/main/java/com/spotinst/sdkjava/client/http/GetRequestWithBody.java b/src/main/java/com/spotinst/sdkjava/client/http/GetRequestWithBody.java index 867c4d321..dd00e418e 100644 --- a/src/main/java/com/spotinst/sdkjava/client/http/GetRequestWithBody.java +++ b/src/main/java/com/spotinst/sdkjava/client/http/GetRequestWithBody.java @@ -1,11 +1,18 @@ package com.spotinst.sdkjava.client.http; +import org.apache.http.annotation.Contract; +import org.apache.http.annotation.ThreadingBehavior; import org.apache.http.client.methods.HttpPost; import java.net.URI; -public class GetRequestWithBody extends HttpPost { +/** + * Created by Saikumar Jalda on 03 Mar 2022 + * + */ +@Contract(threading = ThreadingBehavior.UNSAFE) +public class GetRequestWithBody extends HttpPost { @Override public String getMethod() { return "GET"; diff --git a/src/main/java/com/spotinst/sdkjava/client/rest/RestClient.java b/src/main/java/com/spotinst/sdkjava/client/rest/RestClient.java index 2f70000d8..b4a14019b 100755 --- a/src/main/java/com/spotinst/sdkjava/client/rest/RestClient.java +++ b/src/main/java/com/spotinst/sdkjava/client/rest/RestClient.java @@ -323,4 +323,5 @@ private static RestResponse buildRestResponse(HttpResponse response) throws Spot return retVal; } + } diff --git a/src/main/java/com/spotinst/sdkjava/example/elastigroup/aws/ElastigroupUsageExample.java b/src/main/java/com/spotinst/sdkjava/example/elastigroup/aws/ElastigroupUsageExample.java index 85f47d246..3e4cbdfa1 100644 --- a/src/main/java/com/spotinst/sdkjava/example/elastigroup/aws/ElastigroupUsageExample.java +++ b/src/main/java/com/spotinst/sdkjava/example/elastigroup/aws/ElastigroupUsageExample.java @@ -9,8 +9,9 @@ import com.spotinst.sdkjava.model.bl.elastigroup.aws.*; import com.spotinst.sdkjava.model.requests.elastigroup.*; import com.spotinst.sdkjava.model.requests.elastigroup.aws.*; +import com.spotinst.sdkjava.model.bl.elastigroup.aws.SuspendedScalingPolicy; +import com.spotinst.sdkjava.model.responses.elastigroup.aws.CodeDeployBGDeploymentResponse; import com.sun.org.apache.xpath.internal.operations.Bool; - import java.io.IOException; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -223,6 +224,15 @@ public static void main(String[] args) throws IOException { // Beanstalk Reimport System.out.println("----------Beanstalk Reimport--------------"); beanstalkReimport(elastigroupClient, groupId); + + //Create codeDeploy B/G deployment + System.out.println("----------Create CodeDeploy B/G Deployment--------------"); + deploymentId = createCodeDeployBGDeployment(elastigroupClient, "elastigroup-id").get(0).getId(); + + //Get codeDeploy B/G deployment + System.out.println("----------Get CodeDeploy B/G Deployment--------------"); + String getDeploymentId = getCodeDeployBGDeployment(elastigroupClient, "elastigroup-id").get(0).getId(); + } private static void getInstanceHealthiness(SpotinstElastigroupClient elastigroupClient, String elastigroupId) { @@ -1311,4 +1321,85 @@ private static Elastigroup beanstalkReimport(SpotinstElastigroupClient client, S System.out.println(String.format("Instance ID: %s", response.getId())); return response; } + + private static List createCodeDeployBGDeployment(SpotinstElastigroupClient elastigroupClient, + String elastigroupId) { + + //Build Tags + Tag.Builder tagsBuilder = Tag.Builder.get(); + Tag tags = + tagsBuilder.setTagKey("ver").setTagValue("pink").build(); + List tagsArrayList = new ArrayList<>(); + tagsArrayList.add(tags); + + //Build deploymentGroup + ElastigroupDeploymentGroup.Builder deploymentGroupBuilder = ElastigroupDeploymentGroup.Builder.get(); + ElastigroupDeploymentGroup deploymentGroup = + deploymentGroupBuilder.setApplicationName("appTest").setDeploymentGroupName("deploymentGroupName").build(); + List deploymentGroupArrayList = new ArrayList<>(); + deploymentGroupArrayList.add(deploymentGroup); + + //Build CodeDeploy + ElastigroupCodeDeployBGDeployment.Builder codeDeployBuilder = ElastigroupCodeDeployBGDeployment.Builder.get(); + ElastigroupCodeDeployBGDeployment codeDeploy = + codeDeployBuilder.setTimeout(20).setTags(tagsArrayList).setDeploymentGroups(deploymentGroupArrayList).build(); + + //Build Create CodeDeploy Deployment Request + ElastigroupCreateCodeDeployRequest.Builder createCodeDeployRequestBuilder = ElastigroupCreateCodeDeployRequest.Builder.get(); + ElastigroupCreateCodeDeployRequest createCodeDeployRequest = + createCodeDeployRequestBuilder.setCodeDeployBGDeployment(codeDeploy).build(); + + System.out.println("Create Deployment Request for elastigroup:" + elastigroupId); + System.out.println(createCodeDeployRequest.toJson()); + + List codeDeployBGDeploymentResponse = + elastigroupClient.createCodeDeployBGDeployment(createCodeDeployRequest, elastigroupId); + + System.out.println("Create deployment for elastigroup: " + elastigroupId + " with id " + codeDeployBGDeploymentResponse.get(0).getId() + + " with groupid " + codeDeployBGDeploymentResponse.get(0).getGroupId() + + " and state " + codeDeployBGDeploymentResponse.get(0).getState()); + + return codeDeployBGDeploymentResponse; + + } + + private static List getCodeDeployBGDeployment(SpotinstElastigroupClient elastigroupClient, + String elastigroupId) { + + //Build Tag + Tag.Builder tagsBuilder = Tag.Builder.get(); + Tag tags = + tagsBuilder.setTagKey("ver").setTagValue("pink").build(); + List tagsArrayList = new ArrayList<>(); + tagsArrayList.add(tags); + + //Build deploymentGroup + ElastigroupDeploymentGroup.Builder deploymentGroupBuilder = ElastigroupDeploymentGroup.Builder.get(); + ElastigroupDeploymentGroup deploymentGroup = + deploymentGroupBuilder.setApplicationName("appTest").setDeploymentGroupName("deploymentGroupName").build(); + List deploymentGroupArrayList = new ArrayList<>(); + deploymentGroupArrayList.add(deploymentGroup); + + //Build CodeDeploy + ElastigroupCodeDeployBGDeployment.Builder codeDeployBuilder = ElastigroupCodeDeployBGDeployment.Builder.get(); + ElastigroupCodeDeployBGDeployment codeDeploy = + codeDeployBuilder.setTimeout(120).setTags(tagsArrayList).setDeploymentGroups(deploymentGroupArrayList).build(); + + //Build Get CodeDeploy Deployment Request + ElastigroupGetCodeDeployRequest.Builder getCodeDeployRequestBuilder = ElastigroupGetCodeDeployRequest.Builder.get(); + ElastigroupGetCodeDeployRequest getCodeDeployRequest = + getCodeDeployRequestBuilder.setCodeDeployBGDeployment(codeDeploy).build(); + + System.out.println("Get Deployment Request for elastigroup:" + elastigroupId); + System.out.println(getCodeDeployRequest.toJson()); + + List codeDeployBGDeploymentResponse = + elastigroupClient.getCodeDeployBGDeployment(getCodeDeployRequest, elastigroupId); + + System.out.println("Get deployment for elastigroup: " + elastigroupId + " with id " + codeDeployBGDeploymentResponse.get(0).getId() + + " with groupid " + codeDeployBGDeploymentResponse.get(0).getGroupId() + + " and state " + codeDeployBGDeploymentResponse.get(0).getState()); + + return codeDeployBGDeploymentResponse; + } } diff --git a/src/main/java/com/spotinst/sdkjava/model/ElastigroupConverter.java b/src/main/java/com/spotinst/sdkjava/model/ElastigroupConverter.java old mode 100755 new mode 100644 index 07a15f8f9..ec539a0b4 --- a/src/main/java/com/spotinst/sdkjava/model/ElastigroupConverter.java +++ b/src/main/java/com/spotinst/sdkjava/model/ElastigroupConverter.java @@ -6,6 +6,7 @@ import com.spotinst.sdkjava.enums.aws.elastigroup.AwsTerminationPolicyEnum; import com.spotinst.sdkjava.model.api.elastigroup.aws.*; import com.spotinst.sdkjava.model.bl.elastigroup.aws.*; +import com.spotinst.sdkjava.model.responses.elastigroup.aws.CodeDeployBGDeploymentResponse; import java.util.LinkedList; import java.util.List; @@ -4060,7 +4061,93 @@ public static ElastigroupGetInstanceStatusResponse toBl( } return retVal; + } + + public static ApiElastigroupCodeDeployBGDeployment toDal(ElastigroupCodeDeployBGDeployment codeDeployBGDeployment) { + ApiElastigroupCodeDeployBGDeployment retVal = null; + + if (codeDeployBGDeployment != null) { + retVal = new ApiElastigroupCodeDeployBGDeployment(); + + if (codeDeployBGDeployment.isTimeoutSet()) { + retVal.setTimeout(codeDeployBGDeployment.getTimeout()); + } + + if (codeDeployBGDeployment.isTagsSet()) { + if (codeDeployBGDeployment.getTags() != null) { + List tags = + codeDeployBGDeployment.getTags().stream().map(ElastigroupConverter::toDal) + .collect(Collectors.toList()); + retVal.setTags(tags); + } + } + + if (codeDeployBGDeployment.isDeploymentGroupsSet()) { + if (codeDeployBGDeployment.getDeploymentGroups() != null) { + List deploymentGroups = + codeDeployBGDeployment.getDeploymentGroups().stream().map((ElastigroupConverter::toDal)) + .collect(Collectors.toList()); + retVal.setDeploymentGroups(deploymentGroups); + } + } + } + return retVal; + } + + public static CodeDeployBGDeploymentResponse toBl(ApiCodeDeployBGDeploymentResponse apiCodeDeployBGResponse) { + CodeDeployBGDeploymentResponse retVal = null; + + if (apiCodeDeployBGResponse != null) { + + retVal = new CodeDeployBGDeploymentResponse(); + + if (apiCodeDeployBGResponse.isIdSet()) { + retVal.setId(apiCodeDeployBGResponse.getId()); + } + if (apiCodeDeployBGResponse.isGroupIdSet()) { + retVal.setGroupId(apiCodeDeployBGResponse.getGroupId()); + } + + if (apiCodeDeployBGResponse.isStateSet()) { + retVal.setState(apiCodeDeployBGResponse.getState()); + } + + if (apiCodeDeployBGResponse.isConfigSet()) { + retVal.setConfig(apiCodeDeployBGResponse.getConfig()); + } + + } + return retVal; + } + + private static CodeDeployConfig toBl(ApiCodeDeployConfig apiCodeDeployConfig) { + CodeDeployConfig retVal = null; + + if (apiCodeDeployConfig != null) { + + retVal = new CodeDeployConfig(); + + if (apiCodeDeployConfig.isTimeoutSet()) { + retVal.setTimeout(apiCodeDeployConfig.getTimeout()); + } + + if (apiCodeDeployConfig.isTagsSet()) { + List tags = + apiCodeDeployConfig.getTag().stream().map(ElastigroupConverter::toBl) + .collect(Collectors.toList()); + retVal.setTags(tags); + } + + if (apiCodeDeployConfig.isDeploymentGroupsSet()) { + List deploymentGroups = + apiCodeDeployConfig.getDeploymentGroups().stream().map(ElastigroupConverter::toBl) + .collect(Collectors.toList()); + retVal.setDeploymentGroups(deploymentGroups); + } + + } + return retVal; } public static ElastigroupGetBeanstalkMaintenanceStatusResponse toBl(ApiElastigroupGetBeanstalkMaintenanceStatusResponse apiGetBeanstalkStatus) { diff --git a/src/main/java/com/spotinst/sdkjava/model/ISpotinstElastigroupRepo.java b/src/main/java/com/spotinst/sdkjava/model/ISpotinstElastigroupRepo.java index 9a02e767c..6e7184b6d 100644 --- a/src/main/java/com/spotinst/sdkjava/model/ISpotinstElastigroupRepo.java +++ b/src/main/java/com/spotinst/sdkjava/model/ISpotinstElastigroupRepo.java @@ -5,6 +5,7 @@ import com.spotinst.sdkjava.model.requests.elastigroup.ElastigroupInstanceLockRequest; import com.spotinst.sdkjava.model.requests.elastigroup.ElastigroupInstanceUnLockRequest; import com.spotinst.sdkjava.model.requests.elastigroup.aws.*; +import com.spotinst.sdkjava.model.responses.elastigroup.aws.CodeDeployBGDeploymentResponse; import java.util.List; @@ -136,4 +137,8 @@ RepoGenericResponse deallocateStatefulInstance(String elastigroupId, St RepoGenericResponse beanstalkReimport(String groupId, String authToken, String account); RepoGenericResponse amiBackup(String elastigroupId, String authToken, String account); + + RepoGenericResponse> createCodeDeployBGDeployment(ElastigroupCreateCodeDeployRequest request, String elastigroupId, String authToken, String account); + + RepoGenericResponse> getCodeDeployBGDeployment(ElastigroupGetCodeDeployRequest request, String elastigroupId, String authToken, String account); } diff --git a/src/main/java/com/spotinst/sdkjava/model/SpotinstElastigroupClient.java b/src/main/java/com/spotinst/sdkjava/model/SpotinstElastigroupClient.java index 2bf6b7807..e15218f2e 100644 --- a/src/main/java/com/spotinst/sdkjava/model/SpotinstElastigroupClient.java +++ b/src/main/java/com/spotinst/sdkjava/model/SpotinstElastigroupClient.java @@ -10,6 +10,7 @@ import com.spotinst.sdkjava.model.requests.elastigroup.ElastigroupInstanceLockRequest; import com.spotinst.sdkjava.model.requests.elastigroup.ElastigroupInstanceUnLockRequest; import com.spotinst.sdkjava.model.requests.elastigroup.aws.*; +import com.spotinst.sdkjava.model.responses.elastigroup.aws.CodeDeployBGDeploymentResponse; import com.spotinst.sdkjava.utils.TimeUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -1430,4 +1431,52 @@ public Boolean amiBackup(String groupId) { return retVal; } + + public List createCodeDeployBGDeployment(ElastigroupCreateCodeDeployRequest request, String elastigroupId) { + + List codeDeployBGDeploymentResponses; + + RepoGenericResponse > getCodeDeployResponse = + getSpotinstElastigroupRepo().createCodeDeployBGDeployment(request, elastigroupId, authToken, account); + + if(getCodeDeployResponse.isRequestSucceed()){ + codeDeployBGDeploymentResponses = getCodeDeployResponse.getValue(); + } + else { + List httpExceptions = getCodeDeployResponse.getHttpExceptions(); + HttpError httpException = httpExceptions.get(0); + LOGGER.error(String.format( + "Error encountered while attempting to get the instance types by region. Code: %s. Message: %s.", + + httpException.getCode(), httpException.getMessage())); + + throw new SpotinstHttpException(httpException.getMessage()); + } + + return codeDeployBGDeploymentResponses; + + } + + public List getCodeDeployBGDeployment(ElastigroupGetCodeDeployRequest request, String elastigroupId) { + + List codeDeployBGDeploymentResponses; + + RepoGenericResponse> getCodeDeployResponse = + getSpotinstElastigroupRepo().getCodeDeployBGDeployment(request, elastigroupId, authToken, account); + + if (getCodeDeployResponse.isRequestSucceed()) { + codeDeployBGDeploymentResponses = getCodeDeployResponse.getValue(); + } else { + List httpExceptions = getCodeDeployResponse.getHttpExceptions(); + HttpError httpException = httpExceptions.get(0); + LOGGER.error(String.format( + "Error encountered while attempting to get the instance types by region. Code: %s. Message: %s.", + + httpException.getCode(), httpException.getMessage())); + + throw new SpotinstHttpException(httpException.getMessage()); + } + + return codeDeployBGDeploymentResponses; + } } \ No newline at end of file diff --git a/src/main/java/com/spotinst/sdkjava/model/SpotinstElastigroupRepo.java b/src/main/java/com/spotinst/sdkjava/model/SpotinstElastigroupRepo.java index 5f3a8ed92..ddcd56c5a 100644 --- a/src/main/java/com/spotinst/sdkjava/model/SpotinstElastigroupRepo.java +++ b/src/main/java/com/spotinst/sdkjava/model/SpotinstElastigroupRepo.java @@ -11,6 +11,7 @@ import com.spotinst.sdkjava.model.requests.elastigroup.ElastigroupInstanceLockRequest; import com.spotinst.sdkjava.model.requests.elastigroup.ElastigroupInstanceUnLockRequest; import com.spotinst.sdkjava.model.requests.elastigroup.aws.*; +import com.spotinst.sdkjava.model.responses.elastigroup.aws.CodeDeployBGDeploymentResponse; import java.util.List; import java.util.stream.Collectors; @@ -30,8 +31,7 @@ public RepoGenericResponse create(Elastigroup elastigroupToCreate, SpotinstElastigroupService.createElastigroup(apiElastigroupToCreate, authToken, account); Elastigroup createdElastigroup = ElastigroupConverter.toBl(apiCreatedElastigroup); retVal = new RepoGenericResponse<>(createdElastigroup); - } - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } @@ -46,8 +46,7 @@ public RepoGenericResponse delete(String identifier, String authToken, Boolean updated = SpotinstElastigroupService.deleteElastigroup(identifier, authToken, account); retVal = new RepoGenericResponse<>(updated); - } - catch (SpotinstHttpException e) { + } catch (SpotinstHttpException e) { retVal = ExceptionHelper.handleHttpException(e); } @@ -64,8 +63,7 @@ public RepoGenericResponse delete(String elastigroupId, String authToke SpotinstElastigroupService.deleteElastigroup(elastigroupId, authToken, account, deleteRequest); retVal = new RepoGenericResponse<>(updated); - } - catch (SpotinstHttpException e) { + } catch (SpotinstHttpException e) { retVal = ExceptionHelper.handleHttpException(e); } @@ -82,8 +80,7 @@ public RepoGenericResponse detachInstances(String elastigroupId, ApiDetachInstancesRequest apiDetachRequest = ApiDetachInstancesRequestConverter.toDal(detachRequest); SpotinstElastigroupService.detachInstances(elastigroupId, apiDetachRequest, authToken, account); retVal = new RepoGenericResponse<>(new Boolean(true)); - } - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } @@ -100,8 +97,7 @@ public RepoGenericResponse update(String elastigroupId, Elastigroup gro try { Boolean success = SpotinstElastigroupService.updateGroup(elastigroupId, apiElastigroup, authToken, account); retVal = new RepoGenericResponse<>(success); - } - catch (SpotinstHttpException e) { + } catch (SpotinstHttpException e) { retVal = ExceptionHelper.handleHttpException(e); } @@ -114,10 +110,9 @@ public RepoGenericResponse get(String elastigroupId, String authTok try { ApiElastigroup apiElastigroup = SpotinstElastigroupService.getGroup(elastigroupId, authToken, account); - Elastigroup elastigroup = ElastigroupConverter.toBl(apiElastigroup); + Elastigroup elastigroup = ElastigroupConverter.toBl(apiElastigroup); retVal = new RepoGenericResponse<>(elastigroup); - } - catch (SpotinstHttpException e) { + } catch (SpotinstHttpException e) { retVal = ExceptionHelper.handleHttpException(e); } @@ -133,8 +128,7 @@ public RepoGenericResponse> getAll(GroupFilter filter, String List elastigroups = apiElastigroups.stream().map(ElastigroupConverter::toBl).collect(Collectors.toList()); retVal = new RepoGenericResponse<>(elastigroups); - } - catch (SpotinstHttpException e) { + } catch (SpotinstHttpException e) { retVal = ExceptionHelper.handleHttpException(e); } @@ -162,8 +156,7 @@ public RepoGenericResponse scaleUp(ElastigroupScalin ElastigroupScalingResponse elastigroupScalingResponse = ApiElastigroupScalingResponseConverter.dalToBl(apiElastigroupScalingResponse); retVal = new RepoGenericResponse<>(elastigroupScalingResponse); - } - catch (SpotinstHttpException e) { + } catch (SpotinstHttpException e) { retVal = ExceptionHelper.handleHttpException(e); } @@ -191,8 +184,7 @@ public RepoGenericResponse scaleDown(ElastigroupScal ElastigroupScalingResponse elastigroupScalingResponse = ApiElastigroupScalingResponseConverter.dalToBl(apiElastigroupScalingResponse); retVal = new RepoGenericResponse<>(elastigroupScalingResponse); - } - catch (SpotinstHttpException e) { + } catch (SpotinstHttpException e) { retVal = ExceptionHelper.handleHttpException(e); } @@ -203,15 +195,14 @@ public RepoGenericResponse scaleDown(ElastigroupScal public RepoGenericResponse clone(String sourceElastigroupId, Elastigroup groupModifications, String authToken, String account) { RepoGenericResponse retVal; - ApiElastigroup apiGroupModifications = ElastigroupConverter.toDal(groupModifications); + ApiElastigroup apiGroupModifications = ElastigroupConverter.toDal(groupModifications); try { ApiElastigroup apiClonedElastigroup = SpotinstElastigroupService .cloneGroup(sourceElastigroupId, apiGroupModifications, authToken, account); Elastigroup clonedElastigroup = ElastigroupConverter.toBl(apiClonedElastigroup); retVal = new RepoGenericResponse<>(clonedElastigroup); - } - catch (SpotinstHttpException e) { + } catch (SpotinstHttpException e) { retVal = ExceptionHelper.handleHttpException(e); } @@ -225,8 +216,7 @@ public RepoGenericResponse enterInstanceStandby(String instanceId, Stri try { Boolean success = SpotinstElastigroupService.enterInstanceStandby(instanceId, authToken, account); retVal = new RepoGenericResponse<>(success); - } - catch (SpotinstHttpException e) { + } catch (SpotinstHttpException e) { retVal = ExceptionHelper.handleHttpException(e); } @@ -240,8 +230,7 @@ public RepoGenericResponse exitInstanceStandby(String instanceId, Strin try { Boolean success = SpotinstElastigroupService.exitInstanceStandby(instanceId, authToken, account); retVal = new RepoGenericResponse<>(success); - } - catch (SpotinstHttpException e) { + } catch (SpotinstHttpException e) { retVal = ExceptionHelper.handleHttpException(e); } @@ -253,7 +242,7 @@ public RepoGenericResponse exitInstanceStandby(String instanceId, Strin public RepoGenericResponse suspendProcesses(String groupId, List suspensions, String authToken, String account) { RepoGenericResponse retVal; - ApiSuspendProcessesRequest request = new ApiSuspendProcessesRequest(); + ApiSuspendProcessesRequest request = new ApiSuspendProcessesRequest(); List apiSuspensions = suspensions.stream().map(ApiProcessSuspensionConverter::toDal).collect(Collectors.toList()); @@ -265,8 +254,7 @@ public RepoGenericResponse suspendProcesses(String groupId, SuspendedProcesses suspendedProcesses = ApiProcessSuspensionConverter.toBl(apiResponse); retVal = new RepoGenericResponse<>(suspendedProcesses); - } - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } @@ -278,7 +266,7 @@ public RepoGenericResponse removeSuspensions(String elastigr List processes, String authToken, String account) { RepoGenericResponse retVal; - ApiRemoveSuspensionsRequest request = new ApiRemoveSuspensionsRequest(); + ApiRemoveSuspensionsRequest request = new ApiRemoveSuspensionsRequest(); List processNames = processes.stream().map(ProcessNameEnum::getName).collect(Collectors.toList()); request.setProcesses(processNames); @@ -289,8 +277,7 @@ public RepoGenericResponse removeSuspensions(String elastigr SuspendedProcesses suspendedProcesses = ApiProcessSuspensionConverter.toBl(apiResponse); retVal = new RepoGenericResponse<>(suspendedProcesses); - } - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } @@ -308,8 +295,7 @@ public RepoGenericResponse getSuspendedProcesses(String elas SuspendedProcesses suspendedProcesses = ApiProcessSuspensionConverter.toBl(apiResponse); retVal = new RepoGenericResponse<>(suspendedProcesses); - } - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } @@ -324,8 +310,7 @@ public RepoGenericResponse lockInstance(ElastigroupInstanceLockRequest try { Boolean success = SpotinstElastigroupService.lockInstance(lockRequest, authToken, instanceId); retVal = new RepoGenericResponse<>(success); - } - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } @@ -340,8 +325,7 @@ public RepoGenericResponse unlockInstance(ElastigroupInstanceUnLockRequ try { Boolean success = SpotinstElastigroupService.unlockInstance(unlockRequest, authToken, instanceId); retVal = new RepoGenericResponse<>(success); - } - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } @@ -356,8 +340,7 @@ public RepoGenericResponse simulateInstanceInterruption(String authToke try { Boolean success = SpotinstElastigroupService.simulateInstanceInterruption(authToken, account, instanceIds); retVal = new RepoGenericResponse<>(success); - } - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } @@ -379,8 +362,7 @@ public RepoGenericResponse suspendScalingPolicies(String SuspendedScalingPolicy suspendedProcesses = ScalingPoliciesSuspensionConverter.toBl(apiResponse); retVal = new RepoGenericResponse<>(suspendedProcesses); - } - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } return retVal; @@ -400,8 +382,7 @@ public RepoGenericResponse getAllSuspendedScalingP ScalingPoliciesSuspensionConverter.toBl(suspendedApiResponse); retVal = new RepoGenericResponse<>(allSuspendedScalingPolicies); - } - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } return retVal; @@ -416,8 +397,7 @@ public RepoGenericResponse removeSuspendedScalingPolicies(String elasti Boolean removeStatus = SpotinstElastigroupService.removeSuspendScalingPolicies(elastiGroupId, policyName, authToken, account); retVal = new RepoGenericResponse<>(removeStatus); - } - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } return retVal; @@ -426,7 +406,7 @@ public RepoGenericResponse removeSuspendedScalingPolicies(String elasti @Override public RepoGenericResponse startDeployment(String elastigroupId, ElastigroupStartDeployment elastiGroupDeployment, String authToken, String account) { - RepoGenericResponse retVal; + RepoGenericResponse retVal; try { @@ -434,12 +414,10 @@ public RepoGenericResponse startDeployment(S .startDeployment(elastigroupId, elastiGroupDeployment, authToken, account); ElastigroupStartDeploymentResponse - startDeploymentResponse = ElastigroupConverter.toBl(apiElastigroupDeployment); + startDeploymentResponse = ElastigroupConverter.toBl(apiElastigroupDeployment); retVal = new RepoGenericResponse<>(startDeploymentResponse); - } - - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } @@ -460,9 +438,7 @@ public RepoGenericResponse stopDeployment( ElastigroupStopDeploymentResponse stopDeploymentResponse = ElastigroupConverter.toBl(apiStopDeployment); retVal = new RepoGenericResponse<>(stopDeploymentResponse); - } - - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } @@ -481,12 +457,10 @@ public RepoGenericResponse getDeployment .getDeploymentStatus(elastigroupId, deploymentId, authToken, account); ElastigroupGetDeploymentStatusResponse - getDeploymentResponse = ElastigroupConverter.toBl(apiElastigroupGetDeploymentStatusResponse); + getDeploymentResponse = ElastigroupConverter.toBl(apiElastigroupGetDeploymentStatusResponse); retVal = new RepoGenericResponse<>(getDeploymentResponse); - } - - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } @@ -496,7 +470,7 @@ public RepoGenericResponse getDeployment @Override public RepoGenericResponse> getGroupDeploymentStatus(String elastigroupId, String authToken, String account) { - RepoGenericResponse> retVal ; + RepoGenericResponse> retVal; try { @@ -507,9 +481,7 @@ public RepoGenericResponse> getGr apiElastigroupGetGroupDeploymentStatusResponse.stream().map(ElastigroupConverter::toBl).collect(Collectors.toList()); retVal = new RepoGenericResponse<>(getGroupDeploymentResponse); - } - - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } @@ -520,8 +492,8 @@ public RepoGenericResponse> getGr @Override public RepoGenericResponse applyDeploymentAction( - ElastigroupDeploymentStrategyOnFailure elastigroupGetDeploymentActionRequest, String elastigroupId, String deploymentId , String authToken, String account) { - RepoGenericResponse retVal ; + ElastigroupDeploymentStrategyOnFailure elastigroupGetDeploymentActionRequest, String elastigroupId, String deploymentId, String authToken, String account) { + RepoGenericResponse retVal; try { @@ -529,12 +501,10 @@ public RepoGenericResponse applyDeployme .applyDeploymentAction(elastigroupGetDeploymentActionRequest, elastigroupId, deploymentId, authToken, account); ElastigroupGetDeploymentActionResponse - getDeploymentActionResponse = ElastigroupConverter.toBl(apiElastigroupGetDeploymentActionResponse); + getDeploymentActionResponse = ElastigroupConverter.toBl(apiElastigroupGetDeploymentActionResponse); retVal = new RepoGenericResponse<>(getDeploymentActionResponse); - } - - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } @@ -554,11 +524,10 @@ public RepoGenericResponse> getItfMigrationRulesSt List list = getMigrationApiResponse.stream().map(ItfMigrationConverter::toBl) - .collect(Collectors.toList()); + .collect(Collectors.toList()); retVal = new RepoGenericResponse<>(list); - } - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } return retVal; @@ -566,17 +535,16 @@ public RepoGenericResponse> getItfMigrationRulesSt @Override public RepoGenericResponse retryItfMigration(String elastiGroupId, RetryItfMigrationRequest request, - String authToken, String account) { + String authToken, String account) { RepoGenericResponse retVal; try { ApiRetryItfMigrationRequest apiRequest = ItfMigrationConverter.toDal(request); Boolean retryItfMigrationResponse = - SpotinstElastigroupService.retryItfMigration(elastiGroupId,apiRequest, authToken, account); + SpotinstElastigroupService.retryItfMigration(elastiGroupId, apiRequest, authToken, account); retVal = new RepoGenericResponse<>(retryItfMigrationResponse); - } - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } return retVal; @@ -594,9 +562,7 @@ public RepoGenericResponse updateCapacity(String elastigroupId, Elastig .updateCapacity(elastigroupId, elastiGroupUpdateCapacity, authToken, account); retVal = new RepoGenericResponse<>(updateCapacityResponse); - } - - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } @@ -609,15 +575,13 @@ public RepoGenericResponse importEC2Instance(ElastigroupImportEC2In RepoGenericResponse retVal; try { - + ApiElastigroup importEC2Instance = SpotinstElastigroupService .importEC2Instance(elastigroupImportInstance, instanceId, region, authToken, account); Elastigroup importedEC2Instance = ElastigroupConverter.toBl(importEC2Instance); retVal = new RepoGenericResponse<>(importedEC2Instance); - } - - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } @@ -635,9 +599,7 @@ public RepoGenericResponse pauseStatefulInstance(String elastigroupId, .pauseStatefulInstance(elastigroupId, statefulInstanceId, authToken, account); retVal = new RepoGenericResponse<>(pauseStatefulInstanceResponse); - } - - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } @@ -647,7 +609,7 @@ public RepoGenericResponse pauseStatefulInstance(String elastigroupId, @Override public RepoGenericResponse resumeStatefulInstance(String elastigroupId, String statefulInstanceId, - String authToken, String account) { + String authToken, String account) { RepoGenericResponse retVal; try { @@ -657,9 +619,7 @@ public RepoGenericResponse resumeStatefulInstance(String elastigroupId, .resumeStatefulInstance(elastigroupId, statefulInstanceId, authToken, account); retVal = new RepoGenericResponse<>(resumeStatefulInstanceResponse); - } - - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } @@ -669,7 +629,7 @@ public RepoGenericResponse resumeStatefulInstance(String elastigroupId, @Override public RepoGenericResponse recycleStatefulInstance(String elastigroupId, String statefulInstanceId, - String authToken, String account) { + String authToken, String account) { RepoGenericResponse retVal; try { @@ -679,9 +639,7 @@ public RepoGenericResponse recycleStatefulInstance(String elastigroupId .recycleStatefulInstance(elastigroupId, statefulInstanceId, authToken, account); retVal = new RepoGenericResponse<>(recycleStatefulInstanceResponse); - } - - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } @@ -691,7 +649,7 @@ public RepoGenericResponse recycleStatefulInstance(String elastigroupId @Override public RepoGenericResponse deallocateStatefulInstance(String elastigroupId, String statefulInstanceId, - String authToken, String account) { + String authToken, String account) { RepoGenericResponse retVal; try { @@ -701,9 +659,7 @@ public RepoGenericResponse deallocateStatefulInstance(String elastigrou .deallocateStatefulInstance(elastigroupId, statefulInstanceId, authToken, account); retVal = new RepoGenericResponse<>(deallocateStatefulInstanceResponse); - } - - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } @@ -720,12 +676,10 @@ public RepoGenericResponse> listS List listStatefulInstances = SpotinstElastigroupService .listStatefulInstances(elastigroupId, authToken, account); List statefulInstances = listStatefulInstances.stream().map(StatefulElastigroupConverter::toBl) - .collect(Collectors.toList()); + .collect(Collectors.toList()); retVal = new RepoGenericResponse<>(statefulInstances); - } - - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } @@ -744,9 +698,7 @@ public RepoGenericResponse deleteVolumeInStatefulInstance(String elasti .deleteVolumeInStatefulInstance(elastigroupId, statefulInstanceId, volumeId, authToken, account); retVal = new RepoGenericResponse<>(deleteVolumeInStatefulInstanceResponse); - } - - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } @@ -766,9 +718,7 @@ public RepoGenericResponse> getElastilog(E .collect(Collectors.toList()); retVal = new RepoGenericResponse<>(getAllLogs); - } - - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } @@ -787,16 +737,15 @@ public RepoGenericResponse importASG(ImportASGRequest importASGRequ Elastigroup importedASG = ElastigroupConverter.toBl(importASG); retVal = new RepoGenericResponse<>(importedASG); - } - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } return retVal; } - @Override - public RepoGenericResponse> getInstanceTypesByRegion(String region, String authToken, String account) { + @Override + public RepoGenericResponse> getInstanceTypesByRegion(String region, String authToken, String account) { RepoGenericResponse> retVal; try { @@ -807,9 +756,7 @@ public RepoGenericResponse> getInstanceTypesByReg .collect(Collectors.toList()); retVal = new RepoGenericResponse<>(getAllInstanceTypes); - } - - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } @@ -828,9 +775,7 @@ public RepoGenericResponse> getSuggestedInstanceT .collect(Collectors.toList()); retVal = new RepoGenericResponse<>(getAllInstanceTypes); - } - - catch (SpotinstHttpException ex) { + } catch (SpotinstHttpException ex) { retVal = ExceptionHelper.handleHttpException(ex); } @@ -934,7 +879,6 @@ public RepoGenericResponse importStat } return retVal; - } @Override @@ -955,7 +899,6 @@ public RepoGenericResponse getStatef } return retVal; - } @Override @@ -1035,6 +978,7 @@ public RepoGenericResponse getInstanceStat return retVal; } + public RepoGenericResponse amiBackup(String elastigroupId, String authToken, String account) { RepoGenericResponse retVal; @@ -1051,6 +995,25 @@ public RepoGenericResponse amiBackup(String elastigroupId, String authT return retVal; } + @Override + public RepoGenericResponse> createCodeDeployBGDeployment(ElastigroupCreateCodeDeployRequest request, String elastigroupId, String authToken, String account) { + RepoGenericResponse> retVal; + + try { + + List apiCodeDeployResponse = SpotinstElastigroupService + .createCodeDeployBGDeployment(request, elastigroupId, authToken, account); + List codeDeployResponse = apiCodeDeployResponse.stream().map(ElastigroupConverter::toBl) + .collect(Collectors.toList()); + + retVal = new RepoGenericResponse<>(codeDeployResponse); + } catch (SpotinstHttpException ex) { + retVal = ExceptionHelper.handleHttpException(ex); + } + + return retVal; + } + @Override public RepoGenericResponse startBeanstalkMaintenance(String groupId, String authToken, String account) { RepoGenericResponse retVal; @@ -1085,6 +1048,24 @@ public RepoGenericResponse finishBeanstalkMaintenance(String groupId, S return retVal; } + public RepoGenericResponse> getCodeDeployBGDeployment(ElastigroupGetCodeDeployRequest request, String elastigroupId, String authToken, String account) { + RepoGenericResponse> retVal; + + try { + + List apiCodeDeployResponse = SpotinstElastigroupService + .getCodeDeployBGDeployment(request, elastigroupId, authToken, account); + List codeDeployResponse = apiCodeDeployResponse.stream().map(ElastigroupConverter::toBl) + .collect(Collectors.toList()); + + retVal = new RepoGenericResponse<>(codeDeployResponse); + } catch (SpotinstHttpException ex) { + retVal = ExceptionHelper.handleHttpException(ex); + } + + return retVal; + } + @Override public RepoGenericResponse getBeanstalkMaintenanceStatus(String groupId, String authToken, String account) { RepoGenericResponse retVal; @@ -1135,4 +1116,5 @@ public RepoGenericResponse beanstalkReimport(String groupId, String return retVal; } + } \ No newline at end of file diff --git a/src/main/java/com/spotinst/sdkjava/model/SpotinstElastigroupService.java b/src/main/java/com/spotinst/sdkjava/model/SpotinstElastigroupService.java index 9d5ad3cf8..a7b03a1d8 100644 --- a/src/main/java/com/spotinst/sdkjava/model/SpotinstElastigroupService.java +++ b/src/main/java/com/spotinst/sdkjava/model/SpotinstElastigroupService.java @@ -1,6 +1,5 @@ package com.spotinst.sdkjava.model; - import com.spotinst.sdkjava.client.response.BaseServiceEmptyResponse; import com.spotinst.sdkjava.client.response.BaseSpotinstService; import com.spotinst.sdkjava.client.rest.*; @@ -13,7 +12,10 @@ import com.spotinst.sdkjava.model.responses.elastigroup.aws.*; import org.apache.http.HttpStatus; -import java.util.*; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; /** * Created by aharontwizer on 7/27/15. @@ -1905,7 +1907,6 @@ public static ApiElastigroupImportStatefulInstanceResponse importStatefulInstanc RestResponse response = RestClient.sendPost(uri, body, headers, queryParams); // Handle the response. - ElastigroupImportStatefulInstanceApiResponse castedApiResponse = getCastedResponse(response, ElastigroupImportStatefulInstanceApiResponse.class); @@ -2325,4 +2326,85 @@ public static ApiElastigroup beanstalkReimport(String groupId, String authToken, return retVal; } + + public static List createCodeDeployBGDeployment(ElastigroupCreateCodeDeployRequest request, String elastigroupId, String authToken, String account) { + + List apiCodeDeployResponse = new LinkedList<>(); + // Get endpoint + SpotinstHttpConfig config = SpotinstHttpContext.getInstance().getConfiguration(); + String apiEndpoint = config.getEndpoint(); + + // Build query params + Map queryParams = new HashMap<>(); + + // Add account Id Query param + if (account != null) { + queryParams.put("accountId", account); + } + + // Get the headers + Map headers = buildHeaders(authToken); + + // Build URI + String uri = String.format("%s/aws/ec2/group/%s/codeDeploy/blueGreenDeployment", apiEndpoint,elastigroupId); + + // Write to json + Map deploymentRequest = new HashMap<>(); + deploymentRequest.put("deployment", request.getCodeDeployBGDeployment()); + String body = JsonMapper.toJson(deploymentRequest); + + // Send the request. + RestResponse response = RestClient.sendPost(uri, body, headers, queryParams); + + // Handle the response. + CodeDeployBGDeploymentApiResponse + codeDeployResponse = getCastedResponse(response, CodeDeployBGDeploymentApiResponse.class); + + if (codeDeployResponse.getResponse().getCount() > 0) { + apiCodeDeployResponse = codeDeployResponse.getResponse().getItems(); + } + + return apiCodeDeployResponse; + } + + public static List getCodeDeployBGDeployment(ElastigroupGetCodeDeployRequest request, String elastigroupId, String authToken, String account) { + + List apiCodeDeployResponse = new LinkedList<>(); + + // Get endpoint + SpotinstHttpConfig config = SpotinstHttpContext.getInstance().getConfiguration(); + String apiEndpoint = config.getEndpoint(); + + // Build query params + Map queryParams = new HashMap<>(); + + // Add account Id Query param + if (account != null) { + queryParams.put("accountId", account); + } + + // Get the headers + Map headers = buildHeaders(authToken); + + // Build URI + String uri = String.format("%s/aws/ec2/group/%s/codeDeploy/blueGreenDeployment", apiEndpoint,elastigroupId); + + // Write to json + Map getDeploymentRequest = new HashMap<>(); + getDeploymentRequest.put("deployment", request); + String body = JsonMapper.toJson(getDeploymentRequest); + + // Send the request. + RestResponse response = RestClient.sendGetWithBody(uri, body, headers, queryParams); + + // Handle the response. + CodeDeployBGDeploymentApiResponse + codeDeployResponse = getCastedResponse(response, CodeDeployBGDeploymentApiResponse.class); + + if (codeDeployResponse.getResponse().getCount() > 0) { + apiCodeDeployResponse = codeDeployResponse.getResponse().getItems(); + } + + return apiCodeDeployResponse; + } } diff --git a/src/main/java/com/spotinst/sdkjava/model/api/elastigroup/aws/ApiCodeDeployBGDeploymentResponse.java b/src/main/java/com/spotinst/sdkjava/model/api/elastigroup/aws/ApiCodeDeployBGDeploymentResponse.java new file mode 100644 index 000000000..02f59e0f4 --- /dev/null +++ b/src/main/java/com/spotinst/sdkjava/model/api/elastigroup/aws/ApiCodeDeployBGDeploymentResponse.java @@ -0,0 +1,91 @@ +package com.spotinst.sdkjava.model.api.elastigroup.aws; + +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.spotinst.sdkjava.client.rest.IPartialUpdateEntity; +import com.spotinst.sdkjava.model.bl.elastigroup.aws.CodeDeployConfig; +import com.spotinst.sdkjava.model.bl.elastigroup.aws.ElastigroupCodeDeployBGDeployment; + +import java.util.HashSet; +import java.util.Set; +/** + * @author: Saikumar Jalda + * @since: 01/03/2022 + */ +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonFilter("PartialUpdateEntityFilter") +public class ApiCodeDeployBGDeploymentResponse implements IPartialUpdateEntity { + + @JsonIgnore + private Set isSet; + private String id; + private String groupId; + private String state; + private ElastigroupCodeDeployBGDeployment config; + + public ApiCodeDeployBGDeploymentResponse() { + isSet = new HashSet<>(); + } + + public Set getIsSet() { + return isSet; + } + + public void setIsSet(Set isSet) { + this.isSet = isSet; + } + + public String getId() { return id; } + + public void setId(String id) { + isSet.add("id"); + this.id = id; + } + + public String getGroupId() { return groupId; } + + public void setGroupId(String groupId) { + isSet.add("groupId"); + this.groupId = groupId; + } + + public String getState() { return state; } + + public void setState(String state) { + isSet.add("state"); + this.state = state; + } + + public ElastigroupCodeDeployBGDeployment getConfig() { + return config; + } + + public void setConfig(ElastigroupCodeDeployBGDeployment config) { + isSet.add("config"); + this.config = config; + } + + @JsonIgnore + public boolean isIdSet() { + return isSet.contains("id"); + } + + @JsonIgnore + public boolean isGroupIdSet() { + return isSet.contains("groupId"); + } + + @JsonIgnore + public boolean isStateSet() { + return isSet.contains("state"); + } + + @JsonIgnore + public boolean isConfigSet() { + return isSet.contains("config"); + } + +} \ No newline at end of file diff --git a/src/main/java/com/spotinst/sdkjava/model/api/elastigroup/aws/ApiCodeDeployConfig.java b/src/main/java/com/spotinst/sdkjava/model/api/elastigroup/aws/ApiCodeDeployConfig.java new file mode 100644 index 000000000..7a29656ec --- /dev/null +++ b/src/main/java/com/spotinst/sdkjava/model/api/elastigroup/aws/ApiCodeDeployConfig.java @@ -0,0 +1,80 @@ +package com.spotinst.sdkjava.model.api.elastigroup.aws; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.spotinst.sdkjava.model.ApiDeploymentGroup; +import com.spotinst.sdkjava.model.ApiTag; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; +/** + * @author: Saikumar Jalda + * @since: 01/03/2022 + */ +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ApiCodeDeployConfig { + + @JsonIgnore + private Set isSet; + private String timeout; + private List tags; + private List deploymentGroups; + + public ApiCodeDeployConfig() { + isSet = new HashSet<>(); + } + + public Set getIsSet() { + return isSet; + } + + public void setIsSet(Set isSet) { + this.isSet = isSet; + } + + public String getTimeout() { + return timeout; + } + + public void setTimeout(String timeout) { + isSet.add("timeout"); + this.timeout = timeout; + } + + public List getTag() { + return tags; + } + + public void setTags(List tags) { + isSet.add("tags"); + this.tags = tags; + } + + public List getDeploymentGroups() { + return deploymentGroups; + } + + public void setDeploymentGroups(List deploymentGroups) { + isSet.add("deploymentGroups"); + this.deploymentGroups = deploymentGroups; + } + + @JsonIgnore + public boolean isTimeoutSet() { + return isSet.contains("timeout"); + } + + @JsonIgnore + public boolean isTagsSet() { + return isSet.contains("tags"); + } + + @JsonIgnore + public boolean isDeploymentGroupsSet() { + return isSet.contains("deploymentGroups"); + } + +} diff --git a/src/main/java/com/spotinst/sdkjava/model/api/elastigroup/aws/ApiElastigroupCodeDeployBGDeployment.java b/src/main/java/com/spotinst/sdkjava/model/api/elastigroup/aws/ApiElastigroupCodeDeployBGDeployment.java new file mode 100644 index 000000000..e4ada2fe6 --- /dev/null +++ b/src/main/java/com/spotinst/sdkjava/model/api/elastigroup/aws/ApiElastigroupCodeDeployBGDeployment.java @@ -0,0 +1,97 @@ +package com.spotinst.sdkjava.model.api.elastigroup.aws; + +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.spotinst.sdkjava.client.rest.IPartialUpdateEntity; +import com.spotinst.sdkjava.model.ApiDeploymentGroup; +import com.spotinst.sdkjava.model.ApiTag; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * @author: Saikumar Jalda + * @since: 01/03/2022 + */ +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonFilter("PartialUpdateEntityFilter") +public class ApiElastigroupCodeDeployBGDeployment implements IPartialUpdateEntity { + //region Members + @JsonIgnore + private Set isSet; + private int timeout; + private List tags; + private List deploymentGroups; + //endregion + + //region Constructor + + public ApiElastigroupCodeDeployBGDeployment() { + isSet = new HashSet<>(); + } + //endregion + + //region Getters & Setters + + public Set getIsSet() { + return isSet; + } + + public void setIsSet(Set isSet) { + this.isSet = isSet; + } + + public int getTimeout() { + return timeout; + } + + public void setTimeout(int timeout) { + isSet.add("timeout"); + this.timeout = timeout; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + isSet.add("tags"); + this.tags = tags; + } + + public List getDeploymentGroups() { + return deploymentGroups; + } + + public void setDeploymentGroups(List deploymentGroups) { + isSet.add("deploymentGroups"); + this.deploymentGroups = deploymentGroups; + } + + //endregion + + //region isSet methods + // Is timeout Set boolean method + @JsonIgnore + public boolean isTimeoutSet() { + return isSet.contains("timeout"); + } + + // Is tags Set boolean method + @JsonIgnore + public boolean isTagsSet() { + return isSet.contains("tags"); + } + + // Is deploymentGroups Set boolean method + @JsonIgnore + public boolean isDeploymentGroupsSet() { + return isSet.contains("deploymentGroups"); + } + + //endregion +} diff --git a/src/main/java/com/spotinst/sdkjava/model/api/elastigroup/aws/ApiElastigroupDeploymentTags.java b/src/main/java/com/spotinst/sdkjava/model/api/elastigroup/aws/ApiElastigroupDeploymentTags.java new file mode 100644 index 000000000..7d81a29d8 --- /dev/null +++ b/src/main/java/com/spotinst/sdkjava/model/api/elastigroup/aws/ApiElastigroupDeploymentTags.java @@ -0,0 +1,62 @@ +package com.spotinst.sdkjava.model.api.elastigroup.aws; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.HashSet; +import java.util.Set; +/** + * @author: Saikumar Jalda + * @since: 01/03/2022 + */ +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ApiElastigroupDeploymentTags { + + @JsonIgnore + private Set isSet; + private String tagKey; + private String tagValue; + + public ApiElastigroupDeploymentTags() { + isSet = new HashSet<>(); + } + + public Set getIsSet() { + return isSet; + } + + public void setIsSet(Set isSet) { + this.isSet = isSet; + } + + public String getTagKey() { + return tagKey; + } + + public void setTagKey(String tagKey) { + isSet.add("tagKey"); + this.tagKey = tagKey; + } + + public String getTagValue() { + return tagValue; + } + + public void setTagValue(String tagValue) { + isSet.add("tagValue"); + this.tagValue = tagValue; + } + + @JsonIgnore + public boolean isTagKeySet() { + return isSet.contains("tagKey"); + } + + @JsonIgnore + public boolean isTagValueSet() { + return isSet.contains("tagValue"); + } + +} diff --git a/src/main/java/com/spotinst/sdkjava/model/bl/elastigroup/aws/CodeDeployConfig.java b/src/main/java/com/spotinst/sdkjava/model/bl/elastigroup/aws/CodeDeployConfig.java new file mode 100644 index 000000000..16e7b3639 --- /dev/null +++ b/src/main/java/com/spotinst/sdkjava/model/bl/elastigroup/aws/CodeDeployConfig.java @@ -0,0 +1,116 @@ +package com.spotinst.sdkjava.model.bl.elastigroup.aws; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.spotinst.sdkjava.model.ElastigroupDeploymentGroup; +import com.spotinst.sdkjava.model.Tag; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * @author: Saikumar Jalda + * @since: 01/03/2022 + */ + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CodeDeployConfig { + + @JsonIgnore + private Set isSet; + private String timeout; + private List tags; + private List deploymentGroups; + + public CodeDeployConfig() { + isSet = new HashSet<>(); + } + + public Set getIsSet() { + return isSet; + } + + public void setIsSet(Set isSet) { + this.isSet = isSet; + } + + public String getTimeout() { + return timeout; + } + + public void setTimeout(String timeout) { + isSet.add("timeout"); + this.timeout = timeout; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + isSet.add("tags"); + this.tags = tags; + } + + public List getDeploymentGroups() { + return deploymentGroups; + } + + public void setDeploymentGroups(List deploymentGroups) { + isSet.add("deploymentGroups"); + this.deploymentGroups = deploymentGroups; + } + + + public static class Builder { + private CodeDeployConfig config; + + private Builder() { + this.config = new CodeDeployConfig(); + } + + public static Builder get() { + Builder builder = new Builder(); + return builder; + } + + public Builder setTimeout(final String timeout) { + config.setTimeout(timeout); + return this; + } + + public Builder setTags(final List tags) { + config.setTags(tags); + return this; + } + + public Builder setDeploymentGroups(final List deploymentGroups) { + config.setDeploymentGroups(deploymentGroups); + return this; + } + + public CodeDeployConfig build() { + return config; + } + + } + + @JsonIgnore + public boolean isTimeoutSet() { + return isSet.contains("timeout"); + } + + @JsonIgnore + public boolean isTagsSet() { + return isSet.contains("tags"); + } + + @JsonIgnore + public boolean isDeploymentGroupsSet() { + return isSet.contains("deploymentGroups"); + } + +} diff --git a/src/main/java/com/spotinst/sdkjava/model/bl/elastigroup/aws/ElastigroupCodeDeployBGDeployment.java b/src/main/java/com/spotinst/sdkjava/model/bl/elastigroup/aws/ElastigroupCodeDeployBGDeployment.java new file mode 100644 index 000000000..17715dfa1 --- /dev/null +++ b/src/main/java/com/spotinst/sdkjava/model/bl/elastigroup/aws/ElastigroupCodeDeployBGDeployment.java @@ -0,0 +1,137 @@ +package com.spotinst.sdkjava.model.bl.elastigroup.aws; + +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.spotinst.sdkjava.client.rest.IPartialUpdateEntity; +import com.spotinst.sdkjava.model.ElastigroupDeploymentGroup; +import com.spotinst.sdkjava.model.Tag; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * @author: Saikumar Jalda + * @since: 01/03/2022 + */ +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonFilter("PartialUpdateEntityFilter") +public class ElastigroupCodeDeployBGDeployment implements IPartialUpdateEntity { + //region Members + @JsonIgnore + private Set isSet; + private int timeout; + private List tags; + private List deploymentGroups; + //endregion + + //region Constructor + + public ElastigroupCodeDeployBGDeployment() { + isSet = new HashSet<>(); + } + //endregion + + //region Getters & Setters + + public Set getIsSet() { + return isSet; + } + + public void setIsSet(Set isSet) { + this.isSet = isSet; + } + + public int getTimeout() { + return timeout; + } + + public void setTimeout(int timeout) { + isSet.add("timeout"); + this.timeout = timeout; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + isSet.add("tags"); + this.tags = tags; + } + + public List getDeploymentGroups() { + return deploymentGroups; + } + + public void setDeploymentGroups(List deploymentGroups) { + isSet.add("deploymentGroups"); + this.deploymentGroups = deploymentGroups; + } + + //endregion + + //region Builder class + public static class Builder { + //region Members + private ElastigroupCodeDeployBGDeployment codeDeployBGDeployment; + //endregion + + + private Builder() { + this.codeDeployBGDeployment = new ElastigroupCodeDeployBGDeployment(); + } + + public static Builder get() { + ElastigroupCodeDeployBGDeployment.Builder builder = new Builder(); + return builder; + } + + //region Build methods + public Builder setTimeout(int timeout) { + codeDeployBGDeployment.setTimeout(timeout); + return this; + } + + public Builder setTags(List tags) { + codeDeployBGDeployment.setTags(tags); + return this; + } + + public Builder setDeploymentGroups(List deploymentGroups) { + codeDeployBGDeployment.setDeploymentGroups(deploymentGroups); + return this; + } + + public ElastigroupCodeDeployBGDeployment build() { + // Validations + return codeDeployBGDeployment; + } + //endregion + } + //endregion + + + //region isSet methods + // Is deploymenttags Set boolean method + @JsonIgnore + public boolean isTimeoutSet() { + return isSet.contains("timeout"); + } + + @JsonIgnore + public boolean isTagsSet() { + return isSet.contains("tags"); + } + + // Is deploymentGroups Set boolean method + @JsonIgnore + public boolean isDeploymentGroupsSet() { + return isSet.contains("deploymentGroups"); + } + + //endregion +} diff --git a/src/main/java/com/spotinst/sdkjava/model/bl/elastigroup/aws/ElastigroupDeploymentTags.java b/src/main/java/com/spotinst/sdkjava/model/bl/elastigroup/aws/ElastigroupDeploymentTags.java new file mode 100644 index 000000000..898ef08c9 --- /dev/null +++ b/src/main/java/com/spotinst/sdkjava/model/bl/elastigroup/aws/ElastigroupDeploymentTags.java @@ -0,0 +1,91 @@ +package com.spotinst.sdkjava.model.bl.elastigroup.aws; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.HashSet; +import java.util.Set; +/** + * @author: Saikumar Jalda + * @since: 01/03/2022 + */ +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ElastigroupDeploymentTags { + + @JsonIgnore + private Set isSet; + private String tagKey; + private String tagValue; + + public ElastigroupDeploymentTags() { + isSet = new HashSet<>(); + } + + public Set getIsSet() { + return isSet; + } + + public void setIsSet(Set isSet) { + this.isSet = isSet; + } + + public String getTagKey() { + return tagKey; + } + + public void setTagKey(String tagKey) { + isSet.add("tagKey"); + this.tagKey = tagKey; + } + + public String getTagValue() { + return tagValue; + } + + public void setTagValue(String tagValue) { + isSet.add("tagValue"); + this.tagValue = tagValue; + } + + + public static class Builder { + private ElastigroupDeploymentTags configTags; + + private Builder() { + this.configTags = new ElastigroupDeploymentTags(); + } + + public static Builder get() { + Builder builder = new Builder(); + return builder; + } + + public Builder setTagKey(final String tagKey) { + configTags.setTagKey(tagKey); + return this; + } + + public Builder setTagValue(final String tagValue) { + configTags.setTagValue(tagValue); + return this; + } + + public ElastigroupDeploymentTags build() { + return configTags; + } + + } + + @JsonIgnore + public boolean isTagKeySet() { + return isSet.contains("tagKey"); + } + + @JsonIgnore + public boolean isTagValueSet() { + return isSet.contains("tagValue"); + } + +} diff --git a/src/main/java/com/spotinst/sdkjava/model/requests/elastigroup/aws/ElastigroupCreateCodeDeployRequest.java b/src/main/java/com/spotinst/sdkjava/model/requests/elastigroup/aws/ElastigroupCreateCodeDeployRequest.java new file mode 100644 index 000000000..0de746e41 --- /dev/null +++ b/src/main/java/com/spotinst/sdkjava/model/requests/elastigroup/aws/ElastigroupCreateCodeDeployRequest.java @@ -0,0 +1,58 @@ +package com.spotinst.sdkjava.model.requests.elastigroup.aws; + +import com.spotinst.sdkjava.client.rest.JsonMapper; +import com.spotinst.sdkjava.model.ElastigroupConverter; +import com.spotinst.sdkjava.model.api.elastigroup.aws.ApiElastigroupCodeDeployBGDeployment; +import com.spotinst.sdkjava.model.bl.elastigroup.aws.ElastigroupCodeDeployBGDeployment; + +/** + * @author: Saikumar Jalda + * @since: 01/03/2022 + */ +public class ElastigroupCreateCodeDeployRequest { + + private ElastigroupCodeDeployBGDeployment deployment; + + private ElastigroupCreateCodeDeployRequest() { + } + + public ElastigroupCodeDeployBGDeployment getCodeDeployBGDeployment() { + return deployment; + } + + public void setCodeDeployBGDeployment(ElastigroupCodeDeployBGDeployment deployment) { + this.deployment = deployment; + } + + public static class Builder { + private ElastigroupCreateCodeDeployRequest createCodeDeployRequest; + + private Builder() { + this.createCodeDeployRequest = new ElastigroupCreateCodeDeployRequest(); + } + + public static Builder get() { + Builder builder = new Builder(); + return builder; + } + + public Builder setCodeDeployBGDeployment(ElastigroupCodeDeployBGDeployment deployment) { + createCodeDeployRequest.setCodeDeployBGDeployment(deployment); + return this; + } + + public ElastigroupCreateCodeDeployRequest build() { + return createCodeDeployRequest; + } + } + + //region Json methods + public String toJson() { + ApiElastigroupCodeDeployBGDeployment createCodeDeployRequest = ElastigroupConverter.toDal(deployment); + String codeDeploy = JsonMapper.toJson(createCodeDeployRequest); + return codeDeploy; + } + + //endregion + +} diff --git a/src/main/java/com/spotinst/sdkjava/model/requests/elastigroup/aws/ElastigroupGetCodeDeployRequest.java b/src/main/java/com/spotinst/sdkjava/model/requests/elastigroup/aws/ElastigroupGetCodeDeployRequest.java new file mode 100644 index 000000000..e9ce6f051 --- /dev/null +++ b/src/main/java/com/spotinst/sdkjava/model/requests/elastigroup/aws/ElastigroupGetCodeDeployRequest.java @@ -0,0 +1,58 @@ +package com.spotinst.sdkjava.model.requests.elastigroup.aws; + +import com.spotinst.sdkjava.client.rest.JsonMapper; +import com.spotinst.sdkjava.model.ElastigroupConverter; +import com.spotinst.sdkjava.model.api.elastigroup.aws.ApiElastigroupCodeDeployBGDeployment; +import com.spotinst.sdkjava.model.bl.elastigroup.aws.ElastigroupCodeDeployBGDeployment; + +/** + * @author: Saikumar Jalda + * @since: 01/03/2022 + */ +public class ElastigroupGetCodeDeployRequest { + + private ElastigroupCodeDeployBGDeployment codeDeployBGDeployment; + + private ElastigroupGetCodeDeployRequest() { + } + + public ElastigroupCodeDeployBGDeployment getCodeDeployBGDeployment() { + return codeDeployBGDeployment; + } + + public void setCodeDeployBGDeployment(ElastigroupCodeDeployBGDeployment codeDeployBGDeployment) { + this.codeDeployBGDeployment = codeDeployBGDeployment; + } + + public static class Builder { + private ElastigroupGetCodeDeployRequest getCodeDeployRequest; + + private Builder() { + this.getCodeDeployRequest = new ElastigroupGetCodeDeployRequest(); + } + + public static Builder get() { + Builder builder = new Builder(); + return builder; + } + + public Builder setCodeDeployBGDeployment(ElastigroupCodeDeployBGDeployment codeDeployBGDeployment) { + getCodeDeployRequest.setCodeDeployBGDeployment(codeDeployBGDeployment); + return this; + } + + public ElastigroupGetCodeDeployRequest build() { + return getCodeDeployRequest; + } + } + + //region Json methods + public String toJson() { + ApiElastigroupCodeDeployBGDeployment getCodeDeployRequest = ElastigroupConverter.toDal(codeDeployBGDeployment); + String getCodeDeploy = JsonMapper.toJson(getCodeDeployRequest); + return getCodeDeploy; + } + + //endregion + +} diff --git a/src/main/java/com/spotinst/sdkjava/model/responses/elastigroup/aws/CodeDeployBGDeploymentApiResponse.java b/src/main/java/com/spotinst/sdkjava/model/responses/elastigroup/aws/CodeDeployBGDeploymentApiResponse.java new file mode 100644 index 000000000..1bf7333f1 --- /dev/null +++ b/src/main/java/com/spotinst/sdkjava/model/responses/elastigroup/aws/CodeDeployBGDeploymentApiResponse.java @@ -0,0 +1,11 @@ +package com.spotinst.sdkjava.model.responses.elastigroup.aws; + +import com.spotinst.sdkjava.client.response.BaseServiceItemsResponse; +import com.spotinst.sdkjava.model.api.elastigroup.aws.ApiCodeDeployBGDeploymentResponse; +/** + * @author: Saikumar Jalda + * @since: 01/03/2022 + */ +public class CodeDeployBGDeploymentApiResponse extends BaseServiceItemsResponse { + +} diff --git a/src/main/java/com/spotinst/sdkjava/model/responses/elastigroup/aws/CodeDeployBGDeploymentResponse.java b/src/main/java/com/spotinst/sdkjava/model/responses/elastigroup/aws/CodeDeployBGDeploymentResponse.java new file mode 100644 index 000000000..84b54833a --- /dev/null +++ b/src/main/java/com/spotinst/sdkjava/model/responses/elastigroup/aws/CodeDeployBGDeploymentResponse.java @@ -0,0 +1,127 @@ +package com.spotinst.sdkjava.model.responses.elastigroup.aws; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.spotinst.sdkjava.model.bl.elastigroup.aws.CodeDeployConfig; +import com.spotinst.sdkjava.model.bl.elastigroup.aws.ElastigroupCodeDeployBGDeployment; + +import java.util.HashSet; +import java.util.Set; +/** + * @author: Saikumar Jalda + * @since: 01/03/2022 + */ +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CodeDeployBGDeploymentResponse { + + @JsonIgnore + private Set isSet; + private String id; + private String groupId; + private String state; + //private CodeDeployConfig config; + private ElastigroupCodeDeployBGDeployment config; + + public CodeDeployBGDeploymentResponse() { + isSet = new HashSet<>(); + } + + public Set getIsSet() { + return isSet; + } + + public void setIsSet(Set isSet) { + this.isSet = isSet; + } + + public String getId() { return id; } + + public void setId(String id) { + isSet.add("id"); + this.id = id; + } + + public String getGroupId() { return groupId; } + + public void setGroupId(String groupId) { + isSet.add("groupId"); + this.groupId = groupId; + } + + public String getState() { return state; } + + public void setState(String state) { + isSet.add("state"); + this.state = state; + } + + public ElastigroupCodeDeployBGDeployment getConfig() { + return config; + } + + public void setConfig(ElastigroupCodeDeployBGDeployment config) { + isSet.add("config"); + this.config = config; + } + + public static class Builder { + private CodeDeployBGDeploymentResponse getCodeDeployResponse; + + private Builder() { + this.getCodeDeployResponse = new CodeDeployBGDeploymentResponse(); + } + + public static Builder get() { + Builder builder = new Builder(); + return builder; + } + + public Builder setId(final String id) { + getCodeDeployResponse.setId(id); + return this; + } + + public Builder setGroupId(final String groupId) { + getCodeDeployResponse.setId(groupId); + return this; + } + + public Builder setState(final String state) { + getCodeDeployResponse.setState(state); + return this; + } + + public Builder setConfig(final ElastigroupCodeDeployBGDeployment config) { + getCodeDeployResponse.setConfig(config); + return this; + } + + public CodeDeployBGDeploymentResponse build() { + return getCodeDeployResponse; + } + } + + @JsonIgnore + public boolean isIdSet() { + return isSet.contains("id"); + } + + @JsonIgnore + public boolean isGroupIdSet() { + return isSet.contains("groupId"); + } + + @JsonIgnore + public boolean isStateSet() { + return isSet.contains("state"); + } + + @JsonIgnore + public boolean isConfigSet() { + return isSet.contains("config"); + } + +} +