diff --git a/external-dependencies/download-tibco.sh b/external-dependencies/download-tibco.sh index 7385f47f7..d2e48b6aa 100755 --- a/external-dependencies/download-tibco.sh +++ b/external-dependencies/download-tibco.sh @@ -2,7 +2,7 @@ if [ -f "tibjms.jar" ]; then exit 0; fi rm -rf /tmp/tibco mkdir /tmp/tibco -curl -s -o /tmp/tibco/tibco.zip "https://edownloads.tibco.com/Installers/tap/EMS-CE/10.2.1/TIB_ems-ce_10.2.1_linux_x86_64.zip?SJCDPTPG=1681227113_1e3fe1f60cbbe9ee810af68e0b4256bb&ext=.zip" +curl -s -o /tmp/tibco/tibco.zip "https://edownloads.tibco.com/Installers/tap/EMS-CE/10.2.1/TIB_ems-ce_10.2.1_linux_x86_64.zip?SJCDPTPG=1683881528_ae3eee42628d3f74b67cb52ea15aea45&ext=.zip" cd /tmp/tibco unzip tibco.zip TIB_ems-ce_10.2.1/tar/TIB_ems-ce_10.2.1_linux_x86_64-java_client.tar.gz tar -zxf TIB_ems-ce_10.2.1/tar/TIB_ems-ce_10.2.1_linux_x86_64-java_client.tar.gz opt/tibco/ems/10.2/lib/tibjms.jar diff --git a/notification-service-sdk/pom.xml b/notification-service-sdk/pom.xml index ed2e864d9..d64190d70 100644 --- a/notification-service-sdk/pom.xml +++ b/notification-service-sdk/pom.xml @@ -1,11 +1,9 @@ 4.0.0 - dev.parodos notification-service-sdk jar notification-service-sdk - ${revision} https://github.com/openapitools/openapi-generator OpenAPI Java @@ -41,7 +39,6 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.1 true 128m @@ -75,7 +72,6 @@ org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M5 @@ -151,7 +147,6 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.3.1 attach-javadocs @@ -188,7 +183,6 @@ io.spring.javaformat spring-javaformat-maven-plugin - ${spring.javaformat.version} process-sources @@ -241,17 +235,14 @@ com.squareup.okhttp3 okhttp - ${okhttp-version} com.squareup.okhttp3 logging-interceptor - ${okhttp-version} com.google.code.gson gson - ${gson-version} io.gsonfire @@ -261,12 +252,10 @@ org.apache.commons commons-lang3 - ${commons-lang3-version} jakarta.annotation jakarta.annotation-api - ${jakarta-annotation-version} provided @@ -287,13 +276,6 @@ 1.8.5 1.6.3 - 4.9.2 - 2.8.8 - 3.12.0 0.2.2 - 1.3.5 - 4.13.2 - UTF-8 - 2.17.3 diff --git a/notification-service/pom.xml b/notification-service/pom.xml index a9189814d..601883410 100644 --- a/notification-service/pom.xml +++ b/notification-service/pom.xml @@ -26,19 +26,10 @@ 11 2020.0.6 1.6.4 - 1.2.0 - 11 - 11 5.4.0 - 1.8.5 1.6.3 - 4.9.2 - 2.8.8 - 3.12.0 0.2.2 - 1.3.5 - 2.17.3 @@ -152,17 +143,14 @@ com.squareup.okhttp3 okhttp - ${okhttp-version} com.squareup.okhttp3 logging-interceptor - ${okhttp-version} com.google.code.gson gson - ${gson-version} io.gsonfire @@ -172,12 +160,10 @@ org.apache.commons commons-lang3 - ${commons-lang3-version} jakarta.annotation jakarta.annotation-api - ${jakarta-annotation-version} provided @@ -189,6 +175,13 @@ org.springframework.cloud spring-cloud-starter-config + + + io.micrometer + micrometer-registry-prometheus + runtime + + diff --git a/notification-service/src/main/resources/application.yml b/notification-service/src/main/resources/application.yml index 082528f9f..1e02e55dd 100644 --- a/notification-service/src/main/resources/application.yml +++ b/notification-service/src/main/resources/application.yml @@ -12,4 +12,22 @@ spring: springdoc: writer-with-order-by-keys: true - writer-with-default-pretty-printer: true \ No newline at end of file + writer-with-default-pretty-printer: true + +management: + metrics: + export: + prometheus: + enabled: true + endpoint: + health: + enabled: true + prometheus: + enabled: true + metrics: + enabled: true + endpoints: + enabled-by-default: false + web: + exposure: + include: "health,prometheus" diff --git a/parodos-model-api/pom.xml b/parodos-model-api/pom.xml index 7baac95cc..190cde1e6 100644 --- a/parodos-model-api/pom.xml +++ b/parodos-model-api/pom.xml @@ -26,12 +26,6 @@ http://github.com/parodos-dev/parodos/tree/master - - 1.18.26 - 5.3.26 - 2.14.2 - - @@ -44,23 +38,19 @@ org.projectlombok lombok - ${lombok.version} org.springframework spring-beans - ${spring.framework.version} org.springframework spring-expression - ${spring.framework.version} com.fasterxml.jackson.core jackson-databind - ${jackson-databind.version} junit diff --git a/parodos-model-api/src/main/java/com/redhat/parodos/workflow/enums/WorkFlowStatus.java b/parodos-model-api/src/main/java/com/redhat/parodos/workflow/enums/WorkFlowStatus.java index 449cace2b..753e379ec 100644 --- a/parodos-model-api/src/main/java/com/redhat/parodos/workflow/enums/WorkFlowStatus.java +++ b/parodos-model-api/src/main/java/com/redhat/parodos/workflow/enums/WorkFlowStatus.java @@ -24,6 +24,14 @@ */ public enum WorkFlowStatus { - FAILED, IN_PROGRESS, COMPLETED, PENDING + FAILED, IN_PROGRESS, COMPLETED, PENDING, REJECTED; + + public boolean isFailed() { + return FAILED.name().equals(name()); + } + + public boolean isRejected() { + return REJECTED.name().equals(name()); + } } diff --git a/parodos-model-api/src/main/java/com/redhat/parodos/workflow/task/BaseWorkFlowTask.java b/parodos-model-api/src/main/java/com/redhat/parodos/workflow/task/BaseWorkFlowTask.java index 12a41e558..c7e6455a7 100644 --- a/parodos-model-api/src/main/java/com/redhat/parodos/workflow/task/BaseWorkFlowTask.java +++ b/parodos-model-api/src/main/java/com/redhat/parodos/workflow/task/BaseWorkFlowTask.java @@ -15,22 +15,15 @@ */ package com.redhat.parodos.workflow.task; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -import org.springframework.beans.factory.BeanNameAware; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.redhat.parodos.workflow.context.WorkContextDelegate; import com.redhat.parodos.workflow.exception.MissingParameterException; +import com.redhat.parodos.workflow.utils.WorkContextUtils; import com.redhat.parodos.workflows.work.WorkContext; import com.redhat.parodos.workflows.workflow.WorkFlow; - +import java.util.List; +import java.util.Map; import lombok.Getter; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.BeanNameAware; /** * Base Class for a WorkFlowTask. @@ -65,6 +58,22 @@ public void setWorkFlowCheckers(List workFlowCheckers) { this.workFlowCheckers = workFlowCheckers; } + public String getProjectId(WorkContext workContext) { + return WorkContextUtils.getProjectId(workContext); + } + + public String getMasterExecutionId(WorkContext workContext) { + return WorkContextUtils.getMainExecutionId(workContext); + } + + public void addParameter(WorkContext workContext, String key, String value) { + WorkContextUtils.addParameter(workContext, key, value); + } + + public Map getAllParameters(WorkContext workContext) { + return WorkContextUtils.getAllParameters(workContext, name); + } + /** * Get Parameters specific to this WorkFlowTask, this is a required parameter * @param workContext @@ -74,14 +83,7 @@ public void setWorkFlowCheckers(List workFlowCheckers) { */ public String getRequiredParameterValue(WorkContext workContext, String parameterName) throws MissingParameterException { - Map parameters = Optional - .ofNullable(new ObjectMapper().convertValue( - WorkContextDelegate.read(workContext, WorkContextDelegate.ProcessType.WORKFLOW_TASK_EXECUTION, - name, WorkContextDelegate.Resource.ARGUMENTS), - new TypeReference>() { - })) - .orElse(new HashMap<>()); - parameters.putAll(getParentParameters(workContext, getName())); + Map parameters = getAllParameters(workContext); return parameters.entrySet().stream().filter(entry -> parameterName.equals(entry.getKey())) .map(Map.Entry::getValue).findFirst().orElseThrow(() -> { log.error(String.format("parameter %s is not provided for task %s!", parameterName, name)); @@ -98,40 +100,9 @@ public String getRequiredParameterValue(WorkContext workContext, String paramete * @throws MissingParameterException */ public String getOptionalParameterValue(WorkContext workContext, String parameterName, String defaultValue) { - Map parameters = Optional - .ofNullable(new ObjectMapper().convertValue( - WorkContextDelegate.read(workContext, WorkContextDelegate.ProcessType.WORKFLOW_TASK_EXECUTION, - name, WorkContextDelegate.Resource.ARGUMENTS), - new TypeReference>() { - })) - .orElse(new HashMap<>()); - parameters.putAll(getParentParameters(workContext, getName())); + Map parameters = getAllParameters(workContext); return parameters.entrySet().stream().filter(entry -> parameterName.equals(entry.getKey())) .map(Map.Entry::getValue).findFirst().orElse(defaultValue); } - /** - * Get Parameters that are set at the WorkFlow level - * @param workContext - * @param workName - * @return - */ - private Map getParentParameters(WorkContext workContext, String workName) { - String parentWorkflowName = (String) WorkContextDelegate.read(workContext, - WorkContextDelegate.ProcessType.WORKFLOW_EXECUTION, workName, - WorkContextDelegate.Resource.PARENT_WORKFLOW); - Map map = new HashMap<>(); - Optional.ofNullable( - new ObjectMapper().convertValue( - WorkContextDelegate.read(workContext, WorkContextDelegate.ProcessType.WORKFLOW_EXECUTION, - workName, WorkContextDelegate.Resource.ARGUMENTS), - new TypeReference>() { - })) - .ifPresent(map::putAll); - if (parentWorkflowName != null) { - map.putAll(getParentParameters(workContext, parentWorkflowName)); - } - return map; - } - } \ No newline at end of file diff --git a/parodos-model-api/src/main/java/com/redhat/parodos/workflow/task/enums/WorkFlowTaskStatus.java b/parodos-model-api/src/main/java/com/redhat/parodos/workflow/task/enums/WorkFlowTaskStatus.java index b61658faa..d1510d728 100644 --- a/parodos-model-api/src/main/java/com/redhat/parodos/workflow/task/enums/WorkFlowTaskStatus.java +++ b/parodos-model-api/src/main/java/com/redhat/parodos/workflow/task/enums/WorkFlowTaskStatus.java @@ -24,6 +24,6 @@ */ public enum WorkFlowTaskStatus { - FAILED, COMPLETED, IN_PROGRESS, PENDING + FAILED, COMPLETED, IN_PROGRESS, PENDING, REJECTED } diff --git a/parodos-model-api/src/main/java/com/redhat/parodos/workflow/utils/WorkContextUtils.java b/parodos-model-api/src/main/java/com/redhat/parodos/workflow/utils/WorkContextUtils.java new file mode 100644 index 000000000..f92f94d43 --- /dev/null +++ b/parodos-model-api/src/main/java/com/redhat/parodos/workflow/utils/WorkContextUtils.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2022 Red Hat Developer + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.redhat.parodos.workflow.utils; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.redhat.parodos.workflow.context.WorkContextDelegate; +import com.redhat.parodos.workflows.work.WorkContext; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +/** + * Util Class to parse WorkContext + * + * @author Richard Wang (Github: richardW98) + */ + +public class WorkContextUtils { + + private WorkContextUtils() { + } + + /** + * method to get project id from workContext + * @param workContext + * @return project id + */ + public static String getProjectId(WorkContext workContext) { + return WorkContextDelegate + .read(workContext, WorkContextDelegate.ProcessType.PROJECT, WorkContextDelegate.Resource.ID).toString(); + } + + /** + * get master workflow execution id from workContext + * @param workContext + * @return master workflow execution id + */ + public static String getMainExecutionId(WorkContext workContext) { + return WorkContextDelegate + .read(workContext, WorkContextDelegate.ProcessType.WORKFLOW_EXECUTION, WorkContextDelegate.Resource.ID) + .toString(); + } + + /** + * add a new common parameter to workContext + * @param workContext + * @param key parameter name + * @param value parameter value + */ + public static void addParameter(WorkContext workContext, String key, String value) { + Map parameterMap = Optional + .ofNullable(new ObjectMapper().convertValue(WorkContextDelegate.read(workContext, + WorkContextDelegate.ProcessType.WORKFLOW_EXECUTION, WorkContextDelegate.Resource.ARGUMENTS), + new TypeReference>() { + })) + .orElse(new HashMap<>()); + parameterMap.put(key, value); + WorkContextDelegate.write(workContext, WorkContextDelegate.ProcessType.WORKFLOW_EXECUTION, + WorkContextDelegate.Resource.ARGUMENTS, parameterMap); + } + + /** + * get all available parameters for a task + * @param workContext + * @param name task name + * @return Map of parameters + */ + public static Map getAllParameters(WorkContext workContext, String name) { + Map parameters = Optional + .ofNullable(new ObjectMapper().convertValue( + WorkContextDelegate.read(workContext, WorkContextDelegate.ProcessType.WORKFLOW_TASK_EXECUTION, + name, WorkContextDelegate.Resource.ARGUMENTS), + new TypeReference>() { + })) + .orElse(new HashMap<>()); + parameters.putAll(Optional.ofNullable(new ObjectMapper().convertValue(WorkContextDelegate.read(workContext, + WorkContextDelegate.ProcessType.WORKFLOW_EXECUTION, WorkContextDelegate.Resource.ARGUMENTS), + new TypeReference>() { + })).orElse(new HashMap<>())); + parameters.putAll(getParentParameters(workContext, name)); + return parameters; + } + + private static Map getParentParameters(WorkContext workContext, String workName) { + String parentWorkflowName = (String) WorkContextDelegate.read(workContext, + WorkContextDelegate.ProcessType.WORKFLOW_EXECUTION, workName, + WorkContextDelegate.Resource.PARENT_WORKFLOW); + Map map = new HashMap<>(); + Optional.ofNullable( + new ObjectMapper().convertValue( + WorkContextDelegate.read(workContext, WorkContextDelegate.ProcessType.WORKFLOW_EXECUTION, + workName, WorkContextDelegate.Resource.ARGUMENTS), + new TypeReference>() { + })) + .ifPresent(map::putAll); + if (parentWorkflowName != null) { + map.putAll(getParentParameters(workContext, parentWorkflowName)); + } + return map; + } + +} diff --git a/pattern-detection-library/pom.xml b/pattern-detection-library/pom.xml index effb1ce0e..adf7e46d7 100644 --- a/pattern-detection-library/pom.xml +++ b/pattern-detection-library/pom.xml @@ -27,31 +27,18 @@ - UTF-8 - UTF-8 - 11 - 3.12.0 2.6 - 2.0.6 - 2.0.6 - 1.18.26 - 5.7.2 31.1-jre - 0.3 - 2.14.2 - 2.14.2 org.apache.commons commons-lang3 - ${commons-lang3.version} com.fasterxml.jackson.dataformat jackson-dataformat-yaml - ${jackson.dataformat.version} dev.parodos @@ -61,7 +48,6 @@ com.fasterxml.jackson.core jackson-databind - ${jackson.databind.version} commons-io @@ -71,24 +57,20 @@ org.junit.jupiter junit-jupiter-engine - ${junit.version} test org.slf4j slf4j-api - ${slf4j-api.version} org.slf4j slf4j-simple - ${slf4j-simple.version} test org.projectlombok lombok - ${lombok.version} provided diff --git a/pom.xml b/pom.xml index 94e64a084..c708a2cad 100644 --- a/pom.xml +++ b/pom.xml @@ -59,6 +59,7 @@ 4.13.1 3.5.13 3.17.2 + 4.9.2 workflow-engine @@ -108,6 +109,17 @@ ${assertj.version} test + + + com.squareup.okhttp3 + okhttp + ${okhttp-version} + + + com.squareup.okhttp3 + logging-interceptor + ${okhttp-version} + diff --git a/prebuilt-tasks/pom.xml b/prebuilt-tasks/pom.xml index 5c3b2c5ac..a0e2ec541 100644 --- a/prebuilt-tasks/pom.xml +++ b/prebuilt-tasks/pom.xml @@ -34,7 +34,6 @@ org.projectlombok lombok - 1.18.24 dev.parodos @@ -45,7 +44,6 @@ jakarta.jms jakarta.jms-api - 2.0.3 com.tibco diff --git a/workflow-engine/pom.xml b/workflow-engine/pom.xml index b9acd6727..2bb6b2ad5 100644 --- a/workflow-engine/pom.xml +++ b/workflow-engine/pom.xml @@ -34,7 +34,6 @@ org.slf4j slf4j-api - ${slf4j.version} @@ -53,13 +52,11 @@ org.slf4j slf4j-simple - ${slf4j.version} test org.projectlombok lombok - RELEASE compile diff --git a/workflow-engine/src/main/java/com/redhat/parodos/workflows/work/WorkStatus.java b/workflow-engine/src/main/java/com/redhat/parodos/workflows/work/WorkStatus.java index ddba25084..308b04ca9 100644 --- a/workflow-engine/src/main/java/com/redhat/parodos/workflows/work/WorkStatus.java +++ b/workflow-engine/src/main/java/com/redhat/parodos/workflows/work/WorkStatus.java @@ -36,13 +36,23 @@ public enum WorkStatus { FAILED, /** - * The unit of work has completed successfully + * The unit of work has completed successfully. */ COMPLETED, /** - * The unit of work still in progress (not completed) + * The unit of work still in progress (not completed). */ - IN_PROGRESS + IN_PROGRESS, + + /** + * The unit of work has rejected. + */ + REJECTED, + + /** + * The unit of work is pending checker. + */ + PENDING } diff --git a/workflow-engine/src/main/java/com/redhat/parodos/workflows/workflow/ParallelFlowReport.java b/workflow-engine/src/main/java/com/redhat/parodos/workflows/workflow/ParallelFlowReport.java index 8e1887f67..08461ca13 100644 --- a/workflow-engine/src/main/java/com/redhat/parodos/workflows/workflow/ParallelFlowReport.java +++ b/workflow-engine/src/main/java/com/redhat/parodos/workflows/workflow/ParallelFlowReport.java @@ -81,6 +81,12 @@ void addAll(List workReports) { * successfully completed *
  • {@link org.jeasy.flows.work.WorkStatus#FAILED}: If one of the work units has * failed
  • + *
  • {@link org.jeasy.flows.work.WorkStatus#IN_PROGRESS}: If one of the work units + * is in progress
  • + *
  • {@link org.jeasy.flows.work.WorkStatus#REJECTED}: If one of the work units has + * rejected
  • + *
  • {@link org.jeasy.flows.work.WorkStatus#PENDING}: If one of the work units is + * pending
  • * * @return workflow status */ @@ -88,8 +94,8 @@ void addAll(List workReports) { public WorkStatus getStatus() { WorkStatus workStatus = WorkStatus.COMPLETED; for (WorkReport report : reports) { - if (report.getStatus().equals(WorkStatus.FAILED)) { - return WorkStatus.FAILED; + if (List.of(WorkStatus.FAILED, WorkStatus.REJECTED).contains(report.getStatus())) { + return report.getStatus(); } if (!report.getStatus().equals(WorkStatus.COMPLETED)) { workStatus = report.getStatus(); diff --git a/workflow-examples/pom.xml b/workflow-examples/pom.xml index cb2761462..6f79a803f 100644 --- a/workflow-examples/pom.xml +++ b/workflow-examples/pom.xml @@ -20,27 +20,28 @@ http://github.com/parodos-dev/parodos/tree/master - 1.7.30 - 1.18.26 - 5.3.26 + 2.3.30 + 6.5.1 org.springframework spring-context - ${spring.framework.version} provided org.springframework spring-web - ${spring.framework.version} provided - org.springframework - spring-expression - ${spring.framework.version} + org.springframework + spring-expression + + + org.freemarker + freemarker + ${freemarker.version} dev.parodos @@ -57,13 +58,11 @@ org.slf4j slf4j-api - ${slf4j.version} provided org.projectlombok lombok - ${lombok.version} provided @@ -78,6 +77,16 @@ org.mockito mockito-inline + + io.fabric8 + kubernetes-client + ${fabric8.version} + + + io.fabric8 + openshift-client + ${fabric8.version} + dev.parodos prebuilt-tasks diff --git a/workflow-examples/run_examples.sh b/workflow-examples/run_examples.sh index 9c84970ff..0cdb619f0 100755 --- a/workflow-examples/run_examples.sh +++ b/workflow-examples/run_examples.sh @@ -225,7 +225,7 @@ run_complex_flow() { params='{ "projectId": "'$PROJECT_ID'", - "workFlowName": "onboardingAssessment_ASSESSMENT_WORKFLOW", + "workFlowName": "onboardingMasterAssessment_ASSESSMENT_WORKFLOW", "works": [] }' response=$(execute_workflow "$params" "COMPLETED") diff --git a/workflow-examples/src/main/java/com/redhat/parodos/examples/master/MasterWorkFlowConfiguration.java b/workflow-examples/src/main/java/com/redhat/parodos/examples/master/MasterWorkFlowConfiguration.java index e67a9439e..3d1e91517 100644 --- a/workflow-examples/src/main/java/com/redhat/parodos/examples/master/MasterWorkFlowConfiguration.java +++ b/workflow-examples/src/main/java/com/redhat/parodos/examples/master/MasterWorkFlowConfiguration.java @@ -39,21 +39,21 @@ WorkFlowOption onboardingOption() { // An AssessmentTask returns one or more WorkFlowOption wrapped in a WorkflowOptions @Bean - OnboardingAssessmentTask onboardingAssessmentTask( + OnboardingAssessmentTask onboardingMasterAssessmentTask( @Qualifier("onboardingOption") WorkFlowOption awesomeToolsOption) { return new OnboardingAssessmentTask(awesomeToolsOption); } // A Workflow designed to execute and return WorkflowOption(s) that can be executed // next. In this case there is only one. - @Bean(name = "onboardingAssessment" + WorkFlowConstants.ASSESSMENT_WORKFLOW) + @Bean(name = "onboardingMasterAssessment" + WorkFlowConstants.ASSESSMENT_WORKFLOW) @Assessment WorkFlow assessmentWorkFlow( - @Qualifier("onboardingAssessmentTask") OnboardingAssessmentTask onboardingAssessmentTask) { + @Qualifier("onboardingMasterAssessmentTask") OnboardingAssessmentTask onboardingMasterAssessmentTask) { // @formatter:off return SequentialFlow.Builder.aNewSequentialFlow() - .named("onboardingAssessment" + WorkFlowConstants.ASSESSMENT_WORKFLOW) - .execute(onboardingAssessmentTask) + .named("onboardingMasterAssessment" + WorkFlowConstants.ASSESSMENT_WORKFLOW) + .execute(onboardingMasterAssessmentTask) .build(); // @formatter:on } diff --git a/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/OcpOnboardingWorkFlowConfiguration.java b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/OcpOnboardingWorkFlowConfiguration.java new file mode 100644 index 000000000..4478b80dd --- /dev/null +++ b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/OcpOnboardingWorkFlowConfiguration.java @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2022 Red Hat Developer + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.redhat.parodos.examples.ocponboarding; + +import com.redhat.parodos.examples.ocponboarding.checker.JiraTicketApprovalWorkFlowCheckerTask; +import com.redhat.parodos.examples.ocponboarding.escalation.JiraTicketApprovalEscalationWorkFlowTask; +import com.redhat.parodos.examples.ocponboarding.task.AppLinkEmailNotificationWorkFlowTask; +import com.redhat.parodos.examples.ocponboarding.task.JiraTicketCreationWorkFlowTask; +import com.redhat.parodos.examples.ocponboarding.task.JiraTicketEmailNotificationWorkFlowTask; +import com.redhat.parodos.examples.ocponboarding.task.NotificationWorkFlowTask; +import com.redhat.parodos.examples.ocponboarding.task.OcpAppDeploymentWorkFlowTask; +import com.redhat.parodos.examples.ocponboarding.task.assessment.OnboardingOcpAssessmentTask; +import com.redhat.parodos.workflow.annotation.Assessment; +import com.redhat.parodos.workflow.annotation.Checker; +import com.redhat.parodos.workflow.annotation.Escalation; +import com.redhat.parodos.workflow.annotation.Infrastructure; +import com.redhat.parodos.workflow.annotation.Parameter; +import com.redhat.parodos.workflow.consts.WorkFlowConstants; +import com.redhat.parodos.workflow.option.WorkFlowOption; +import com.redhat.parodos.workflow.parameter.WorkFlowParameterType; +import com.redhat.parodos.workflows.workflow.SequentialFlow; +import com.redhat.parodos.workflows.workflow.WorkFlow; +import java.util.Date; +import java.util.List; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class OcpOnboardingWorkFlowConfiguration { + + // Assessment workflow + @Bean + WorkFlowOption onboardingOcpOption() { + return new WorkFlowOption.Builder("ocpOnboarding", "ocpOnboardingWorkFlow") + .addToDetails("this is for the app to deploy on OCP").displayName("Onboarding to OCP") + .setDescription("this is for the app to deploy on OCP").build(); + } + + @Bean + WorkFlowOption badRepoOption() { + return new WorkFlowOption.Builder("badRepoOption", + "simpleSequentialWorkFlow" + WorkFlowConstants.INFRASTRUCTURE_WORKFLOW) + .addToDetails("Container Fundamentals Training Required").displayName("Training Required") + .setDescription("Container Fundamentals Training Required").build(); + } + + @Bean + WorkFlowOption notSupportOption() { + return new WorkFlowOption.Builder("notSupportOption", + "simpleSequentialWorkFlow" + WorkFlowConstants.INFRASTRUCTURE_WORKFLOW) + .addToDetails("Non-Supported Workflow Steps").displayName("Not Supported") + .setDescription("Non-Supported Workflow Steps").build(); + } + + // An AssessmentTask returns one or more WorkFlowOption wrapped in a WorkflowOptions + @Bean + OnboardingOcpAssessmentTask onboardingAssessmentTask( + @Qualifier("onboardingOcpOption") WorkFlowOption onboardingOcpOption, + @Qualifier("badRepoOption") WorkFlowOption badRepoOption, + @Qualifier("notSupportOption") WorkFlowOption notSupportOption) { + return new OnboardingOcpAssessmentTask(List.of(onboardingOcpOption, badRepoOption, notSupportOption)); + } + + // A Workflow designed to execute and return WorkflowOption(s) that can be executed + // next. In this case there is only one. + @Bean(name = "onboardingAssessment" + WorkFlowConstants.ASSESSMENT_WORKFLOW) + @Assessment + WorkFlow assessmentWorkFlow( + @Qualifier("onboardingAssessmentTask") OnboardingOcpAssessmentTask onboardingAssessmentTask) { + // @formatter:off + return SequentialFlow.Builder.aNewSequentialFlow() + .named("onboardingAssessment" + WorkFlowConstants.ASSESSMENT_WORKFLOW) + .execute(onboardingAssessmentTask) + .build(); + // @formatter:on + } + + // WORKFLOW A - Sequential Flow: + // @formatter:off + // - JiraTicketCreationWorkFlowTask -> JiraTicketApprovalWorkFlowCheckerTask -> JiraTicketApprovalEscalationWorkFlowTask + // - JiraTicketEmailNotificationWorkFlowTask + // @formatter:on + + @Bean + JiraTicketApprovalEscalationWorkFlowTask jiraTicketApprovalEscalationWorkFlowTask( + @Value("${MAIL_SERVICE_URL:service}") String mailServiceUrl, + @Value("${MAIL_SERVICE_SITE_NAME_ESCALATION:site}") String mailServiceSiteName) { + return new JiraTicketApprovalEscalationWorkFlowTask(mailServiceUrl, mailServiceSiteName); + } + + @Bean(name = "jiraTicketApprovalEscalationWorkFlow") + @Escalation + WorkFlow jiraTicketApprovalEscalationWorkFlow( + @Qualifier("jiraTicketApprovalEscalationWorkFlowTask") JiraTicketApprovalEscalationWorkFlowTask jiraTicketApprovalEscalationWorkFlowTask) { + return SequentialFlow.Builder.aNewSequentialFlow().named("jiraTicketApprovalEscalationWorkFlow") + .execute(jiraTicketApprovalEscalationWorkFlowTask).build(); + } + + @Bean + JiraTicketApprovalWorkFlowCheckerTask jiraTicketApprovalWorkFlowCheckerTask( + @Qualifier("jiraTicketApprovalEscalationWorkFlow") WorkFlow jiraTicketApprovalEscalationWorkFlow, + @Value("${JIRA_URL:test}") String url, @Value("${JIRA_USER:user}") String username, + @Value("${JIRA_TOKEN:token}") String password) { + return new JiraTicketApprovalWorkFlowCheckerTask(jiraTicketApprovalEscalationWorkFlow, + new Date().getTime() / 1000 + 30, url, username, password); + } + + @Bean(name = "jiraTicketApprovalWorkFlowChecker") + @Checker(cronExpression = "*/5 * * * * ?") + WorkFlow jiraTicketApprovalWorkFlowChecker( + @Qualifier("jiraTicketApprovalWorkFlowCheckerTask") JiraTicketApprovalWorkFlowCheckerTask jiraTicketApprovalWorkFlowCheckerTask) { + return SequentialFlow.Builder.aNewSequentialFlow().named("jiraTicketApprovalWorkFlowChecker") + .execute(jiraTicketApprovalWorkFlowCheckerTask).build(); + } + + @Bean + JiraTicketCreationWorkFlowTask jiraTicketCreationWorkFlowTask( + @Qualifier("jiraTicketApprovalWorkFlowChecker") WorkFlow jiraTicketApprovalWorkFlowChecker, + @Value("${JIRA_URL:test}") String url, @Value("${JIRA_USER:user}") String username, + @Value("${JIRA_TOKEN:token}") String password, @Value("${JIRA_APPROVER:approver}") String approverId) { + JiraTicketCreationWorkFlowTask jiraTicketCreationWorkFlowTask = new JiraTicketCreationWorkFlowTask(url, + username, password, approverId); + jiraTicketCreationWorkFlowTask.setWorkFlowCheckers(List.of(jiraTicketApprovalWorkFlowChecker)); + return jiraTicketCreationWorkFlowTask; + } + + @Bean + JiraTicketEmailNotificationWorkFlowTask jiraTicketEmailNotificationWorkFlowTask( + @Value("${MAIL_SERVICE_URL:service}") String mailServiceUrl, + @Value("${MAIL_SERVICE_SITE_NAME_JIRA:site}") String mailServiceSiteName) { + return new JiraTicketEmailNotificationWorkFlowTask(mailServiceUrl, mailServiceSiteName); + } + + @Bean + NotificationWorkFlowTask notificationWorkFlowTask( + @Value("${NOTIFICATION_SERVER_URL:test}") String notificationServiceUrl) { + return new NotificationWorkFlowTask(notificationServiceUrl); + } + + @Bean(name = "workFlowA") + @Infrastructure + WorkFlow workFlowA( + @Qualifier("jiraTicketCreationWorkFlowTask") JiraTicketCreationWorkFlowTask jiraTicketCreationWorkFlowTask, + @Qualifier("notificationWorkFlowTask") NotificationWorkFlowTask notificationWorkFlowTask, + @Qualifier("jiraTicketEmailNotificationWorkFlowTask") JiraTicketEmailNotificationWorkFlowTask jiraTicketEmailNotificationWorkFlowTask) { + return SequentialFlow.Builder.aNewSequentialFlow().named("workFlowA").execute(jiraTicketCreationWorkFlowTask) + .then(notificationWorkFlowTask).then(jiraTicketEmailNotificationWorkFlowTask).build(); + } + + // WORKFLOW B - Sequential Flow: + // - OcpAppDeploymentWorkFlowTask + // - JiraTicketEmailNotificationWorkFlowTask + @Bean + OcpAppDeploymentWorkFlowTask ocpAppDeploymentWorkFlowTask( + @Value("${CLUSTER_API_URL:cluster}") String clusterApiUrl) { + return new OcpAppDeploymentWorkFlowTask(clusterApiUrl); + } + + @Bean + AppLinkEmailNotificationWorkFlowTask appLinkEmailNotificationWorkFlowTask( + @Value("${MAIL_SERVICE_URL:service}") String mailServiceUrl, + @Value("${MAIL_SERVICE_SITE_NAME_APP:site}") String mailServiceSiteName) { + return new AppLinkEmailNotificationWorkFlowTask(mailServiceUrl, mailServiceSiteName); + } + + @Bean(name = "workFlowB") + @Infrastructure + WorkFlow workFlowB( + @Qualifier("ocpAppDeploymentWorkFlowTask") OcpAppDeploymentWorkFlowTask ocpAppDeploymentWorkFlowTask, + @Qualifier("appLinkEmailNotificationWorkFlowTask") AppLinkEmailNotificationWorkFlowTask appLinkEmailNotificationWorkFlowTask) { + return SequentialFlow.Builder.aNewSequentialFlow().named("workFlowB").execute(ocpAppDeploymentWorkFlowTask) + .then(appLinkEmailNotificationWorkFlowTask).build(); + } + + // OCP ONBOARDING WORKFLOW - Sequential Flow: + // - workFlowA + // - workFlowB + + @Bean(name = "ocpOnboardingWorkFlow") + @Infrastructure(parameters = { @Parameter(key = "NAMESPACE", description = "The namespace in the ocp cluster", + type = WorkFlowParameterType.TEXT, optional = false) }) + WorkFlow ocpOnboardingWorkFlow(@Qualifier("workFlowA") WorkFlow workFlowA, + @Qualifier("workFlowB") WorkFlow workFlowB) { + return SequentialFlow.Builder.aNewSequentialFlow().named("ocpOnboardingWorkFlow").execute(workFlowA) + .then(workFlowB).build(); + } + +} diff --git a/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/checker/JiraTicketApprovalWorkFlowCheckerTask.java b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/checker/JiraTicketApprovalWorkFlowCheckerTask.java new file mode 100644 index 000000000..b92c200be --- /dev/null +++ b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/checker/JiraTicketApprovalWorkFlowCheckerTask.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2022 Red Hat Developer + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.redhat.parodos.examples.ocponboarding.checker; + +import com.redhat.parodos.examples.utils.RestUtils; +import com.redhat.parodos.workflow.exception.MissingParameterException; +import com.redhat.parodos.workflow.task.checker.BaseWorkFlowCheckerTask; +import com.redhat.parodos.workflow.task.enums.WorkFlowTaskOutput; +import com.redhat.parodos.workflows.work.DefaultWorkReport; +import com.redhat.parodos.workflows.work.WorkContext; +import com.redhat.parodos.workflows.work.WorkReport; +import com.redhat.parodos.workflows.work.WorkStatus; +import com.redhat.parodos.examples.ocponboarding.task.dto.jira.GetJiraTicketResponseDto; +import com.redhat.parodos.examples.ocponboarding.task.dto.jira.GetJiraTicketResponseValue; +import com.redhat.parodos.workflows.workflow.WorkFlow; +import java.util.List; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.RestClientException; + +/** + * An example of a task that calls a Jira Endpoint with a BasicAuth Header + * + * @author Richard Wang (Github: richardW98) + */ + +@Slf4j +public class JiraTicketApprovalWorkFlowCheckerTask extends BaseWorkFlowCheckerTask { + + private static final String ISSUE_KEY = "ISSUE_KEY"; + + private static final String CLUSTER_TOKEN = "CLUSTER_TOKEN"; + + private static final String CLUSTER_TOKEN_CUSTOM_FIELD_ID = "customfield_10064"; + + private static final String DONE = "DONE"; + + private static final String DECLINED = "DECLINED"; + + private final String jiraServiceBaseUrl; + + private final String jiraUsername; + + private final String jiraPassword; + + public JiraTicketApprovalWorkFlowCheckerTask(WorkFlow jiraTicketApprovalEscalationWorkFlow, long sla, + String jiraServiceBaseUrl, String jiraUsername, String jiraPassword) { + super(jiraTicketApprovalEscalationWorkFlow, sla); + this.jiraServiceBaseUrl = jiraServiceBaseUrl; + this.jiraUsername = jiraUsername; + this.jiraPassword = jiraPassword; + } + + /** + * Executed by the InfrastructureTask engine as part of the Workflow + */ + @Override + public WorkReport checkWorkFlowStatus(WorkContext workContext) { + log.info("Start jiraTicketApprovalWorkFlowCheckerTask..."); + try { + String urlString = jiraServiceBaseUrl + "/rest/servicedeskapi/request/"; + String issueKey = getRequiredParameterValue(workContext, ISSUE_KEY); + log.info("Calling: urlString: {} username: {}", urlString, jiraUsername); + + ResponseEntity result = RestUtils.restExchange(urlString + issueKey, jiraUsername, + jiraPassword, GetJiraTicketResponseDto.class); + GetJiraTicketResponseDto responseDto = result.getBody(); + + if (!result.getStatusCode().is2xxSuccessful() || responseDto == null) { + log.error("Call to the API was not successful. Response: {}", result.getStatusCode()); + } + else { + log.info("Rest call completed: {}", responseDto.getIssueKey()); + switch (responseDto.getCurrentStatus().getStatus().toUpperCase()) { + case DONE: + log.info("request {} is approved", responseDto.getIssueKey()); + String clusterToken = responseDto.getRequestFieldValues().stream() + .filter(requestFieldValue -> requestFieldValue.getFieldId() + .equals(CLUSTER_TOKEN_CUSTOM_FIELD_ID)) + .findFirst().map(GetJiraTicketResponseValue::getValue) + .orElseThrow(() -> new MissingParameterException( + "cluster token is not provided by approver!")) + .toString(); + addParameter(workContext, CLUSTER_TOKEN, clusterToken); + return new DefaultWorkReport(WorkStatus.COMPLETED, workContext); + case DECLINED: + log.info("request {} is rejected", responseDto.getIssueKey()); + return new DefaultWorkReport(WorkStatus.REJECTED, workContext); + default: + log.info("request {} is waiting for approval", responseDto.getIssueKey()); + break; + } + } + } + catch (RestClientException e) { + log.error("There was an issue with the REST call: {}", e.getMessage()); + } + catch (MissingParameterException e) { + log.error("There was an error getting parameter(s): {}", e.getMessage()); + } + return new DefaultWorkReport(WorkStatus.FAILED, workContext); + } + + @Override + public List getWorkFlowTaskOutputs() { + return List.of(WorkFlowTaskOutput.HTTP2XX, WorkFlowTaskOutput.OTHER); + } + +} diff --git a/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/escalation/JiraTicketApprovalEscalationWorkFlowTask.java b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/escalation/JiraTicketApprovalEscalationWorkFlowTask.java new file mode 100644 index 000000000..6f11485dc --- /dev/null +++ b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/escalation/JiraTicketApprovalEscalationWorkFlowTask.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2022 Red Hat Developer + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.redhat.parodos.examples.ocponboarding.escalation; + +import static java.util.Objects.isNull; + +import com.redhat.parodos.examples.ocponboarding.task.dto.email.MessageRequestDTO; +import com.redhat.parodos.examples.utils.RestUtils; +import com.redhat.parodos.workflow.exception.MissingParameterException; +import com.redhat.parodos.workflow.task.enums.WorkFlowTaskOutput; +import com.redhat.parodos.workflow.task.infrastructure.BaseInfrastructureWorkFlowTask; +import com.redhat.parodos.workflows.work.DefaultWorkReport; +import com.redhat.parodos.workflows.work.WorkContext; +import com.redhat.parodos.workflows.work.WorkReport; +import com.redhat.parodos.workflows.work.WorkStatus; +import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; +import java.util.List; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpEntity; +import org.springframework.http.ResponseEntity; + +/** + * An example of a task that send an escalation email notification for a pending Jira + * ticket review and approval + * + * @author Annel Ketcha (Github: anludke) + */ + +@Slf4j +public class JiraTicketApprovalEscalationWorkFlowTask extends BaseInfrastructureWorkFlowTask { + + private static final String ISSUE_LINK = "ISSUE_LINK"; + + private final String mailServiceUrl; + + private final String mailServiceSiteName; + + public JiraTicketApprovalEscalationWorkFlowTask(String mailServiceUrl, String mailServiceSiteName) { + super(); + this.mailServiceUrl = mailServiceUrl; + this.mailServiceSiteName = mailServiceSiteName; + } + + @Override + public WorkReport execute(WorkContext workContext) { + log.info("Start jiraTicketApprovalEscalationWorkFlowTask..."); + + // requester name to extract securityContext or from workContext + String requesterName = "Test Test"; + + // requester email to extract securityContext or from workContext + String requesterEmail = "ttest@test.com"; + + // jira ticket url to extract from workContext + String jiraTicketUrl; + try { + jiraTicketUrl = getRequiredParameterValue(workContext, ISSUE_LINK); + log.info("Jira ticket url is: {}", jiraTicketUrl); + } + catch (MissingParameterException e) { + log.error("JiraTicketApprovalEscalationWorkFlowTask failed! Message: {}", e.getMessage()); + return new DefaultWorkReport(WorkStatus.FAILED, workContext); + } + + // message request payload + MessageRequestDTO messageRequestDTO = MessageRequestDTO.builder().name(requesterName).email(requesterEmail) + .siteName(mailServiceSiteName).message(getMessage(jiraTicketUrl)).build(); + + ResponseEntity responseEntity = null; + try { + HttpEntity requestEntity = new HttpEntity<>(messageRequestDTO); + LocalDateTime startDateTime = LocalDateTime.now(); + responseEntity = RestUtils.executePost(mailServiceUrl, requestEntity); + log.info("Request duration: {} ms", ChronoUnit.MILLIS.between(startDateTime, LocalDateTime.now())); + } + catch (Exception e) { + log.error("Error occurred when submitting message: {}", e.getMessage()); + } + + if (!isNull(responseEntity) && responseEntity.getStatusCode().is2xxSuccessful() + && !isNull(responseEntity.getBody()) && responseEntity.getBody().contains("Mail Sent")) { + log.info("JiraTicketApprovalEscalationWorkFlowTask completed!"); + return new DefaultWorkReport(WorkStatus.COMPLETED, workContext); + } + log.info("JiraTicketApprovalEscalationWorkFlowTask failed!"); + return new DefaultWorkReport(WorkStatus.FAILED, workContext); + } + + @Override + public List getWorkFlowTaskOutputs() { + return List.of(WorkFlowTaskOutput.EXCEPTION, WorkFlowTaskOutput.OTHER); + } + + private String getMessage(String jiraTicketUrl) { + return "Hi there," + "\n" + "The jira ticket below has been escalated due to pending review and approval." + + "\n" + "Jira ticket url: " + jiraTicketUrl + "\n" + "Thank you," + "\n" + "The Parodos Team"; + } + +} diff --git a/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/AppLinkEmailNotificationWorkFlowTask.java b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/AppLinkEmailNotificationWorkFlowTask.java new file mode 100644 index 000000000..c58ef40f0 --- /dev/null +++ b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/AppLinkEmailNotificationWorkFlowTask.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2022 Red Hat Developer + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.redhat.parodos.examples.ocponboarding.task; + +import static java.util.Objects.isNull; + +import com.redhat.parodos.examples.ocponboarding.task.dto.email.MessageRequestDTO; +import com.redhat.parodos.examples.utils.RestUtils; +import com.redhat.parodos.workflow.exception.MissingParameterException; +import com.redhat.parodos.workflow.task.enums.WorkFlowTaskOutput; +import com.redhat.parodos.workflow.task.infrastructure.BaseInfrastructureWorkFlowTask; +import com.redhat.parodos.workflows.work.DefaultWorkReport; +import com.redhat.parodos.workflows.work.WorkContext; +import com.redhat.parodos.workflows.work.WorkReport; +import com.redhat.parodos.workflows.work.WorkStatus; +import java.io.IOException; +import java.io.StringWriter; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import freemarker.template.Configuration; +import freemarker.template.Template; +import freemarker.template.TemplateException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpEntity; +import org.springframework.http.ResponseEntity; + +/** + * An example of a task that send an app link email notification + * + * @author Annel Ketcha (Github: anludke) + */ + +@Slf4j +public class AppLinkEmailNotificationWorkFlowTask extends BaseInfrastructureWorkFlowTask { + + private final static String TEMPLATE_DEFAULT_ENCODING = "UTF-8"; + + private final static String TEMPLATE_BASE_PACKAGE_PATH = "templates"; + + private final static String TEMPLATE_NAME = "appLinkEmailNotification.ftlh"; + + private static final String APP_LINK_PARAMETER_NAME = "APP_LINK"; + + private final String mailServiceUrl; + + private final String mailServiceSiteName; + + public AppLinkEmailNotificationWorkFlowTask(String mailServiceUrl, String mailServiceSiteName) { + super(); + this.mailServiceUrl = mailServiceUrl; + this.mailServiceSiteName = mailServiceSiteName; + } + + @Override + public WorkReport execute(WorkContext workContext) { + log.info("Start appLinkEmailNotificationWorkFlowTask..."); + + // requester name to extract securityContext or from workContext + String requesterName = "Test Test"; + + // requester email to extract securityContext or from workContext + String requesterEmail = "ttest@test.com"; + + // fill in message data to extract from workContext + Map messageData = new HashMap<>(); + String appLink; + try { + appLink = getRequiredParameterValue(workContext, APP_LINK_PARAMETER_NAME); + messageData.put("appLink", appLink); + log.info("App link is: {}", appLink); + } + catch (MissingParameterException e) { + log.error("AppLinkEmailNotificationWorkFlowTask failed! Message: {}", e.getMessage()); + return new DefaultWorkReport(WorkStatus.FAILED, workContext); + } + + ResponseEntity responseEntity = null; + try { + // message template + String message = getMessage(TEMPLATE_NAME, messageData); + if (message.isEmpty()) { + log.info("AppLinkEmailNotificationWorkFlowTask failed due to empty message template!"); + return new DefaultWorkReport(WorkStatus.FAILED, workContext); + } + // message request payload + MessageRequestDTO messageRequestDTO = MessageRequestDTO.builder().name(requesterName).email(requesterEmail) + .siteName(mailServiceSiteName).message(message).build(); + HttpEntity requestEntity = new HttpEntity<>(messageRequestDTO); + responseEntity = RestUtils.executePost(mailServiceUrl, requestEntity); + } + catch (Exception e) { + log.error("Error occurred when preparing or submitting the message: {}", e.getMessage()); + } + + if (!isNull(responseEntity) && responseEntity.getStatusCode().is2xxSuccessful() + && !isNull(responseEntity.getBody()) && responseEntity.getBody().contains("Mail Sent")) { + log.info("AppLinkEmailNotificationWorkFlowTask completed!"); + return new DefaultWorkReport(WorkStatus.COMPLETED, workContext); + } + + log.info("AppLinkEmailNotificationWorkFlowTask failed!"); + return new DefaultWorkReport(WorkStatus.FAILED, workContext); + } + + @Override + public List getWorkFlowTaskOutputs() { + return List.of(WorkFlowTaskOutput.EXCEPTION, WorkFlowTaskOutput.OTHER); + } + + private String getMessage(String templateName, Map templateData) + throws IOException, TemplateException { + String message = ""; + Configuration cfg = new Configuration(Configuration.VERSION_2_3_30); + cfg.setClassLoaderForTemplateLoading(getClass().getClassLoader(), TEMPLATE_BASE_PACKAGE_PATH); + cfg.setDefaultEncoding(TEMPLATE_DEFAULT_ENCODING); + Template template = cfg.getTemplate(templateName); + try (StringWriter out = new StringWriter()) { + template.process(templateData, out); + message = out.getBuffer().toString(); + out.flush(); + } + return message; + } + +} diff --git a/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/JiraTicketCreationWorkFlowTask.java b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/JiraTicketCreationWorkFlowTask.java new file mode 100644 index 000000000..94bf4845f --- /dev/null +++ b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/JiraTicketCreationWorkFlowTask.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2022 Red Hat Developer + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.redhat.parodos.examples.ocponboarding.task; + +import com.redhat.parodos.examples.utils.RestUtils; +import com.redhat.parodos.workflow.task.enums.WorkFlowTaskOutput; +import com.redhat.parodos.workflow.task.infrastructure.BaseInfrastructureWorkFlowTask; +import com.redhat.parodos.workflows.work.DefaultWorkReport; +import com.redhat.parodos.workflows.work.WorkContext; +import com.redhat.parodos.workflows.work.WorkReport; +import com.redhat.parodos.workflows.work.WorkStatus; +import com.redhat.parodos.examples.ocponboarding.task.dto.jira.CreateJiraTicketRequestDto; +import com.redhat.parodos.examples.ocponboarding.task.dto.jira.RequestFieldValues; +import com.redhat.parodos.examples.ocponboarding.task.dto.jira.CreateJiraTicketResponseDto; +import java.util.List; +import java.util.Objects; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.ResponseEntity; + +/** + * An example of a task that calls a Jira Endpoint with a BasicAuth Header + * + * @author Richard Wang (Github: richardW98) + */ + +@Slf4j +public class JiraTicketCreationWorkFlowTask extends BaseInfrastructureWorkFlowTask { + + private static final String NOTIFICATION_MESSAGE = "NOTIFICATION_MESSAGE"; + + private static final String NOTIFICATION_SUBJECT = "NOTIFICATION_SUBJECT"; + + private static final String NAMESPACE = "NAMESPACE"; + + private static final String ISSUE_KEY = "ISSUE_KEY"; + + private static final String ISSUE_LINK = "ISSUE_LINK"; + + private static final String WEB_LINK = "web"; + + private static final String JIRA_TICKET_CREATED = "jira ticket created - "; + + private static final String JIRA_TICKET_LINK = "jira ticket link: "; + + private final String jiraServiceBaseUrl; + + private final String jiraUsername; + + private final String jiraPassword; + + private final String approverId; + + public JiraTicketCreationWorkFlowTask(String jiraServiceBaseUrl, String jiraUsername, String jiraPassword, + String approverId) { + super(); + this.jiraServiceBaseUrl = jiraServiceBaseUrl; + this.jiraUsername = jiraUsername; + this.jiraPassword = jiraPassword; + this.approverId = approverId; + } + + /** + * Executed by the InfrastructureTask engine as part of the Workflow + */ + public WorkReport execute(WorkContext workContext) { + log.info("Start jiraTicketCreationWorkFlowTask..."); + try { + String urlString = jiraServiceBaseUrl + "/rest/servicedeskapi/request"; + String serviceDeskId = "1"; + String requestTypeId = "35"; + String projectId = getProjectId(workContext); + String namespace = getOptionalParameterValue(workContext, NAMESPACE, "demo"); + log.info("Calling: urlString: {} username: {}", urlString, jiraUsername); + + CreateJiraTicketRequestDto request = CreateJiraTicketRequestDto.builder().serviceDeskId(serviceDeskId) + .requestTypeId(requestTypeId) + .requestFieldValues(RequestFieldValues.builder() + .approvers(List.of(RequestFieldValues.JiraUser.builder().accountId(approverId).build())) + .summary(String.format("Onboard %s in namespace %s on ocp", projectId, namespace)) + .projectName(projectId).namespace(namespace).build()) + .build(); + + ResponseEntity response = RestUtils.executePost(urlString, request, + jiraUsername, jiraPassword, CreateJiraTicketResponseDto.class); + + if (response.getStatusCode().is2xxSuccessful()) { + log.info("Rest call completed: {}", Objects.requireNonNull(response.getBody()).getIssueId()); + addParameter(workContext, ISSUE_KEY, Objects.requireNonNull(response.getBody()).getIssueKey()); + addParameter(workContext, ISSUE_LINK, + Objects.requireNonNull(response.getBody()).getLinks().get(WEB_LINK)); + + addParameter(workContext, NOTIFICATION_SUBJECT, + JIRA_TICKET_CREATED + Objects.requireNonNull(response.getBody()).getIssueKey()); + addParameter(workContext, NOTIFICATION_MESSAGE, + JIRA_TICKET_LINK + Objects.requireNonNull(response.getBody()).getLinks().get(WEB_LINK)); + return new DefaultWorkReport(WorkStatus.COMPLETED, workContext); + } + log.error("Call to the API was not successful. Response: {}", response.getStatusCode()); + } + catch (Exception e) { + log.error("There was an issue with the REST call: {}", e.getMessage()); + } + return new DefaultWorkReport(WorkStatus.FAILED, workContext); + } + + @Override + public List getWorkFlowTaskOutputs() { + return List.of(WorkFlowTaskOutput.HTTP2XX, WorkFlowTaskOutput.OTHER); + } + +} diff --git a/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/JiraTicketEmailNotificationWorkFlowTask.java b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/JiraTicketEmailNotificationWorkFlowTask.java new file mode 100644 index 000000000..266d090ed --- /dev/null +++ b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/JiraTicketEmailNotificationWorkFlowTask.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2022 Red Hat Developer + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.redhat.parodos.examples.ocponboarding.task; + +import static java.util.Objects.isNull; + +import com.redhat.parodos.examples.ocponboarding.task.dto.email.MessageRequestDTO; +import com.redhat.parodos.examples.utils.RestUtils; +import com.redhat.parodos.workflow.exception.MissingParameterException; +import com.redhat.parodos.workflow.task.enums.WorkFlowTaskOutput; +import com.redhat.parodos.workflow.task.infrastructure.BaseInfrastructureWorkFlowTask; +import com.redhat.parodos.workflows.work.DefaultWorkReport; +import com.redhat.parodos.workflows.work.WorkContext; +import com.redhat.parodos.workflows.work.WorkReport; +import com.redhat.parodos.workflows.work.WorkStatus; +import java.util.List; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpEntity; +import org.springframework.http.ResponseEntity; + +/** + * An example of a task that send a Jira ticket email notification + * + * @author Annel Ketch (Github: anludke) + */ + +@Slf4j +public class JiraTicketEmailNotificationWorkFlowTask extends BaseInfrastructureWorkFlowTask { + + private static final String ISSUE_LINK_PARAMETER_NAME = "ISSUE_LINK"; + + private final String mailServiceUrl; + + private final String mailServiceSiteName; + + public JiraTicketEmailNotificationWorkFlowTask(String mailServiceUrl, String mailServiceSiteName) { + super(); + this.mailServiceUrl = mailServiceUrl; + this.mailServiceSiteName = mailServiceSiteName; + } + + @Override + public WorkReport execute(WorkContext workContext) { + log.info("Start jiraTicketEmailNotificationWorkFlowTask..."); + + // requester name to extract securityContext or from workContext + String requesterName = "Test Test"; + + // requester email to extract securityContext or from workContext + String requesterEmail = "ttest@test.com"; + + // jira ticket url to extract from workContext + String jiraTicketUrl; + try { + jiraTicketUrl = getRequiredParameterValue(workContext, ISSUE_LINK_PARAMETER_NAME); + log.info("Jira ticket url is: {}", jiraTicketUrl); + } + catch (MissingParameterException e) { + log.error("JiraTicketEmailNotificationWorkFlowTask failed! Message: {}", e.getMessage()); + return new DefaultWorkReport(WorkStatus.FAILED, workContext); + } + + // message request payload + MessageRequestDTO messageRequestDTO = MessageRequestDTO.builder().name(requesterName).email(requesterEmail) + .siteName(mailServiceSiteName).message(getMessage(jiraTicketUrl)).build(); + + ResponseEntity responseEntity = null; + try { + HttpEntity requestEntity = new HttpEntity<>(messageRequestDTO); + responseEntity = RestUtils.executePost(mailServiceUrl, requestEntity); + } + catch (Exception e) { + log.error("Error occurred when submitting message: {}", e.getMessage()); + } + + if (!isNull(responseEntity) && responseEntity.getStatusCode().is2xxSuccessful() + && !isNull(responseEntity.getBody()) && responseEntity.getBody().contains("Mail Sent")) { + log.info("JiraTicketEmailNotificationWorkFlowTask completed!"); + return new DefaultWorkReport(WorkStatus.COMPLETED, workContext); + } + + log.info("JiraTicketEmailNotificationWorkFlowTask failed!"); + return new DefaultWorkReport(WorkStatus.FAILED, workContext); + } + + @Override + public List getWorkFlowTaskOutputs() { + return List.of(WorkFlowTaskOutput.EXCEPTION, WorkFlowTaskOutput.OTHER); + } + + private String getMessage(String jiraTicketUrl) { + return "Hi there," + "\n" + "Please review the jira ticket below and approve." + "\n" + "Jira ticket url: " + + jiraTicketUrl + "\n" + "Thank you," + "\n" + "The Parodos Team"; + } + +} \ No newline at end of file diff --git a/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/NotificationWorkFlowTask.java b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/NotificationWorkFlowTask.java new file mode 100644 index 000000000..4d83a7b05 --- /dev/null +++ b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/NotificationWorkFlowTask.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2022 Red Hat Developer + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.redhat.parodos.examples.ocponboarding.task; + +import com.redhat.parodos.examples.ocponboarding.task.dto.notification.NotificationRequest; +import com.redhat.parodos.examples.utils.RestUtils; +import com.redhat.parodos.workflow.task.enums.WorkFlowTaskOutput; +import com.redhat.parodos.workflow.task.infrastructure.BaseInfrastructureWorkFlowTask; +import com.redhat.parodos.workflows.work.DefaultWorkReport; +import com.redhat.parodos.workflows.work.WorkContext; +import com.redhat.parodos.workflows.work.WorkReport; +import com.redhat.parodos.workflows.work.WorkStatus; +import java.util.List; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpEntity; +import org.springframework.http.ResponseEntity; + +/** + * send message to notification service + * + * @author Richard Wang (Github: richardw98) + * @author Annel Ketcha (Github: anludke) + */ + +@Slf4j +public class NotificationWorkFlowTask extends BaseInfrastructureWorkFlowTask { + + private static final String NOTIFICATION_MESSAGE = "NOTIFICATION_MESSAGE"; + + private static final String NOTIFICATION_SUBJECT = "NOTIFICATION_SUBJECT"; + + private final String notificationServiceUrl; + + public NotificationWorkFlowTask(String notificationServiceUrl) { + super(); + this.notificationServiceUrl = notificationServiceUrl; + } + + /** + * Executed by the InfrastructureTask engine as part of the Workflow + */ + public WorkReport execute(WorkContext workContext) { + try { + String subject = getRequiredParameterValue(workContext, NOTIFICATION_SUBJECT); + String message = getRequiredParameterValue(workContext, NOTIFICATION_MESSAGE); + + NotificationRequest request = NotificationRequest.builder().usernames(List.of("test")).subject(subject) + .body(message).build(); + + HttpEntity notificationRequestHttpEntity = RestUtils.getRequestWithHeaders(request, + "test", "test"); + + ResponseEntity response = RestUtils.executePost(notificationServiceUrl + "/api/v1/messages", + notificationRequestHttpEntity); + + if (response.getStatusCode().is2xxSuccessful()) { + log.info("Rest call completed: {}", response.getBody()); + return new DefaultWorkReport(WorkStatus.COMPLETED, workContext); + } + log.error("Call to the API was not successful. Response: {}", response.getStatusCode()); + } + catch (Exception e) { + log.error("There was an issue with the REST call: {}", e.getMessage()); + } + return new DefaultWorkReport(WorkStatus.FAILED, workContext); + } + + public List getWorkFlowTaskOutputs() { + return List.of(WorkFlowTaskOutput.HTTP2XX, WorkFlowTaskOutput.OTHER); + } + +} diff --git a/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/OcpAppDeploymentWorkFlowTask.java b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/OcpAppDeploymentWorkFlowTask.java new file mode 100644 index 000000000..fb04439bc --- /dev/null +++ b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/OcpAppDeploymentWorkFlowTask.java @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2022 Red Hat Developer + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.redhat.parodos.examples.ocponboarding.task; + +import com.redhat.parodos.workflow.exception.MissingParameterException; +import com.redhat.parodos.workflow.task.infrastructure.BaseInfrastructureWorkFlowTask; +import com.redhat.parodos.workflows.work.DefaultWorkReport; +import com.redhat.parodos.workflows.work.WorkContext; +import com.redhat.parodos.workflows.work.WorkReport; +import com.redhat.parodos.workflows.work.WorkStatus; +import io.fabric8.kubernetes.api.model.IntOrString; +import io.fabric8.kubernetes.api.model.Service; +import io.fabric8.kubernetes.api.model.ServiceBuilder; +import io.fabric8.kubernetes.api.model.apps.Deployment; +import io.fabric8.kubernetes.api.model.apps.DeploymentBuilder; +import io.fabric8.kubernetes.client.Config; +import io.fabric8.kubernetes.client.ConfigBuilder; +import io.fabric8.kubernetes.client.KubernetesClient; +import io.fabric8.kubernetes.client.KubernetesClientBuilder; +import io.fabric8.kubernetes.client.KubernetesClientException; +import io.fabric8.openshift.api.model.ProjectRequestBuilder; +import io.fabric8.openshift.api.model.Route; +import io.fabric8.openshift.api.model.RouteBuilder; +import io.fabric8.openshift.api.model.RoutePortBuilder; +import io.fabric8.openshift.api.model.RouteTargetReferenceBuilder; +import io.fabric8.openshift.client.OpenShiftClient; +import java.util.Collections; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class OcpAppDeploymentWorkFlowTask extends BaseInfrastructureWorkFlowTask { + + private static final String OPENSHIFT_NGINX = "twalter/openshift-nginx"; + + private static final int CONTAINER_PORT = 8081; + + private static final String DEMO_PORT = "demo-port"; + + private static final String APP_LINK = "APP_LINK"; + + private static final String NGINX = "nginx"; + + private static final String NAMESPACE = "NAMESPACE"; + + private static final String CLUSTER_TOKEN = "CLUSTER_TOKEN"; + + private final String clusterApiUrl; + + public OcpAppDeploymentWorkFlowTask(String clusterApiUrl) { + this.clusterApiUrl = clusterApiUrl; + } + + @Override + public WorkReport execute(WorkContext workContext) { + log.info("Start ocpAppDeploymentWorkFlowTask..."); + try { + String namespace = getRequiredParameterValue(workContext, NAMESPACE); + String clusterToken = getRequiredParameterValue(workContext, CLUSTER_TOKEN); + + Config config = new ConfigBuilder().withMasterUrl(clusterApiUrl).withOauthToken(clusterToken).build(); + + try (KubernetesClient kclient = new KubernetesClientBuilder().withConfig(config).build()) { + OpenShiftClient client = kclient.adapt(OpenShiftClient.class); + + // Project + createProject(client, namespace); + + // Deployment + Deployment deployment = new DeploymentBuilder().withNewMetadata().withName(NGINX).endMetadata() + .withNewSpec().withReplicas(1).withNewTemplate().withNewMetadata().addToLabels("app", NGINX) + .endMetadata().withNewSpec().addNewContainer().withName(NGINX).withImage(OPENSHIFT_NGINX) + .addNewPort().withContainerPort(CONTAINER_PORT).endPort().endContainer().endSpec().endTemplate() + .withNewSelector().addToMatchLabels("app", NGINX).endSelector().endSpec().build(); + client.apps().deployments().inNamespace(namespace).resource(deployment).create(); + + // Service + Service service = new ServiceBuilder().withNewMetadata().withName(NGINX).endMetadata().withNewSpec() + .withSelector(Collections.singletonMap("app", NGINX)).addNewPort().withName(DEMO_PORT) + .withProtocol("TCP").withPort(CONTAINER_PORT).withTargetPort(new IntOrString(CONTAINER_PORT)) + .endPort().endSpec().build(); + client.services().inNamespace(namespace).resource(service).create(); + + // Route + Route route = new RouteBuilder().withNewMetadata().withName(NGINX).endMetadata().withNewSpec() + .withTo(new RouteTargetReferenceBuilder().withKind("Service").withName(NGINX).build()) + .withPort(new RoutePortBuilder().withTargetPort(new IntOrString(CONTAINER_PORT)).build()) + .endSpec().build(); + route = client.routes().inNamespace(namespace).resource(route).create(); + + addParameter(workContext, APP_LINK, route.getSpec().getHost()); + log.info("deployment is successful"); + } + } + catch (MissingParameterException e) { + log.error("can't get namespace or cluster token"); + return new DefaultWorkReport(WorkStatus.FAILED, workContext); + } + catch (KubernetesClientException e) { + log.error("deploy failed. error message: {}", e.getMessage()); + return new DefaultWorkReport(WorkStatus.FAILED, workContext); + } + + return new DefaultWorkReport(WorkStatus.COMPLETED, workContext); + } + + private void createProject(OpenShiftClient client, String namespace) { + try { + client.projectrequests().create(new ProjectRequestBuilder().withNewMetadata().withName(namespace) + .endMetadata().withDescription(namespace).withDisplayName(namespace).build()); + } + catch (KubernetesClientException e) { + log.info("project {} already exists: {}", namespace, e.getClass().getSimpleName()); + } + } + +} diff --git a/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/assessment/OnboardingOcpAssessmentTask.java b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/assessment/OnboardingOcpAssessmentTask.java new file mode 100644 index 000000000..733a375a1 --- /dev/null +++ b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/assessment/OnboardingOcpAssessmentTask.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2022 Red Hat Developer + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.redhat.parodos.examples.ocponboarding.task.assessment; + +import com.redhat.parodos.workflow.context.WorkContextDelegate; +import com.redhat.parodos.workflow.exception.MissingParameterException; +import com.redhat.parodos.workflow.option.WorkFlowOption; +import com.redhat.parodos.workflow.option.WorkFlowOptions; +import com.redhat.parodos.workflow.task.assessment.BaseAssessmentTask; +import com.redhat.parodos.workflow.task.enums.WorkFlowTaskOutput; +import com.redhat.parodos.workflow.task.parameter.WorkFlowTaskParameter; +import com.redhat.parodos.workflow.task.parameter.WorkFlowTaskParameterType; +import com.redhat.parodos.workflows.work.DefaultWorkReport; +import com.redhat.parodos.workflows.work.WorkContext; +import com.redhat.parodos.workflows.work.WorkReport; +import com.redhat.parodos.workflows.work.WorkStatus; +import java.util.Collections; +import java.util.List; +import lombok.extern.slf4j.Slf4j; + +/** + * Simple Assessment to determine if an Onboarding Workflow is appropriate. It returns a + * WorkflowOption to represent the Onboarding Workflow + * + * @author Richard Wang (Github: richardW98) + */ +@Slf4j +public class OnboardingOcpAssessmentTask extends BaseAssessmentTask { + + private static final String GIT_REPO_URL = "GIT_REPO_URL"; + + public OnboardingOcpAssessmentTask(List workflowOptions) { + super(workflowOptions); + } + + @Override + public WorkReport execute(WorkContext workContext) { + try { + log.info("parameter {} value: {}", GIT_REPO_URL, getRequiredParameterValue(workContext, GIT_REPO_URL)); + } + catch (MissingParameterException e) { + log.error("can't get parameter {} value", GIT_REPO_URL); + return new DefaultWorkReport(WorkStatus.FAILED, workContext); + } + WorkFlowOptions workFlowOptions = new WorkFlowOptions.Builder().build(); + workFlowOptions.setNewOptions(getWorkFlowOptions()); + + WorkContextDelegate.write(workContext, WorkContextDelegate.ProcessType.WORKFLOW_EXECUTION, + WorkContextDelegate.Resource.WORKFLOW_OPTIONS, + // @formatter:off + workFlowOptions); + // @formatter:on + return new DefaultWorkReport(WorkStatus.COMPLETED, workContext); + } + + public List getWorkFlowTaskParameters() { + return List.of(WorkFlowTaskParameter.builder().key(GIT_REPO_URL) + .description("Enter some information to use for the Assessment to determine if they can onboard") + .optional(false).type(WorkFlowTaskParameterType.TEXT).build()); + } + + @Override + public List getWorkFlowTaskOutputs() { + return Collections.emptyList(); + } + +} diff --git a/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/dto/email/MessageRequestDTO.java b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/dto/email/MessageRequestDTO.java new file mode 100644 index 000000000..c6caf54b1 --- /dev/null +++ b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/dto/email/MessageRequestDTO.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2022 Red Hat Developer + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.redhat.parodos.examples.ocponboarding.task.dto.email; + +import lombok.Builder; +import lombok.Data; + +@Builder +@Data +public class MessageRequestDTO { + + private String name; + + private String email; + + private String message; + + private String siteName; + +} \ No newline at end of file diff --git a/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/dto/jira/CreateJiraTicketRequestDto.java b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/dto/jira/CreateJiraTicketRequestDto.java new file mode 100644 index 000000000..91a67744b --- /dev/null +++ b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/dto/jira/CreateJiraTicketRequestDto.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 Red Hat Developer + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.redhat.parodos.examples.ocponboarding.task.dto.jira; + +import lombok.Builder; +import lombok.Data; + +@Builder +@Data +public class CreateJiraTicketRequestDto { + + private String serviceDeskId; + + private String requestTypeId; + + private RequestFieldValues requestFieldValues; + +} \ No newline at end of file diff --git a/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/dto/jira/CreateJiraTicketResponseDto.java b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/dto/jira/CreateJiraTicketResponseDto.java new file mode 100644 index 000000000..1a0b165d9 --- /dev/null +++ b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/dto/jira/CreateJiraTicketResponseDto.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022 Red Hat Developer + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.redhat.parodos.examples.ocponboarding.task.dto.jira; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import java.util.Map; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class CreateJiraTicketResponseDto { + + private String issueId; + + private String issueKey; + + @JsonProperty("_links") + private Map links; + +} diff --git a/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/dto/jira/GetJiraTicketResponseDto.java b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/dto/jira/GetJiraTicketResponseDto.java new file mode 100644 index 000000000..3e43c2e66 --- /dev/null +++ b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/dto/jira/GetJiraTicketResponseDto.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2022 Red Hat Developer + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.redhat.parodos.examples.ocponboarding.task.dto.jira; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class GetJiraTicketResponseDto { + + private String issueId; + + private String issueKey; + + private List requestFieldValues; + + private JiraStatus currentStatus; + + @JsonProperty("_links") + private Map links; + +} diff --git a/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/dto/jira/GetJiraTicketResponseValue.java b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/dto/jira/GetJiraTicketResponseValue.java new file mode 100644 index 000000000..d48f50c36 --- /dev/null +++ b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/dto/jira/GetJiraTicketResponseValue.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2022 Red Hat Developer + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.redhat.parodos.examples.ocponboarding.task.dto.jira; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class GetJiraTicketResponseValue { + + private String fieldId; + + private String label; + + private Object value; + +} diff --git a/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/dto/jira/JiraStatus.java b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/dto/jira/JiraStatus.java new file mode 100644 index 000000000..53a20ca90 --- /dev/null +++ b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/dto/jira/JiraStatus.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 Red Hat Developer + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.redhat.parodos.examples.ocponboarding.task.dto.jira; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class JiraStatus { + + private String status; + +} diff --git a/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/dto/jira/RequestFieldValues.java b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/dto/jira/RequestFieldValues.java new file mode 100644 index 000000000..0ddd0e76c --- /dev/null +++ b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/dto/jira/RequestFieldValues.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022 Red Hat Developer + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.redhat.parodos.examples.ocponboarding.task.dto.jira; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Builder; +import lombok.Data; + +import java.util.List; + +@Builder +@Data +public class RequestFieldValues { + + private String summary; + + @JsonProperty("customfield_10003") + private List approvers; + + @JsonProperty("customfield_10065") + private String projectName; + + @JsonProperty("customfield_10066") + private String namespace; + + @Builder + @Data + public static class JiraUser { + + private String accountId; + + } + +} diff --git a/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/dto/notification/NotificationRequest.java b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/dto/notification/NotificationRequest.java new file mode 100644 index 000000000..09af635d4 --- /dev/null +++ b/workflow-examples/src/main/java/com/redhat/parodos/examples/ocponboarding/task/dto/notification/NotificationRequest.java @@ -0,0 +1,32 @@ +package com.redhat.parodos.examples.ocponboarding.task.dto.notification; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * request DTO of notification service + * + * @author Richard Wang (Github: RichardW98) + * + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class NotificationRequest implements Serializable { + + private List usernames; + + private String subject; + + @Builder.Default + private String messageType = "MIGRATE"; + + private String body; + +} diff --git a/workflow-examples/src/main/java/com/redhat/parodos/examples/utils/RestUtils.java b/workflow-examples/src/main/java/com/redhat/parodos/examples/utils/RestUtils.java index 016e80cb9..4f0328521 100644 --- a/workflow-examples/src/main/java/com/redhat/parodos/examples/utils/RestUtils.java +++ b/workflow-examples/src/main/java/com/redhat/parodos/examples/utils/RestUtils.java @@ -5,7 +5,6 @@ import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.web.client.RestTemplate; - import java.net.URI; import java.util.Base64; @@ -35,6 +34,26 @@ public static ResponseEntity executePost(String urlString, String payloa return restTemplate.postForEntity(urlString, payload, String.class); } + /** + * Create a new resource by POSTing the given requestEntity to the URL, and returns + * the response as String. + * @see org.springframework.web.client.RestTemplate#postForEntity(URI, Object, Class) + * @param urlString the URL + * @param requestEntity object to post + * @return the response as string + */ + public static ResponseEntity executePost(String urlString, HttpEntity requestEntity) { + RestTemplate restTemplate = new RestTemplate(); + return restTemplate.exchange(urlString, HttpMethod.POST, requestEntity, String.class); + } + + public static ResponseEntity executePost(String urlString, T requestDto, String username, String password, + Class responseType) { + HttpEntity request = getRequestWithHeaders(requestDto, username, password); + RestTemplate restTemplate = new RestTemplate(); + return restTemplate.postForEntity(urlString, request, responseType); + } + /** * Execute the GET HTTP method to the given URL, writing the given request entity to * the request, and returns the response as ResponseEntity. @@ -52,6 +71,13 @@ public static ResponseEntity restExchange(String urlString, String usern String.class); } + public static ResponseEntity restExchange(String urlString, String username, String password, + Class responseType) { + RestTemplate restTemplate = new RestTemplate(); + return restTemplate.exchange(urlString, HttpMethod.GET, getRequestWithHeaders(username, password), + responseType); + } + /** * Creates a new HttpHeader and set the Authorization object according to @see * getBase64Creds @@ -66,6 +92,20 @@ public static HttpEntity getRequestWithHeaders(String username, String p return new HttpEntity<>(headers); } + /** + * Creates a new HttpHeader with request and set the Authorization object according + * to @see getBase64Creds + * @param username the username + * @param password the password + * @return the @see org.springframework.http.HttpEntity + */ + public static HttpEntity getRequestWithHeaders(T request, String username, String password) { + String base64Creds = getBase64Creds(username, password); + HttpHeaders headers = new HttpHeaders(); + headers.add("Authorization", "Basic " + base64Creds); + return new HttpEntity<>(request, headers); + } + /** * Generates a Base64 encoding of username:password string * @param username the username diff --git a/workflow-examples/src/main/java/org/parodos/workflow/examples/CustomWorkFlowConfiguration.java b/workflow-examples/src/main/java/org/parodos/workflow/examples/custom/CustomWorkFlowConfiguration.java similarity index 81% rename from workflow-examples/src/main/java/org/parodos/workflow/examples/CustomWorkFlowConfiguration.java rename to workflow-examples/src/main/java/org/parodos/workflow/examples/custom/CustomWorkFlowConfiguration.java index 82841a128..42d896a72 100644 --- a/workflow-examples/src/main/java/org/parodos/workflow/examples/CustomWorkFlowConfiguration.java +++ b/workflow-examples/src/main/java/org/parodos/workflow/examples/custom/CustomWorkFlowConfiguration.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.parodos.workflow.examples; +package org.parodos.workflow.examples.custom; import com.redhat.parodos.workflow.annotation.Checker; import com.redhat.parodos.workflow.annotation.Infrastructure; +import com.redhat.parodos.workflow.annotation.Parameter; import com.redhat.parodos.workflow.consts.WorkFlowConstants; +import com.redhat.parodos.workflow.parameter.WorkFlowParameterType; import com.redhat.parodos.workflows.workflow.SequentialFlow; import com.redhat.parodos.workflows.workflow.WorkFlow; -import org.parodos.workflow.examples.task.CustomWorkFlowTask; -import org.parodos.workflow.examples.task.SimpleWorkFlowCheckerTask; +import org.parodos.workflow.examples.custom.task.CustomWorkFlowTask; +import org.parodos.workflow.examples.custom.task.SimpleWorkFlowCheckerTask; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -38,11 +40,6 @@ public class CustomWorkFlowConfiguration { // START Custom Sequential Example (WorkflowTasks and Workflow Definitions) - @Bean - CustomWorkFlowTask customWorkFlowTaskOne() { - return new CustomWorkFlowTask(); - } - @Bean CustomWorkFlowTask customWorkFlowTaskOne(@Qualifier("simpleWorkFlowChecker") WorkFlow simpleWorkFlowChecker) { CustomWorkFlowTask customWorkFlowTaskOne = new CustomWorkFlowTask(); @@ -56,7 +53,11 @@ CustomWorkFlowTask customWorkFlowTaskTwo() { } @Bean(name = "customWorkflow" + WorkFlowConstants.INFRASTRUCTURE_WORKFLOW) - @Infrastructure + @Infrastructure(parameters = { + @Parameter(key = "workloadId", description = "The workload id", type = WorkFlowParameterType.TEXT, + optional = false), + @Parameter(key = "projectUrl", description = "The project url", type = WorkFlowParameterType.URL, + optional = true) }) WorkFlow customWorkflow(@Qualifier("customWorkFlowTaskOne") CustomWorkFlowTask customWorkFlowTaskOne, @Qualifier("customWorkFlowTaskTwo") CustomWorkFlowTask customWorkFlowTaskTwo) { // @formatter:off @@ -64,7 +65,7 @@ WorkFlow customWorkflow(@Qualifier("customWorkFlowTaskOne") CustomWorkFlowTask c .Builder.aNewSequentialFlow() .named("customWorkflow" + WorkFlowConstants.INFRASTRUCTURE_WORKFLOW) .execute(customWorkFlowTaskOne) - .then(customWorkFlowTaskTwo) + .then(customWorkFlowTaskTwo) .build(); // @formatter:on } diff --git a/workflow-examples/src/main/java/org/parodos/workflow/examples/task/CustomWorkFlowTask.java b/workflow-examples/src/main/java/org/parodos/workflow/examples/custom/task/CustomWorkFlowTask.java similarity index 96% rename from workflow-examples/src/main/java/org/parodos/workflow/examples/task/CustomWorkFlowTask.java rename to workflow-examples/src/main/java/org/parodos/workflow/examples/custom/task/CustomWorkFlowTask.java index 863eb7537..23eae6cdf 100644 --- a/workflow-examples/src/main/java/org/parodos/workflow/examples/task/CustomWorkFlowTask.java +++ b/workflow-examples/src/main/java/org/parodos/workflow/examples/custom/task/CustomWorkFlowTask.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.parodos.workflow.examples.task; +package org.parodos.workflow.examples.custom.task; import com.redhat.parodos.workflow.task.infrastructure.BaseInfrastructureWorkFlowTask; import com.redhat.parodos.workflows.work.DefaultWorkReport; diff --git a/workflow-examples/src/main/java/org/parodos/workflow/examples/task/SimpleWorkFlowCheckerTask.java b/workflow-examples/src/main/java/org/parodos/workflow/examples/custom/task/SimpleWorkFlowCheckerTask.java similarity index 92% rename from workflow-examples/src/main/java/org/parodos/workflow/examples/task/SimpleWorkFlowCheckerTask.java rename to workflow-examples/src/main/java/org/parodos/workflow/examples/custom/task/SimpleWorkFlowCheckerTask.java index 856a114f3..2b6ff303a 100644 --- a/workflow-examples/src/main/java/org/parodos/workflow/examples/task/SimpleWorkFlowCheckerTask.java +++ b/workflow-examples/src/main/java/org/parodos/workflow/examples/custom/task/SimpleWorkFlowCheckerTask.java @@ -1,4 +1,4 @@ -package org.parodos.workflow.examples.task; +package org.parodos.workflow.examples.custom.task; import com.redhat.parodos.workflow.task.checker.BaseWorkFlowCheckerTask; import com.redhat.parodos.workflows.work.DefaultWorkReport; diff --git a/workflow-examples/src/main/resources/templates/appLinkEmailNotification.ftlh b/workflow-examples/src/main/resources/templates/appLinkEmailNotification.ftlh new file mode 100644 index 000000000..462378d3c --- /dev/null +++ b/workflow-examples/src/main/resources/templates/appLinkEmailNotification.ftlh @@ -0,0 +1,8 @@ +Hi there! + +Congratulations! Your application has been successfully deployed in OCP. +See below the app link of your application. +Application link: ${appLink} + +Thank you, +The Parodos Team \ No newline at end of file diff --git a/workflow-examples/src/test/java/com/redhat/parodos/examples/integration/SimpleWorkFlow.java b/workflow-examples/src/test/java/com/redhat/parodos/examples/integration/SimpleWorkFlow.java new file mode 100644 index 000000000..db425171d --- /dev/null +++ b/workflow-examples/src/test/java/com/redhat/parodos/examples/integration/SimpleWorkFlow.java @@ -0,0 +1,159 @@ +package com.redhat.parodos.examples.integration; + +import com.redhat.parodos.examples.integration.utils.ExamplesUtils; +import com.redhat.parodos.sdk.api.ApiClient; +import com.redhat.parodos.sdk.api.ApiException; +import com.redhat.parodos.sdk.api.Configuration; +import com.redhat.parodos.sdk.api.ProjectApi; +import com.redhat.parodos.sdk.api.WorkflowApi; +import com.redhat.parodos.sdk.api.WorkflowDefinitionApi; +import com.redhat.parodos.sdk.model.ArgumentRequestDTO; +import com.redhat.parodos.sdk.model.ProjectRequestDTO; +import com.redhat.parodos.sdk.model.ProjectResponseDTO; +import com.redhat.parodos.sdk.model.WorkFlowDefinitionResponseDTO; +import com.redhat.parodos.sdk.model.WorkFlowRequestDTO; +import com.redhat.parodos.sdk.model.WorkFlowResponseDTO; +import com.redhat.parodos.sdk.model.WorkFlowResponseDTO.WorkStatusEnum; +import com.redhat.parodos.sdk.model.WorkRequestDTO; +import com.redhat.parodos.workflow.consts.WorkFlowConstants; +import com.redhat.parodos.workflow.enums.WorkFlowProcessingType; +import com.redhat.parodos.workflow.enums.WorkFlowType; +import com.redhat.parodos.workflow.enums.WorkType; +import com.redhat.parodos.workflow.utils.CredUtils; +import lombok.extern.slf4j.Slf4j; +import org.junit.Before; +import org.junit.Test; +import org.springframework.http.HttpHeaders; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + +import static com.redhat.parodos.examples.integration.utils.ExamplesUtils.getProjectByNameAndDescription; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * @author Gloria Ciavarrini (Github: gciavarrini) + */ +@Slf4j +public class SimpleWorkFlow { + + private static final String projectName = "project-1"; + + private static final String projectDescription = "an example project"; + + private ApiClient apiClient; + + @Before + public void setUp() throws IOException { + apiClient = Configuration.getDefaultApiClient(); + apiClient.addDefaultHeader(HttpHeaders.AUTHORIZATION, "Basic " + CredUtils.getBase64Creds("test", "test")); + + } + + @Test + public void runSimpleWorkFlow() throws ApiException { + log.info("Running simple flow"); + + ProjectApi projectApi = new ProjectApi(apiClient); + + ExamplesUtils.waitProjectStart(projectApi); + log.info("Project is ✔️ on {}", apiClient.getBasePath()); + + ProjectResponseDTO testProject; + + // RETRIEVE ALL PROJECTS AVAILABLE + log.info("Get all available projects"); + List projects = projectApi.getProjects(); + + // CHECK IF testProject ALREADY EXISTS + testProject = getProjectByNameAndDescription(projects, projectName, projectDescription); + + // CREATE PROJECT "Test Project Name" IF NOT EXISTS + if (testProject == null) { + log.info("There are no projects. Creating project {}", projectName); + // DEFINE A TEST PROJECT REQUEST + ProjectRequestDTO projectRequestDTO = new ProjectRequestDTO(); + projectRequestDTO.setName(projectName); + projectRequestDTO.setDescription(projectDescription); + + ProjectResponseDTO projectResponseDTO = projectApi.createProject(projectRequestDTO); + assertNotNull(projectResponseDTO); + assertEquals(projectName, projectResponseDTO.getName()); + assertEquals(projectDescription, projectResponseDTO.getDescription()); + log.info("Project {} successfully created", projectName); + } + + // ASSERT PROJECT "testProject" IS PRESENT + projects = projectApi.getProjects(); + log.debug("PROJECTS: {}", projects); + assertTrue(projects.size() > 0); + testProject = getProjectByNameAndDescription(projects, projectName, projectDescription); + assertNotNull(testProject); + + // GET simpleSequentialWorkFlow DEFINITIONS + WorkflowDefinitionApi workflowDefinitionApi = new WorkflowDefinitionApi(); + List simpleSequentialWorkFlowDefinitions = workflowDefinitionApi + .getWorkFlowDefinitions("simpleSequentialWorkFlow" + WorkFlowConstants.INFRASTRUCTURE_WORKFLOW); + assertEquals(1, simpleSequentialWorkFlowDefinitions.size()); + + // GET WORKFLOW DEFINITION BY Id + WorkFlowDefinitionResponseDTO simpleSequentialWorkFlowDefinition = workflowDefinitionApi + .getWorkFlowDefinitionById(simpleSequentialWorkFlowDefinitions.get(0).getId().toString()); + + assertNotNull(simpleSequentialWorkFlowDefinition.getId()); + assertEquals("simpleSequentialWorkFlow" + WorkFlowConstants.INFRASTRUCTURE_WORKFLOW, + simpleSequentialWorkFlowDefinition.getName()); + assertEquals(WorkFlowProcessingType.SEQUENTIAL.toString(), + simpleSequentialWorkFlowDefinition.getProcessingType()); + assertEquals(WorkFlowType.INFRASTRUCTURE.toString(), simpleSequentialWorkFlowDefinition.getType()); + + assertNotNull(simpleSequentialWorkFlowDefinition.getWorks()); + assertTrue(simpleSequentialWorkFlowDefinition.getWorks().size() == 2); + assertEquals("restCallTask", simpleSequentialWorkFlowDefinition.getWorks().get(0).getName()); + assertEquals(WorkType.TASK.toString(), simpleSequentialWorkFlowDefinition.getWorks().get(0).getWorkType()); + assertNull(simpleSequentialWorkFlowDefinition.getWorks().get(0).getWorks()); + assertNull(simpleSequentialWorkFlowDefinition.getWorks().get(0).getProcessingType()); + assertNotNull(simpleSequentialWorkFlowDefinition.getWorks().get(0).getParameters()); + + assertEquals("loggingTask", simpleSequentialWorkFlowDefinition.getWorks().get(1).getName()); + assertEquals(WorkType.TASK.toString(), simpleSequentialWorkFlowDefinition.getWorks().get(1).getWorkType()); + assertNull(simpleSequentialWorkFlowDefinition.getWorks().get(1).getWorks()); + assertNull(simpleSequentialWorkFlowDefinition.getWorks().get(1).getProcessingType()); + assertNotNull(simpleSequentialWorkFlowDefinition.getWorks().get(1).getParameters()); + + // Define WorkRequests + WorkRequestDTO work1 = new WorkRequestDTO(); + work1.setWorkName("restCallTask"); + work1.setArguments(Arrays.asList(new ArgumentRequestDTO().key("url").value("https://httpbin.org/post"), + new ArgumentRequestDTO().key("payload").value("'Hello!'"))); + + WorkRequestDTO work2 = new WorkRequestDTO(); + work2.setWorkName("loggingTask"); + work2.setArguments(Arrays.asList(new ArgumentRequestDTO().key("user-id").value("test-user-id"), + new ArgumentRequestDTO().key("api-server").value("test-api-server"))); + + // Define WorkFlowRequest + WorkFlowRequestDTO workFlowRequestDTO = new WorkFlowRequestDTO(); + workFlowRequestDTO.setProjectId(testProject.getId()); + workFlowRequestDTO.setWorkFlowName("simpleSequentialWorkFlow_INFRASTRUCTURE_WORKFLOW"); + workFlowRequestDTO.setWorks(Arrays.asList(work1, work2)); + + WorkflowApi workflowApi = new WorkflowApi(); + log.info("******** Running The Simple Sequence Flow ********"); + WorkFlowResponseDTO workFlowResponseDTO = workflowApi.execute(workFlowRequestDTO); + + assertNotNull(workFlowResponseDTO.getWorkFlowExecutionId()); + assertNull(workFlowResponseDTO.getWorkFlowOptions()); + assertNotNull(workFlowResponseDTO.getWorkStatus()); + assertEquals(WorkStatusEnum.COMPLETED, workFlowResponseDTO.getWorkStatus()); + + log.info("workflow finished successfully with response: {}", workFlowResponseDTO); + log.info("******** Simple Sequence Flow Completed ********"); + } + +} \ No newline at end of file diff --git a/workflow-examples/src/test/java/com/redhat/parodos/examples/integration/utils/ExamplesUtils.java b/workflow-examples/src/test/java/com/redhat/parodos/examples/integration/utils/ExamplesUtils.java new file mode 100644 index 000000000..64c399f7e --- /dev/null +++ b/workflow-examples/src/test/java/com/redhat/parodos/examples/integration/utils/ExamplesUtils.java @@ -0,0 +1,66 @@ +package com.redhat.parodos.examples.integration.utils; + +import com.redhat.parodos.sdk.api.ApiCallback; +import com.redhat.parodos.sdk.api.ApiException; +import com.redhat.parodos.sdk.api.ProjectApi; +import com.redhat.parodos.sdk.model.ProjectResponseDTO; +import lombok.extern.slf4j.Slf4j; +import org.assertj.core.util.Strings; + +import javax.annotation.Nullable; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * @author Gloria Ciavarrini (Github: gciavarrini) + */ +@Slf4j +public final class ExamplesUtils { + + public static void waitProjectStart(ProjectApi projectApi) throws ApiException { + AtomicBoolean retry = new AtomicBoolean(true); + ApiCallback> apiCallback = new ApiCallback<>() { + AtomicInteger failureCounter = new AtomicInteger(0); + + @Override + public void onFailure(ApiException e, int statusCode, Map> responseHeaders) { + int i = failureCounter.incrementAndGet(); + if (i >= 100) { + retry.set(false); + } + } + + @Override + public void onSuccess(List result, int statusCode, + Map> responseHeaders) { + retry.set(false); + } + + @Override + public void onUploadProgress(long bytesWritten, long contentLength, boolean done) { + return; + } + + @Override + public void onDownloadProgress(long bytesRead, long contentLength, boolean done) { + return; + } + }; + + if (retry.get()) { + projectApi.getProjectsAsync(apiCallback); + } + } + + @Nullable + public static ProjectResponseDTO getProjectByNameAndDescription(List projects, + String projectName, String projectDescription) { + return projects.stream() + .filter(prj -> projectName.equals(prj.getName()) && projectDescription.equals(prj.getDescription()) + && prj.getUsername() == null && !Strings.isNullOrEmpty(prj.getId())) + .findAny().orElse(null); + } + +} \ No newline at end of file diff --git a/workflow-examples/src/test/java/com/redhat/parodos/examples/ocponboarding/escalation/JiraTicketApprovalEscalationWorkFlowTaskTest.java b/workflow-examples/src/test/java/com/redhat/parodos/examples/ocponboarding/escalation/JiraTicketApprovalEscalationWorkFlowTaskTest.java new file mode 100644 index 000000000..8d929ea67 --- /dev/null +++ b/workflow-examples/src/test/java/com/redhat/parodos/examples/ocponboarding/escalation/JiraTicketApprovalEscalationWorkFlowTaskTest.java @@ -0,0 +1,120 @@ +package com.redhat.parodos.examples.ocponboarding.escalation; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.spy; + +import com.redhat.parodos.examples.base.BaseInfrastructureWorkFlowTaskTest; +import com.redhat.parodos.examples.utils.RestUtils; +import com.redhat.parodos.workflow.exception.MissingParameterException; +import com.redhat.parodos.workflow.task.enums.WorkFlowTaskOutput; +import com.redhat.parodos.workflow.task.infrastructure.BaseInfrastructureWorkFlowTask; +import com.redhat.parodos.workflow.task.parameter.WorkFlowTaskParameter; +import com.redhat.parodos.workflows.work.WorkContext; +import com.redhat.parodos.workflows.work.WorkReport; +import com.redhat.parodos.workflows.work.WorkStatus; +import java.util.List; +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockedStatic; +import org.mockito.Mockito; +import org.springframework.http.HttpEntity; +import org.springframework.http.ResponseEntity; + +/** + * Jira Ticket Email Notification Workflow Task execution test + * + * @author Annel Ketcha (GitHub: anludke) + */ +public class JiraTicketApprovalEscalationWorkFlowTaskTest extends BaseInfrastructureWorkFlowTaskTest { + + private static final String MAIL_SERVICE_URL_TEST = "mail-service-url-test"; + + private static final String MAIL_SERVICE_SITE_NAME_TEST = "mail-service-site-name-test"; + + private static final String ISSUE_LINK_PARAMETER_NAME = "ISSUE_LINK"; + + public static final String JIRA_TICKET_URL_TEST = "jira-ticket-url-test"; + + private JiraTicketApprovalEscalationWorkFlowTask jiraTicketApprovalEscalationWorkFlowTask; + + @Before + public void setUp() { + this.jiraTicketApprovalEscalationWorkFlowTask = spy( + (JiraTicketApprovalEscalationWorkFlowTask) getConcretePersonImplementation()); + + try { + doReturn(JIRA_TICKET_URL_TEST).when(this.jiraTicketApprovalEscalationWorkFlowTask) + .getRequiredParameterValue(Mockito.any(WorkContext.class), eq(ISSUE_LINK_PARAMETER_NAME)); + } + catch (MissingParameterException e) { + throw new RuntimeException(e); + } + } + + @Override + protected BaseInfrastructureWorkFlowTask getConcretePersonImplementation() { + return new JiraTicketApprovalEscalationWorkFlowTask(MAIL_SERVICE_URL_TEST, MAIL_SERVICE_SITE_NAME_TEST); + } + + @Test + public void executeSuccess() { + // given + WorkContext workContext = Mockito.mock(WorkContext.class); + try (MockedStatic restUtilsMockedStatic = Mockito.mockStatic(RestUtils.class)) { + restUtilsMockedStatic + .when(() -> RestUtils.executePost(eq(MAIL_SERVICE_URL_TEST), Mockito.any(HttpEntity.class))) + .thenReturn(ResponseEntity.ok("Mail Sent")); + + // when + WorkReport workReport = jiraTicketApprovalEscalationWorkFlowTask.execute(workContext); + + // then + assertEquals(WorkStatus.COMPLETED, workReport.getStatus()); + } + } + + @Test + public void executeFail() { + // given + WorkContext workContext = Mockito.mock(WorkContext.class); + try (MockedStatic restUtilsMockedStatic = Mockito.mockStatic(RestUtils.class)) { + restUtilsMockedStatic + .when(() -> RestUtils.executePost(eq(MAIL_SERVICE_URL_TEST), Mockito.any(HttpEntity.class))) + .thenReturn(ResponseEntity.internalServerError().build()); + + // when + WorkReport workReport = jiraTicketApprovalEscalationWorkFlowTask.execute(workContext); + + // then + assertEquals(WorkStatus.FAILED, workReport.getStatus()); + } + } + + @Test + public void testGetWorkFlowTaskParameters() { + // when + List workFlowTaskParameters = jiraTicketApprovalEscalationWorkFlowTask + .getWorkFlowTaskParameters(); + + // then + assertNotNull(workFlowTaskParameters); + assertEquals(0, workFlowTaskParameters.size()); + } + + @Test + public void testGetWorkFlowTaskOutputs() { + // when + List workFlowTaskOutputs = jiraTicketApprovalEscalationWorkFlowTask + .getWorkFlowTaskOutputs(); + + // then + assertNotNull(workFlowTaskOutputs); + assertEquals(2, workFlowTaskOutputs.size()); + assertEquals(WorkFlowTaskOutput.EXCEPTION, workFlowTaskOutputs.get(0)); + assertEquals(WorkFlowTaskOutput.OTHER, workFlowTaskOutputs.get(1)); + } + +} \ No newline at end of file diff --git a/workflow-examples/src/test/java/com/redhat/parodos/examples/ocponboarding/task/AppLinkEmailNotificationWorkFlowTaskTest.java b/workflow-examples/src/test/java/com/redhat/parodos/examples/ocponboarding/task/AppLinkEmailNotificationWorkFlowTaskTest.java new file mode 100644 index 000000000..40b566844 --- /dev/null +++ b/workflow-examples/src/test/java/com/redhat/parodos/examples/ocponboarding/task/AppLinkEmailNotificationWorkFlowTaskTest.java @@ -0,0 +1,118 @@ +package com.redhat.parodos.examples.ocponboarding.task; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.spy; + +import com.redhat.parodos.examples.base.BaseInfrastructureWorkFlowTaskTest; +import com.redhat.parodos.examples.utils.RestUtils; +import com.redhat.parodos.workflow.exception.MissingParameterException; +import com.redhat.parodos.workflow.task.enums.WorkFlowTaskOutput; +import com.redhat.parodos.workflow.task.infrastructure.BaseInfrastructureWorkFlowTask; +import com.redhat.parodos.workflow.task.parameter.WorkFlowTaskParameter; +import com.redhat.parodos.workflows.work.WorkContext; +import com.redhat.parodos.workflows.work.WorkReport; +import com.redhat.parodos.workflows.work.WorkStatus; +import java.util.List; +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockedStatic; +import org.mockito.Mockito; +import org.springframework.http.HttpEntity; +import org.springframework.http.ResponseEntity; + +/** + * App Link Email Notification Workflow Task execution test + * + * @author Annel Ketcha (GitHub: anludke) + */ +public class AppLinkEmailNotificationWorkFlowTaskTest extends BaseInfrastructureWorkFlowTaskTest { + + private static final String MAIL_SERVICE_URL_TEST = "mail-service-url-test"; + + private static final String MAIL_SERVICE_SITE_NAME_TEST = "mail-service-site-name-test"; + + private static final String APP_LINK_PARAMETER_NAME = "APP_LINK"; + + public static final String APP_LINK_TEST = "app-link-test"; + + private AppLinkEmailNotificationWorkFlowTask appLinkEmailNotificationWorkFlowTask; + + @Before + public void setUp() { + this.appLinkEmailNotificationWorkFlowTask = spy( + (AppLinkEmailNotificationWorkFlowTask) getConcretePersonImplementation()); + try { + doReturn(APP_LINK_TEST).when(this.appLinkEmailNotificationWorkFlowTask) + .getRequiredParameterValue(Mockito.any(WorkContext.class), eq(APP_LINK_PARAMETER_NAME)); + } + catch (MissingParameterException e) { + throw new RuntimeException(e); + } + } + + @Override + protected BaseInfrastructureWorkFlowTask getConcretePersonImplementation() { + return new AppLinkEmailNotificationWorkFlowTask(MAIL_SERVICE_URL_TEST, MAIL_SERVICE_SITE_NAME_TEST); + } + + @Test + public void executeSuccess() { + // given + WorkContext workContext = Mockito.mock(WorkContext.class); + try (MockedStatic restUtilsMockedStatic = Mockito.mockStatic(RestUtils.class)) { + restUtilsMockedStatic + .when(() -> RestUtils.executePost(eq(MAIL_SERVICE_URL_TEST), Mockito.any(HttpEntity.class))) + .thenReturn(ResponseEntity.ok("Mail Sent")); + + // when + WorkReport workReport = appLinkEmailNotificationWorkFlowTask.execute(workContext); + + // then + assertEquals(WorkStatus.COMPLETED, workReport.getStatus()); + } + } + + @Test + public void executeFail() { + // given + WorkContext workContext = Mockito.mock(WorkContext.class); + try (MockedStatic restUtilsMockedStatic = Mockito.mockStatic(RestUtils.class)) { + restUtilsMockedStatic + .when(() -> RestUtils.executePost(eq(MAIL_SERVICE_URL_TEST), Mockito.any(HttpEntity.class))) + .thenReturn(ResponseEntity.internalServerError().build()); + + // when + WorkReport workReport = appLinkEmailNotificationWorkFlowTask.execute(workContext); + + // then + assertEquals(WorkStatus.FAILED, workReport.getStatus()); + } + } + + @Test + public void testGetWorkFlowTaskParameters() { + // when + List workFlowTaskParameters = appLinkEmailNotificationWorkFlowTask + .getWorkFlowTaskParameters(); + + // then + assertNotNull(workFlowTaskParameters); + assertEquals(0, workFlowTaskParameters.size()); + } + + @Test + public void testGetWorkFlowTaskOutputs() { + // when + List workFlowTaskOutputs = appLinkEmailNotificationWorkFlowTask.getWorkFlowTaskOutputs(); + + // then + assertNotNull(workFlowTaskOutputs); + assertEquals(2, workFlowTaskOutputs.size()); + assertEquals(WorkFlowTaskOutput.EXCEPTION, workFlowTaskOutputs.get(0)); + assertEquals(WorkFlowTaskOutput.OTHER, workFlowTaskOutputs.get(1)); + } + +} diff --git a/workflow-examples/src/test/java/com/redhat/parodos/examples/ocponboarding/task/JiraTicketCreationWorkFlowTaskTest.java b/workflow-examples/src/test/java/com/redhat/parodos/examples/ocponboarding/task/JiraTicketCreationWorkFlowTaskTest.java new file mode 100644 index 000000000..0f656409f --- /dev/null +++ b/workflow-examples/src/test/java/com/redhat/parodos/examples/ocponboarding/task/JiraTicketCreationWorkFlowTaskTest.java @@ -0,0 +1,135 @@ +package com.redhat.parodos.examples.ocponboarding.task; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.spy; + +import com.redhat.parodos.examples.base.BaseInfrastructureWorkFlowTaskTest; +import com.redhat.parodos.examples.ocponboarding.task.dto.jira.CreateJiraTicketResponseDto; +import com.redhat.parodos.examples.utils.RestUtils; +import com.redhat.parodos.workflow.task.enums.WorkFlowTaskOutput; +import com.redhat.parodos.workflow.task.infrastructure.BaseInfrastructureWorkFlowTask; +import com.redhat.parodos.workflow.task.parameter.WorkFlowTaskParameter; +import com.redhat.parodos.workflow.utils.WorkContextUtils; +import com.redhat.parodos.workflows.work.WorkContext; +import com.redhat.parodos.workflows.work.WorkReport; +import com.redhat.parodos.workflows.work.WorkStatus; +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockedStatic; +import org.mockito.Mockito; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import java.util.List; +import java.util.Map; + +/** + * Jira Ticket Creation Workflow Task execution test + * + * @author Annel Ketcha (GitHub: anludke) + */ +public class JiraTicketCreationWorkFlowTaskTest extends BaseInfrastructureWorkFlowTaskTest { + + private static final String JIRA_SERVICE_BASE_URL_TEST = "jira-service-base-url-test"; + + private static final String JIRA_USERNAME_TEST = "jira-username-test"; + + private static final String JIRA_PASSWORD_TEST = "jira-password-test"; + + private static final String APPROVER_ID_TEST = "approver-id-test"; + + private static final String PROJECT_ID_TEST = "project-id-test"; + + private static final String ISSUE_ID_TEST = "issue-ID-test"; + + private static final String ISSUE_KEY_TEST = "issue-key-test"; + + private static final String WEB_LINK_KEY = "web"; + + private static final String WEB_LINK_VALUE = "web-link-test"; + + private static final String NAMESPACE_PARAMETER_KEY = "NAMESPACE"; + + private static final String NAMESPACE_PARAMETER_VALUE = "namespace-test"; + + private JiraTicketCreationWorkFlowTask jiraTicketCreationWorkFlowTask; + + @Before + public void setUp() { + this.jiraTicketCreationWorkFlowTask = spy((JiraTicketCreationWorkFlowTask) getConcretePersonImplementation()); + } + + @Override + protected BaseInfrastructureWorkFlowTask getConcretePersonImplementation() { + return new JiraTicketCreationWorkFlowTask(JIRA_SERVICE_BASE_URL_TEST, JIRA_USERNAME_TEST, JIRA_PASSWORD_TEST, + APPROVER_ID_TEST); + } + + @Test + public void executeSuccess() { + // given + WorkContext workContext = Mockito.mock(WorkContext.class); + + try (MockedStatic restUtilsMockedStatic = Mockito.mockStatic(RestUtils.class)) { + restUtilsMockedStatic.when( + () -> RestUtils.executePost(any(String.class), any(), any(String.class), any(String.class), any())) + .thenReturn(new ResponseEntity<>(CreateJiraTicketResponseDto.builder().issueId(ISSUE_ID_TEST) + .issueKey(ISSUE_KEY_TEST).links(Map.of(WEB_LINK_KEY, WEB_LINK_VALUE)).build(), + HttpStatus.OK)); + + try (MockedStatic workContextUtilsMockedStatic = Mockito + .mockStatic(WorkContextUtils.class)) { + workContextUtilsMockedStatic + .when(() -> WorkContextUtils.getAllParameters(any(WorkContext.class), any(String.class))) + .thenReturn(Map.of(NAMESPACE_PARAMETER_KEY, NAMESPACE_PARAMETER_VALUE)); + + workContextUtilsMockedStatic.when(() -> WorkContextUtils.getProjectId(any(WorkContext.class))) + .thenReturn(PROJECT_ID_TEST); + // when + WorkReport workReport = jiraTicketCreationWorkFlowTask.execute(workContext); + // then + assertEquals(WorkStatus.COMPLETED, workReport.getStatus()); + } + } + } + + @Test + public void executeFail() { + // given + WorkContext workContext = Mockito.mock(WorkContext.class); + + try (MockedStatic restUtilsMockedStatic = Mockito.mockStatic(RestUtils.class)) { + restUtilsMockedStatic.when( + () -> RestUtils.executePost(any(String.class), any(), any(String.class), any(String.class), any())) + .thenReturn(new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR)); + // when + WorkReport workReport = jiraTicketCreationWorkFlowTask.execute(workContext); + // then + assertEquals(WorkStatus.FAILED, workReport.getStatus()); + } + } + + @Test + public void testGetWorkFlowTaskParameters() { + // when + List workFlowTaskParameters = jiraTicketCreationWorkFlowTask.getWorkFlowTaskParameters(); + + // then + assertNotNull(workFlowTaskParameters); + assertEquals(0, workFlowTaskParameters.size()); + } + + @Test + public void testGetWorkFlowTaskOutputs() { + // when + List workFlowTaskOutputs = jiraTicketCreationWorkFlowTask.getWorkFlowTaskOutputs(); + + // then + assertNotNull(workFlowTaskOutputs); + assertEquals(2, workFlowTaskOutputs.size()); + assertEquals(WorkFlowTaskOutput.HTTP2XX, workFlowTaskOutputs.get(0)); + assertEquals(WorkFlowTaskOutput.OTHER, workFlowTaskOutputs.get(1)); + } + +} diff --git a/workflow-examples/src/test/java/com/redhat/parodos/examples/ocponboarding/task/JiraTicketEmailNotificationWorkFlowTaskTest.java b/workflow-examples/src/test/java/com/redhat/parodos/examples/ocponboarding/task/JiraTicketEmailNotificationWorkFlowTaskTest.java new file mode 100644 index 000000000..5c249061c --- /dev/null +++ b/workflow-examples/src/test/java/com/redhat/parodos/examples/ocponboarding/task/JiraTicketEmailNotificationWorkFlowTaskTest.java @@ -0,0 +1,119 @@ +package com.redhat.parodos.examples.ocponboarding.task; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.spy; + +import com.redhat.parodos.examples.base.BaseInfrastructureWorkFlowTaskTest; +import com.redhat.parodos.examples.utils.RestUtils; +import com.redhat.parodos.workflow.exception.MissingParameterException; +import com.redhat.parodos.workflow.task.enums.WorkFlowTaskOutput; +import com.redhat.parodos.workflow.task.infrastructure.BaseInfrastructureWorkFlowTask; +import com.redhat.parodos.workflow.task.parameter.WorkFlowTaskParameter; +import com.redhat.parodos.workflows.work.WorkContext; +import com.redhat.parodos.workflows.work.WorkReport; +import com.redhat.parodos.workflows.work.WorkStatus; +import java.util.List; +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockedStatic; +import org.mockito.Mockito; +import org.springframework.http.HttpEntity; +import org.springframework.http.ResponseEntity; + +/** + * Jira Ticket Email Notification Workflow Task execution test + * + * @author Annel Ketcha (GitHub: anludke) + */ +public class JiraTicketEmailNotificationWorkFlowTaskTest extends BaseInfrastructureWorkFlowTaskTest { + + private static final String MAIL_SERVICE_URL_TEST = "mail-service-url-test"; + + private static final String MAIL_SERVICE_SITE_NAME_TEST = "mail-service-site-name-test"; + + private static final String ISSUE_LINK_PARAMETER_NAME = "ISSUE_LINK"; + + public static final String JIRA_TICKET_URL_TEST = "jira-ticket-url-test"; + + private JiraTicketEmailNotificationWorkFlowTask jiraTicketEmailNotificationWorkFlowTask; + + @Before + public void setUp() { + this.jiraTicketEmailNotificationWorkFlowTask = spy( + (JiraTicketEmailNotificationWorkFlowTask) getConcretePersonImplementation()); + + try { + doReturn(JIRA_TICKET_URL_TEST).when(this.jiraTicketEmailNotificationWorkFlowTask) + .getRequiredParameterValue(Mockito.any(WorkContext.class), eq(ISSUE_LINK_PARAMETER_NAME)); + } + catch (MissingParameterException e) { + throw new RuntimeException(e); + } + } + + @Override + protected BaseInfrastructureWorkFlowTask getConcretePersonImplementation() { + return new JiraTicketEmailNotificationWorkFlowTask(MAIL_SERVICE_URL_TEST, MAIL_SERVICE_SITE_NAME_TEST); + } + + @Test + public void executeSuccess() { + // given + WorkContext workContext = Mockito.mock(WorkContext.class); + try (MockedStatic restUtilsMockedStatic = Mockito.mockStatic(RestUtils.class)) { + restUtilsMockedStatic + .when(() -> RestUtils.executePost(eq(MAIL_SERVICE_URL_TEST), Mockito.any(HttpEntity.class))) + .thenReturn(ResponseEntity.ok("Mail Sent")); + + // when + WorkReport workReport = jiraTicketEmailNotificationWorkFlowTask.execute(workContext); + + // then + assertEquals(WorkStatus.COMPLETED, workReport.getStatus()); + } + } + + @Test + public void executeFail() { + // given + WorkContext workContext = Mockito.mock(WorkContext.class); + try (MockedStatic restUtilsMockedStatic = Mockito.mockStatic(RestUtils.class)) { + restUtilsMockedStatic + .when(() -> RestUtils.executePost(eq(MAIL_SERVICE_URL_TEST), Mockito.any(HttpEntity.class))) + .thenReturn(ResponseEntity.internalServerError().build()); + + // when + WorkReport workReport = jiraTicketEmailNotificationWorkFlowTask.execute(workContext); + + // then + assertEquals(WorkStatus.FAILED, workReport.getStatus()); + } + } + + @Test + public void testGetWorkFlowTaskParameters() { + // when + List workFlowTaskParameters = jiraTicketEmailNotificationWorkFlowTask + .getWorkFlowTaskParameters(); + + // then + assertNotNull(workFlowTaskParameters); + assertEquals(0, workFlowTaskParameters.size()); + } + + @Test + public void testGetWorkFlowTaskOutputs() { + // when + List workFlowTaskOutputs = jiraTicketEmailNotificationWorkFlowTask.getWorkFlowTaskOutputs(); + + // then + assertNotNull(workFlowTaskOutputs); + assertEquals(2, workFlowTaskOutputs.size()); + assertEquals(WorkFlowTaskOutput.EXCEPTION, workFlowTaskOutputs.get(0)); + assertEquals(WorkFlowTaskOutput.OTHER, workFlowTaskOutputs.get(1)); + } + +} \ No newline at end of file diff --git a/workflow-examples/src/test/java/com/redhat/parodos/examples/ocponboarding/task/NotificationWorkFlowTaskTest.java b/workflow-examples/src/test/java/com/redhat/parodos/examples/ocponboarding/task/NotificationWorkFlowTaskTest.java new file mode 100644 index 000000000..7111db94f --- /dev/null +++ b/workflow-examples/src/test/java/com/redhat/parodos/examples/ocponboarding/task/NotificationWorkFlowTaskTest.java @@ -0,0 +1,117 @@ +package com.redhat.parodos.examples.ocponboarding.task; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.spy; + +import com.redhat.parodos.examples.base.BaseInfrastructureWorkFlowTaskTest; +import com.redhat.parodos.examples.ocponboarding.task.dto.notification.NotificationRequest; +import com.redhat.parodos.examples.utils.RestUtils; +import com.redhat.parodos.workflow.exception.MissingParameterException; +import com.redhat.parodos.workflow.task.enums.WorkFlowTaskOutput; +import com.redhat.parodos.workflow.task.infrastructure.BaseInfrastructureWorkFlowTask; +import com.redhat.parodos.workflows.work.WorkContext; +import com.redhat.parodos.workflows.work.WorkReport; +import com.redhat.parodos.workflows.work.WorkStatus; +import java.util.List; +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockedStatic; +import org.mockito.Mockito; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; + +/** + * Notification Workflow Task execution test + * + * @author Annel Ketcha (GitHub: anludke) + */ +public class NotificationWorkFlowTaskTest extends BaseInfrastructureWorkFlowTaskTest { + + private static final String NOTIFICATION_MESSAGE_TEST = "NOTIFICATION_MESSAGE"; + + private static final String NOTIFICATION_MESSAGE_VALUE_TEST = "notification-message-value-test"; + + private static final String NOTIFICATION_SUBJECT_TEST = "NOTIFICATION_SUBJECT"; + + private static final String NOTIFICATION_SUBJECT_VALUE_TEST = "notification-subject-value-test"; + + private static final String NOTIFICATION_SERVICE_URL = "notification-service-url"; + + private NotificationWorkFlowTask notificationWorkFlowTask; + + @Before + public void setUp() { + this.notificationWorkFlowTask = spy((NotificationWorkFlowTask) getConcretePersonImplementation()); + try { + doReturn(NOTIFICATION_SUBJECT_VALUE_TEST).when(this.notificationWorkFlowTask) + .getRequiredParameterValue(Mockito.any(WorkContext.class), eq(NOTIFICATION_SUBJECT_TEST)); + + doReturn(NOTIFICATION_MESSAGE_VALUE_TEST).when(this.notificationWorkFlowTask) + .getRequiredParameterValue(Mockito.any(WorkContext.class), eq(NOTIFICATION_MESSAGE_TEST)); + } + catch (MissingParameterException e) { + throw new RuntimeException(e); + } + } + + @Override + protected BaseInfrastructureWorkFlowTask getConcretePersonImplementation() { + return new NotificationWorkFlowTask(NOTIFICATION_SERVICE_URL); + } + + @Test + public void executeSuccess() { + WorkContext workContext = Mockito.mock(WorkContext.class); + try (MockedStatic restUtilsMockedStatic = Mockito.mockStatic(RestUtils.class)) { + restUtilsMockedStatic.when(() -> RestUtils.getRequestWithHeaders(any(NotificationRequest.class), + any(String.class), any(String.class))) + .thenReturn(new HttpEntity<>(NotificationRequest.builder().build())); + + restUtilsMockedStatic.when(() -> RestUtils.executePost(any(String.class), any(HttpEntity.class))) + .thenReturn(new ResponseEntity<>("OK", HttpStatus.OK)); + + // when + WorkReport workReport = notificationWorkFlowTask.execute(workContext); + + // then + assertEquals(WorkStatus.COMPLETED, workReport.getStatus()); + } + } + + @Test + public void executeFail() { + WorkContext workContext = Mockito.mock(WorkContext.class); + try (MockedStatic restUtilsMockedStatic = Mockito.mockStatic(RestUtils.class)) { + restUtilsMockedStatic.when(() -> RestUtils.getRequestWithHeaders(any(NotificationRequest.class), + any(String.class), any(String.class))) + .thenReturn(new HttpEntity<>(NotificationRequest.builder().build())); + + restUtilsMockedStatic.when(() -> RestUtils.executePost(any(String.class), any(HttpEntity.class))) + .thenReturn(new ResponseEntity<>(HttpStatus.BAD_REQUEST)); + + // when + WorkReport workReport = notificationWorkFlowTask.execute(workContext); + + // then + assertEquals(WorkStatus.FAILED, workReport.getStatus()); + } + } + + @Test + public void testGetWorkFlowTaskOutputs() { + // when + List workFlowTaskOutputs = notificationWorkFlowTask.getWorkFlowTaskOutputs(); + + // then + assertNotNull(workFlowTaskOutputs); + assertEquals(2, workFlowTaskOutputs.size()); + assertEquals(WorkFlowTaskOutput.HTTP2XX, workFlowTaskOutputs.get(0)); + assertEquals(WorkFlowTaskOutput.OTHER, workFlowTaskOutputs.get(1)); + } + +} diff --git a/workflow-service-sdk/api/openapi.yaml b/workflow-service-sdk/api/openapi.yaml index d0f8b2a58..d58164789 100644 --- a/workflow-service-sdk/api/openapi.yaml +++ b/workflow-service-sdk/api/openapi.yaml @@ -349,6 +349,7 @@ components: - COMPLETED - IN_PROGRESS - PENDING + - REJECTED type: string type: object WorkFlowDefinitionResponseDTO: @@ -704,6 +705,8 @@ components: - FAILED - COMPLETED - IN_PROGRESS + - REJECTED + - PENDING type: string type: object WorkFlowStatusResponseDTO: diff --git a/workflow-service-sdk/docs/WorkFlowCheckerTaskRequestDTO.md b/workflow-service-sdk/docs/WorkFlowCheckerTaskRequestDTO.md index 2f109a415..f6579b977 100644 --- a/workflow-service-sdk/docs/WorkFlowCheckerTaskRequestDTO.md +++ b/workflow-service-sdk/docs/WorkFlowCheckerTaskRequestDTO.md @@ -19,6 +19,7 @@ FAILED | "FAILED" COMPLETED | "COMPLETED" IN_PROGRESS | "IN_PROGRESS" PENDING | "PENDING" +REJECTED | "REJECTED" diff --git a/workflow-service-sdk/docs/WorkFlowResponseDTO.md b/workflow-service-sdk/docs/WorkFlowResponseDTO.md index 94d44e80d..7a1d98646 100644 --- a/workflow-service-sdk/docs/WorkFlowResponseDTO.md +++ b/workflow-service-sdk/docs/WorkFlowResponseDTO.md @@ -20,6 +20,8 @@ Name | Value FAILED | "FAILED" COMPLETED | "COMPLETED" IN_PROGRESS | "IN_PROGRESS" +REJECTED | "REJECTED" +PENDING | "PENDING" diff --git a/workflow-service-sdk/pom.xml b/workflow-service-sdk/pom.xml index 788df481f..f26f6870b 100644 --- a/workflow-service-sdk/pom.xml +++ b/workflow-service-sdk/pom.xml @@ -14,6 +14,7 @@ Workflow Service SDK for Parodos https://github.com/parodos-dev/parodos + 0.0.34 5.4.0 1.18.26 @@ -23,6 +24,14 @@ io.spring.javaformat spring-javaformat-maven-plugin + + + process-resources + + apply + + + maven-clean-plugin @@ -60,6 +69,7 @@ generate-client-api-code + generate-sources generate @@ -121,17 +131,14 @@ javax.xml.bind jaxb-api - 2.2.11 com.fasterxml.jackson.datatype jackson-datatype-jsr310 - 2.14.2 com.fasterxml.jackson.dataformat jackson-dataformat-yaml - 2.14.2 org.openapitools @@ -141,12 +148,10 @@ com.squareup.okhttp3 okhttp - 4.9.2 com.squareup.okhttp3 logging-interceptor - 4.9.2 io.gsonfire @@ -156,12 +161,10 @@ javax.annotation javax.annotation-api - 1.3.2 javax.validation validation-api - 2.0.1.Final org.springframework.boot @@ -170,7 +173,6 @@ org.projectlombok lombok - ${lombok.version} provided diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ApiCallback.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ApiCallback.java index 7100cb254..693ce5a6b 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ApiCallback.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ApiCallback.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.api; import java.io.IOException; @@ -24,39 +23,38 @@ * @param The return type */ public interface ApiCallback { - /** - * This is called when the API call fails. - * - * @param e The exception causing the failure - * @param statusCode Status code of the response if available, otherwise it would be 0 - * @param responseHeaders Headers of the response if available, otherwise it would be null - */ - void onFailure(ApiException e, int statusCode, Map> responseHeaders); - - /** - * This is called when the API call succeeded. - * - * @param result The result deserialized from response - * @param statusCode Status code of the response - * @param responseHeaders Headers of the response - */ - void onSuccess(T result, int statusCode, Map> responseHeaders); - - /** - * This is called when the API upload processing. - * - * @param bytesWritten bytes Written - * @param contentLength content length of request body - * @param done write end - */ - void onUploadProgress(long bytesWritten, long contentLength, boolean done); - - /** - * This is called when the API download processing. - * - * @param bytesRead bytes Read - * @param contentLength content length of the response - * @param done Read end - */ - void onDownloadProgress(long bytesRead, long contentLength, boolean done); + + /** + * This is called when the API call fails. + * @param e The exception causing the failure + * @param statusCode Status code of the response if available, otherwise it would be 0 + * @param responseHeaders Headers of the response if available, otherwise it would be + * null + */ + void onFailure(ApiException e, int statusCode, Map> responseHeaders); + + /** + * This is called when the API call succeeded. + * @param result The result deserialized from response + * @param statusCode Status code of the response + * @param responseHeaders Headers of the response + */ + void onSuccess(T result, int statusCode, Map> responseHeaders); + + /** + * This is called when the API upload processing. + * @param bytesWritten bytes Written + * @param contentLength content length of request body + * @param done write end + */ + void onUploadProgress(long bytesWritten, long contentLength, boolean done); + + /** + * This is called when the API download processing. + * @param bytesRead bytes Read + * @param contentLength content length of the response + * @param done Read end + */ + void onDownloadProgress(long bytesRead, long contentLength, boolean done); + } diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ApiClient.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ApiClient.java index 3d0a8946e..cae67f126 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ApiClient.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ApiClient.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.api; import okhttp3.*; @@ -53,1360 +52,1374 @@ import com.redhat.parodos.sdk.api.auth.ApiKeyAuth; /** - *

    ApiClient class.

    + *

    + * ApiClient class. + *

    */ public class ApiClient { - private String basePath = "http://localhost:8080"; - private boolean debugging = false; - private Map defaultHeaderMap = new HashMap(); - private Map defaultCookieMap = new HashMap(); - private String tempFolderPath = null; - - private Map authentications; - - private DateFormat dateFormat; - private DateFormat datetimeFormat; - private boolean lenientDatetimeFormat; - private int dateLength; - - private InputStream sslCaCert; - private boolean verifyingSsl; - private KeyManager[] keyManagers; - - private OkHttpClient httpClient; - private JSON json; - - private HttpLoggingInterceptor loggingInterceptor; - - /** - * Basic constructor for ApiClient - */ - public ApiClient() { - init(); - initHttpClient(); - - // Setup authentications (key: authentication name, value: authentication). - // Prevent the authentications from being modified. - authentications = Collections.unmodifiableMap(authentications); - } - - /** - * Basic constructor with custom OkHttpClient - * - * @param client a {@link okhttp3.OkHttpClient} object - */ - public ApiClient(OkHttpClient client) { - init(); - - httpClient = client; - - // Setup authentications (key: authentication name, value: authentication). - // Prevent the authentications from being modified. - authentications = Collections.unmodifiableMap(authentications); - } - - private void initHttpClient() { - initHttpClient(Collections.emptyList()); - } - - private void initHttpClient(List interceptors) { - OkHttpClient.Builder builder = new OkHttpClient.Builder(); - builder.addNetworkInterceptor(getProgressInterceptor()); - for (Interceptor interceptor: interceptors) { - builder.addInterceptor(interceptor); - } - - httpClient = builder.build(); - } - - private void init() { - verifyingSsl = true; - - json = new JSON(); - - // Set default User-Agent. - setUserAgent("OpenAPI-Generator/1.0.7-SNAPSHOT/java"); - - authentications = new HashMap(); - } - - /** - * Get base path - * - * @return Base path - */ - public String getBasePath() { - return basePath; - } - - /** - * Set base path - * - * @param basePath Base path of the URL (e.g http://localhost:8080 - * @return An instance of OkHttpClient - */ - public ApiClient setBasePath(String basePath) { - this.basePath = basePath; - return this; - } - - /** - * Get HTTP client - * - * @return An instance of OkHttpClient - */ - public OkHttpClient getHttpClient() { - return httpClient; - } - - /** - * Set HTTP client, which must never be null. - * - * @param newHttpClient An instance of OkHttpClient - * @return Api Client - * @throws java.lang.NullPointerException when newHttpClient is null - */ - public ApiClient setHttpClient(OkHttpClient newHttpClient) { - this.httpClient = Objects.requireNonNull(newHttpClient, "HttpClient must not be null!"); - return this; - } - - /** - * Get JSON - * - * @return JSON object - */ - public JSON getJSON() { - return json; - } - - /** - * Set JSON - * - * @param json JSON object - * @return Api client - */ - public ApiClient setJSON(JSON json) { - this.json = json; - return this; - } - - /** - * True if isVerifyingSsl flag is on - * - * @return True if isVerifySsl flag is on - */ - public boolean isVerifyingSsl() { - return verifyingSsl; - } - - /** - * Configure whether to verify certificate and hostname when making https requests. - * Default to true. - * NOTE: Do NOT set to false in production code, otherwise you would face multiple types of cryptographic attacks. - * - * @param verifyingSsl True to verify TLS/SSL connection - * @return ApiClient - */ - public ApiClient setVerifyingSsl(boolean verifyingSsl) { - this.verifyingSsl = verifyingSsl; - applySslSettings(); - return this; - } - - /** - * Get SSL CA cert. - * - * @return Input stream to the SSL CA cert - */ - public InputStream getSslCaCert() { - return sslCaCert; - } - - /** - * Configure the CA certificate to be trusted when making https requests. - * Use null to reset to default. - * - * @param sslCaCert input stream for SSL CA cert - * @return ApiClient - */ - public ApiClient setSslCaCert(InputStream sslCaCert) { - this.sslCaCert = sslCaCert; - applySslSettings(); - return this; - } - - /** - *

    Getter for the field keyManagers.

    - * - * @return an array of {@link javax.net.ssl.KeyManager} objects - */ - public KeyManager[] getKeyManagers() { - return keyManagers; - } - - /** - * Configure client keys to use for authorization in an SSL session. - * Use null to reset to default. - * - * @param managers The KeyManagers to use - * @return ApiClient - */ - public ApiClient setKeyManagers(KeyManager[] managers) { - this.keyManagers = managers; - applySslSettings(); - return this; - } - - /** - *

    Getter for the field dateFormat.

    - * - * @return a {@link java.text.DateFormat} object - */ - public DateFormat getDateFormat() { - return dateFormat; - } - - /** - *

    Setter for the field dateFormat.

    - * - * @param dateFormat a {@link java.text.DateFormat} object - * @return a {@link org.openapitools.client.ApiClient} object - */ - public ApiClient setDateFormat(DateFormat dateFormat) { - this.json.setDateFormat(dateFormat); - return this; - } - - /** - *

    Set SqlDateFormat.

    - * - * @param dateFormat a {@link java.text.DateFormat} object - * @return a {@link org.openapitools.client.ApiClient} object - */ - public ApiClient setSqlDateFormat(DateFormat dateFormat) { - this.json.setSqlDateFormat(dateFormat); - return this; - } - - /** - *

    Set LenientOnJson.

    - * - * @param lenientOnJson a boolean - * @return a {@link org.openapitools.client.ApiClient} object - */ - public ApiClient setLenientOnJson(boolean lenientOnJson) { - this.json.setLenientOnJson(lenientOnJson); - return this; - } - - /** - * Get authentications (key: authentication name, value: authentication). - * - * @return Map of authentication objects - */ - public Map getAuthentications() { - return authentications; - } - - /** - * Get authentication for the given name. - * - * @param authName The authentication name - * @return The authentication, null if not found - */ - public Authentication getAuthentication(String authName) { - return authentications.get(authName); - } - - - /** - * Helper method to set username for the first HTTP basic authentication. - * - * @param username Username - */ - public void setUsername(String username) { - for (Authentication auth : authentications.values()) { - if (auth instanceof HttpBasicAuth) { - ((HttpBasicAuth) auth).setUsername(username); - return; - } - } - throw new RuntimeException("No HTTP basic authentication configured!"); - } - - /** - * Helper method to set password for the first HTTP basic authentication. - * - * @param password Password - */ - public void setPassword(String password) { - for (Authentication auth : authentications.values()) { - if (auth instanceof HttpBasicAuth) { - ((HttpBasicAuth) auth).setPassword(password); - return; - } - } - throw new RuntimeException("No HTTP basic authentication configured!"); - } - - /** - * Helper method to set API key value for the first API key authentication. - * - * @param apiKey API key - */ - public void setApiKey(String apiKey) { - for (Authentication auth : authentications.values()) { - if (auth instanceof ApiKeyAuth) { - ((ApiKeyAuth) auth).setApiKey(apiKey); - return; - } - } - throw new RuntimeException("No API key authentication configured!"); - } - - /** - * Helper method to set API key prefix for the first API key authentication. - * - * @param apiKeyPrefix API key prefix - */ - public void setApiKeyPrefix(String apiKeyPrefix) { - for (Authentication auth : authentications.values()) { - if (auth instanceof ApiKeyAuth) { - ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix); - return; - } - } - throw new RuntimeException("No API key authentication configured!"); - } - - /** - * Helper method to set access token for the first OAuth2 authentication. - * - * @param accessToken Access token - */ - public void setAccessToken(String accessToken) { - throw new RuntimeException("No OAuth2 authentication configured!"); - } - - /** - * Set the User-Agent header's value (by adding to the default header map). - * - * @param userAgent HTTP request's user agent - * @return ApiClient - */ - public ApiClient setUserAgent(String userAgent) { - addDefaultHeader("User-Agent", userAgent); - return this; - } - - /** - * Add a default header. - * - * @param key The header's key - * @param value The header's value - * @return ApiClient - */ - public ApiClient addDefaultHeader(String key, String value) { - defaultHeaderMap.put(key, value); - return this; - } - - /** - * Add a default cookie. - * - * @param key The cookie's key - * @param value The cookie's value - * @return ApiClient - */ - public ApiClient addDefaultCookie(String key, String value) { - defaultCookieMap.put(key, value); - return this; - } - - /** - * Check that whether debugging is enabled for this API client. - * - * @return True if debugging is enabled, false otherwise. - */ - public boolean isDebugging() { - return debugging; - } - - /** - * Enable/disable debugging for this API client. - * - * @param debugging To enable (true) or disable (false) debugging - * @return ApiClient - */ - public ApiClient setDebugging(boolean debugging) { - if (debugging != this.debugging) { - if (debugging) { - loggingInterceptor = new HttpLoggingInterceptor(); - loggingInterceptor.setLevel(Level.BODY); - httpClient = httpClient.newBuilder().addInterceptor(loggingInterceptor).build(); - } else { - final OkHttpClient.Builder builder = httpClient.newBuilder(); - builder.interceptors().remove(loggingInterceptor); - httpClient = builder.build(); - loggingInterceptor = null; - } - } - this.debugging = debugging; - return this; - } - - /** - * The path of temporary folder used to store downloaded files from endpoints - * with file response. The default value is null, i.e. using - * the system's default temporary folder. - * - * @see createTempFile - * @return Temporary folder path - */ - public String getTempFolderPath() { - return tempFolderPath; - } - - /** - * Set the temporary folder path (for downloading files) - * - * @param tempFolderPath Temporary folder path - * @return ApiClient - */ - public ApiClient setTempFolderPath(String tempFolderPath) { - this.tempFolderPath = tempFolderPath; - return this; - } - - /** - * Get connection timeout (in milliseconds). - * - * @return Timeout in milliseconds - */ - public int getConnectTimeout() { - return httpClient.connectTimeoutMillis(); - } - - /** - * Sets the connect timeout (in milliseconds). - * A value of 0 means no timeout, otherwise values must be between 1 and - * {@link java.lang.Integer#MAX_VALUE}. - * - * @param connectionTimeout connection timeout in milliseconds - * @return Api client - */ - public ApiClient setConnectTimeout(int connectionTimeout) { - httpClient = httpClient.newBuilder().connectTimeout(connectionTimeout, TimeUnit.MILLISECONDS).build(); - return this; - } - - /** - * Get read timeout (in milliseconds). - * - * @return Timeout in milliseconds - */ - public int getReadTimeout() { - return httpClient.readTimeoutMillis(); - } - - /** - * Sets the read timeout (in milliseconds). - * A value of 0 means no timeout, otherwise values must be between 1 and - * {@link java.lang.Integer#MAX_VALUE}. - * - * @param readTimeout read timeout in milliseconds - * @return Api client - */ - public ApiClient setReadTimeout(int readTimeout) { - httpClient = httpClient.newBuilder().readTimeout(readTimeout, TimeUnit.MILLISECONDS).build(); - return this; - } - - /** - * Get write timeout (in milliseconds). - * - * @return Timeout in milliseconds - */ - public int getWriteTimeout() { - return httpClient.writeTimeoutMillis(); - } - - /** - * Sets the write timeout (in milliseconds). - * A value of 0 means no timeout, otherwise values must be between 1 and - * {@link java.lang.Integer#MAX_VALUE}. - * - * @param writeTimeout connection timeout in milliseconds - * @return Api client - */ - public ApiClient setWriteTimeout(int writeTimeout) { - httpClient = httpClient.newBuilder().writeTimeout(writeTimeout, TimeUnit.MILLISECONDS).build(); - return this; - } - - - /** - * Format the given parameter object into string. - * - * @param param Parameter - * @return String representation of the parameter - */ - public String parameterToString(Object param) { - if (param == null) { - return ""; - } else if (param instanceof Date ) { - //Serialize to json string and remove the " enclosing characters - String jsonStr = json.serialize(param); - return jsonStr.substring(1, jsonStr.length() - 1); - } else if (param instanceof Collection) { - StringBuilder b = new StringBuilder(); - for (Object o : (Collection) param) { - if (b.length() > 0) { - b.append(","); - } - b.append(String.valueOf(o)); - } - return b.toString(); - } else { - return String.valueOf(param); - } - } - - /** - * Formats the specified query parameter to a list containing a single {@code Pair} object. - * - * Note that {@code value} must not be a collection. - * - * @param name The name of the parameter. - * @param value The value of the parameter. - * @return A list containing a single {@code Pair} object. - */ - public List parameterToPair(String name, Object value) { - List params = new ArrayList(); - - // preconditions - if (name == null || name.isEmpty() || value == null || value instanceof Collection) { - return params; - } - - params.add(new Pair(name, parameterToString(value))); - return params; - } - - /** - * Formats the specified collection query parameters to a list of {@code Pair} objects. - * - * Note that the values of each of the returned Pair objects are percent-encoded. - * - * @param collectionFormat The collection format of the parameter. - * @param name The name of the parameter. - * @param value The value of the parameter. - * @return A list of {@code Pair} objects. - */ - public List parameterToPairs(String collectionFormat, String name, Collection value) { - List params = new ArrayList(); - - // preconditions - if (name == null || name.isEmpty() || value == null || value.isEmpty()) { - return params; - } - - // create the params based on the collection format - if ("multi".equals(collectionFormat)) { - for (Object item : value) { - params.add(new Pair(name, escapeString(parameterToString(item)))); - } - return params; - } - - // collectionFormat is assumed to be "csv" by default - String delimiter = ","; - - // escape all delimiters except commas, which are URI reserved - // characters - if ("ssv".equals(collectionFormat)) { - delimiter = escapeString(" "); - } else if ("tsv".equals(collectionFormat)) { - delimiter = escapeString("\t"); - } else if ("pipes".equals(collectionFormat)) { - delimiter = escapeString("|"); - } - - StringBuilder sb = new StringBuilder(); - for (Object item : value) { - sb.append(delimiter); - sb.append(escapeString(parameterToString(item))); - } - - params.add(new Pair(name, sb.substring(delimiter.length()))); - - return params; - } - - /** - * Formats the specified collection path parameter to a string value. - * - * @param collectionFormat The collection format of the parameter. - * @param value The value of the parameter. - * @return String representation of the parameter - */ - public String collectionPathParameterToString(String collectionFormat, Collection value) { - // create the value based on the collection format - if ("multi".equals(collectionFormat)) { - // not valid for path params - return parameterToString(value); - } - - // collectionFormat is assumed to be "csv" by default - String delimiter = ","; - - if ("ssv".equals(collectionFormat)) { - delimiter = " "; - } else if ("tsv".equals(collectionFormat)) { - delimiter = "\t"; - } else if ("pipes".equals(collectionFormat)) { - delimiter = "|"; - } - - StringBuilder sb = new StringBuilder() ; - for (Object item : value) { - sb.append(delimiter); - sb.append(parameterToString(item)); - } - - return sb.substring(delimiter.length()); - } - - /** - * Sanitize filename by removing path. - * e.g. ../../sun.gif becomes sun.gif - * - * @param filename The filename to be sanitized - * @return The sanitized filename - */ - public String sanitizeFilename(String filename) { - return filename.replaceAll(".*[/\\\\]", ""); - } - - /** - * Check if the given MIME is a JSON MIME. - * JSON MIME examples: - * application/json - * application/json; charset=UTF8 - * APPLICATION/JSON - * application/vnd.company+json - * "* / *" is also default to JSON - * @param mime MIME (Multipurpose Internet Mail Extensions) - * @return True if the given MIME is JSON, false otherwise. - */ - public boolean isJsonMime(String mime) { - String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"; - return mime != null && (mime.matches(jsonMime) || mime.equals("*/*")); - } - - /** - * Select the Accept header's value from the given accepts array: - * if JSON exists in the given array, use it; - * otherwise use all of them (joining into a string) - * - * @param accepts The accepts array to select from - * @return The Accept header to use. If the given array is empty, - * null will be returned (not to set the Accept header explicitly). - */ - public String selectHeaderAccept(String[] accepts) { - if (accepts.length == 0) { - return null; - } - for (String accept : accepts) { - if (isJsonMime(accept)) { - return accept; - } - } - return StringUtil.join(accepts, ","); - } - - /** - * Select the Content-Type header's value from the given array: - * if JSON exists in the given array, use it; - * otherwise use the first one of the array. - * - * @param contentTypes The Content-Type array to select from - * @return The Content-Type header to use. If the given array is empty, - * returns null. If it matches "any", JSON will be used. - */ - public String selectHeaderContentType(String[] contentTypes) { - if (contentTypes.length == 0) { - return null; - } - - if (contentTypes[0].equals("*/*")) { - return "application/json"; - } - - for (String contentType : contentTypes) { - if (isJsonMime(contentType)) { - return contentType; - } - } - - return contentTypes[0]; - } - - /** - * Escape the given string to be used as URL query value. - * - * @param str String to be escaped - * @return Escaped string - */ - public String escapeString(String str) { - try { - return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20"); - } catch (UnsupportedEncodingException e) { - return str; - } - } - - /** - * Deserialize response body to Java object, according to the return type and - * the Content-Type response header. - * - * @param Type - * @param response HTTP response - * @param returnType The type of the Java object - * @return The deserialized Java object - * @throws org.openapitools.client.ApiException If fail to deserialize response body, i.e. cannot read response body - * or the Content-Type of the response is not supported. - */ - @SuppressWarnings("unchecked") - public T deserialize(Response response, Type returnType) throws ApiException { - if (response == null || returnType == null) { - return null; - } - - if ("byte[]".equals(returnType.toString())) { - // Handle binary response (byte array). - try { - return (T) response.body().bytes(); - } catch (IOException e) { - throw new ApiException(e); - } - } else if (returnType.equals(File.class)) { - // Handle file downloading. - return (T) downloadFileFromResponse(response); - } - - String respBody; - try { - if (response.body() != null) - respBody = response.body().string(); - else - respBody = null; - } catch (IOException e) { - throw new ApiException(e); - } - - if (respBody == null || "".equals(respBody)) { - return null; - } - - String contentType = response.headers().get("Content-Type"); - if (contentType == null) { - // ensuring a default content type - contentType = "application/json"; - } - if (isJsonMime(contentType)) { - return json.deserialize(respBody, returnType); - } else if (returnType.equals(String.class)) { - // Expecting string, return the raw response body. - return (T) respBody; - } else { - throw new ApiException( - "Content type \"" + contentType + "\" is not supported for type: " + returnType, - response.code(), - response.headers().toMultimap(), - respBody); - } - } - - /** - * Serialize the given Java object into request body according to the object's - * class and the request Content-Type. - * - * @param obj The Java object - * @param contentType The request Content-Type - * @return The serialized request body - * @throws org.openapitools.client.ApiException If fail to serialize the given object - */ - public RequestBody serialize(Object obj, String contentType) throws ApiException { - if (obj instanceof byte[]) { - // Binary (byte array) body parameter support. - return RequestBody.create((byte[]) obj, MediaType.parse(contentType)); - } else if (obj instanceof File) { - // File body parameter support. - return RequestBody.create((File) obj, MediaType.parse(contentType)); - } else if ("text/plain".equals(contentType) && obj instanceof String) { - return RequestBody.create((String) obj, MediaType.parse(contentType)); - } else if (isJsonMime(contentType)) { - String content; - if (obj != null) { - content = json.serialize(obj); - } else { - content = null; - } - return RequestBody.create(content, MediaType.parse(contentType)); - } else { - throw new ApiException("Content type \"" + contentType + "\" is not supported"); - } - } - - /** - * Download file from the given response. - * - * @param response An instance of the Response object - * @throws org.openapitools.client.ApiException If fail to read file content from response and write to disk - * @return Downloaded file - */ - public File downloadFileFromResponse(Response response) throws ApiException { - try { - File file = prepareDownloadFile(response); - BufferedSink sink = Okio.buffer(Okio.sink(file)); - sink.writeAll(response.body().source()); - sink.close(); - return file; - } catch (IOException e) { - throw new ApiException(e); - } - } - - /** - * Prepare file for download - * - * @param response An instance of the Response object - * @return Prepared file for the download - * @throws java.io.IOException If fail to prepare file for download - */ - public File prepareDownloadFile(Response response) throws IOException { - String filename = null; - String contentDisposition = response.header("Content-Disposition"); - if (contentDisposition != null && !"".equals(contentDisposition)) { - // Get filename from the Content-Disposition header. - Pattern pattern = Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?"); - Matcher matcher = pattern.matcher(contentDisposition); - if (matcher.find()) { - filename = sanitizeFilename(matcher.group(1)); - } - } - - String prefix = null; - String suffix = null; - if (filename == null) { - prefix = "download-"; - suffix = ""; - } else { - int pos = filename.lastIndexOf("."); - if (pos == -1) { - prefix = filename + "-"; - } else { - prefix = filename.substring(0, pos) + "-"; - suffix = filename.substring(pos); - } - // Files.createTempFile requires the prefix to be at least three characters long - if (prefix.length() < 3) - prefix = "download-"; - } - - if (tempFolderPath == null) - return Files.createTempFile(prefix, suffix).toFile(); - else - return Files.createTempFile(Paths.get(tempFolderPath), prefix, suffix).toFile(); - } - - /** - * {@link #execute(Call, Type)} - * - * @param Type - * @param call An instance of the Call object - * @return ApiResponse<T> - * @throws org.openapitools.client.ApiException If fail to execute the call - */ - public ApiResponse execute(Call call) throws ApiException { - return execute(call, null); - } - - /** - * Execute HTTP call and deserialize the HTTP response body into the given return type. - * - * @param returnType The return type used to deserialize HTTP response body - * @param The return type corresponding to (same with) returnType - * @param call Call - * @return ApiResponse object containing response status, headers and - * data, which is a Java object deserialized from response body and would be null - * when returnType is null. - * @throws org.openapitools.client.ApiException If fail to execute the call - */ - public ApiResponse execute(Call call, Type returnType) throws ApiException { - try { - Response response = call.execute(); - T data = handleResponse(response, returnType); - return new ApiResponse(response.code(), response.headers().toMultimap(), data); - } catch (IOException e) { - throw new ApiException(e); - } - } - - /** - * {@link #executeAsync(Call, Type, ApiCallback)} - * - * @param Type - * @param call An instance of the Call object - * @param callback ApiCallback<T> - */ - public void executeAsync(Call call, ApiCallback callback) { - executeAsync(call, null, callback); - } - - /** - * Execute HTTP call asynchronously. - * - * @param Type - * @param call The callback to be executed when the API call finishes - * @param returnType Return type - * @param callback ApiCallback - * @see #execute(Call, Type) - */ - @SuppressWarnings("unchecked") - public void executeAsync(Call call, final Type returnType, final ApiCallback callback) { - call.enqueue(new Callback() { - @Override - public void onFailure(Call call, IOException e) { - callback.onFailure(new ApiException(e), 0, null); - } - - @Override - public void onResponse(Call call, Response response) throws IOException { - T result; - try { - result = (T) handleResponse(response, returnType); - } catch (ApiException e) { - callback.onFailure(e, response.code(), response.headers().toMultimap()); - return; - } catch (Exception e) { - callback.onFailure(new ApiException(e), response.code(), response.headers().toMultimap()); - return; - } - callback.onSuccess(result, response.code(), response.headers().toMultimap()); - } - }); - } - - /** - * Handle the given response, return the deserialized object when the response is successful. - * - * @param Type - * @param response Response - * @param returnType Return type - * @return Type - * @throws org.openapitools.client.ApiException If the response has an unsuccessful status code or - * fail to deserialize the response body - */ - public T handleResponse(Response response, Type returnType) throws ApiException { - if (response.isSuccessful()) { - if (returnType == null || response.code() == 204) { - // returning null if the returnType is not defined, - // or the status code is 204 (No Content) - if (response.body() != null) { - try { - response.body().close(); - } catch (Exception e) { - throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap()); - } - } - return null; - } else { - return deserialize(response, returnType); - } - } else { - String respBody = null; - if (response.body() != null) { - try { - respBody = response.body().string(); - } catch (IOException e) { - throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap()); - } - } - throw new ApiException(response.message(), response.code(), response.headers().toMultimap(), respBody); - } - } - - /** - * Build HTTP call with the given options. - * - * @param path The sub-path of the HTTP URL - * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE" - * @param queryParams The query parameters - * @param collectionQueryParams The collection query parameters - * @param body The request body object - * @param headerParams The header parameters - * @param cookieParams The cookie parameters - * @param formParams The form parameters - * @param authNames The authentications to apply - * @param callback Callback for upload/download progress - * @return The HTTP call - * @throws org.openapitools.client.ApiException If fail to serialize the request body object - */ - public Call buildCall(String baseUrl, String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { - Request request = buildRequest(baseUrl, path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, authNames, callback); - - return httpClient.newCall(request); - } - - /** - * Build an HTTP request with the given options. - * - * @param path The sub-path of the HTTP URL - * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE" - * @param queryParams The query parameters - * @param collectionQueryParams The collection query parameters - * @param body The request body object - * @param headerParams The header parameters - * @param cookieParams The cookie parameters - * @param formParams The form parameters - * @param authNames The authentications to apply - * @param callback Callback for upload/download progress - * @return The HTTP request - * @throws org.openapitools.client.ApiException If fail to serialize the request body object - */ - public Request buildRequest(String baseUrl, String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { - // aggregate queryParams (non-collection) and collectionQueryParams into allQueryParams - List allQueryParams = new ArrayList(queryParams); - allQueryParams.addAll(collectionQueryParams); - - final String url = buildUrl(baseUrl, path, queryParams, collectionQueryParams); - - // prepare HTTP request body - RequestBody reqBody; - String contentType = headerParams.get("Content-Type"); - - if (!HttpMethod.permitsRequestBody(method)) { - reqBody = null; - } else if ("application/x-www-form-urlencoded".equals(contentType)) { - reqBody = buildRequestBodyFormEncoding(formParams); - } else if ("multipart/form-data".equals(contentType)) { - reqBody = buildRequestBodyMultipart(formParams); - } else if (body == null) { - if ("DELETE".equals(method)) { - // allow calling DELETE without sending a request body - reqBody = null; - } else { - // use an empty request body (for POST, PUT and PATCH) - reqBody = RequestBody.create("", MediaType.parse(contentType)); - } - } else { - reqBody = serialize(body, contentType); - } - - // update parameters with authentication settings - updateParamsForAuth(authNames, allQueryParams, headerParams, cookieParams, requestBodyToString(reqBody), method, URI.create(url)); - - final Request.Builder reqBuilder = new Request.Builder().url(url); - processHeaderParams(headerParams, reqBuilder); - processCookieParams(cookieParams, reqBuilder); - - // Associate callback with request (if not null) so interceptor can - // access it when creating ProgressResponseBody - reqBuilder.tag(callback); - - Request request = null; - - if (callback != null && reqBody != null) { - ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, callback); - request = reqBuilder.method(method, progressRequestBody).build(); - } else { - request = reqBuilder.method(method, reqBody).build(); - } - - return request; - } - - /** - * Build full URL by concatenating base path, the given sub path and query parameters. - * - * @param path The sub path - * @param queryParams The query parameters - * @param collectionQueryParams The collection query parameters - * @return The full URL - */ - public String buildUrl(String baseUrl, String path, List queryParams, List collectionQueryParams) { - final StringBuilder url = new StringBuilder(); - if (baseUrl != null) { - url.append(baseUrl).append(path); - } else { - url.append(basePath).append(path); - } - - if (queryParams != null && !queryParams.isEmpty()) { - // support (constant) query string in `path`, e.g. "/posts?draft=1" - String prefix = path.contains("?") ? "&" : "?"; - for (Pair param : queryParams) { - if (param.getValue() != null) { - if (prefix != null) { - url.append(prefix); - prefix = null; - } else { - url.append("&"); - } - String value = parameterToString(param.getValue()); - url.append(escapeString(param.getName())).append("=").append(escapeString(value)); - } - } - } - - if (collectionQueryParams != null && !collectionQueryParams.isEmpty()) { - String prefix = url.toString().contains("?") ? "&" : "?"; - for (Pair param : collectionQueryParams) { - if (param.getValue() != null) { - if (prefix != null) { - url.append(prefix); - prefix = null; - } else { - url.append("&"); - } - String value = parameterToString(param.getValue()); - // collection query parameter value already escaped as part of parameterToPairs - url.append(escapeString(param.getName())).append("=").append(value); - } - } - } - - return url.toString(); - } - - /** - * Set header parameters to the request builder, including default headers. - * - * @param headerParams Header parameters in the form of Map - * @param reqBuilder Request.Builder - */ - public void processHeaderParams(Map headerParams, Request.Builder reqBuilder) { - for (Entry param : headerParams.entrySet()) { - reqBuilder.header(param.getKey(), parameterToString(param.getValue())); - } - for (Entry header : defaultHeaderMap.entrySet()) { - if (!headerParams.containsKey(header.getKey())) { - reqBuilder.header(header.getKey(), parameterToString(header.getValue())); - } - } - } - - /** - * Set cookie parameters to the request builder, including default cookies. - * - * @param cookieParams Cookie parameters in the form of Map - * @param reqBuilder Request.Builder - */ - public void processCookieParams(Map cookieParams, Request.Builder reqBuilder) { - for (Entry param : cookieParams.entrySet()) { - reqBuilder.addHeader("Cookie", String.format("%s=%s", param.getKey(), param.getValue())); - } - for (Entry param : defaultCookieMap.entrySet()) { - if (!cookieParams.containsKey(param.getKey())) { - reqBuilder.addHeader("Cookie", String.format("%s=%s", param.getKey(), param.getValue())); - } - } - } - - /** - * Update query and header parameters based on authentication settings. - * - * @param authNames The authentications to apply - * @param queryParams List of query parameters - * @param headerParams Map of header parameters - * @param cookieParams Map of cookie parameters - * @param payload HTTP request body - * @param method HTTP method - * @param uri URI - */ - public void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams, - Map cookieParams, String payload, String method, URI uri) throws ApiException { - for (String authName : authNames) { - Authentication auth = authentications.get(authName); - if (auth == null) { - throw new RuntimeException("Authentication undefined: " + authName); - } - auth.applyToParams(queryParams, headerParams, cookieParams, payload, method, uri); - } - } - - /** - * Build a form-encoding request body with the given form parameters. - * - * @param formParams Form parameters in the form of Map - * @return RequestBody - */ - public RequestBody buildRequestBodyFormEncoding(Map formParams) { - okhttp3.FormBody.Builder formBuilder = new okhttp3.FormBody.Builder(); - for (Entry param : formParams.entrySet()) { - formBuilder.add(param.getKey(), parameterToString(param.getValue())); - } - return formBuilder.build(); - } - - /** - * Build a multipart (file uploading) request body with the given form parameters, - * which could contain text fields and file fields. - * - * @param formParams Form parameters in the form of Map - * @return RequestBody - */ - public RequestBody buildRequestBodyMultipart(Map formParams) { - MultipartBody.Builder mpBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM); - for (Entry param : formParams.entrySet()) { - if (param.getValue() instanceof File) { - File file = (File) param.getValue(); - Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\"; filename=\"" + file.getName() + "\""); - MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file)); - mpBuilder.addPart(partHeaders, RequestBody.create(file, mediaType)); - } else { - Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\""); - mpBuilder.addPart(partHeaders, RequestBody.create(parameterToString(param.getValue()), null)); - } - } - return mpBuilder.build(); - } - - /** - * Guess Content-Type header from the given file (defaults to "application/octet-stream"). - * - * @param file The given file - * @return The guessed Content-Type - */ - public String guessContentTypeFromFile(File file) { - String contentType = URLConnection.guessContentTypeFromName(file.getName()); - if (contentType == null) { - return "application/octet-stream"; - } else { - return contentType; - } - } - - /** - * Get network interceptor to add it to the httpClient to track download progress for - * async requests. - */ - private Interceptor getProgressInterceptor() { - return new Interceptor() { - @Override - public Response intercept(Interceptor.Chain chain) throws IOException { - final Request request = chain.request(); - final Response originalResponse = chain.proceed(request); - if (request.tag() instanceof ApiCallback) { - final ApiCallback callback = (ApiCallback) request.tag(); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), callback)) - .build(); - } - return originalResponse; - } - }; - } - - /** - * Apply SSL related settings to httpClient according to the current values of - * verifyingSsl and sslCaCert. - */ - private void applySslSettings() { - try { - TrustManager[] trustManagers; - HostnameVerifier hostnameVerifier; - if (!verifyingSsl) { - trustManagers = new TrustManager[]{ - new X509TrustManager() { - @Override - public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { - } - - @Override - public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { - } - - @Override - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return new java.security.cert.X509Certificate[]{}; - } - } - }; - hostnameVerifier = new HostnameVerifier() { - @Override - public boolean verify(String hostname, SSLSession session) { - return true; - } - }; - } else { - TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); - - if (sslCaCert == null) { - trustManagerFactory.init((KeyStore) null); - } else { - char[] password = null; // Any password will work. - CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); - Collection certificates = certificateFactory.generateCertificates(sslCaCert); - if (certificates.isEmpty()) { - throw new IllegalArgumentException("expected non-empty set of trusted certificates"); - } - KeyStore caKeyStore = newEmptyKeyStore(password); - int index = 0; - for (Certificate certificate : certificates) { - String certificateAlias = "ca" + Integer.toString(index++); - caKeyStore.setCertificateEntry(certificateAlias, certificate); - } - trustManagerFactory.init(caKeyStore); - } - trustManagers = trustManagerFactory.getTrustManagers(); - hostnameVerifier = OkHostnameVerifier.INSTANCE; - } - - SSLContext sslContext = SSLContext.getInstance("TLS"); - sslContext.init(keyManagers, trustManagers, new SecureRandom()); - httpClient = httpClient.newBuilder() - .sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustManagers[0]) - .hostnameVerifier(hostnameVerifier) - .build(); - } catch (GeneralSecurityException e) { - throw new RuntimeException(e); - } - } - - private KeyStore newEmptyKeyStore(char[] password) throws GeneralSecurityException { - try { - KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); - keyStore.load(null, password); - return keyStore; - } catch (IOException e) { - throw new AssertionError(e); - } - } - - /** - * Convert the HTTP request body to a string. - * - * @param request The HTTP request object - * @return The string representation of the HTTP request body - * @throws org.openapitools.client.ApiException If fail to serialize the request body object into a string - */ - private String requestBodyToString(RequestBody requestBody) throws ApiException { - if (requestBody != null) { - try { - final Buffer buffer = new Buffer(); - requestBody.writeTo(buffer); - return buffer.readUtf8(); - } catch (final IOException e) { - throw new ApiException(e); - } - } - - // empty http request body - return ""; - } + private String basePath = "http://localhost:8080"; + + private boolean debugging = false; + + private Map defaultHeaderMap = new HashMap(); + + private Map defaultCookieMap = new HashMap(); + + private String tempFolderPath = null; + + private Map authentications; + + private DateFormat dateFormat; + + private DateFormat datetimeFormat; + + private boolean lenientDatetimeFormat; + + private int dateLength; + + private InputStream sslCaCert; + + private boolean verifyingSsl; + + private KeyManager[] keyManagers; + + private OkHttpClient httpClient; + + private JSON json; + + private HttpLoggingInterceptor loggingInterceptor; + + /** + * Basic constructor for ApiClient + */ + public ApiClient() { + init(); + initHttpClient(); + + // Setup authentications (key: authentication name, value: authentication). + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); + } + + /** + * Basic constructor with custom OkHttpClient + * @param client a {@link okhttp3.OkHttpClient} object + */ + public ApiClient(OkHttpClient client) { + init(); + + httpClient = client; + + // Setup authentications (key: authentication name, value: authentication). + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); + } + + private void initHttpClient() { + initHttpClient(Collections.emptyList()); + } + + private void initHttpClient(List interceptors) { + OkHttpClient.Builder builder = new OkHttpClient.Builder(); + builder.addNetworkInterceptor(getProgressInterceptor()); + for (Interceptor interceptor : interceptors) { + builder.addInterceptor(interceptor); + } + + httpClient = builder.build(); + } + + private void init() { + verifyingSsl = true; + + json = new JSON(); + + // Set default User-Agent. + setUserAgent("OpenAPI-Generator/1.0.7-SNAPSHOT/java"); + + authentications = new HashMap(); + } + + /** + * Get base path + * @return Base path + */ + public String getBasePath() { + return basePath; + } + + /** + * Set base path + * @param basePath Base path of the URL (e.g http://localhost:8080 + * @return An instance of OkHttpClient + */ + public ApiClient setBasePath(String basePath) { + this.basePath = basePath; + return this; + } + + /** + * Get HTTP client + * @return An instance of OkHttpClient + */ + public OkHttpClient getHttpClient() { + return httpClient; + } + + /** + * Set HTTP client, which must never be null. + * @param newHttpClient An instance of OkHttpClient + * @return Api Client + * @throws java.lang.NullPointerException when newHttpClient is null + */ + public ApiClient setHttpClient(OkHttpClient newHttpClient) { + this.httpClient = Objects.requireNonNull(newHttpClient, "HttpClient must not be null!"); + return this; + } + + /** + * Get JSON + * @return JSON object + */ + public JSON getJSON() { + return json; + } + + /** + * Set JSON + * @param json JSON object + * @return Api client + */ + public ApiClient setJSON(JSON json) { + this.json = json; + return this; + } + + /** + * True if isVerifyingSsl flag is on + * @return True if isVerifySsl flag is on + */ + public boolean isVerifyingSsl() { + return verifyingSsl; + } + + /** + * Configure whether to verify certificate and hostname when making https requests. + * Default to true. NOTE: Do NOT set to false in production code, otherwise you would + * face multiple types of cryptographic attacks. + * @param verifyingSsl True to verify TLS/SSL connection + * @return ApiClient + */ + public ApiClient setVerifyingSsl(boolean verifyingSsl) { + this.verifyingSsl = verifyingSsl; + applySslSettings(); + return this; + } + + /** + * Get SSL CA cert. + * @return Input stream to the SSL CA cert + */ + public InputStream getSslCaCert() { + return sslCaCert; + } + + /** + * Configure the CA certificate to be trusted when making https requests. Use null to + * reset to default. + * @param sslCaCert input stream for SSL CA cert + * @return ApiClient + */ + public ApiClient setSslCaCert(InputStream sslCaCert) { + this.sslCaCert = sslCaCert; + applySslSettings(); + return this; + } + + /** + *

    + * Getter for the field keyManagers. + *

    + * @return an array of {@link javax.net.ssl.KeyManager} objects + */ + public KeyManager[] getKeyManagers() { + return keyManagers; + } + + /** + * Configure client keys to use for authorization in an SSL session. Use null to reset + * to default. + * @param managers The KeyManagers to use + * @return ApiClient + */ + public ApiClient setKeyManagers(KeyManager[] managers) { + this.keyManagers = managers; + applySslSettings(); + return this; + } + + /** + *

    + * Getter for the field dateFormat. + *

    + * @return a {@link java.text.DateFormat} object + */ + public DateFormat getDateFormat() { + return dateFormat; + } + + /** + *

    + * Setter for the field dateFormat. + *

    + * @param dateFormat a {@link java.text.DateFormat} object + * @return a {@link org.openapitools.client.ApiClient} object + */ + public ApiClient setDateFormat(DateFormat dateFormat) { + this.json.setDateFormat(dateFormat); + return this; + } + + /** + *

    + * Set SqlDateFormat. + *

    + * @param dateFormat a {@link java.text.DateFormat} object + * @return a {@link org.openapitools.client.ApiClient} object + */ + public ApiClient setSqlDateFormat(DateFormat dateFormat) { + this.json.setSqlDateFormat(dateFormat); + return this; + } + + /** + *

    + * Set LenientOnJson. + *

    + * @param lenientOnJson a boolean + * @return a {@link org.openapitools.client.ApiClient} object + */ + public ApiClient setLenientOnJson(boolean lenientOnJson) { + this.json.setLenientOnJson(lenientOnJson); + return this; + } + + /** + * Get authentications (key: authentication name, value: authentication). + * @return Map of authentication objects + */ + public Map getAuthentications() { + return authentications; + } + + /** + * Get authentication for the given name. + * @param authName The authentication name + * @return The authentication, null if not found + */ + public Authentication getAuthentication(String authName) { + return authentications.get(authName); + } + + /** + * Helper method to set username for the first HTTP basic authentication. + * @param username Username + */ + public void setUsername(String username) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setUsername(username); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set password for the first HTTP basic authentication. + * @param password Password + */ + public void setPassword(String password) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setPassword(password); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set API key value for the first API key authentication. + * @param apiKey API key + */ + public void setApiKey(String apiKey) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKey(apiKey); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Helper method to set API key prefix for the first API key authentication. + * @param apiKeyPrefix API key prefix + */ + public void setApiKeyPrefix(String apiKeyPrefix) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Helper method to set access token for the first OAuth2 authentication. + * @param accessToken Access token + */ + public void setAccessToken(String accessToken) { + throw new RuntimeException("No OAuth2 authentication configured!"); + } + + /** + * Set the User-Agent header's value (by adding to the default header map). + * @param userAgent HTTP request's user agent + * @return ApiClient + */ + public ApiClient setUserAgent(String userAgent) { + addDefaultHeader("User-Agent", userAgent); + return this; + } + + /** + * Add a default header. + * @param key The header's key + * @param value The header's value + * @return ApiClient + */ + public ApiClient addDefaultHeader(String key, String value) { + defaultHeaderMap.put(key, value); + return this; + } + + /** + * Add a default cookie. + * @param key The cookie's key + * @param value The cookie's value + * @return ApiClient + */ + public ApiClient addDefaultCookie(String key, String value) { + defaultCookieMap.put(key, value); + return this; + } + + /** + * Check that whether debugging is enabled for this API client. + * @return True if debugging is enabled, false otherwise. + */ + public boolean isDebugging() { + return debugging; + } + + /** + * Enable/disable debugging for this API client. + * @param debugging To enable (true) or disable (false) debugging + * @return ApiClient + */ + public ApiClient setDebugging(boolean debugging) { + if (debugging != this.debugging) { + if (debugging) { + loggingInterceptor = new HttpLoggingInterceptor(); + loggingInterceptor.setLevel(Level.BODY); + httpClient = httpClient.newBuilder().addInterceptor(loggingInterceptor).build(); + } + else { + final OkHttpClient.Builder builder = httpClient.newBuilder(); + builder.interceptors().remove(loggingInterceptor); + httpClient = builder.build(); + loggingInterceptor = null; + } + } + this.debugging = debugging; + return this; + } + + /** + * The path of temporary folder used to store downloaded files from endpoints with + * file response. The default value is null, i.e. using the system's + * default temporary folder. + * + * @see createTempFile + * @return Temporary folder path + */ + public String getTempFolderPath() { + return tempFolderPath; + } + + /** + * Set the temporary folder path (for downloading files) + * @param tempFolderPath Temporary folder path + * @return ApiClient + */ + public ApiClient setTempFolderPath(String tempFolderPath) { + this.tempFolderPath = tempFolderPath; + return this; + } + + /** + * Get connection timeout (in milliseconds). + * @return Timeout in milliseconds + */ + public int getConnectTimeout() { + return httpClient.connectTimeoutMillis(); + } + + /** + * Sets the connect timeout (in milliseconds). A value of 0 means no timeout, + * otherwise values must be between 1 and {@link java.lang.Integer#MAX_VALUE}. + * @param connectionTimeout connection timeout in milliseconds + * @return Api client + */ + public ApiClient setConnectTimeout(int connectionTimeout) { + httpClient = httpClient.newBuilder().connectTimeout(connectionTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + /** + * Get read timeout (in milliseconds). + * @return Timeout in milliseconds + */ + public int getReadTimeout() { + return httpClient.readTimeoutMillis(); + } + + /** + * Sets the read timeout (in milliseconds). A value of 0 means no timeout, otherwise + * values must be between 1 and {@link java.lang.Integer#MAX_VALUE}. + * @param readTimeout read timeout in milliseconds + * @return Api client + */ + public ApiClient setReadTimeout(int readTimeout) { + httpClient = httpClient.newBuilder().readTimeout(readTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + /** + * Get write timeout (in milliseconds). + * @return Timeout in milliseconds + */ + public int getWriteTimeout() { + return httpClient.writeTimeoutMillis(); + } + + /** + * Sets the write timeout (in milliseconds). A value of 0 means no timeout, otherwise + * values must be between 1 and {@link java.lang.Integer#MAX_VALUE}. + * @param writeTimeout connection timeout in milliseconds + * @return Api client + */ + public ApiClient setWriteTimeout(int writeTimeout) { + httpClient = httpClient.newBuilder().writeTimeout(writeTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + /** + * Format the given parameter object into string. + * @param param Parameter + * @return String representation of the parameter + */ + public String parameterToString(Object param) { + if (param == null) { + return ""; + } + else if (param instanceof Date) { + // Serialize to json string and remove the " enclosing characters + String jsonStr = json.serialize(param); + return jsonStr.substring(1, jsonStr.length() - 1); + } + else if (param instanceof Collection) { + StringBuilder b = new StringBuilder(); + for (Object o : (Collection) param) { + if (b.length() > 0) { + b.append(","); + } + b.append(String.valueOf(o)); + } + return b.toString(); + } + else { + return String.valueOf(param); + } + } + + /** + * Formats the specified query parameter to a list containing a single {@code Pair} + * object. + * + * Note that {@code value} must not be a collection. + * @param name The name of the parameter. + * @param value The value of the parameter. + * @return A list containing a single {@code Pair} object. + */ + public List parameterToPair(String name, Object value) { + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null || value instanceof Collection) { + return params; + } + + params.add(new Pair(name, parameterToString(value))); + return params; + } + + /** + * Formats the specified collection query parameters to a list of {@code Pair} + * objects. + * + * Note that the values of each of the returned Pair objects are percent-encoded. + * @param collectionFormat The collection format of the parameter. + * @param name The name of the parameter. + * @param value The value of the parameter. + * @return A list of {@code Pair} objects. + */ + public List parameterToPairs(String collectionFormat, String name, Collection value) { + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null || value.isEmpty()) { + return params; + } + + // create the params based on the collection format + if ("multi".equals(collectionFormat)) { + for (Object item : value) { + params.add(new Pair(name, escapeString(parameterToString(item)))); + } + return params; + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + // escape all delimiters except commas, which are URI reserved + // characters + if ("ssv".equals(collectionFormat)) { + delimiter = escapeString(" "); + } + else if ("tsv".equals(collectionFormat)) { + delimiter = escapeString("\t"); + } + else if ("pipes".equals(collectionFormat)) { + delimiter = escapeString("|"); + } + + StringBuilder sb = new StringBuilder(); + for (Object item : value) { + sb.append(delimiter); + sb.append(escapeString(parameterToString(item))); + } + + params.add(new Pair(name, sb.substring(delimiter.length()))); + + return params; + } + + /** + * Formats the specified collection path parameter to a string value. + * @param collectionFormat The collection format of the parameter. + * @param value The value of the parameter. + * @return String representation of the parameter + */ + public String collectionPathParameterToString(String collectionFormat, Collection value) { + // create the value based on the collection format + if ("multi".equals(collectionFormat)) { + // not valid for path params + return parameterToString(value); + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + if ("ssv".equals(collectionFormat)) { + delimiter = " "; + } + else if ("tsv".equals(collectionFormat)) { + delimiter = "\t"; + } + else if ("pipes".equals(collectionFormat)) { + delimiter = "|"; + } + + StringBuilder sb = new StringBuilder(); + for (Object item : value) { + sb.append(delimiter); + sb.append(parameterToString(item)); + } + + return sb.substring(delimiter.length()); + } + + /** + * Sanitize filename by removing path. e.g. ../../sun.gif becomes sun.gif + * @param filename The filename to be sanitized + * @return The sanitized filename + */ + public String sanitizeFilename(String filename) { + return filename.replaceAll(".*[/\\\\]", ""); + } + + /** + * Check if the given MIME is a JSON MIME. JSON MIME examples: application/json + * application/json; charset=UTF8 APPLICATION/JSON application/vnd.company+json "* / + * *" is also default to JSON + * @param mime MIME (Multipurpose Internet Mail Extensions) + * @return True if the given MIME is JSON, false otherwise. + */ + public boolean isJsonMime(String mime) { + String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"; + return mime != null && (mime.matches(jsonMime) || mime.equals("*/*")); + } + + /** + * Select the Accept header's value from the given accepts array: if JSON exists in + * the given array, use it; otherwise use all of them (joining into a string) + * @param accepts The accepts array to select from + * @return The Accept header to use. If the given array is empty, null will be + * returned (not to set the Accept header explicitly). + */ + public String selectHeaderAccept(String[] accepts) { + if (accepts.length == 0) { + return null; + } + for (String accept : accepts) { + if (isJsonMime(accept)) { + return accept; + } + } + return StringUtil.join(accepts, ","); + } + + /** + * Select the Content-Type header's value from the given array: if JSON exists in the + * given array, use it; otherwise use the first one of the array. + * @param contentTypes The Content-Type array to select from + * @return The Content-Type header to use. If the given array is empty, returns null. + * If it matches "any", JSON will be used. + */ + public String selectHeaderContentType(String[] contentTypes) { + if (contentTypes.length == 0) { + return null; + } + + if (contentTypes[0].equals("*/*")) { + return "application/json"; + } + + for (String contentType : contentTypes) { + if (isJsonMime(contentType)) { + return contentType; + } + } + + return contentTypes[0]; + } + + /** + * Escape the given string to be used as URL query value. + * @param str String to be escaped + * @return Escaped string + */ + public String escapeString(String str) { + try { + return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20"); + } + catch (UnsupportedEncodingException e) { + return str; + } + } + + /** + * Deserialize response body to Java object, according to the return type and the + * Content-Type response header. + * @param Type + * @param response HTTP response + * @param returnType The type of the Java object + * @return The deserialized Java object + * @throws org.openapitools.client.ApiException If fail to deserialize response body, + * i.e. cannot read response body or the Content-Type of the response is not + * supported. + */ + @SuppressWarnings("unchecked") + public T deserialize(Response response, Type returnType) throws ApiException { + if (response == null || returnType == null) { + return null; + } + + if ("byte[]".equals(returnType.toString())) { + // Handle binary response (byte array). + try { + return (T) response.body().bytes(); + } + catch (IOException e) { + throw new ApiException(e); + } + } + else if (returnType.equals(File.class)) { + // Handle file downloading. + return (T) downloadFileFromResponse(response); + } + + String respBody; + try { + if (response.body() != null) + respBody = response.body().string(); + else + respBody = null; + } + catch (IOException e) { + throw new ApiException(e); + } + + if (respBody == null || "".equals(respBody)) { + return null; + } + + String contentType = response.headers().get("Content-Type"); + if (contentType == null) { + // ensuring a default content type + contentType = "application/json"; + } + if (isJsonMime(contentType)) { + return json.deserialize(respBody, returnType); + } + else if (returnType.equals(String.class)) { + // Expecting string, return the raw response body. + return (T) respBody; + } + else { + throw new ApiException("Content type \"" + contentType + "\" is not supported for type: " + returnType, + response.code(), response.headers().toMultimap(), respBody); + } + } + + /** + * Serialize the given Java object into request body according to the object's class + * and the request Content-Type. + * @param obj The Java object + * @param contentType The request Content-Type + * @return The serialized request body + * @throws org.openapitools.client.ApiException If fail to serialize the given object + */ + public RequestBody serialize(Object obj, String contentType) throws ApiException { + if (obj instanceof byte[]) { + // Binary (byte array) body parameter support. + return RequestBody.create((byte[]) obj, MediaType.parse(contentType)); + } + else if (obj instanceof File) { + // File body parameter support. + return RequestBody.create((File) obj, MediaType.parse(contentType)); + } + else if ("text/plain".equals(contentType) && obj instanceof String) { + return RequestBody.create((String) obj, MediaType.parse(contentType)); + } + else if (isJsonMime(contentType)) { + String content; + if (obj != null) { + content = json.serialize(obj); + } + else { + content = null; + } + return RequestBody.create(content, MediaType.parse(contentType)); + } + else { + throw new ApiException("Content type \"" + contentType + "\" is not supported"); + } + } + + /** + * Download file from the given response. + * @param response An instance of the Response object + * @throws org.openapitools.client.ApiException If fail to read file content from + * response and write to disk + * @return Downloaded file + */ + public File downloadFileFromResponse(Response response) throws ApiException { + try { + File file = prepareDownloadFile(response); + BufferedSink sink = Okio.buffer(Okio.sink(file)); + sink.writeAll(response.body().source()); + sink.close(); + return file; + } + catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * Prepare file for download + * @param response An instance of the Response object + * @return Prepared file for the download + * @throws java.io.IOException If fail to prepare file for download + */ + public File prepareDownloadFile(Response response) throws IOException { + String filename = null; + String contentDisposition = response.header("Content-Disposition"); + if (contentDisposition != null && !"".equals(contentDisposition)) { + // Get filename from the Content-Disposition header. + Pattern pattern = Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?"); + Matcher matcher = pattern.matcher(contentDisposition); + if (matcher.find()) { + filename = sanitizeFilename(matcher.group(1)); + } + } + + String prefix = null; + String suffix = null; + if (filename == null) { + prefix = "download-"; + suffix = ""; + } + else { + int pos = filename.lastIndexOf("."); + if (pos == -1) { + prefix = filename + "-"; + } + else { + prefix = filename.substring(0, pos) + "-"; + suffix = filename.substring(pos); + } + // Files.createTempFile requires the prefix to be at least three characters + // long + if (prefix.length() < 3) + prefix = "download-"; + } + + if (tempFolderPath == null) + return Files.createTempFile(prefix, suffix).toFile(); + else + return Files.createTempFile(Paths.get(tempFolderPath), prefix, suffix).toFile(); + } + + /** + * {@link #execute(Call, Type)} + * @param Type + * @param call An instance of the Call object + * @return ApiResponse<T> + * @throws org.openapitools.client.ApiException If fail to execute the call + */ + public ApiResponse execute(Call call) throws ApiException { + return execute(call, null); + } + + /** + * Execute HTTP call and deserialize the HTTP response body into the given return + * type. + * @param returnType The return type used to deserialize HTTP response body + * @param The return type corresponding to (same with) returnType + * @param call Call + * @return ApiResponse object containing response status, headers and data, which is a + * Java object deserialized from response body and would be null when returnType is + * null. + * @throws org.openapitools.client.ApiException If fail to execute the call + */ + public ApiResponse execute(Call call, Type returnType) throws ApiException { + try { + Response response = call.execute(); + T data = handleResponse(response, returnType); + return new ApiResponse(response.code(), response.headers().toMultimap(), data); + } + catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * {@link #executeAsync(Call, Type, ApiCallback)} + * @param Type + * @param call An instance of the Call object + * @param callback ApiCallback<T> + */ + public void executeAsync(Call call, ApiCallback callback) { + executeAsync(call, null, callback); + } + + /** + * Execute HTTP call asynchronously. + * @param Type + * @param call The callback to be executed when the API call finishes + * @param returnType Return type + * @param callback ApiCallback + * @see #execute(Call, Type) + */ + @SuppressWarnings("unchecked") + public void executeAsync(Call call, final Type returnType, final ApiCallback callback) { + call.enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + callback.onFailure(new ApiException(e), 0, null); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + T result; + try { + result = (T) handleResponse(response, returnType); + } + catch (ApiException e) { + callback.onFailure(e, response.code(), response.headers().toMultimap()); + return; + } + catch (Exception e) { + callback.onFailure(new ApiException(e), response.code(), response.headers().toMultimap()); + return; + } + callback.onSuccess(result, response.code(), response.headers().toMultimap()); + } + }); + } + + /** + * Handle the given response, return the deserialized object when the response is + * successful. + * @param Type + * @param response Response + * @param returnType Return type + * @return Type + * @throws org.openapitools.client.ApiException If the response has an unsuccessful + * status code or fail to deserialize the response body + */ + public T handleResponse(Response response, Type returnType) throws ApiException { + if (response.isSuccessful()) { + if (returnType == null || response.code() == 204) { + // returning null if the returnType is not defined, + // or the status code is 204 (No Content) + if (response.body() != null) { + try { + response.body().close(); + } + catch (Exception e) { + throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap()); + } + } + return null; + } + else { + return deserialize(response, returnType); + } + } + else { + String respBody = null; + if (response.body() != null) { + try { + respBody = response.body().string(); + } + catch (IOException e) { + throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap()); + } + } + throw new ApiException(response.message(), response.code(), response.headers().toMultimap(), respBody); + } + } + + /** + * Build HTTP call with the given options. + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", + * "PATCH" and "DELETE" + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param cookieParams The cookie parameters + * @param formParams The form parameters + * @param authNames The authentications to apply + * @param callback Callback for upload/download progress + * @return The HTTP call + * @throws org.openapitools.client.ApiException If fail to serialize the request body + * object + */ + public Call buildCall(String baseUrl, String path, String method, List queryParams, + List collectionQueryParams, Object body, Map headerParams, + Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) + throws ApiException { + Request request = buildRequest(baseUrl, path, method, queryParams, collectionQueryParams, body, headerParams, + cookieParams, formParams, authNames, callback); + + return httpClient.newCall(request); + } + + /** + * Build an HTTP request with the given options. + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", + * "PATCH" and "DELETE" + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param cookieParams The cookie parameters + * @param formParams The form parameters + * @param authNames The authentications to apply + * @param callback Callback for upload/download progress + * @return The HTTP request + * @throws org.openapitools.client.ApiException If fail to serialize the request body + * object + */ + public Request buildRequest(String baseUrl, String path, String method, List queryParams, + List collectionQueryParams, Object body, Map headerParams, + Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) + throws ApiException { + // aggregate queryParams (non-collection) and collectionQueryParams into + // allQueryParams + List allQueryParams = new ArrayList(queryParams); + allQueryParams.addAll(collectionQueryParams); + + final String url = buildUrl(baseUrl, path, queryParams, collectionQueryParams); + + // prepare HTTP request body + RequestBody reqBody; + String contentType = headerParams.get("Content-Type"); + + if (!HttpMethod.permitsRequestBody(method)) { + reqBody = null; + } + else if ("application/x-www-form-urlencoded".equals(contentType)) { + reqBody = buildRequestBodyFormEncoding(formParams); + } + else if ("multipart/form-data".equals(contentType)) { + reqBody = buildRequestBodyMultipart(formParams); + } + else if (body == null) { + if ("DELETE".equals(method)) { + // allow calling DELETE without sending a request body + reqBody = null; + } + else { + // use an empty request body (for POST, PUT and PATCH) + reqBody = RequestBody.create("", MediaType.parse(contentType)); + } + } + else { + reqBody = serialize(body, contentType); + } + + // update parameters with authentication settings + updateParamsForAuth(authNames, allQueryParams, headerParams, cookieParams, requestBodyToString(reqBody), method, + URI.create(url)); + + final Request.Builder reqBuilder = new Request.Builder().url(url); + processHeaderParams(headerParams, reqBuilder); + processCookieParams(cookieParams, reqBuilder); + + // Associate callback with request (if not null) so interceptor can + // access it when creating ProgressResponseBody + reqBuilder.tag(callback); + + Request request = null; + + if (callback != null && reqBody != null) { + ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, callback); + request = reqBuilder.method(method, progressRequestBody).build(); + } + else { + request = reqBuilder.method(method, reqBody).build(); + } + + return request; + } + + /** + * Build full URL by concatenating base path, the given sub path and query parameters. + * @param path The sub path + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @return The full URL + */ + public String buildUrl(String baseUrl, String path, List queryParams, List collectionQueryParams) { + final StringBuilder url = new StringBuilder(); + if (baseUrl != null) { + url.append(baseUrl).append(path); + } + else { + url.append(basePath).append(path); + } + + if (queryParams != null && !queryParams.isEmpty()) { + // support (constant) query string in `path`, e.g. "/posts?draft=1" + String prefix = path.contains("?") ? "&" : "?"; + for (Pair param : queryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } + else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + url.append(escapeString(param.getName())).append("=").append(escapeString(value)); + } + } + } + + if (collectionQueryParams != null && !collectionQueryParams.isEmpty()) { + String prefix = url.toString().contains("?") ? "&" : "?"; + for (Pair param : collectionQueryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } + else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + // collection query parameter value already escaped as part of + // parameterToPairs + url.append(escapeString(param.getName())).append("=").append(value); + } + } + } + + return url.toString(); + } + + /** + * Set header parameters to the request builder, including default headers. + * @param headerParams Header parameters in the form of Map + * @param reqBuilder Request.Builder + */ + public void processHeaderParams(Map headerParams, Request.Builder reqBuilder) { + for (Entry param : headerParams.entrySet()) { + reqBuilder.header(param.getKey(), parameterToString(param.getValue())); + } + for (Entry header : defaultHeaderMap.entrySet()) { + if (!headerParams.containsKey(header.getKey())) { + reqBuilder.header(header.getKey(), parameterToString(header.getValue())); + } + } + } + + /** + * Set cookie parameters to the request builder, including default cookies. + * @param cookieParams Cookie parameters in the form of Map + * @param reqBuilder Request.Builder + */ + public void processCookieParams(Map cookieParams, Request.Builder reqBuilder) { + for (Entry param : cookieParams.entrySet()) { + reqBuilder.addHeader("Cookie", String.format("%s=%s", param.getKey(), param.getValue())); + } + for (Entry param : defaultCookieMap.entrySet()) { + if (!cookieParams.containsKey(param.getKey())) { + reqBuilder.addHeader("Cookie", String.format("%s=%s", param.getKey(), param.getValue())); + } + } + } + + /** + * Update query and header parameters based on authentication settings. + * @param authNames The authentications to apply + * @param queryParams List of query parameters + * @param headerParams Map of header parameters + * @param cookieParams Map of cookie parameters + * @param payload HTTP request body + * @param method HTTP method + * @param uri URI + */ + public void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams, + Map cookieParams, String payload, String method, URI uri) throws ApiException { + for (String authName : authNames) { + Authentication auth = authentications.get(authName); + if (auth == null) { + throw new RuntimeException("Authentication undefined: " + authName); + } + auth.applyToParams(queryParams, headerParams, cookieParams, payload, method, uri); + } + } + + /** + * Build a form-encoding request body with the given form parameters. + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyFormEncoding(Map formParams) { + okhttp3.FormBody.Builder formBuilder = new okhttp3.FormBody.Builder(); + for (Entry param : formParams.entrySet()) { + formBuilder.add(param.getKey(), parameterToString(param.getValue())); + } + return formBuilder.build(); + } + + /** + * Build a multipart (file uploading) request body with the given form parameters, + * which could contain text fields and file fields. + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyMultipart(Map formParams) { + MultipartBody.Builder mpBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM); + for (Entry param : formParams.entrySet()) { + if (param.getValue() instanceof File) { + File file = (File) param.getValue(); + Headers partHeaders = Headers.of("Content-Disposition", + "form-data; name=\"" + param.getKey() + "\"; filename=\"" + file.getName() + "\""); + MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file)); + mpBuilder.addPart(partHeaders, RequestBody.create(file, mediaType)); + } + else { + Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\""); + mpBuilder.addPart(partHeaders, RequestBody.create(parameterToString(param.getValue()), null)); + } + } + return mpBuilder.build(); + } + + /** + * Guess Content-Type header from the given file (defaults to + * "application/octet-stream"). + * @param file The given file + * @return The guessed Content-Type + */ + public String guessContentTypeFromFile(File file) { + String contentType = URLConnection.guessContentTypeFromName(file.getName()); + if (contentType == null) { + return "application/octet-stream"; + } + else { + return contentType; + } + } + + /** + * Get network interceptor to add it to the httpClient to track download progress for + * async requests. + */ + private Interceptor getProgressInterceptor() { + return new Interceptor() { + @Override + public Response intercept(Interceptor.Chain chain) throws IOException { + final Request request = chain.request(); + final Response originalResponse = chain.proceed(request); + if (request.tag() instanceof ApiCallback) { + final ApiCallback callback = (ApiCallback) request.tag(); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), callback)).build(); + } + return originalResponse; + } + }; + } + + /** + * Apply SSL related settings to httpClient according to the current values of + * verifyingSsl and sslCaCert. + */ + private void applySslSettings() { + try { + TrustManager[] trustManagers; + HostnameVerifier hostnameVerifier; + if (!verifyingSsl) { + trustManagers = new TrustManager[] { new X509TrustManager() { + @Override + public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) + throws CertificateException { + } + + @Override + public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) + throws CertificateException { + } + + @Override + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return new java.security.cert.X509Certificate[] {}; + } + } }; + hostnameVerifier = new HostnameVerifier() { + @Override + public boolean verify(String hostname, SSLSession session) { + return true; + } + }; + } + else { + TrustManagerFactory trustManagerFactory = TrustManagerFactory + .getInstance(TrustManagerFactory.getDefaultAlgorithm()); + + if (sslCaCert == null) { + trustManagerFactory.init((KeyStore) null); + } + else { + char[] password = null; // Any password will work. + CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); + Collection certificates = certificateFactory.generateCertificates(sslCaCert); + if (certificates.isEmpty()) { + throw new IllegalArgumentException("expected non-empty set of trusted certificates"); + } + KeyStore caKeyStore = newEmptyKeyStore(password); + int index = 0; + for (Certificate certificate : certificates) { + String certificateAlias = "ca" + Integer.toString(index++); + caKeyStore.setCertificateEntry(certificateAlias, certificate); + } + trustManagerFactory.init(caKeyStore); + } + trustManagers = trustManagerFactory.getTrustManagers(); + hostnameVerifier = OkHostnameVerifier.INSTANCE; + } + + SSLContext sslContext = SSLContext.getInstance("TLS"); + sslContext.init(keyManagers, trustManagers, new SecureRandom()); + httpClient = httpClient.newBuilder() + .sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustManagers[0]) + .hostnameVerifier(hostnameVerifier).build(); + } + catch (GeneralSecurityException e) { + throw new RuntimeException(e); + } + } + + private KeyStore newEmptyKeyStore(char[] password) throws GeneralSecurityException { + try { + KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); + keyStore.load(null, password); + return keyStore; + } + catch (IOException e) { + throw new AssertionError(e); + } + } + + /** + * Convert the HTTP request body to a string. + * @param request The HTTP request object + * @return The string representation of the HTTP request body + * @throws org.openapitools.client.ApiException If fail to serialize the request body + * object into a string + */ + private String requestBodyToString(RequestBody requestBody) throws ApiException { + if (requestBody != null) { + try { + final Buffer buffer = new Buffer(); + requestBody.writeTo(buffer); + return buffer.readUtf8(); + } + catch (final IOException e) { + throw new ApiException(e); + } + } + + // empty http request body + return ""; + } + } diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ApiException.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ApiException.java index 8873a1222..e0de23a67 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ApiException.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ApiException.java @@ -3,152 +3,166 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.api; import java.util.Map; import java.util.List; /** - *

    ApiException class.

    + *

    + * ApiException class. + *

    */ @SuppressWarnings("serial") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ApiException extends Exception { - private int code = 0; - private Map> responseHeaders = null; - private String responseBody = null; - - /** - *

    Constructor for ApiException.

    - */ - public ApiException() {} - - /** - *

    Constructor for ApiException.

    - * - * @param throwable a {@link java.lang.Throwable} object - */ - public ApiException(Throwable throwable) { - super(throwable); - } - - /** - *

    Constructor for ApiException.

    - * - * @param message the error message - */ - public ApiException(String message) { - super(message); - } - - /** - *

    Constructor for ApiException.

    - * - * @param message the error message - * @param throwable a {@link java.lang.Throwable} object - * @param code HTTP status code - * @param responseHeaders a {@link java.util.Map} of HTTP response headers - * @param responseBody the response body - */ - public ApiException(String message, Throwable throwable, int code, Map> responseHeaders, String responseBody) { - super(message, throwable); - this.code = code; - this.responseHeaders = responseHeaders; - this.responseBody = responseBody; - } - - /** - *

    Constructor for ApiException.

    - * - * @param message the error message - * @param code HTTP status code - * @param responseHeaders a {@link java.util.Map} of HTTP response headers - * @param responseBody the response body - */ - public ApiException(String message, int code, Map> responseHeaders, String responseBody) { - this(message, (Throwable) null, code, responseHeaders, responseBody); - } - - /** - *

    Constructor for ApiException.

    - * - * @param message the error message - * @param throwable a {@link java.lang.Throwable} object - * @param code HTTP status code - * @param responseHeaders a {@link java.util.Map} of HTTP response headers - */ - public ApiException(String message, Throwable throwable, int code, Map> responseHeaders) { - this(message, throwable, code, responseHeaders, null); - } - - /** - *

    Constructor for ApiException.

    - * - * @param code HTTP status code - * @param responseHeaders a {@link java.util.Map} of HTTP response headers - * @param responseBody the response body - */ - public ApiException(int code, Map> responseHeaders, String responseBody) { - this((String) null, (Throwable) null, code, responseHeaders, responseBody); - } - - /** - *

    Constructor for ApiException.

    - * - * @param code HTTP status code - * @param message a {@link java.lang.String} object - */ - public ApiException(int code, String message) { - super(message); - this.code = code; - } - - /** - *

    Constructor for ApiException.

    - * - * @param code HTTP status code - * @param message the error message - * @param responseHeaders a {@link java.util.Map} of HTTP response headers - * @param responseBody the response body - */ - public ApiException(int code, String message, Map> responseHeaders, String responseBody) { - this(code, message); - this.responseHeaders = responseHeaders; - this.responseBody = responseBody; - } - - /** - * Get the HTTP status code. - * - * @return HTTP status code - */ - public int getCode() { - return code; - } - - /** - * Get the HTTP response headers. - * - * @return A map of list of string - */ - public Map> getResponseHeaders() { - return responseHeaders; - } - - /** - * Get the HTTP response body. - * - * @return Response body in the form of string - */ - public String getResponseBody() { - return responseBody; - } + + private int code = 0; + + private Map> responseHeaders = null; + + private String responseBody = null; + + /** + *

    + * Constructor for ApiException. + *

    + */ + public ApiException() { + } + + /** + *

    + * Constructor for ApiException. + *

    + * @param throwable a {@link java.lang.Throwable} object + */ + public ApiException(Throwable throwable) { + super(throwable); + } + + /** + *

    + * Constructor for ApiException. + *

    + * @param message the error message + */ + public ApiException(String message) { + super(message); + } + + /** + *

    + * Constructor for ApiException. + *

    + * @param message the error message + * @param throwable a {@link java.lang.Throwable} object + * @param code HTTP status code + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(String message, Throwable throwable, int code, Map> responseHeaders, + String responseBody) { + super(message, throwable); + this.code = code; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + *

    + * Constructor for ApiException. + *

    + * @param message the error message + * @param code HTTP status code + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(String message, int code, Map> responseHeaders, String responseBody) { + this(message, (Throwable) null, code, responseHeaders, responseBody); + } + + /** + *

    + * Constructor for ApiException. + *

    + * @param message the error message + * @param throwable a {@link java.lang.Throwable} object + * @param code HTTP status code + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + */ + public ApiException(String message, Throwable throwable, int code, Map> responseHeaders) { + this(message, throwable, code, responseHeaders, null); + } + + /** + *

    + * Constructor for ApiException. + *

    + * @param code HTTP status code + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(int code, Map> responseHeaders, String responseBody) { + this((String) null, (Throwable) null, code, responseHeaders, responseBody); + } + + /** + *

    + * Constructor for ApiException. + *

    + * @param code HTTP status code + * @param message a {@link java.lang.String} object + */ + public ApiException(int code, String message) { + super(message); + this.code = code; + } + + /** + *

    + * Constructor for ApiException. + *

    + * @param code HTTP status code + * @param message the error message + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(int code, String message, Map> responseHeaders, String responseBody) { + this(code, message); + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + * Get the HTTP status code. + * @return HTTP status code + */ + public int getCode() { + return code; + } + + /** + * Get the HTTP response headers. + * @return A map of list of string + */ + public Map> getResponseHeaders() { + return responseHeaders; + } + + /** + * Get the HTTP response body. + * @return Response body in the form of string + */ + public String getResponseBody() { + return responseBody; + } + } diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ApiResponse.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ApiResponse.java index 1037b2758..6146b74ec 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ApiResponse.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ApiResponse.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.api; import java.util.List; @@ -20,57 +19,66 @@ * API response returned by API call. */ public class ApiResponse { - final private int statusCode; - final private Map> headers; - final private T data; - /** - *

    Constructor for ApiResponse.

    - * - * @param statusCode The status code of HTTP response - * @param headers The headers of HTTP response - */ - public ApiResponse(int statusCode, Map> headers) { - this(statusCode, headers, null); - } + final private int statusCode; + + final private Map> headers; + + final private T data; + + /** + *

    + * Constructor for ApiResponse. + *

    + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + */ + public ApiResponse(int statusCode, Map> headers) { + this(statusCode, headers, null); + } + + /** + *

    + * Constructor for ApiResponse. + *

    + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + * @param data The object deserialized from response bod + */ + public ApiResponse(int statusCode, Map> headers, T data) { + this.statusCode = statusCode; + this.headers = headers; + this.data = data; + } - /** - *

    Constructor for ApiResponse.

    - * - * @param statusCode The status code of HTTP response - * @param headers The headers of HTTP response - * @param data The object deserialized from response bod - */ - public ApiResponse(int statusCode, Map> headers, T data) { - this.statusCode = statusCode; - this.headers = headers; - this.data = data; - } + /** + *

    + * Get the status code. + *

    + * @return the status code + */ + public int getStatusCode() { + return statusCode; + } - /** - *

    Get the status code.

    - * - * @return the status code - */ - public int getStatusCode() { - return statusCode; - } + /** + *

    + * Get the headers. + *

    + * @return a {@link java.util.Map} of headers + */ + public Map> getHeaders() { + return headers; + } - /** - *

    Get the headers.

    - * - * @return a {@link java.util.Map} of headers - */ - public Map> getHeaders() { - return headers; - } + /** + *

    + * Get the data. + *

    + * @return the data + */ + public T getData() { + return data; + } - /** - *

    Get the data.

    - * - * @return the data - */ - public T getData() { - return data; - } } diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/Configuration.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/Configuration.java index de69ab7bc..a3db7e1bf 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/Configuration.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/Configuration.java @@ -3,37 +3,36 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.api; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Configuration { - private static ApiClient defaultApiClient = new ApiClient(); - /** - * Get the default API client, which would be used when creating API - * instances without providing an API client. - * - * @return Default API client - */ - public static ApiClient getDefaultApiClient() { - return defaultApiClient; - } + private static ApiClient defaultApiClient = new ApiClient(); + + /** + * Get the default API client, which would be used when creating API instances without + * providing an API client. + * @return Default API client + */ + public static ApiClient getDefaultApiClient() { + return defaultApiClient; + } + + /** + * Set the default API client, which would be used when creating API instances without + * providing an API client. + * @param apiClient API client + */ + public static void setDefaultApiClient(ApiClient apiClient) { + defaultApiClient = apiClient; + } - /** - * Set the default API client, which would be used when creating API - * instances without providing an API client. - * - * @param apiClient API client - */ - public static void setDefaultApiClient(ApiClient apiClient) { - defaultApiClient = apiClient; - } } diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/GzipRequestInterceptor.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/GzipRequestInterceptor.java index fbd160ae5..c0c907d49 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/GzipRequestInterceptor.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/GzipRequestInterceptor.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.api; import okhttp3.*; @@ -27,59 +26,59 @@ * Taken from https://github.com/square/okhttp/issues/350 */ class GzipRequestInterceptor implements Interceptor { - @Override - public Response intercept(Chain chain) throws IOException { - Request originalRequest = chain.request(); - if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) { - return chain.proceed(originalRequest); - } - Request compressedRequest = originalRequest.newBuilder() - .header("Content-Encoding", "gzip") - .method(originalRequest.method(), forceContentLength(gzip(originalRequest.body()))) - .build(); - return chain.proceed(compressedRequest); - } + @Override + public Response intercept(Chain chain) throws IOException { + Request originalRequest = chain.request(); + if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) { + return chain.proceed(originalRequest); + } + + Request compressedRequest = originalRequest.newBuilder().header("Content-Encoding", "gzip") + .method(originalRequest.method(), forceContentLength(gzip(originalRequest.body()))).build(); + return chain.proceed(compressedRequest); + } + + private RequestBody forceContentLength(final RequestBody requestBody) throws IOException { + final Buffer buffer = new Buffer(); + requestBody.writeTo(buffer); + return new RequestBody() { + @Override + public MediaType contentType() { + return requestBody.contentType(); + } - private RequestBody forceContentLength(final RequestBody requestBody) throws IOException { - final Buffer buffer = new Buffer(); - requestBody.writeTo(buffer); - return new RequestBody() { - @Override - public MediaType contentType() { - return requestBody.contentType(); - } + @Override + public long contentLength() { + return buffer.size(); + } - @Override - public long contentLength() { - return buffer.size(); - } + @Override + public void writeTo(BufferedSink sink) throws IOException { + sink.write(buffer.snapshot()); + } + }; + } - @Override - public void writeTo(BufferedSink sink) throws IOException { - sink.write(buffer.snapshot()); - } - }; - } + private RequestBody gzip(final RequestBody body) { + return new RequestBody() { + @Override + public MediaType contentType() { + return body.contentType(); + } - private RequestBody gzip(final RequestBody body) { - return new RequestBody() { - @Override - public MediaType contentType() { - return body.contentType(); - } + @Override + public long contentLength() { + return -1; // We don't know the compressed length in advance! + } - @Override - public long contentLength() { - return -1; // We don't know the compressed length in advance! - } + @Override + public void writeTo(BufferedSink sink) throws IOException { + BufferedSink gzipSink = Okio.buffer(new GzipSink(sink)); + body.writeTo(gzipSink); + gzipSink.close(); + } + }; + } - @Override - public void writeTo(BufferedSink sink) throws IOException { - BufferedSink gzipSink = Okio.buffer(new GzipSink(sink)); - body.writeTo(gzipSink); - gzipSink.close(); - } - }; - } } diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/JSON.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/JSON.java index 370f65cbf..b4acf6b1d 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/JSON.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/JSON.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.api; import com.google.gson.Gson; @@ -39,270 +38,284 @@ import java.util.HashMap; public class JSON { - private Gson gson; - private boolean isLenientOnJson = false; - private DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); - private SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); - private ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); - - @SuppressWarnings("unchecked") - public static GsonBuilder createGson() { - GsonFireBuilder fireBuilder = new GsonFireBuilder() - ; - GsonBuilder builder = fireBuilder.createGsonBuilder(); - return builder; - } - - private static String getDiscriminatorValue(JsonElement readElement, String discriminatorField) { - JsonElement element = readElement.getAsJsonObject().get(discriminatorField); - if (null == element) { - throw new IllegalArgumentException("missing discriminator field: <" + discriminatorField + ">"); - } - return element.getAsString(); - } - - /** - * Returns the Java class that implements the OpenAPI schema for the specified discriminator value. - * - * @param classByDiscriminatorValue The map of discriminator values to Java classes. - * @param discriminatorValue The value of the OpenAPI discriminator in the input data. - * @return The Java class that implements the OpenAPI schema - */ - private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) { - Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue); - if (null == clazz) { - throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">"); - } - return clazz; - } - - public JSON() { - gson = createGson() - .registerTypeAdapter(Date.class, dateTypeAdapter) - .registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter) - .registerTypeAdapter(byte[].class, byteArrayAdapter) - .create(); - } - - /** - * Get Gson. - * - * @return Gson - */ - public Gson getGson() { - return gson; - } - - /** - * Set Gson. - * - * @param gson Gson - * @return JSON - */ - public JSON setGson(Gson gson) { - this.gson = gson; - return this; - } - - /** - * Configure the parser to be liberal in what it accepts. - * - * @param lenientOnJson Set it to true to ignore some syntax errors - * @return JSON - * @see https://www.javadoc.io/doc/com.google.code.gson/gson/2.8.5/com/google/gson/stream/JsonReader.html - */ - public JSON setLenientOnJson(boolean lenientOnJson) { - isLenientOnJson = lenientOnJson; - return this; - } - - /** - * Serialize the given Java object into JSON string. - * - * @param obj Object - * @return String representation of the JSON - */ - public String serialize(Object obj) { - return gson.toJson(obj); - } - - /** - * Deserialize the given JSON string to Java object. - * - * @param Type - * @param body The JSON string - * @param returnType The type to deserialize into - * @return The deserialized Java object - */ - @SuppressWarnings("unchecked") - public T deserialize(String body, Type returnType) { - try { - if (isLenientOnJson) { - JsonReader jsonReader = new JsonReader(new StringReader(body)); - // see https://www.javadoc.io/doc/com.google.code.gson/gson/2.8.5/com/google/gson/stream/JsonReader.html - jsonReader.setLenient(true); - return gson.fromJson(jsonReader, returnType); - } else { - return gson.fromJson(body, returnType); - } - } catch (JsonParseException e) { - // Fallback processing when failed to parse JSON form response body: - // return the response body string directly for the String return type; - if (returnType.equals(String.class)) { - return (T) body; - } else { - throw (e); - } - } - } - - /** - * Gson TypeAdapter for Byte Array type - */ - public class ByteArrayAdapter extends TypeAdapter { - - @Override - public void write(JsonWriter out, byte[] value) throws IOException { - if (value == null) { - out.nullValue(); - } else { - out.value(ByteString.of(value).base64()); - } - } - - @Override - public byte[] read(JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String bytesAsBase64 = in.nextString(); - ByteString byteString = ByteString.decodeBase64(bytesAsBase64); - return byteString.toByteArray(); - } - } - } - - /** - * Gson TypeAdapter for java.sql.Date type - * If the dateFormat is null, a simple "yyyy-MM-dd" format will be used - * (more efficient than SimpleDateFormat). - */ - public static class SqlDateTypeAdapter extends TypeAdapter { - - private DateFormat dateFormat; - - public SqlDateTypeAdapter() {} - - public SqlDateTypeAdapter(DateFormat dateFormat) { - this.dateFormat = dateFormat; - } - - public void setFormat(DateFormat dateFormat) { - this.dateFormat = dateFormat; - } - - @Override - public void write(JsonWriter out, java.sql.Date date) throws IOException { - if (date == null) { - out.nullValue(); - } else { - String value; - if (dateFormat != null) { - value = dateFormat.format(date); - } else { - value = date.toString(); - } - out.value(value); - } - } - - @Override - public java.sql.Date read(JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - try { - if (dateFormat != null) { - return new java.sql.Date(dateFormat.parse(date).getTime()); - } - return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime()); - } catch (ParseException e) { - throw new JsonParseException(e); - } - } - } - } - - /** - * Gson TypeAdapter for java.util.Date type - * If the dateFormat is null, ISO8601Utils will be used. - */ - public static class DateTypeAdapter extends TypeAdapter { - - private DateFormat dateFormat; - - public DateTypeAdapter() {} - - public DateTypeAdapter(DateFormat dateFormat) { - this.dateFormat = dateFormat; - } - - public void setFormat(DateFormat dateFormat) { - this.dateFormat = dateFormat; - } - - @Override - public void write(JsonWriter out, Date date) throws IOException { - if (date == null) { - out.nullValue(); - } else { - String value; - if (dateFormat != null) { - value = dateFormat.format(date); - } else { - value = ISO8601Utils.format(date, true); - } - out.value(value); - } - } - - @Override - public Date read(JsonReader in) throws IOException { - try { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - try { - if (dateFormat != null) { - return dateFormat.parse(date); - } - return ISO8601Utils.parse(date, new ParsePosition(0)); - } catch (ParseException e) { - throw new JsonParseException(e); - } - } - } catch (IllegalArgumentException e) { - throw new JsonParseException(e); - } - } - } - - public JSON setDateFormat(DateFormat dateFormat) { - dateTypeAdapter.setFormat(dateFormat); - return this; - } - - public JSON setSqlDateFormat(DateFormat dateFormat) { - sqlDateTypeAdapter.setFormat(dateFormat); - return this; - } + + private Gson gson; + + private boolean isLenientOnJson = false; + + private DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); + + private SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); + + private ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); + + @SuppressWarnings("unchecked") + public static GsonBuilder createGson() { + GsonFireBuilder fireBuilder = new GsonFireBuilder(); + GsonBuilder builder = fireBuilder.createGsonBuilder(); + return builder; + } + + private static String getDiscriminatorValue(JsonElement readElement, String discriminatorField) { + JsonElement element = readElement.getAsJsonObject().get(discriminatorField); + if (null == element) { + throw new IllegalArgumentException("missing discriminator field: <" + discriminatorField + ">"); + } + return element.getAsString(); + } + + /** + * Returns the Java class that implements the OpenAPI schema for the specified + * discriminator value. + * @param classByDiscriminatorValue The map of discriminator values to Java classes. + * @param discriminatorValue The value of the OpenAPI discriminator in the input data. + * @return The Java class that implements the OpenAPI schema + */ + private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) { + Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue); + if (null == clazz) { + throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">"); + } + return clazz; + } + + public JSON() { + gson = createGson().registerTypeAdapter(Date.class, dateTypeAdapter) + .registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter) + .registerTypeAdapter(byte[].class, byteArrayAdapter).create(); + } + + /** + * Get Gson. + * @return Gson + */ + public Gson getGson() { + return gson; + } + + /** + * Set Gson. + * @param gson Gson + * @return JSON + */ + public JSON setGson(Gson gson) { + this.gson = gson; + return this; + } + + /** + * Configure the parser to be liberal in what it accepts. + * @param lenientOnJson Set it to true to ignore some syntax errors + * @return JSON + * @see https://www.javadoc.io/doc/com.google.code.gson/gson/2.8.5/com/google/gson/stream/JsonReader.html + */ + public JSON setLenientOnJson(boolean lenientOnJson) { + isLenientOnJson = lenientOnJson; + return this; + } + + /** + * Serialize the given Java object into JSON string. + * @param obj Object + * @return String representation of the JSON + */ + public String serialize(Object obj) { + return gson.toJson(obj); + } + + /** + * Deserialize the given JSON string to Java object. + * @param Type + * @param body The JSON string + * @param returnType The type to deserialize into + * @return The deserialized Java object + */ + @SuppressWarnings("unchecked") + public T deserialize(String body, Type returnType) { + try { + if (isLenientOnJson) { + JsonReader jsonReader = new JsonReader(new StringReader(body)); + // see + // https://www.javadoc.io/doc/com.google.code.gson/gson/2.8.5/com/google/gson/stream/JsonReader.html + jsonReader.setLenient(true); + return gson.fromJson(jsonReader, returnType); + } + else { + return gson.fromJson(body, returnType); + } + } + catch (JsonParseException e) { + // Fallback processing when failed to parse JSON form response body: + // return the response body string directly for the String return type; + if (returnType.equals(String.class)) { + return (T) body; + } + else { + throw (e); + } + } + } + + /** + * Gson TypeAdapter for Byte Array type + */ + public class ByteArrayAdapter extends TypeAdapter { + + @Override + public void write(JsonWriter out, byte[] value) throws IOException { + if (value == null) { + out.nullValue(); + } + else { + out.value(ByteString.of(value).base64()); + } + } + + @Override + public byte[] read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String bytesAsBase64 = in.nextString(); + ByteString byteString = ByteString.decodeBase64(bytesAsBase64); + return byteString.toByteArray(); + } + } + + } + + /** + * Gson TypeAdapter for java.sql.Date type If the dateFormat is null, a simple + * "yyyy-MM-dd" format will be used (more efficient than SimpleDateFormat). + */ + public static class SqlDateTypeAdapter extends TypeAdapter { + + private DateFormat dateFormat; + + public SqlDateTypeAdapter() { + } + + public SqlDateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public void write(JsonWriter out, java.sql.Date date) throws IOException { + if (date == null) { + out.nullValue(); + } + else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } + else { + value = date.toString(); + } + out.value(value); + } + } + + @Override + public java.sql.Date read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return new java.sql.Date(dateFormat.parse(date).getTime()); + } + return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime()); + } + catch (ParseException e) { + throw new JsonParseException(e); + } + } + } + + } + + /** + * Gson TypeAdapter for java.util.Date type If the dateFormat is null, ISO8601Utils + * will be used. + */ + public static class DateTypeAdapter extends TypeAdapter { + + private DateFormat dateFormat; + + public DateTypeAdapter() { + } + + public DateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public void write(JsonWriter out, Date date) throws IOException { + if (date == null) { + out.nullValue(); + } + else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } + else { + value = ISO8601Utils.format(date, true); + } + out.value(value); + } + } + + @Override + public Date read(JsonReader in) throws IOException { + try { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return dateFormat.parse(date); + } + return ISO8601Utils.parse(date, new ParsePosition(0)); + } + catch (ParseException e) { + throw new JsonParseException(e); + } + } + } + catch (IllegalArgumentException e) { + throw new JsonParseException(e); + } + } + + } + + public JSON setDateFormat(DateFormat dateFormat) { + dateTypeAdapter.setFormat(dateFormat); + return this; + } + + public JSON setSqlDateFormat(DateFormat dateFormat) { + sqlDateTypeAdapter.setFormat(dateFormat); + return this; + } } diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/LoginApi.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/LoginApi.java index f80ac2fa7..2212d7cc1 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/LoginApi.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/LoginApi.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.api; import com.redhat.parodos.sdk.api.ApiCallback; @@ -26,8 +25,6 @@ import java.io.IOException; - - import java.lang.reflect.Type; import java.util.ArrayList; import java.util.HashMap; @@ -35,158 +32,213 @@ import java.util.Map; public class LoginApi { - private ApiClient localVarApiClient; - private int localHostIndex; - private String localCustomBaseUrl; - - public LoginApi() { - this(Configuration.getDefaultApiClient()); - } - - public LoginApi(ApiClient apiClient) { - this.localVarApiClient = apiClient; - } - - public ApiClient getApiClient() { - return localVarApiClient; - } - - public void setApiClient(ApiClient apiClient) { - this.localVarApiClient = apiClient; - } - - public int getHostIndex() { - return localHostIndex; - } - - public void setHostIndex(int hostIndex) { - this.localHostIndex = hostIndex; - } - - public String getCustomBaseUrl() { - return localCustomBaseUrl; - } - - public void setCustomBaseUrl(String customBaseUrl) { - this.localCustomBaseUrl = customBaseUrl; - } - - /** - * Build call for login - * @param _callback Callback for upload/download progress - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - * @http.response.details - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    - */ - public okhttp3.Call loginCall(final ApiCallback _callback) throws ApiException { - String basePath = null; - - // Operation Servers - String[] localBasePaths = new String[] { }; - - // Determine Base Path to Use - if (localCustomBaseUrl != null){ - basePath = localCustomBaseUrl; - } else if ( localBasePaths.length > 0 ) { - basePath = localBasePaths[localHostIndex]; - } else { - basePath = null; - } - - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/api/v1/login"; - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarCookieParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - - }; - final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) { - localVarHeaderParams.put("Accept", localVarAccept); - } - - final String[] localVarContentTypes = { - - }; - final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarContentType != null) { - localVarHeaderParams.put("Content-Type", localVarContentType); - } - - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); - } - - @SuppressWarnings("rawtypes") - private okhttp3.Call loginValidateBeforeCall(final ApiCallback _callback) throws ApiException { - - - okhttp3.Call localVarCall = loginCall(_callback); - return localVarCall; - - } - - /** - * Login - * - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - * @http.response.details - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    - */ - public void login() throws ApiException { - loginWithHttpInfo(); - } - - /** - * Login - * - * @return ApiResponse<Void> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - * @http.response.details - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    - */ - public ApiResponse loginWithHttpInfo() throws ApiException { - okhttp3.Call localVarCall = loginValidateBeforeCall(null); - return localVarApiClient.execute(localVarCall); - } - - /** - * Login (asynchronously) - * - * @param _callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - * @http.response.details - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    - */ - public okhttp3.Call loginAsync(final ApiCallback _callback) throws ApiException { - - okhttp3.Call localVarCall = loginValidateBeforeCall(_callback); - localVarApiClient.executeAsync(localVarCall, _callback); - return localVarCall; - } + + private ApiClient localVarApiClient; + + private int localHostIndex; + + private String localCustomBaseUrl; + + public LoginApi() { + this(Configuration.getDefaultApiClient()); + } + + public LoginApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + /** + * Build call for login + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    + */ + public okhttp3.Call loginCall(final ApiCallback _callback) throws ApiException { + String basePath = null; + + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } + else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } + else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/api/v1/login"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, + localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, + localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call loginValidateBeforeCall(final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = loginCall(_callback); + return localVarCall; + + } + + /** + * Login + * @throws ApiException If fail to call the API, e.g. server error or cannot + * deserialize the response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    + */ + public void login() throws ApiException { + loginWithHttpInfo(); + } + + /** + * Login + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot + * deserialize the response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    + */ + public ApiResponse loginWithHttpInfo() throws ApiException { + okhttp3.Call localVarCall = loginValidateBeforeCall(null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Login (asynchronously) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request + * body object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    + */ + public okhttp3.Call loginAsync(final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = loginValidateBeforeCall(_callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + } diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/Pair.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/Pair.java index f8d4dd024..5a257eb74 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/Pair.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/Pair.java @@ -3,55 +3,57 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.api; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Pair { - private String name = ""; - private String value = ""; - public Pair (String name, String value) { - setName(name); - setValue(value); - } + private String name = ""; + + private String value = ""; + + public Pair(String name, String value) { + setName(name); + setValue(value); + } + + private void setName(String name) { + if (!isValidString(name)) { + return; + } - private void setName(String name) { - if (!isValidString(name)) { - return; - } + this.name = name; + } - this.name = name; - } + private void setValue(String value) { + if (!isValidString(value)) { + return; + } - private void setValue(String value) { - if (!isValidString(value)) { - return; - } + this.value = value; + } - this.value = value; - } + public String getName() { + return this.name; + } - public String getName() { - return this.name; - } + public String getValue() { + return this.value; + } - public String getValue() { - return this.value; - } + private boolean isValidString(String arg) { + if (arg == null) { + return false; + } - private boolean isValidString(String arg) { - if (arg == null) { - return false; - } + return true; + } - return true; - } } diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ProgressRequestBody.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ProgressRequestBody.java index 94f77b367..0548564f9 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ProgressRequestBody.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ProgressRequestBody.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.api; import okhttp3.MediaType; @@ -26,48 +25,50 @@ public class ProgressRequestBody extends RequestBody { - private final RequestBody requestBody; - - private final ApiCallback callback; - - public ProgressRequestBody(RequestBody requestBody, ApiCallback callback) { - this.requestBody = requestBody; - this.callback = callback; - } - - @Override - public MediaType contentType() { - return requestBody.contentType(); - } - - @Override - public long contentLength() throws IOException { - return requestBody.contentLength(); - } - - @Override - public void writeTo(BufferedSink sink) throws IOException { - BufferedSink bufferedSink = Okio.buffer(sink(sink)); - requestBody.writeTo(bufferedSink); - bufferedSink.flush(); - } - - private Sink sink(Sink sink) { - return new ForwardingSink(sink) { - - long bytesWritten = 0L; - long contentLength = 0L; - - @Override - public void write(Buffer source, long byteCount) throws IOException { - super.write(source, byteCount); - if (contentLength == 0) { - contentLength = contentLength(); - } - - bytesWritten += byteCount; - callback.onUploadProgress(bytesWritten, contentLength, bytesWritten == contentLength); - } - }; - } + private final RequestBody requestBody; + + private final ApiCallback callback; + + public ProgressRequestBody(RequestBody requestBody, ApiCallback callback) { + this.requestBody = requestBody; + this.callback = callback; + } + + @Override + public MediaType contentType() { + return requestBody.contentType(); + } + + @Override + public long contentLength() throws IOException { + return requestBody.contentLength(); + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + BufferedSink bufferedSink = Okio.buffer(sink(sink)); + requestBody.writeTo(bufferedSink); + bufferedSink.flush(); + } + + private Sink sink(Sink sink) { + return new ForwardingSink(sink) { + + long bytesWritten = 0L; + + long contentLength = 0L; + + @Override + public void write(Buffer source, long byteCount) throws IOException { + super.write(source, byteCount); + if (contentLength == 0) { + contentLength = contentLength(); + } + + bytesWritten += byteCount; + callback.onUploadProgress(bytesWritten, contentLength, bytesWritten == contentLength); + } + }; + } + } diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ProgressResponseBody.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ProgressResponseBody.java index 87b06e614..330665545 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ProgressResponseBody.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ProgressResponseBody.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.api; import okhttp3.MediaType; @@ -26,45 +25,49 @@ public class ProgressResponseBody extends ResponseBody { - private final ResponseBody responseBody; - private final ApiCallback callback; - private BufferedSource bufferedSource; + private final ResponseBody responseBody; + + private final ApiCallback callback; + + private BufferedSource bufferedSource; + + public ProgressResponseBody(ResponseBody responseBody, ApiCallback callback) { + this.responseBody = responseBody; + this.callback = callback; + } - public ProgressResponseBody(ResponseBody responseBody, ApiCallback callback) { - this.responseBody = responseBody; - this.callback = callback; - } + @Override + public MediaType contentType() { + return responseBody.contentType(); + } - @Override - public MediaType contentType() { - return responseBody.contentType(); - } + @Override + public long contentLength() { + return responseBody.contentLength(); + } - @Override - public long contentLength() { - return responseBody.contentLength(); - } + @Override + public BufferedSource source() { + if (bufferedSource == null) { + bufferedSource = Okio.buffer(source(responseBody.source())); + } + return bufferedSource; + } - @Override - public BufferedSource source() { - if (bufferedSource == null) { - bufferedSource = Okio.buffer(source(responseBody.source())); - } - return bufferedSource; - } + private Source source(Source source) { + return new ForwardingSource(source) { + long totalBytesRead = 0L; - private Source source(Source source) { - return new ForwardingSource(source) { - long totalBytesRead = 0L; + @Override + public long read(Buffer sink, long byteCount) throws IOException { + long bytesRead = super.read(sink, byteCount); + // read() returns the number of bytes read, or -1 if this source is + // exhausted. + totalBytesRead += bytesRead != -1 ? bytesRead : 0; + callback.onDownloadProgress(totalBytesRead, responseBody.contentLength(), bytesRead == -1); + return bytesRead; + } + }; + } - @Override - public long read(Buffer sink, long byteCount) throws IOException { - long bytesRead = super.read(sink, byteCount); - // read() returns the number of bytes read, or -1 if this source is exhausted. - totalBytesRead += bytesRead != -1 ? bytesRead : 0; - callback.onDownloadProgress(totalBytesRead, responseBody.contentLength(), bytesRead == -1); - return bytesRead; - } - }; - } } diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ProjectApi.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ProjectApi.java index 7fa7aafe1..bccae07cc 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ProjectApi.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ProjectApi.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.api; import com.redhat.parodos.sdk.api.ApiCallback; @@ -26,7 +25,6 @@ import java.io.IOException; - import com.redhat.parodos.sdk.model.ProjectRequestDTO; import com.redhat.parodos.sdk.model.ProjectResponseDTO; @@ -37,433 +35,628 @@ import java.util.Map; public class ProjectApi { - private ApiClient localVarApiClient; - private int localHostIndex; - private String localCustomBaseUrl; - - public ProjectApi() { - this(Configuration.getDefaultApiClient()); - } - - public ProjectApi(ApiClient apiClient) { - this.localVarApiClient = apiClient; - } - - public ApiClient getApiClient() { - return localVarApiClient; - } - - public void setApiClient(ApiClient apiClient) { - this.localVarApiClient = apiClient; - } - - public int getHostIndex() { - return localHostIndex; - } - - public void setHostIndex(int hostIndex) { - this.localHostIndex = hostIndex; - } - - public String getCustomBaseUrl() { - return localCustomBaseUrl; - } - - public void setCustomBaseUrl(String customBaseUrl) { - this.localCustomBaseUrl = customBaseUrl; - } - - /** - * Build call for createProject - * @param projectRequestDTO (required) - * @param _callback Callback for upload/download progress - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - * @http.response.details - - - - -
    Status Code Description Response Headers
    201 Created -
    401 Unauthorized -
    - */ - public okhttp3.Call createProjectCall(ProjectRequestDTO projectRequestDTO, final ApiCallback _callback) throws ApiException { - String basePath = null; - - // Operation Servers - String[] localBasePaths = new String[] { }; - - // Determine Base Path to Use - if (localCustomBaseUrl != null){ - basePath = localCustomBaseUrl; - } else if ( localBasePaths.length > 0 ) { - basePath = localBasePaths[localHostIndex]; - } else { - basePath = null; - } - - Object localVarPostBody = projectRequestDTO; - - // create path and map variables - String localVarPath = "/api/v1/projects"; - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarCookieParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) { - localVarHeaderParams.put("Accept", localVarAccept); - } - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarContentType != null) { - localVarHeaderParams.put("Content-Type", localVarContentType); - } - - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); - } - - @SuppressWarnings("rawtypes") - private okhttp3.Call createProjectValidateBeforeCall(ProjectRequestDTO projectRequestDTO, final ApiCallback _callback) throws ApiException { - - // verify the required parameter 'projectRequestDTO' is set - if (projectRequestDTO == null) { - throw new ApiException("Missing the required parameter 'projectRequestDTO' when calling createProject(Async)"); - } - - - okhttp3.Call localVarCall = createProjectCall(projectRequestDTO, _callback); - return localVarCall; - - } - - /** - * Creates a new project - * - * @param projectRequestDTO (required) - * @return ProjectResponseDTO - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - * @http.response.details - - - - -
    Status Code Description Response Headers
    201 Created -
    401 Unauthorized -
    - */ - public ProjectResponseDTO createProject(ProjectRequestDTO projectRequestDTO) throws ApiException { - ApiResponse localVarResp = createProjectWithHttpInfo(projectRequestDTO); - return localVarResp.getData(); - } - - /** - * Creates a new project - * - * @param projectRequestDTO (required) - * @return ApiResponse<ProjectResponseDTO> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - * @http.response.details - - - - -
    Status Code Description Response Headers
    201 Created -
    401 Unauthorized -
    - */ - public ApiResponse createProjectWithHttpInfo(ProjectRequestDTO projectRequestDTO) throws ApiException { - okhttp3.Call localVarCall = createProjectValidateBeforeCall(projectRequestDTO, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return localVarApiClient.execute(localVarCall, localVarReturnType); - } - - /** - * Creates a new project (asynchronously) - * - * @param projectRequestDTO (required) - * @param _callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - * @http.response.details - - - - -
    Status Code Description Response Headers
    201 Created -
    401 Unauthorized -
    - */ - public okhttp3.Call createProjectAsync(ProjectRequestDTO projectRequestDTO, final ApiCallback _callback) throws ApiException { - - okhttp3.Call localVarCall = createProjectValidateBeforeCall(projectRequestDTO, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); - localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); - return localVarCall; - } - /** - * Build call for getProjectById - * @param id (required) - * @param _callback Callback for upload/download progress - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - * @http.response.details - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    404 Not found -
    - */ - public okhttp3.Call getProjectByIdCall(String id, final ApiCallback _callback) throws ApiException { - String basePath = null; - - // Operation Servers - String[] localBasePaths = new String[] { }; - - // Determine Base Path to Use - if (localCustomBaseUrl != null){ - basePath = localCustomBaseUrl; - } else if ( localBasePaths.length > 0 ) { - basePath = localBasePaths[localHostIndex]; - } else { - basePath = null; - } - - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/api/v1/projects/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarCookieParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) { - localVarHeaderParams.put("Accept", localVarAccept); - } - - final String[] localVarContentTypes = { - - }; - final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarContentType != null) { - localVarHeaderParams.put("Content-Type", localVarContentType); - } - - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); - } - - @SuppressWarnings("rawtypes") - private okhttp3.Call getProjectByIdValidateBeforeCall(String id, final ApiCallback _callback) throws ApiException { - - // verify the required parameter 'id' is set - if (id == null) { - throw new ApiException("Missing the required parameter 'id' when calling getProjectById(Async)"); - } - - - okhttp3.Call localVarCall = getProjectByIdCall(id, _callback); - return localVarCall; - - } - - /** - * Returns information about a specified project - * - * @param id (required) - * @return ProjectResponseDTO - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - * @http.response.details - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    404 Not found -
    - */ - public ProjectResponseDTO getProjectById(String id) throws ApiException { - ApiResponse localVarResp = getProjectByIdWithHttpInfo(id); - return localVarResp.getData(); - } - - /** - * Returns information about a specified project - * - * @param id (required) - * @return ApiResponse<ProjectResponseDTO> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - * @http.response.details - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    404 Not found -
    - */ - public ApiResponse getProjectByIdWithHttpInfo(String id) throws ApiException { - okhttp3.Call localVarCall = getProjectByIdValidateBeforeCall(id, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return localVarApiClient.execute(localVarCall, localVarReturnType); - } - - /** - * Returns information about a specified project (asynchronously) - * - * @param id (required) - * @param _callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - * @http.response.details - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    404 Not found -
    - */ - public okhttp3.Call getProjectByIdAsync(String id, final ApiCallback _callback) throws ApiException { - - okhttp3.Call localVarCall = getProjectByIdValidateBeforeCall(id, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); - localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); - return localVarCall; - } - /** - * Build call for getProjects - * @param _callback Callback for upload/download progress - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - * @http.response.details - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    403 Forbidden -
    - */ - public okhttp3.Call getProjectsCall(final ApiCallback _callback) throws ApiException { - String basePath = null; - - // Operation Servers - String[] localBasePaths = new String[] { }; - - // Determine Base Path to Use - if (localCustomBaseUrl != null){ - basePath = localCustomBaseUrl; - } else if ( localBasePaths.length > 0 ) { - basePath = localBasePaths[localHostIndex]; - } else { - basePath = null; - } - - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/api/v1/projects"; - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarCookieParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) { - localVarHeaderParams.put("Accept", localVarAccept); - } - - final String[] localVarContentTypes = { - - }; - final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarContentType != null) { - localVarHeaderParams.put("Content-Type", localVarContentType); - } - - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); - } - - @SuppressWarnings("rawtypes") - private okhttp3.Call getProjectsValidateBeforeCall(final ApiCallback _callback) throws ApiException { - - - okhttp3.Call localVarCall = getProjectsCall(_callback); - return localVarCall; - - } - - /** - * Returns a list of project - * - * @return List<ProjectResponseDTO> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - * @http.response.details - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    403 Forbidden -
    - */ - public List getProjects() throws ApiException { - ApiResponse> localVarResp = getProjectsWithHttpInfo(); - return localVarResp.getData(); - } - - /** - * Returns a list of project - * - * @return ApiResponse<List<ProjectResponseDTO>> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - * @http.response.details - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    403 Forbidden -
    - */ - public ApiResponse> getProjectsWithHttpInfo() throws ApiException { - okhttp3.Call localVarCall = getProjectsValidateBeforeCall(null); - Type localVarReturnType = new TypeToken>(){}.getType(); - return localVarApiClient.execute(localVarCall, localVarReturnType); - } - - /** - * Returns a list of project (asynchronously) - * - * @param _callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - * @http.response.details - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    403 Forbidden -
    - */ - public okhttp3.Call getProjectsAsync(final ApiCallback> _callback) throws ApiException { - - okhttp3.Call localVarCall = getProjectsValidateBeforeCall(_callback); - Type localVarReturnType = new TypeToken>(){}.getType(); - localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); - return localVarCall; - } + + private ApiClient localVarApiClient; + + private int localHostIndex; + + private String localCustomBaseUrl; + + public ProjectApi() { + this(Configuration.getDefaultApiClient()); + } + + public ProjectApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + /** + * Build call for createProject + * @param projectRequestDTO (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    201Created-
    401Unauthorized-
    + */ + public okhttp3.Call createProjectCall(ProjectRequestDTO projectRequestDTO, final ApiCallback _callback) + throws ApiException { + String basePath = null; + + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } + else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } + else { + basePath = null; + } + + Object localVarPostBody = projectRequestDTO; + + // create path and map variables + String localVarPath = "/api/v1/projects"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { "application/json" }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, + localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, + localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call createProjectValidateBeforeCall(ProjectRequestDTO projectRequestDTO, + final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'projectRequestDTO' is set + if (projectRequestDTO == null) { + throw new ApiException( + "Missing the required parameter 'projectRequestDTO' when calling createProject(Async)"); + } + + okhttp3.Call localVarCall = createProjectCall(projectRequestDTO, _callback); + return localVarCall; + + } + + /** + * Creates a new project + * @param projectRequestDTO (required) + * @return ProjectResponseDTO + * @throws ApiException If fail to call the API, e.g. server error or cannot + * deserialize the response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    201Created-
    401Unauthorized-
    + */ + public ProjectResponseDTO createProject(ProjectRequestDTO projectRequestDTO) throws ApiException { + ApiResponse localVarResp = createProjectWithHttpInfo(projectRequestDTO); + return localVarResp.getData(); + } + + /** + * Creates a new project + * @param projectRequestDTO (required) + * @return ApiResponse<ProjectResponseDTO> + * @throws ApiException If fail to call the API, e.g. server error or cannot + * deserialize the response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    201Created-
    401Unauthorized-
    + */ + public ApiResponse createProjectWithHttpInfo(ProjectRequestDTO projectRequestDTO) + throws ApiException { + okhttp3.Call localVarCall = createProjectValidateBeforeCall(projectRequestDTO, null); + Type localVarReturnType = new TypeToken() { + }.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Creates a new project (asynchronously) + * @param projectRequestDTO (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request + * body object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    201Created-
    401Unauthorized-
    + */ + public okhttp3.Call createProjectAsync(ProjectRequestDTO projectRequestDTO, + final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = createProjectValidateBeforeCall(projectRequestDTO, _callback); + Type localVarReturnType = new TypeToken() { + }.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for getProjectById + * @param id (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    404Not found-
    + */ + public okhttp3.Call getProjectByIdCall(String id, final ApiCallback _callback) throws ApiException { + String basePath = null; + + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } + else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } + else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/api/v1/projects/{id}".replaceAll("\\{" + "id" + "\\}", + localVarApiClient.escapeString(id.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, + localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, + localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getProjectByIdValidateBeforeCall(String id, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'id' is set + if (id == null) { + throw new ApiException("Missing the required parameter 'id' when calling getProjectById(Async)"); + } + + okhttp3.Call localVarCall = getProjectByIdCall(id, _callback); + return localVarCall; + + } + + /** + * Returns information about a specified project + * @param id (required) + * @return ProjectResponseDTO + * @throws ApiException If fail to call the API, e.g. server error or cannot + * deserialize the response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    404Not found-
    + */ + public ProjectResponseDTO getProjectById(String id) throws ApiException { + ApiResponse localVarResp = getProjectByIdWithHttpInfo(id); + return localVarResp.getData(); + } + + /** + * Returns information about a specified project + * @param id (required) + * @return ApiResponse<ProjectResponseDTO> + * @throws ApiException If fail to call the API, e.g. server error or cannot + * deserialize the response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    404Not found-
    + */ + public ApiResponse getProjectByIdWithHttpInfo(String id) throws ApiException { + okhttp3.Call localVarCall = getProjectByIdValidateBeforeCall(id, null); + Type localVarReturnType = new TypeToken() { + }.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Returns information about a specified project (asynchronously) + * @param id (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request + * body object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    404Not found-
    + */ + public okhttp3.Call getProjectByIdAsync(String id, final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = getProjectByIdValidateBeforeCall(id, _callback); + Type localVarReturnType = new TypeToken() { + }.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for getProjects + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    403Forbidden-
    + */ + public okhttp3.Call getProjectsCall(final ApiCallback _callback) throws ApiException { + String basePath = null; + + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } + else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } + else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/api/v1/projects"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, + localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, + localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getProjectsValidateBeforeCall(final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getProjectsCall(_callback); + return localVarCall; + + } + + /** + * Returns a list of project + * @return List<ProjectResponseDTO> + * @throws ApiException If fail to call the API, e.g. server error or cannot + * deserialize the response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    403Forbidden-
    + */ + public List getProjects() throws ApiException { + ApiResponse> localVarResp = getProjectsWithHttpInfo(); + return localVarResp.getData(); + } + + /** + * Returns a list of project + * @return ApiResponse<List<ProjectResponseDTO>> + * @throws ApiException If fail to call the API, e.g. server error or cannot + * deserialize the response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    403Forbidden-
    + */ + public ApiResponse> getProjectsWithHttpInfo() throws ApiException { + okhttp3.Call localVarCall = getProjectsValidateBeforeCall(null); + Type localVarReturnType = new TypeToken>() { + }.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Returns a list of project (asynchronously) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request + * body object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    403Forbidden-
    + */ + public okhttp3.Call getProjectsAsync(final ApiCallback> _callback) throws ApiException { + + okhttp3.Call localVarCall = getProjectsValidateBeforeCall(_callback); + Type localVarReturnType = new TypeToken>() { + }.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + } diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ServerConfiguration.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ServerConfiguration.java index 337fb5b6f..0c3f1ad7c 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ServerConfiguration.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ServerConfiguration.java @@ -6,53 +6,57 @@ * Representing a Server configuration. */ public class ServerConfiguration { - public String URL; - public String description; - public Map variables; - - /** - * @param URL A URL to the target host. - * @param description A description of the host designated by the URL. - * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. - */ - public ServerConfiguration(String URL, String description, Map variables) { - this.URL = URL; - this.description = description; - this.variables = variables; - } - - /** - * Format URL template using given variables. - * - * @param variables A map between a variable name and its value. - * @return Formatted URL. - */ - public String URL(Map variables) { - String url = this.URL; - - // go through variables and replace placeholders - for (Map.Entry variable: this.variables.entrySet()) { - String name = variable.getKey(); - ServerVariable serverVariable = variable.getValue(); - String value = serverVariable.defaultValue; - - if (variables != null && variables.containsKey(name)) { - value = variables.get(name); - if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) { - throw new RuntimeException("The variable " + name + " in the server URL has invalid value " + value + "."); - } - } - url = url.replaceAll("\\{" + name + "\\}", value); - } - return url; - } - - /** - * Format URL template using default server variables. - * - * @return Formatted URL. - */ - public String URL() { - return URL(null); - } + + public String URL; + + public String description; + + public Map variables; + + /** + * @param URL A URL to the target host. + * @param description A description of the host designated by the URL. + * @param variables A map between a variable name and its value. The value is used for + * substitution in the server's URL template. + */ + public ServerConfiguration(String URL, String description, Map variables) { + this.URL = URL; + this.description = description; + this.variables = variables; + } + + /** + * Format URL template using given variables. + * @param variables A map between a variable name and its value. + * @return Formatted URL. + */ + public String URL(Map variables) { + String url = this.URL; + + // go through variables and replace placeholders + for (Map.Entry variable : this.variables.entrySet()) { + String name = variable.getKey(); + ServerVariable serverVariable = variable.getValue(); + String value = serverVariable.defaultValue; + + if (variables != null && variables.containsKey(name)) { + value = variables.get(name); + if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) { + throw new RuntimeException( + "The variable " + name + " in the server URL has invalid value " + value + "."); + } + } + url = url.replaceAll("\\{" + name + "\\}", value); + } + return url; + } + + /** + * Format URL template using default server variables. + * @return Formatted URL. + */ + public String URL() { + return URL(null); + } + } diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ServerVariable.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ServerVariable.java index 4047ad1c1..d04cc05d9 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ServerVariable.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/ServerVariable.java @@ -6,18 +6,23 @@ * Representing a Server Variable for server URL template substitution. */ public class ServerVariable { - public String description; - public String defaultValue; - public HashSet enumValues = null; - /** - * @param description A description for the server variable. - * @param defaultValue The default value to use for substitution. - * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set. - */ - public ServerVariable(String description, String defaultValue, HashSet enumValues) { - this.description = description; - this.defaultValue = defaultValue; - this.enumValues = enumValues; - } + public String description; + + public String defaultValue; + + public HashSet enumValues = null; + + /** + * @param description A description for the server variable. + * @param defaultValue The default value to use for substitution. + * @param enumValues An enumeration of string values to be used if the substitution + * options are from a limited set. + */ + public ServerVariable(String description, String defaultValue, HashSet enumValues) { + this.description = description; + this.defaultValue = defaultValue; + this.enumValues = enumValues; + } + } diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/StringUtil.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/StringUtil.java index 6e10bc459..0d1a27365 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/StringUtil.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/StringUtil.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.api; import java.util.Collection; @@ -18,66 +17,66 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class StringUtil { - /** - * Check if the given array contains the given value (with case-insensitive comparison). - * - * @param array The array - * @param value The value to search - * @return true if the array contains the value - */ - public static boolean containsIgnoreCase(String[] array, String value) { - for (String str : array) { - if (value == null && str == null) { - return true; - } - if (value != null && value.equalsIgnoreCase(str)) { - return true; - } - } - return false; - } - /** - * Join an array of strings with the given separator. - *

    - * Note: This might be replaced by utility method from commons-lang or guava someday - * if one of those libraries is added as dependency. - *

    - * - * @param array The array of strings - * @param separator The separator - * @return the resulting string - */ - public static String join(String[] array, String separator) { - int len = array.length; - if (len == 0) { - return ""; - } + /** + * Check if the given array contains the given value (with case-insensitive + * comparison). + * @param array The array + * @param value The value to search + * @return true if the array contains the value + */ + public static boolean containsIgnoreCase(String[] array, String value) { + for (String str : array) { + if (value == null && str == null) { + return true; + } + if (value != null && value.equalsIgnoreCase(str)) { + return true; + } + } + return false; + } + + /** + * Join an array of strings with the given separator. + *

    + * Note: This might be replaced by utility method from commons-lang or guava someday + * if one of those libraries is added as dependency. + *

    + * @param array The array of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(String[] array, String separator) { + int len = array.length; + if (len == 0) { + return ""; + } + + StringBuilder out = new StringBuilder(); + out.append(array[0]); + for (int i = 1; i < len; i++) { + out.append(separator).append(array[i]); + } + return out.toString(); + } - StringBuilder out = new StringBuilder(); - out.append(array[0]); - for (int i = 1; i < len; i++) { - out.append(separator).append(array[i]); - } - return out.toString(); - } + /** + * Join a list of strings with the given separator. + * @param list The list of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(Collection list, String separator) { + Iterator iterator = list.iterator(); + StringBuilder out = new StringBuilder(); + if (iterator.hasNext()) { + out.append(iterator.next()); + } + while (iterator.hasNext()) { + out.append(separator).append(iterator.next()); + } + return out.toString(); + } - /** - * Join a list of strings with the given separator. - * - * @param list The list of strings - * @param separator The separator - * @return the resulting string - */ - public static String join(Collection list, String separator) { - Iterator iterator = list.iterator(); - StringBuilder out = new StringBuilder(); - if (iterator.hasNext()) { - out.append(iterator.next()); - } - while (iterator.hasNext()) { - out.append(separator).append(iterator.next()); - } - return out.toString(); - } } diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/WorkflowApi.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/WorkflowApi.java index fd0eb3126..8296dc0a9 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/WorkflowApi.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/WorkflowApi.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.api; import com.redhat.parodos.sdk.api.ApiCallback; @@ -26,7 +25,6 @@ import java.io.IOException; - import com.redhat.parodos.sdk.model.WorkFlowCheckerTaskRequestDTO; import com.redhat.parodos.sdk.model.WorkFlowRequestDTO; import com.redhat.parodos.sdk.model.WorkFlowResponseDTO; @@ -39,470 +37,715 @@ import java.util.Map; public class WorkflowApi { - private ApiClient localVarApiClient; - private int localHostIndex; - private String localCustomBaseUrl; - - public WorkflowApi() { - this(Configuration.getDefaultApiClient()); - } - - public WorkflowApi(ApiClient apiClient) { - this.localVarApiClient = apiClient; - } - - public ApiClient getApiClient() { - return localVarApiClient; - } - - public void setApiClient(ApiClient apiClient) { - this.localVarApiClient = apiClient; - } - - public int getHostIndex() { - return localHostIndex; - } - - public void setHostIndex(int hostIndex) { - this.localHostIndex = hostIndex; - } - - public String getCustomBaseUrl() { - return localCustomBaseUrl; - } - - public void setCustomBaseUrl(String customBaseUrl) { - this.localCustomBaseUrl = customBaseUrl; - } - - /** - * Build call for execute - * @param workFlowRequestDTO (required) - * @param _callback Callback for upload/download progress - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - * @http.response.details - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    403 Forbidden -
    - */ - public okhttp3.Call executeCall(WorkFlowRequestDTO workFlowRequestDTO, final ApiCallback _callback) throws ApiException { - String basePath = null; - - // Operation Servers - String[] localBasePaths = new String[] { }; - - // Determine Base Path to Use - if (localCustomBaseUrl != null){ - basePath = localCustomBaseUrl; - } else if ( localBasePaths.length > 0 ) { - basePath = localBasePaths[localHostIndex]; - } else { - basePath = null; - } - - Object localVarPostBody = workFlowRequestDTO; - - // create path and map variables - String localVarPath = "/api/v1/workflows"; - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarCookieParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) { - localVarHeaderParams.put("Accept", localVarAccept); - } - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarContentType != null) { - localVarHeaderParams.put("Content-Type", localVarContentType); - } - - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); - } - - @SuppressWarnings("rawtypes") - private okhttp3.Call executeValidateBeforeCall(WorkFlowRequestDTO workFlowRequestDTO, final ApiCallback _callback) throws ApiException { - - // verify the required parameter 'workFlowRequestDTO' is set - if (workFlowRequestDTO == null) { - throw new ApiException("Missing the required parameter 'workFlowRequestDTO' when calling execute(Async)"); - } - - - okhttp3.Call localVarCall = executeCall(workFlowRequestDTO, _callback); - return localVarCall; - - } - - /** - * Executes a workflow - * - * @param workFlowRequestDTO (required) - * @return WorkFlowResponseDTO - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - * @http.response.details - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    403 Forbidden -
    - */ - public WorkFlowResponseDTO execute(WorkFlowRequestDTO workFlowRequestDTO) throws ApiException { - ApiResponse localVarResp = executeWithHttpInfo(workFlowRequestDTO); - return localVarResp.getData(); - } - - /** - * Executes a workflow - * - * @param workFlowRequestDTO (required) - * @return ApiResponse<WorkFlowResponseDTO> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - * @http.response.details - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    403 Forbidden -
    - */ - public ApiResponse executeWithHttpInfo(WorkFlowRequestDTO workFlowRequestDTO) throws ApiException { - okhttp3.Call localVarCall = executeValidateBeforeCall(workFlowRequestDTO, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return localVarApiClient.execute(localVarCall, localVarReturnType); - } - - /** - * Executes a workflow (asynchronously) - * - * @param workFlowRequestDTO (required) - * @param _callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - * @http.response.details - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    403 Forbidden -
    - */ - public okhttp3.Call executeAsync(WorkFlowRequestDTO workFlowRequestDTO, final ApiCallback _callback) throws ApiException { - - okhttp3.Call localVarCall = executeValidateBeforeCall(workFlowRequestDTO, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); - localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); - return localVarCall; - } - /** - * Build call for getStatus - * @param workFlowExecutionId (required) - * @param _callback Callback for upload/download progress - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - * @http.response.details - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    403 Forbidden -
    - */ - public okhttp3.Call getStatusCall(String workFlowExecutionId, final ApiCallback _callback) throws ApiException { - String basePath = null; - - // Operation Servers - String[] localBasePaths = new String[] { }; - - // Determine Base Path to Use - if (localCustomBaseUrl != null){ - basePath = localCustomBaseUrl; - } else if ( localBasePaths.length > 0 ) { - basePath = localBasePaths[localHostIndex]; - } else { - basePath = null; - } - - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/api/v1/workflows/{workFlowExecutionId}/status" - .replaceAll("\\{" + "workFlowExecutionId" + "\\}", localVarApiClient.escapeString(workFlowExecutionId.toString())); - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarCookieParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) { - localVarHeaderParams.put("Accept", localVarAccept); - } - - final String[] localVarContentTypes = { - - }; - final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarContentType != null) { - localVarHeaderParams.put("Content-Type", localVarContentType); - } - - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); - } - - @SuppressWarnings("rawtypes") - private okhttp3.Call getStatusValidateBeforeCall(String workFlowExecutionId, final ApiCallback _callback) throws ApiException { - - // verify the required parameter 'workFlowExecutionId' is set - if (workFlowExecutionId == null) { - throw new ApiException("Missing the required parameter 'workFlowExecutionId' when calling getStatus(Async)"); - } - - - okhttp3.Call localVarCall = getStatusCall(workFlowExecutionId, _callback); - return localVarCall; - - } - - /** - * Returns a workflow status - * - * @param workFlowExecutionId (required) - * @return WorkFlowStatusResponseDTO - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - * @http.response.details - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    403 Forbidden -
    - */ - public WorkFlowStatusResponseDTO getStatus(String workFlowExecutionId) throws ApiException { - ApiResponse localVarResp = getStatusWithHttpInfo(workFlowExecutionId); - return localVarResp.getData(); - } - - /** - * Returns a workflow status - * - * @param workFlowExecutionId (required) - * @return ApiResponse<WorkFlowStatusResponseDTO> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - * @http.response.details - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    403 Forbidden -
    - */ - public ApiResponse getStatusWithHttpInfo(String workFlowExecutionId) throws ApiException { - okhttp3.Call localVarCall = getStatusValidateBeforeCall(workFlowExecutionId, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return localVarApiClient.execute(localVarCall, localVarReturnType); - } - - /** - * Returns a workflow status (asynchronously) - * - * @param workFlowExecutionId (required) - * @param _callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - * @http.response.details - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    403 Forbidden -
    - */ - public okhttp3.Call getStatusAsync(String workFlowExecutionId, final ApiCallback _callback) throws ApiException { - - okhttp3.Call localVarCall = getStatusValidateBeforeCall(workFlowExecutionId, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); - localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); - return localVarCall; - } - /** - * Build call for updateWorkFlowCheckerTaskStatus - * @param workFlowExecutionId (required) - * @param workFlowCheckerTaskName (required) - * @param workFlowCheckerTaskRequestDTO (required) - * @param _callback Callback for upload/download progress - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - * @http.response.details - - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    403 Forbidden -
    404 Not found -
    - */ - public okhttp3.Call updateWorkFlowCheckerTaskStatusCall(String workFlowExecutionId, String workFlowCheckerTaskName, WorkFlowCheckerTaskRequestDTO workFlowCheckerTaskRequestDTO, final ApiCallback _callback) throws ApiException { - String basePath = null; - - // Operation Servers - String[] localBasePaths = new String[] { }; - - // Determine Base Path to Use - if (localCustomBaseUrl != null){ - basePath = localCustomBaseUrl; - } else if ( localBasePaths.length > 0 ) { - basePath = localBasePaths[localHostIndex]; - } else { - basePath = null; - } - - Object localVarPostBody = workFlowCheckerTaskRequestDTO; - - // create path and map variables - String localVarPath = "/api/v1/workflows/{workFlowExecutionId}/checkers/{workFlowCheckerTaskName}" - .replaceAll("\\{" + "workFlowExecutionId" + "\\}", localVarApiClient.escapeString(workFlowExecutionId.toString())) - .replaceAll("\\{" + "workFlowCheckerTaskName" + "\\}", localVarApiClient.escapeString(workFlowCheckerTaskName.toString())); - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarCookieParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) { - localVarHeaderParams.put("Accept", localVarAccept); - } - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarContentType != null) { - localVarHeaderParams.put("Content-Type", localVarContentType); - } - - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); - } - - @SuppressWarnings("rawtypes") - private okhttp3.Call updateWorkFlowCheckerTaskStatusValidateBeforeCall(String workFlowExecutionId, String workFlowCheckerTaskName, WorkFlowCheckerTaskRequestDTO workFlowCheckerTaskRequestDTO, final ApiCallback _callback) throws ApiException { - - // verify the required parameter 'workFlowExecutionId' is set - if (workFlowExecutionId == null) { - throw new ApiException("Missing the required parameter 'workFlowExecutionId' when calling updateWorkFlowCheckerTaskStatus(Async)"); - } - - // verify the required parameter 'workFlowCheckerTaskName' is set - if (workFlowCheckerTaskName == null) { - throw new ApiException("Missing the required parameter 'workFlowCheckerTaskName' when calling updateWorkFlowCheckerTaskStatus(Async)"); - } - - // verify the required parameter 'workFlowCheckerTaskRequestDTO' is set - if (workFlowCheckerTaskRequestDTO == null) { - throw new ApiException("Missing the required parameter 'workFlowCheckerTaskRequestDTO' when calling updateWorkFlowCheckerTaskStatus(Async)"); - } - - - okhttp3.Call localVarCall = updateWorkFlowCheckerTaskStatusCall(workFlowExecutionId, workFlowCheckerTaskName, workFlowCheckerTaskRequestDTO, _callback); - return localVarCall; - - } - - /** - * Updates a workflow checker task status - * - * @param workFlowExecutionId (required) - * @param workFlowCheckerTaskName (required) - * @param workFlowCheckerTaskRequestDTO (required) - * @return String - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - * @http.response.details - - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    403 Forbidden -
    404 Not found -
    - */ - public String updateWorkFlowCheckerTaskStatus(String workFlowExecutionId, String workFlowCheckerTaskName, WorkFlowCheckerTaskRequestDTO workFlowCheckerTaskRequestDTO) throws ApiException { - ApiResponse localVarResp = updateWorkFlowCheckerTaskStatusWithHttpInfo(workFlowExecutionId, workFlowCheckerTaskName, workFlowCheckerTaskRequestDTO); - return localVarResp.getData(); - } - - /** - * Updates a workflow checker task status - * - * @param workFlowExecutionId (required) - * @param workFlowCheckerTaskName (required) - * @param workFlowCheckerTaskRequestDTO (required) - * @return ApiResponse<String> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - * @http.response.details - - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    403 Forbidden -
    404 Not found -
    - */ - public ApiResponse updateWorkFlowCheckerTaskStatusWithHttpInfo(String workFlowExecutionId, String workFlowCheckerTaskName, WorkFlowCheckerTaskRequestDTO workFlowCheckerTaskRequestDTO) throws ApiException { - okhttp3.Call localVarCall = updateWorkFlowCheckerTaskStatusValidateBeforeCall(workFlowExecutionId, workFlowCheckerTaskName, workFlowCheckerTaskRequestDTO, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return localVarApiClient.execute(localVarCall, localVarReturnType); - } - - /** - * Updates a workflow checker task status (asynchronously) - * - * @param workFlowExecutionId (required) - * @param workFlowCheckerTaskName (required) - * @param workFlowCheckerTaskRequestDTO (required) - * @param _callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - * @http.response.details - - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    403 Forbidden -
    404 Not found -
    - */ - public okhttp3.Call updateWorkFlowCheckerTaskStatusAsync(String workFlowExecutionId, String workFlowCheckerTaskName, WorkFlowCheckerTaskRequestDTO workFlowCheckerTaskRequestDTO, final ApiCallback _callback) throws ApiException { - - okhttp3.Call localVarCall = updateWorkFlowCheckerTaskStatusValidateBeforeCall(workFlowExecutionId, workFlowCheckerTaskName, workFlowCheckerTaskRequestDTO, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); - localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); - return localVarCall; - } + + private ApiClient localVarApiClient; + + private int localHostIndex; + + private String localCustomBaseUrl; + + public WorkflowApi() { + this(Configuration.getDefaultApiClient()); + } + + public WorkflowApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + /** + * Build call for execute + * @param workFlowRequestDTO (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    403Forbidden-
    + */ + public okhttp3.Call executeCall(WorkFlowRequestDTO workFlowRequestDTO, final ApiCallback _callback) + throws ApiException { + String basePath = null; + + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } + else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } + else { + basePath = null; + } + + Object localVarPostBody = workFlowRequestDTO; + + // create path and map variables + String localVarPath = "/api/v1/workflows"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { "application/json" }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, + localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, + localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call executeValidateBeforeCall(WorkFlowRequestDTO workFlowRequestDTO, final ApiCallback _callback) + throws ApiException { + + // verify the required parameter 'workFlowRequestDTO' is set + if (workFlowRequestDTO == null) { + throw new ApiException("Missing the required parameter 'workFlowRequestDTO' when calling execute(Async)"); + } + + okhttp3.Call localVarCall = executeCall(workFlowRequestDTO, _callback); + return localVarCall; + + } + + /** + * Executes a workflow + * @param workFlowRequestDTO (required) + * @return WorkFlowResponseDTO + * @throws ApiException If fail to call the API, e.g. server error or cannot + * deserialize the response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    403Forbidden-
    + */ + public WorkFlowResponseDTO execute(WorkFlowRequestDTO workFlowRequestDTO) throws ApiException { + ApiResponse localVarResp = executeWithHttpInfo(workFlowRequestDTO); + return localVarResp.getData(); + } + + /** + * Executes a workflow + * @param workFlowRequestDTO (required) + * @return ApiResponse<WorkFlowResponseDTO> + * @throws ApiException If fail to call the API, e.g. server error or cannot + * deserialize the response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    403Forbidden-
    + */ + public ApiResponse executeWithHttpInfo(WorkFlowRequestDTO workFlowRequestDTO) + throws ApiException { + okhttp3.Call localVarCall = executeValidateBeforeCall(workFlowRequestDTO, null); + Type localVarReturnType = new TypeToken() { + }.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Executes a workflow (asynchronously) + * @param workFlowRequestDTO (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request + * body object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    403Forbidden-
    + */ + public okhttp3.Call executeAsync(WorkFlowRequestDTO workFlowRequestDTO, + final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = executeValidateBeforeCall(workFlowRequestDTO, _callback); + Type localVarReturnType = new TypeToken() { + }.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for getStatus + * @param workFlowExecutionId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    403Forbidden-
    + */ + public okhttp3.Call getStatusCall(String workFlowExecutionId, final ApiCallback _callback) throws ApiException { + String basePath = null; + + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } + else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } + else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/api/v1/workflows/{workFlowExecutionId}/status".replaceAll( + "\\{" + "workFlowExecutionId" + "\\}", localVarApiClient.escapeString(workFlowExecutionId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, + localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, + localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getStatusValidateBeforeCall(String workFlowExecutionId, final ApiCallback _callback) + throws ApiException { + + // verify the required parameter 'workFlowExecutionId' is set + if (workFlowExecutionId == null) { + throw new ApiException( + "Missing the required parameter 'workFlowExecutionId' when calling getStatus(Async)"); + } + + okhttp3.Call localVarCall = getStatusCall(workFlowExecutionId, _callback); + return localVarCall; + + } + + /** + * Returns a workflow status + * @param workFlowExecutionId (required) + * @return WorkFlowStatusResponseDTO + * @throws ApiException If fail to call the API, e.g. server error or cannot + * deserialize the response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    403Forbidden-
    + */ + public WorkFlowStatusResponseDTO getStatus(String workFlowExecutionId) throws ApiException { + ApiResponse localVarResp = getStatusWithHttpInfo(workFlowExecutionId); + return localVarResp.getData(); + } + + /** + * Returns a workflow status + * @param workFlowExecutionId (required) + * @return ApiResponse<WorkFlowStatusResponseDTO> + * @throws ApiException If fail to call the API, e.g. server error or cannot + * deserialize the response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    403Forbidden-
    + */ + public ApiResponse getStatusWithHttpInfo(String workFlowExecutionId) + throws ApiException { + okhttp3.Call localVarCall = getStatusValidateBeforeCall(workFlowExecutionId, null); + Type localVarReturnType = new TypeToken() { + }.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Returns a workflow status (asynchronously) + * @param workFlowExecutionId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request + * body object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    403Forbidden-
    + */ + public okhttp3.Call getStatusAsync(String workFlowExecutionId, + final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getStatusValidateBeforeCall(workFlowExecutionId, _callback); + Type localVarReturnType = new TypeToken() { + }.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for updateWorkFlowCheckerTaskStatus + * @param workFlowExecutionId (required) + * @param workFlowCheckerTaskName (required) + * @param workFlowCheckerTaskRequestDTO (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    403Forbidden-
    404Not found-
    + */ + public okhttp3.Call updateWorkFlowCheckerTaskStatusCall(String workFlowExecutionId, String workFlowCheckerTaskName, + WorkFlowCheckerTaskRequestDTO workFlowCheckerTaskRequestDTO, final ApiCallback _callback) + throws ApiException { + String basePath = null; + + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } + else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } + else { + basePath = null; + } + + Object localVarPostBody = workFlowCheckerTaskRequestDTO; + + // create path and map variables + String localVarPath = "/api/v1/workflows/{workFlowExecutionId}/checkers/{workFlowCheckerTaskName}" + .replaceAll("\\{" + "workFlowExecutionId" + "\\}", + localVarApiClient.escapeString(workFlowExecutionId.toString())) + .replaceAll("\\{" + "workFlowCheckerTaskName" + "\\}", + localVarApiClient.escapeString(workFlowCheckerTaskName.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { "application/json" }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, + localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, + localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call updateWorkFlowCheckerTaskStatusValidateBeforeCall(String workFlowExecutionId, + String workFlowCheckerTaskName, WorkFlowCheckerTaskRequestDTO workFlowCheckerTaskRequestDTO, + final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'workFlowExecutionId' is set + if (workFlowExecutionId == null) { + throw new ApiException( + "Missing the required parameter 'workFlowExecutionId' when calling updateWorkFlowCheckerTaskStatus(Async)"); + } + + // verify the required parameter 'workFlowCheckerTaskName' is set + if (workFlowCheckerTaskName == null) { + throw new ApiException( + "Missing the required parameter 'workFlowCheckerTaskName' when calling updateWorkFlowCheckerTaskStatus(Async)"); + } + + // verify the required parameter 'workFlowCheckerTaskRequestDTO' is set + if (workFlowCheckerTaskRequestDTO == null) { + throw new ApiException( + "Missing the required parameter 'workFlowCheckerTaskRequestDTO' when calling updateWorkFlowCheckerTaskStatus(Async)"); + } + + okhttp3.Call localVarCall = updateWorkFlowCheckerTaskStatusCall(workFlowExecutionId, workFlowCheckerTaskName, + workFlowCheckerTaskRequestDTO, _callback); + return localVarCall; + + } + + /** + * Updates a workflow checker task status + * @param workFlowExecutionId (required) + * @param workFlowCheckerTaskName (required) + * @param workFlowCheckerTaskRequestDTO (required) + * @return String + * @throws ApiException If fail to call the API, e.g. server error or cannot + * deserialize the response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    403Forbidden-
    404Not found-
    + */ + public String updateWorkFlowCheckerTaskStatus(String workFlowExecutionId, String workFlowCheckerTaskName, + WorkFlowCheckerTaskRequestDTO workFlowCheckerTaskRequestDTO) throws ApiException { + ApiResponse localVarResp = updateWorkFlowCheckerTaskStatusWithHttpInfo(workFlowExecutionId, + workFlowCheckerTaskName, workFlowCheckerTaskRequestDTO); + return localVarResp.getData(); + } + + /** + * Updates a workflow checker task status + * @param workFlowExecutionId (required) + * @param workFlowCheckerTaskName (required) + * @param workFlowCheckerTaskRequestDTO (required) + * @return ApiResponse<String> + * @throws ApiException If fail to call the API, e.g. server error or cannot + * deserialize the response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    403Forbidden-
    404Not found-
    + */ + public ApiResponse updateWorkFlowCheckerTaskStatusWithHttpInfo(String workFlowExecutionId, + String workFlowCheckerTaskName, WorkFlowCheckerTaskRequestDTO workFlowCheckerTaskRequestDTO) + throws ApiException { + okhttp3.Call localVarCall = updateWorkFlowCheckerTaskStatusValidateBeforeCall(workFlowExecutionId, + workFlowCheckerTaskName, workFlowCheckerTaskRequestDTO, null); + Type localVarReturnType = new TypeToken() { + }.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Updates a workflow checker task status (asynchronously) + * @param workFlowExecutionId (required) + * @param workFlowCheckerTaskName (required) + * @param workFlowCheckerTaskRequestDTO (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request + * body object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    403Forbidden-
    404Not found-
    + */ + public okhttp3.Call updateWorkFlowCheckerTaskStatusAsync(String workFlowExecutionId, String workFlowCheckerTaskName, + WorkFlowCheckerTaskRequestDTO workFlowCheckerTaskRequestDTO, final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = updateWorkFlowCheckerTaskStatusValidateBeforeCall(workFlowExecutionId, + workFlowCheckerTaskName, workFlowCheckerTaskRequestDTO, _callback); + Type localVarReturnType = new TypeToken() { + }.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + } diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/WorkflowDefinitionApi.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/WorkflowDefinitionApi.java index bf9fd5d19..eb9165fb4 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/WorkflowDefinitionApi.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/WorkflowDefinitionApi.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.api; import com.redhat.parodos.sdk.api.ApiCallback; @@ -26,7 +25,6 @@ import java.io.IOException; - import com.redhat.parodos.sdk.model.WorkFlowDefinitionResponseDTO; import java.lang.reflect.Type; @@ -36,310 +34,455 @@ import java.util.Map; public class WorkflowDefinitionApi { - private ApiClient localVarApiClient; - private int localHostIndex; - private String localCustomBaseUrl; - - public WorkflowDefinitionApi() { - this(Configuration.getDefaultApiClient()); - } - - public WorkflowDefinitionApi(ApiClient apiClient) { - this.localVarApiClient = apiClient; - } - - public ApiClient getApiClient() { - return localVarApiClient; - } - - public void setApiClient(ApiClient apiClient) { - this.localVarApiClient = apiClient; - } - - public int getHostIndex() { - return localHostIndex; - } - - public void setHostIndex(int hostIndex) { - this.localHostIndex = hostIndex; - } - - public String getCustomBaseUrl() { - return localCustomBaseUrl; - } - - public void setCustomBaseUrl(String customBaseUrl) { - this.localCustomBaseUrl = customBaseUrl; - } - - /** - * Build call for getWorkFlowDefinitionById - * @param id (required) - * @param _callback Callback for upload/download progress - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - * @http.response.details - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    404 Not found -
    - */ - public okhttp3.Call getWorkFlowDefinitionByIdCall(String id, final ApiCallback _callback) throws ApiException { - String basePath = null; - - // Operation Servers - String[] localBasePaths = new String[] { }; - - // Determine Base Path to Use - if (localCustomBaseUrl != null){ - basePath = localCustomBaseUrl; - } else if ( localBasePaths.length > 0 ) { - basePath = localBasePaths[localHostIndex]; - } else { - basePath = null; - } - - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/api/v1/workflowdefinitions/{id}" - .replaceAll("\\{" + "id" + "\\}", localVarApiClient.escapeString(id.toString())); - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarCookieParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) { - localVarHeaderParams.put("Accept", localVarAccept); - } - - final String[] localVarContentTypes = { - - }; - final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarContentType != null) { - localVarHeaderParams.put("Content-Type", localVarContentType); - } - - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); - } - - @SuppressWarnings("rawtypes") - private okhttp3.Call getWorkFlowDefinitionByIdValidateBeforeCall(String id, final ApiCallback _callback) throws ApiException { - - // verify the required parameter 'id' is set - if (id == null) { - throw new ApiException("Missing the required parameter 'id' when calling getWorkFlowDefinitionById(Async)"); - } - - - okhttp3.Call localVarCall = getWorkFlowDefinitionByIdCall(id, _callback); - return localVarCall; - - } - - /** - * Returns information about a workflow definition by id - * - * @param id (required) - * @return WorkFlowDefinitionResponseDTO - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - * @http.response.details - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    404 Not found -
    - */ - public WorkFlowDefinitionResponseDTO getWorkFlowDefinitionById(String id) throws ApiException { - ApiResponse localVarResp = getWorkFlowDefinitionByIdWithHttpInfo(id); - return localVarResp.getData(); - } - - /** - * Returns information about a workflow definition by id - * - * @param id (required) - * @return ApiResponse<WorkFlowDefinitionResponseDTO> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - * @http.response.details - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    404 Not found -
    - */ - public ApiResponse getWorkFlowDefinitionByIdWithHttpInfo(String id) throws ApiException { - okhttp3.Call localVarCall = getWorkFlowDefinitionByIdValidateBeforeCall(id, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return localVarApiClient.execute(localVarCall, localVarReturnType); - } - - /** - * Returns information about a workflow definition by id (asynchronously) - * - * @param id (required) - * @param _callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - * @http.response.details - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    404 Not found -
    - */ - public okhttp3.Call getWorkFlowDefinitionByIdAsync(String id, final ApiCallback _callback) throws ApiException { - - okhttp3.Call localVarCall = getWorkFlowDefinitionByIdValidateBeforeCall(id, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); - localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); - return localVarCall; - } - /** - * Build call for getWorkFlowDefinitions - * @param name (optional) - * @param _callback Callback for upload/download progress - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - * @http.response.details - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    403 Forbidden -
    - */ - public okhttp3.Call getWorkFlowDefinitionsCall(String name, final ApiCallback _callback) throws ApiException { - String basePath = null; - - // Operation Servers - String[] localBasePaths = new String[] { }; - - // Determine Base Path to Use - if (localCustomBaseUrl != null){ - basePath = localCustomBaseUrl; - } else if ( localBasePaths.length > 0 ) { - basePath = localBasePaths[localHostIndex]; - } else { - basePath = null; - } - - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/api/v1/workflowdefinitions"; - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarCookieParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - if (name != null) { - localVarQueryParams.addAll(localVarApiClient.parameterToPair("name", name)); - } - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) { - localVarHeaderParams.put("Accept", localVarAccept); - } - - final String[] localVarContentTypes = { - - }; - final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarContentType != null) { - localVarHeaderParams.put("Content-Type", localVarContentType); - } - - String[] localVarAuthNames = new String[] { }; - return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); - } - - @SuppressWarnings("rawtypes") - private okhttp3.Call getWorkFlowDefinitionsValidateBeforeCall(String name, final ApiCallback _callback) throws ApiException { - - - okhttp3.Call localVarCall = getWorkFlowDefinitionsCall(name, _callback); - return localVarCall; - - } - - /** - * Returns a list of workflow definition - * - * @param name (optional) - * @return List<WorkFlowDefinitionResponseDTO> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - * @http.response.details - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    403 Forbidden -
    - */ - public List getWorkFlowDefinitions(String name) throws ApiException { - ApiResponse> localVarResp = getWorkFlowDefinitionsWithHttpInfo(name); - return localVarResp.getData(); - } - - /** - * Returns a list of workflow definition - * - * @param name (optional) - * @return ApiResponse<List<WorkFlowDefinitionResponseDTO>> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - * @http.response.details - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    403 Forbidden -
    - */ - public ApiResponse> getWorkFlowDefinitionsWithHttpInfo(String name) throws ApiException { - okhttp3.Call localVarCall = getWorkFlowDefinitionsValidateBeforeCall(name, null); - Type localVarReturnType = new TypeToken>(){}.getType(); - return localVarApiClient.execute(localVarCall, localVarReturnType); - } - - /** - * Returns a list of workflow definition (asynchronously) - * - * @param name (optional) - * @param _callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - * @http.response.details - - - - - -
    Status Code Description Response Headers
    200 Succeeded -
    401 Unauthorized -
    403 Forbidden -
    - */ - public okhttp3.Call getWorkFlowDefinitionsAsync(String name, final ApiCallback> _callback) throws ApiException { - - okhttp3.Call localVarCall = getWorkFlowDefinitionsValidateBeforeCall(name, _callback); - Type localVarReturnType = new TypeToken>(){}.getType(); - localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); - return localVarCall; - } + + private ApiClient localVarApiClient; + + private int localHostIndex; + + private String localCustomBaseUrl; + + public WorkflowDefinitionApi() { + this(Configuration.getDefaultApiClient()); + } + + public WorkflowDefinitionApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + /** + * Build call for getWorkFlowDefinitionById + * @param id (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    404Not found-
    + */ + public okhttp3.Call getWorkFlowDefinitionByIdCall(String id, final ApiCallback _callback) throws ApiException { + String basePath = null; + + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } + else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } + else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/api/v1/workflowdefinitions/{id}".replaceAll("\\{" + "id" + "\\}", + localVarApiClient.escapeString(id.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, + localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, + localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getWorkFlowDefinitionByIdValidateBeforeCall(String id, final ApiCallback _callback) + throws ApiException { + + // verify the required parameter 'id' is set + if (id == null) { + throw new ApiException("Missing the required parameter 'id' when calling getWorkFlowDefinitionById(Async)"); + } + + okhttp3.Call localVarCall = getWorkFlowDefinitionByIdCall(id, _callback); + return localVarCall; + + } + + /** + * Returns information about a workflow definition by id + * @param id (required) + * @return WorkFlowDefinitionResponseDTO + * @throws ApiException If fail to call the API, e.g. server error or cannot + * deserialize the response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    404Not found-
    + */ + public WorkFlowDefinitionResponseDTO getWorkFlowDefinitionById(String id) throws ApiException { + ApiResponse localVarResp = getWorkFlowDefinitionByIdWithHttpInfo(id); + return localVarResp.getData(); + } + + /** + * Returns information about a workflow definition by id + * @param id (required) + * @return ApiResponse<WorkFlowDefinitionResponseDTO> + * @throws ApiException If fail to call the API, e.g. server error or cannot + * deserialize the response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    404Not found-
    + */ + public ApiResponse getWorkFlowDefinitionByIdWithHttpInfo(String id) + throws ApiException { + okhttp3.Call localVarCall = getWorkFlowDefinitionByIdValidateBeforeCall(id, null); + Type localVarReturnType = new TypeToken() { + }.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Returns information about a workflow definition by id (asynchronously) + * @param id (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request + * body object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    404Not found-
    + */ + public okhttp3.Call getWorkFlowDefinitionByIdAsync(String id, + final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getWorkFlowDefinitionByIdValidateBeforeCall(id, _callback); + Type localVarReturnType = new TypeToken() { + }.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for getWorkFlowDefinitions + * @param name (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    403Forbidden-
    + */ + public okhttp3.Call getWorkFlowDefinitionsCall(String name, final ApiCallback _callback) throws ApiException { + String basePath = null; + + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } + else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } + else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/api/v1/workflowdefinitions"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (name != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("name", name)); + } + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, + localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, + localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getWorkFlowDefinitionsValidateBeforeCall(String name, final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = getWorkFlowDefinitionsCall(name, _callback); + return localVarCall; + + } + + /** + * Returns a list of workflow definition + * @param name (optional) + * @return List<WorkFlowDefinitionResponseDTO> + * @throws ApiException If fail to call the API, e.g. server error or cannot + * deserialize the response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    403Forbidden-
    + */ + public List getWorkFlowDefinitions(String name) throws ApiException { + ApiResponse> localVarResp = getWorkFlowDefinitionsWithHttpInfo(name); + return localVarResp.getData(); + } + + /** + * Returns a list of workflow definition + * @param name (optional) + * @return ApiResponse<List<WorkFlowDefinitionResponseDTO>> + * @throws ApiException If fail to call the API, e.g. server error or cannot + * deserialize the response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    403Forbidden-
    + */ + public ApiResponse> getWorkFlowDefinitionsWithHttpInfo(String name) + throws ApiException { + okhttp3.Call localVarCall = getWorkFlowDefinitionsValidateBeforeCall(name, null); + Type localVarReturnType = new TypeToken>() { + }.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Returns a list of workflow definition (asynchronously) + * @param name (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request + * body object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Status CodeDescriptionResponse Headers
    200Succeeded-
    401Unauthorized-
    403Forbidden-
    + */ + public okhttp3.Call getWorkFlowDefinitionsAsync(String name, + final ApiCallback> _callback) throws ApiException { + + okhttp3.Call localVarCall = getWorkFlowDefinitionsValidateBeforeCall(name, _callback); + Type localVarReturnType = new TypeToken>() { + }.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + } diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/auth/ApiKeyAuth.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/auth/ApiKeyAuth.java index 0f52de845..efdb3822d 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/auth/ApiKeyAuth.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/auth/ApiKeyAuth.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.api.auth; import com.redhat.parodos.sdk.api.ApiException; @@ -22,59 +21,66 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ApiKeyAuth implements Authentication { - private final String location; - private final String paramName; - - private String apiKey; - private String apiKeyPrefix; - - public ApiKeyAuth(String location, String paramName) { - this.location = location; - this.paramName = paramName; - } - - public String getLocation() { - return location; - } - - public String getParamName() { - return paramName; - } - - public String getApiKey() { - return apiKey; - } - - public void setApiKey(String apiKey) { - this.apiKey = apiKey; - } - - public String getApiKeyPrefix() { - return apiKeyPrefix; - } - - public void setApiKeyPrefix(String apiKeyPrefix) { - this.apiKeyPrefix = apiKeyPrefix; - } - - @Override - public void applyToParams(List queryParams, Map headerParams, Map cookieParams, - String payload, String method, URI uri) throws ApiException { - if (apiKey == null) { - return; - } - String value; - if (apiKeyPrefix != null) { - value = apiKeyPrefix + " " + apiKey; - } else { - value = apiKey; - } - if ("query".equals(location)) { - queryParams.add(new Pair(paramName, value)); - } else if ("header".equals(location)) { - headerParams.put(paramName, value); - } else if ("cookie".equals(location)) { - cookieParams.put(paramName, value); - } - } + + private final String location; + + private final String paramName; + + private String apiKey; + + private String apiKeyPrefix; + + public ApiKeyAuth(String location, String paramName) { + this.location = location; + this.paramName = paramName; + } + + public String getLocation() { + return location; + } + + public String getParamName() { + return paramName; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public String getApiKeyPrefix() { + return apiKeyPrefix; + } + + public void setApiKeyPrefix(String apiKeyPrefix) { + this.apiKeyPrefix = apiKeyPrefix; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, + Map cookieParams, String payload, String method, URI uri) throws ApiException { + if (apiKey == null) { + return; + } + String value; + if (apiKeyPrefix != null) { + value = apiKeyPrefix + " " + apiKey; + } + else { + value = apiKey; + } + if ("query".equals(location)) { + queryParams.add(new Pair(paramName, value)); + } + else if ("header".equals(location)) { + headerParams.put(paramName, value); + } + else if ("cookie".equals(location)) { + cookieParams.put(paramName, value); + } + } + } diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/auth/Authentication.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/auth/Authentication.java index b05447435..2908c87fa 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/auth/Authentication.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/auth/Authentication.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.api.auth; import com.redhat.parodos.sdk.api.Pair; @@ -21,16 +20,18 @@ import java.util.List; public interface Authentication { - /** - * Apply authentication settings to header and query params. - * - * @param queryParams List of query parameters - * @param headerParams Map of header parameters - * @param cookieParams Map of cookie parameters - * @param payload HTTP request body - * @param method HTTP method - * @param uri URI - * @throws ApiException if failed to update the parameters - */ - void applyToParams(List queryParams, Map headerParams, Map cookieParams, String payload, String method, URI uri) throws ApiException; + + /** + * Apply authentication settings to header and query params. + * @param queryParams List of query parameters + * @param headerParams Map of header parameters + * @param cookieParams Map of cookie parameters + * @param payload HTTP request body + * @param method HTTP method + * @param uri URI + * @throws ApiException if failed to update the parameters + */ + void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException; + } diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/auth/HttpBasicAuth.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/auth/HttpBasicAuth.java index 383225b43..5142e3ab9 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/auth/HttpBasicAuth.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/auth/HttpBasicAuth.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.api.auth; import com.redhat.parodos.sdk.api.Pair; @@ -25,33 +24,35 @@ import java.io.UnsupportedEncodingException; public class HttpBasicAuth implements Authentication { - private String username; - private String password; - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - @Override - public void applyToParams(List queryParams, Map headerParams, Map cookieParams, - String payload, String method, URI uri) throws ApiException { - if (username == null && password == null) { - return; - } - headerParams.put("Authorization", Credentials.basic( - username == null ? "" : username, - password == null ? "" : password)); - } + + private String username; + + private String password; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, + Map cookieParams, String payload, String method, URI uri) throws ApiException { + if (username == null && password == null) { + return; + } + headerParams.put("Authorization", + Credentials.basic(username == null ? "" : username, password == null ? "" : password)); + } + } diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/auth/HttpBearerAuth.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/auth/HttpBearerAuth.java index 7ff6a9cb3..fb2592c62 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/auth/HttpBearerAuth.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/api/auth/HttpBearerAuth.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.api.auth; import com.redhat.parodos.sdk.api.ApiException; @@ -22,42 +21,45 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class HttpBearerAuth implements Authentication { - private final String scheme; - private String bearerToken; - - public HttpBearerAuth(String scheme) { - this.scheme = scheme; - } - - /** - * Gets the token, which together with the scheme, will be sent as the value of the Authorization header. - * - * @return The bearer token - */ - public String getBearerToken() { - return bearerToken; - } - - /** - * Sets the token, which together with the scheme, will be sent as the value of the Authorization header. - * - * @param bearerToken The bearer token to send in the Authorization header - */ - public void setBearerToken(String bearerToken) { - this.bearerToken = bearerToken; - } - - @Override - public void applyToParams(List queryParams, Map headerParams, Map cookieParams, - String payload, String method, URI uri) throws ApiException { - if (bearerToken == null) { - return; - } - - headerParams.put("Authorization", (scheme != null ? upperCaseBearer(scheme) + " " : "") + bearerToken); - } - - private static String upperCaseBearer(String scheme) { - return ("bearer".equalsIgnoreCase(scheme)) ? "Bearer" : scheme; - } + + private final String scheme; + + private String bearerToken; + + public HttpBearerAuth(String scheme) { + this.scheme = scheme; + } + + /** + * Gets the token, which together with the scheme, will be sent as the value of the + * Authorization header. + * @return The bearer token + */ + public String getBearerToken() { + return bearerToken; + } + + /** + * Sets the token, which together with the scheme, will be sent as the value of the + * Authorization header. + * @param bearerToken The bearer token to send in the Authorization header + */ + public void setBearerToken(String bearerToken) { + this.bearerToken = bearerToken; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, + Map cookieParams, String payload, String method, URI uri) throws ApiException { + if (bearerToken == null) { + return; + } + + headerParams.put("Authorization", (scheme != null ? upperCaseBearer(scheme) + " " : "") + bearerToken); + } + + private static String upperCaseBearer(String scheme) { + return ("bearer".equalsIgnoreCase(scheme)) ? "Bearer" : scheme; + } + } diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/ArgumentRequestDTO.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/ArgumentRequestDTO.java index 4ba315ced..61c9edee6 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/ArgumentRequestDTO.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/ArgumentRequestDTO.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import java.util.Objects; @@ -27,104 +26,103 @@ /** * ArgumentRequestDTO */ -@lombok.Data @lombok.AllArgsConstructor @lombok.Builder +@lombok.Data +@lombok.AllArgsConstructor +@lombok.Builder @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ArgumentRequestDTO { - public static final String SERIALIZED_NAME_KEY = "key"; - @SerializedName(SERIALIZED_NAME_KEY) - private String key; - - public static final String SERIALIZED_NAME_VALUE = "value"; - @SerializedName(SERIALIZED_NAME_VALUE) - private String value; - - public ArgumentRequestDTO() { - } - - public ArgumentRequestDTO key(String key) { - - this.key = key; - return this; - } - - /** - * Get key - * @return key - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getKey() { - return key; - } - - - public void setKey(String key) { - this.key = key; - } - - - public ArgumentRequestDTO value(String value) { - - this.value = value; - return this; - } - - /** - * Get value - * @return value - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getValue() { - return value; - } - - - public void setValue(String value) { - this.value = value; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ArgumentRequestDTO argumentRequestDTO = (ArgumentRequestDTO) o; - return Objects.equals(this.key, argumentRequestDTO.key) && - Objects.equals(this.value, argumentRequestDTO.value); - } - - @Override - public int hashCode() { - return Objects.hash(key, value); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ArgumentRequestDTO {\n"); - sb.append(" key: ").append(toIndentedString(key)).append("\n"); - sb.append(" value: ").append(toIndentedString(value)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} + public static final String SERIALIZED_NAME_KEY = "key"; + + @SerializedName(SERIALIZED_NAME_KEY) + private String key; + + public static final String SERIALIZED_NAME_VALUE = "value"; + + @SerializedName(SERIALIZED_NAME_VALUE) + private String value; + + public ArgumentRequestDTO() { + } + + public ArgumentRequestDTO key(String key) { + + this.key = key; + return this; + } + + /** + * Get key + * @return key + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public ArgumentRequestDTO value(String value) { + + this.value = value; + return this; + } + + /** + * Get value + * @return value + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArgumentRequestDTO argumentRequestDTO = (ArgumentRequestDTO) o; + return Objects.equals(this.key, argumentRequestDTO.key) && Objects.equals(this.value, argumentRequestDTO.value); + } + + @Override + public int hashCode() { + return Objects.hash(key, value); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArgumentRequestDTO {\n"); + sb.append(" key: ").append(toIndentedString(key)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the + * first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/ProjectRequestDTO.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/ProjectRequestDTO.java index 346fe6e86..2faec6f14 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/ProjectRequestDTO.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/ProjectRequestDTO.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import java.util.Objects; @@ -27,104 +26,104 @@ /** * ProjectRequestDTO */ -@lombok.Data @lombok.AllArgsConstructor @lombok.Builder +@lombok.Data +@lombok.AllArgsConstructor +@lombok.Builder @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ProjectRequestDTO { - public static final String SERIALIZED_NAME_DESCRIPTION = "description"; - @SerializedName(SERIALIZED_NAME_DESCRIPTION) - private String description; - - public static final String SERIALIZED_NAME_NAME = "name"; - @SerializedName(SERIALIZED_NAME_NAME) - private String name; - - public ProjectRequestDTO() { - } - - public ProjectRequestDTO description(String description) { - - this.description = description; - return this; - } - - /** - * Get description - * @return description - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getDescription() { - return description; - } - - - public void setDescription(String description) { - this.description = description; - } - - - public ProjectRequestDTO name(String name) { - - this.name = name; - return this; - } - - /** - * Get name - * @return name - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getName() { - return name; - } - - - public void setName(String name) { - this.name = name; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ProjectRequestDTO projectRequestDTO = (ProjectRequestDTO) o; - return Objects.equals(this.description, projectRequestDTO.description) && - Objects.equals(this.name, projectRequestDTO.name); - } - - @Override - public int hashCode() { - return Objects.hash(description, name); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ProjectRequestDTO {\n"); - sb.append(" description: ").append(toIndentedString(description)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + private String description; + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public ProjectRequestDTO() { + } + + public ProjectRequestDTO description(String description) { + + this.description = description; + return this; + } + + /** + * Get description + * @return description + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public ProjectRequestDTO name(String name) { + + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ProjectRequestDTO projectRequestDTO = (ProjectRequestDTO) o; + return Objects.equals(this.description, projectRequestDTO.description) + && Objects.equals(this.name, projectRequestDTO.name); + } + + @Override + public int hashCode() { + return Objects.hash(description, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ProjectRequestDTO {\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the + * first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/ProjectResponseDTO.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/ProjectResponseDTO.java index baeb961f6..fbeff7eea 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/ProjectResponseDTO.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/ProjectResponseDTO.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import java.util.Objects; @@ -28,220 +27,216 @@ /** * ProjectResponseDTO */ -@lombok.Data @lombok.AllArgsConstructor @lombok.Builder +@lombok.Data +@lombok.AllArgsConstructor +@lombok.Builder @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ProjectResponseDTO { - public static final String SERIALIZED_NAME_CREATE_DATE = "createDate"; - @SerializedName(SERIALIZED_NAME_CREATE_DATE) - private Date createDate; - public static final String SERIALIZED_NAME_DESCRIPTION = "description"; - @SerializedName(SERIALIZED_NAME_DESCRIPTION) - private String description; - - public static final String SERIALIZED_NAME_ID = "id"; - @SerializedName(SERIALIZED_NAME_ID) - private String id; - - public static final String SERIALIZED_NAME_MODIFY_DATE = "modifyDate"; - @SerializedName(SERIALIZED_NAME_MODIFY_DATE) - private Date modifyDate; + public static final String SERIALIZED_NAME_CREATE_DATE = "createDate"; - public static final String SERIALIZED_NAME_NAME = "name"; - @SerializedName(SERIALIZED_NAME_NAME) - private String name; + @SerializedName(SERIALIZED_NAME_CREATE_DATE) + private Date createDate; - public static final String SERIALIZED_NAME_USERNAME = "username"; - @SerializedName(SERIALIZED_NAME_USERNAME) - private String username; + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; - public ProjectResponseDTO() { - } + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + private String description; - public ProjectResponseDTO createDate(Date createDate) { - - this.createDate = createDate; - return this; - } + public static final String SERIALIZED_NAME_ID = "id"; - /** - * Get createDate - * @return createDate - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @SerializedName(SERIALIZED_NAME_ID) + private String id; - public Date getCreateDate() { - return createDate; - } + public static final String SERIALIZED_NAME_MODIFY_DATE = "modifyDate"; + @SerializedName(SERIALIZED_NAME_MODIFY_DATE) + private Date modifyDate; - public void setCreateDate(Date createDate) { - this.createDate = createDate; - } + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; - public ProjectResponseDTO description(String description) { - - this.description = description; - return this; - } + public static final String SERIALIZED_NAME_USERNAME = "username"; - /** - * Get description - * @return description - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @SerializedName(SERIALIZED_NAME_USERNAME) + private String username; - public String getDescription() { - return description; - } + public ProjectResponseDTO() { + } + public ProjectResponseDTO createDate(Date createDate) { - public void setDescription(String description) { - this.description = description; - } + this.createDate = createDate; + return this; + } + /** + * Get createDate + * @return createDate + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") - public ProjectResponseDTO id(String id) { - - this.id = id; - return this; - } - - /** - * Get id - * @return id - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getId() { - return id; - } - - - public void setId(String id) { - this.id = id; - } - - - public ProjectResponseDTO modifyDate(Date modifyDate) { - - this.modifyDate = modifyDate; - return this; - } - - /** - * Get modifyDate - * @return modifyDate - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public Date getModifyDate() { - return modifyDate; - } - - - public void setModifyDate(Date modifyDate) { - this.modifyDate = modifyDate; - } - - - public ProjectResponseDTO name(String name) { - - this.name = name; - return this; - } - - /** - * Get name - * @return name - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getName() { - return name; - } - - - public void setName(String name) { - this.name = name; - } - - - public ProjectResponseDTO username(String username) { - - this.username = username; - return this; - } - - /** - * Get username - * @return username - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getUsername() { - return username; - } - - - public void setUsername(String username) { - this.username = username; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ProjectResponseDTO projectResponseDTO = (ProjectResponseDTO) o; - return Objects.equals(this.createDate, projectResponseDTO.createDate) && - Objects.equals(this.description, projectResponseDTO.description) && - Objects.equals(this.id, projectResponseDTO.id) && - Objects.equals(this.modifyDate, projectResponseDTO.modifyDate) && - Objects.equals(this.name, projectResponseDTO.name) && - Objects.equals(this.username, projectResponseDTO.username); - } - - @Override - public int hashCode() { - return Objects.hash(createDate, description, id, modifyDate, name, username); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ProjectResponseDTO {\n"); - sb.append(" createDate: ").append(toIndentedString(createDate)).append("\n"); - sb.append(" description: ").append(toIndentedString(description)).append("\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" modifyDate: ").append(toIndentedString(modifyDate)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" username: ").append(toIndentedString(username)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } + public Date getCreateDate() { + return createDate; + } -} + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } + + public ProjectResponseDTO description(String description) { + + this.description = description; + return this; + } + + /** + * Get description + * @return description + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public ProjectResponseDTO id(String id) { + + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public ProjectResponseDTO modifyDate(Date modifyDate) { + + this.modifyDate = modifyDate; + return this; + } + + /** + * Get modifyDate + * @return modifyDate + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public Date getModifyDate() { + return modifyDate; + } + + public void setModifyDate(Date modifyDate) { + this.modifyDate = modifyDate; + } + + public ProjectResponseDTO name(String name) { + + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ProjectResponseDTO username(String username) { + + this.username = username; + return this; + } + + /** + * Get username + * @return username + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ProjectResponseDTO projectResponseDTO = (ProjectResponseDTO) o; + return Objects.equals(this.createDate, projectResponseDTO.createDate) + && Objects.equals(this.description, projectResponseDTO.description) + && Objects.equals(this.id, projectResponseDTO.id) + && Objects.equals(this.modifyDate, projectResponseDTO.modifyDate) + && Objects.equals(this.name, projectResponseDTO.name) + && Objects.equals(this.username, projectResponseDTO.username); + } + + @Override + public int hashCode() { + return Objects.hash(createDate, description, id, modifyDate, name, username); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ProjectResponseDTO {\n"); + sb.append(" createDate: ").append(toIndentedString(createDate)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" modifyDate: ").append(toIndentedString(modifyDate)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the + * first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkDefinitionResponseDTO.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkDefinitionResponseDTO.java index 521e5d8dd..85f30c310 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkDefinitionResponseDTO.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkDefinitionResponseDTO.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import java.util.Objects; @@ -31,353 +30,351 @@ /** * WorkDefinitionResponseDTO */ -@lombok.Data @lombok.AllArgsConstructor @lombok.Builder +@lombok.Data +@lombok.AllArgsConstructor +@lombok.Builder @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class WorkDefinitionResponseDTO { - public static final String SERIALIZED_NAME_AUTHOR = "author"; - @SerializedName(SERIALIZED_NAME_AUTHOR) - private String author; - - public static final String SERIALIZED_NAME_ID = "id"; - @SerializedName(SERIALIZED_NAME_ID) - private String id; - - public static final String SERIALIZED_NAME_NAME = "name"; - @SerializedName(SERIALIZED_NAME_NAME) - private String name; - - /** - * Gets or Sets outputs - */ - @JsonAdapter(OutputsEnum.Adapter.class) - public enum OutputsEnum { - EXCEPTION("EXCEPTION"), - - HTTP2XX("HTTP2XX"), - - NO_EXCEPTION("NO_EXCEPTION"), - - OTHER("OTHER"); - - private String value; - - OutputsEnum(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - public static OutputsEnum fromValue(String value) { - for (OutputsEnum b : OutputsEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final OutputsEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public OutputsEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return OutputsEnum.fromValue(value); - } - } - } - - public static final String SERIALIZED_NAME_OUTPUTS = "outputs"; - @SerializedName(SERIALIZED_NAME_OUTPUTS) - private List outputs = null; - - public static final String SERIALIZED_NAME_PARAMETERS = "parameters"; - @SerializedName(SERIALIZED_NAME_PARAMETERS) - private Map> parameters = null; - - public static final String SERIALIZED_NAME_PROCESSING_TYPE = "processingType"; - @SerializedName(SERIALIZED_NAME_PROCESSING_TYPE) - private String processingType; - - public static final String SERIALIZED_NAME_WORK_TYPE = "workType"; - @SerializedName(SERIALIZED_NAME_WORK_TYPE) - private String workType; - - public static final String SERIALIZED_NAME_WORKS = "works"; - @SerializedName(SERIALIZED_NAME_WORKS) - private List works = null; - - public WorkDefinitionResponseDTO() { - } - - public WorkDefinitionResponseDTO author(String author) { - - this.author = author; - return this; - } - - /** - * Get author - * @return author - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getAuthor() { - return author; - } - - - public void setAuthor(String author) { - this.author = author; - } - - - public WorkDefinitionResponseDTO id(String id) { - - this.id = id; - return this; - } - - /** - * Get id - * @return id - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getId() { - return id; - } - - - public void setId(String id) { - this.id = id; - } - - - public WorkDefinitionResponseDTO name(String name) { - - this.name = name; - return this; - } - - /** - * Get name - * @return name - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getName() { - return name; - } - - - public void setName(String name) { - this.name = name; - } - - - public WorkDefinitionResponseDTO outputs(List outputs) { - - this.outputs = outputs; - return this; - } - - public WorkDefinitionResponseDTO addOutputsItem(OutputsEnum outputsItem) { - if (this.outputs == null) { - this.outputs = new ArrayList(); - } - this.outputs.add(outputsItem); - return this; - } - /** - * Get outputs - * @return outputs - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public List getOutputs() { - return outputs; - } - - - public void setOutputs(List outputs) { - this.outputs = outputs; - } - - - public WorkDefinitionResponseDTO parameters(Map> parameters) { - - this.parameters = parameters; - return this; - } - - public WorkDefinitionResponseDTO putParametersItem(String key, Map parametersItem) { - if (this.parameters == null) { - this.parameters = new HashMap>(); - } - this.parameters.put(key, parametersItem); - return this; - } - - /** - * Get parameters - * @return parameters - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public Map> getParameters() { - return parameters; - } - - - public void setParameters(Map> parameters) { - this.parameters = parameters; - } - - - public WorkDefinitionResponseDTO processingType(String processingType) { - - this.processingType = processingType; - return this; - } - - /** - * Get processingType - * @return processingType - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getProcessingType() { - return processingType; - } - - - public void setProcessingType(String processingType) { - this.processingType = processingType; - } - - - public WorkDefinitionResponseDTO workType(String workType) { - - this.workType = workType; - return this; - } - - /** - * Get workType - * @return workType - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getWorkType() { - return workType; - } - - - public void setWorkType(String workType) { - this.workType = workType; - } - - - public WorkDefinitionResponseDTO works(List works) { - - this.works = works; - return this; - } - - public WorkDefinitionResponseDTO addWorksItem(WorkDefinitionResponseDTO worksItem) { - if (this.works == null) { - this.works = new ArrayList(); - } - this.works.add(worksItem); - return this; - } - - /** - * Get works - * @return works - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public List getWorks() { - return works; - } - - - public void setWorks(List works) { - this.works = works; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - WorkDefinitionResponseDTO workDefinitionResponseDTO = (WorkDefinitionResponseDTO) o; - return Objects.equals(this.author, workDefinitionResponseDTO.author) && - Objects.equals(this.id, workDefinitionResponseDTO.id) && - Objects.equals(this.name, workDefinitionResponseDTO.name) && - Objects.equals(this.outputs, workDefinitionResponseDTO.outputs) && - Objects.equals(this.parameters, workDefinitionResponseDTO.parameters) && - Objects.equals(this.processingType, workDefinitionResponseDTO.processingType) && - Objects.equals(this.workType, workDefinitionResponseDTO.workType) && - Objects.equals(this.works, workDefinitionResponseDTO.works); - } - - @Override - public int hashCode() { - return Objects.hash(author, id, name, outputs, parameters, processingType, workType, works); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class WorkDefinitionResponseDTO {\n"); - sb.append(" author: ").append(toIndentedString(author)).append("\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" outputs: ").append(toIndentedString(outputs)).append("\n"); - sb.append(" parameters: ").append(toIndentedString(parameters)).append("\n"); - sb.append(" processingType: ").append(toIndentedString(processingType)).append("\n"); - sb.append(" workType: ").append(toIndentedString(workType)).append("\n"); - sb.append(" works: ").append(toIndentedString(works)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } + public static final String SERIALIZED_NAME_AUTHOR = "author"; -} + @SerializedName(SERIALIZED_NAME_AUTHOR) + private String author; + + public static final String SERIALIZED_NAME_ID = "id"; + + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + /** + * Gets or Sets outputs + */ + @JsonAdapter(OutputsEnum.Adapter.class) + public enum OutputsEnum { + + EXCEPTION("EXCEPTION"), + + HTTP2XX("HTTP2XX"), + + NO_EXCEPTION("NO_EXCEPTION"), + + OTHER("OTHER"); + + private String value; + + OutputsEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static OutputsEnum fromValue(String value) { + for (OutputsEnum b : OutputsEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write(final JsonWriter jsonWriter, final OutputsEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public OutputsEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return OutputsEnum.fromValue(value); + } + + } + + } + + public static final String SERIALIZED_NAME_OUTPUTS = "outputs"; + + @SerializedName(SERIALIZED_NAME_OUTPUTS) + private List outputs = null; + + public static final String SERIALIZED_NAME_PARAMETERS = "parameters"; + + @SerializedName(SERIALIZED_NAME_PARAMETERS) + private Map> parameters = null; + + public static final String SERIALIZED_NAME_PROCESSING_TYPE = "processingType"; + @SerializedName(SERIALIZED_NAME_PROCESSING_TYPE) + private String processingType; + + public static final String SERIALIZED_NAME_WORK_TYPE = "workType"; + + @SerializedName(SERIALIZED_NAME_WORK_TYPE) + private String workType; + + public static final String SERIALIZED_NAME_WORKS = "works"; + + @SerializedName(SERIALIZED_NAME_WORKS) + private List works = null; + + public WorkDefinitionResponseDTO() { + } + + public WorkDefinitionResponseDTO author(String author) { + + this.author = author; + return this; + } + + /** + * Get author + * @return author + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } + + public WorkDefinitionResponseDTO id(String id) { + + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public WorkDefinitionResponseDTO name(String name) { + + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public WorkDefinitionResponseDTO outputs(List outputs) { + + this.outputs = outputs; + return this; + } + + public WorkDefinitionResponseDTO addOutputsItem(OutputsEnum outputsItem) { + if (this.outputs == null) { + this.outputs = new ArrayList(); + } + this.outputs.add(outputsItem); + return this; + } + + /** + * Get outputs + * @return outputs + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getOutputs() { + return outputs; + } + + public void setOutputs(List outputs) { + this.outputs = outputs; + } + + public WorkDefinitionResponseDTO parameters(Map> parameters) { + + this.parameters = parameters; + return this; + } + + public WorkDefinitionResponseDTO putParametersItem(String key, Map parametersItem) { + if (this.parameters == null) { + this.parameters = new HashMap>(); + } + this.parameters.put(key, parametersItem); + return this; + } + + /** + * Get parameters + * @return parameters + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public Map> getParameters() { + return parameters; + } + + public void setParameters(Map> parameters) { + this.parameters = parameters; + } + + public WorkDefinitionResponseDTO processingType(String processingType) { + + this.processingType = processingType; + return this; + } + + /** + * Get processingType + * @return processingType + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getProcessingType() { + return processingType; + } + + public void setProcessingType(String processingType) { + this.processingType = processingType; + } + + public WorkDefinitionResponseDTO workType(String workType) { + + this.workType = workType; + return this; + } + + /** + * Get workType + * @return workType + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getWorkType() { + return workType; + } + + public void setWorkType(String workType) { + this.workType = workType; + } + + public WorkDefinitionResponseDTO works(List works) { + + this.works = works; + return this; + } + + public WorkDefinitionResponseDTO addWorksItem(WorkDefinitionResponseDTO worksItem) { + if (this.works == null) { + this.works = new ArrayList(); + } + this.works.add(worksItem); + return this; + } + + /** + * Get works + * @return works + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getWorks() { + return works; + } + + public void setWorks(List works) { + this.works = works; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WorkDefinitionResponseDTO workDefinitionResponseDTO = (WorkDefinitionResponseDTO) o; + return Objects.equals(this.author, workDefinitionResponseDTO.author) + && Objects.equals(this.id, workDefinitionResponseDTO.id) + && Objects.equals(this.name, workDefinitionResponseDTO.name) + && Objects.equals(this.outputs, workDefinitionResponseDTO.outputs) + && Objects.equals(this.parameters, workDefinitionResponseDTO.parameters) + && Objects.equals(this.processingType, workDefinitionResponseDTO.processingType) + && Objects.equals(this.workType, workDefinitionResponseDTO.workType) + && Objects.equals(this.works, workDefinitionResponseDTO.works); + } + + @Override + public int hashCode() { + return Objects.hash(author, id, name, outputs, parameters, processingType, workType, works); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WorkDefinitionResponseDTO {\n"); + sb.append(" author: ").append(toIndentedString(author)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" outputs: ").append(toIndentedString(outputs)).append("\n"); + sb.append(" parameters: ").append(toIndentedString(parameters)).append("\n"); + sb.append(" processingType: ").append(toIndentedString(processingType)).append("\n"); + sb.append(" workType: ").append(toIndentedString(workType)).append("\n"); + sb.append(" works: ").append(toIndentedString(works)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the + * first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowCheckerTaskRequestDTO.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowCheckerTaskRequestDTO.java index 652192319..c53861f1a 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowCheckerTaskRequestDTO.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowCheckerTaskRequestDTO.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import java.util.Objects; @@ -27,126 +26,133 @@ /** * WorkFlowCheckerTaskRequestDTO */ -@lombok.Data @lombok.AllArgsConstructor @lombok.Builder +@lombok.Data +@lombok.AllArgsConstructor +@lombok.Builder @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class WorkFlowCheckerTaskRequestDTO { - /** - * Gets or Sets status - */ - @JsonAdapter(StatusEnum.Adapter.class) - public enum StatusEnum { - FAILED("FAILED"), - - COMPLETED("COMPLETED"), - - IN_PROGRESS("IN_PROGRESS"), - - PENDING("PENDING"); - - private String value; - - StatusEnum(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - public static StatusEnum fromValue(String value) { - for (StatusEnum b : StatusEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public StatusEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return StatusEnum.fromValue(value); - } - } - } - - public static final String SERIALIZED_NAME_STATUS = "status"; - @SerializedName(SERIALIZED_NAME_STATUS) - private StatusEnum status; - - public WorkFlowCheckerTaskRequestDTO() { - } - - public WorkFlowCheckerTaskRequestDTO status(StatusEnum status) { - - this.status = status; - return this; - } - - /** - * Get status - * @return status - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public StatusEnum getStatus() { - return status; - } - - - public void setStatus(StatusEnum status) { - this.status = status; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - WorkFlowCheckerTaskRequestDTO workFlowCheckerTaskRequestDTO = (WorkFlowCheckerTaskRequestDTO) o; - return Objects.equals(this.status, workFlowCheckerTaskRequestDTO.status); - } - - @Override - public int hashCode() { - return Objects.hash(status); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class WorkFlowCheckerTaskRequestDTO {\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} + /** + * Gets or Sets status + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + + FAILED("FAILED"), + + COMPLETED("COMPLETED"), + IN_PROGRESS("IN_PROGRESS"), + + PENDING("PENDING"), + + REJECTED("REJECTED"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + + } + + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + + @SerializedName(SERIALIZED_NAME_STATUS) + private StatusEnum status; + + public WorkFlowCheckerTaskRequestDTO() { + } + + public WorkFlowCheckerTaskRequestDTO status(StatusEnum status) { + + this.status = status; + return this; + } + + /** + * Get status + * @return status + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public StatusEnum getStatus() { + return status; + } + + public void setStatus(StatusEnum status) { + this.status = status; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WorkFlowCheckerTaskRequestDTO workFlowCheckerTaskRequestDTO = (WorkFlowCheckerTaskRequestDTO) o; + return Objects.equals(this.status, workFlowCheckerTaskRequestDTO.status); + } + + @Override + public int hashCode() { + return Objects.hash(status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WorkFlowCheckerTaskRequestDTO {\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the + * first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowDefinitionResponseDTO.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowDefinitionResponseDTO.java index 1506cf985..55f3d11a6 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowDefinitionResponseDTO.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowDefinitionResponseDTO.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import java.util.Objects; @@ -35,352 +34,345 @@ /** * WorkFlowDefinitionResponseDTO */ -@lombok.Data @lombok.AllArgsConstructor @lombok.Builder +@lombok.Data +@lombok.AllArgsConstructor +@lombok.Builder @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class WorkFlowDefinitionResponseDTO { - public static final String SERIALIZED_NAME_AUTHOR = "author"; - @SerializedName(SERIALIZED_NAME_AUTHOR) - private String author; - - public static final String SERIALIZED_NAME_CREATE_DATE = "createDate"; - @SerializedName(SERIALIZED_NAME_CREATE_DATE) - private Date createDate; - - public static final String SERIALIZED_NAME_ID = "id"; - @SerializedName(SERIALIZED_NAME_ID) - private UUID id; - - public static final String SERIALIZED_NAME_MODIFY_DATE = "modifyDate"; - @SerializedName(SERIALIZED_NAME_MODIFY_DATE) - private Date modifyDate; - public static final String SERIALIZED_NAME_NAME = "name"; - @SerializedName(SERIALIZED_NAME_NAME) - private String name; + public static final String SERIALIZED_NAME_AUTHOR = "author"; - public static final String SERIALIZED_NAME_PARAMETERS = "parameters"; - @SerializedName(SERIALIZED_NAME_PARAMETERS) - private Map> parameters = null; - - public static final String SERIALIZED_NAME_PROCESSING_TYPE = "processingType"; - @SerializedName(SERIALIZED_NAME_PROCESSING_TYPE) - private String processingType; - - public static final String SERIALIZED_NAME_PROPERTIES = "properties"; - @SerializedName(SERIALIZED_NAME_PROPERTIES) - private WorkFlowPropertiesDefinitionDTO properties; + @SerializedName(SERIALIZED_NAME_AUTHOR) + private String author; - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) - private String type; + public static final String SERIALIZED_NAME_CREATE_DATE = "createDate"; - public static final String SERIALIZED_NAME_WORKS = "works"; - @SerializedName(SERIALIZED_NAME_WORKS) - private List works = null; + @SerializedName(SERIALIZED_NAME_CREATE_DATE) + private Date createDate; - public WorkFlowDefinitionResponseDTO() { - } + public static final String SERIALIZED_NAME_ID = "id"; - public WorkFlowDefinitionResponseDTO author(String author) { - - this.author = author; - return this; - } + @SerializedName(SERIALIZED_NAME_ID) + private UUID id; - /** - * Get author - * @return author - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + public static final String SERIALIZED_NAME_MODIFY_DATE = "modifyDate"; - public String getAuthor() { - return author; - } + @SerializedName(SERIALIZED_NAME_MODIFY_DATE) + private Date modifyDate; + public static final String SERIALIZED_NAME_NAME = "name"; - public void setAuthor(String author) { - this.author = author; - } + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + public static final String SERIALIZED_NAME_PARAMETERS = "parameters"; - public WorkFlowDefinitionResponseDTO createDate(Date createDate) { - - this.createDate = createDate; - return this; - } + @SerializedName(SERIALIZED_NAME_PARAMETERS) + private Map> parameters = null; - /** - * Get createDate - * @return createDate - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + public static final String SERIALIZED_NAME_PROCESSING_TYPE = "processingType"; - public Date getCreateDate() { - return createDate; - } + @SerializedName(SERIALIZED_NAME_PROCESSING_TYPE) + private String processingType; + public static final String SERIALIZED_NAME_PROPERTIES = "properties"; - public void setCreateDate(Date createDate) { - this.createDate = createDate; - } + @SerializedName(SERIALIZED_NAME_PROPERTIES) + private WorkFlowPropertiesDefinitionDTO properties; + public static final String SERIALIZED_NAME_TYPE = "type"; - public WorkFlowDefinitionResponseDTO id(UUID id) { - - this.id = id; - return this; - } + @SerializedName(SERIALIZED_NAME_TYPE) + private String type; - /** - * Get id - * @return id - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + public static final String SERIALIZED_NAME_WORKS = "works"; - public UUID getId() { - return id; - } + @SerializedName(SERIALIZED_NAME_WORKS) + private List works = null; + public WorkFlowDefinitionResponseDTO() { + } - public void setId(UUID id) { - this.id = id; - } + public WorkFlowDefinitionResponseDTO author(String author) { + this.author = author; + return this; + } - public WorkFlowDefinitionResponseDTO modifyDate(Date modifyDate) { - - this.modifyDate = modifyDate; - return this; - } + /** + * Get author + * @return author + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") - /** - * Get modifyDate - * @return modifyDate - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + public String getAuthor() { + return author; + } - public Date getModifyDate() { - return modifyDate; - } + public void setAuthor(String author) { + this.author = author; + } + public WorkFlowDefinitionResponseDTO createDate(Date createDate) { - public void setModifyDate(Date modifyDate) { - this.modifyDate = modifyDate; - } + this.createDate = createDate; + return this; + } + /** + * Get createDate + * @return createDate + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") - public WorkFlowDefinitionResponseDTO name(String name) { - - this.name = name; - return this; - } + public Date getCreateDate() { + return createDate; + } - /** - * Get name - * @return name - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } - public String getName() { - return name; - } + public WorkFlowDefinitionResponseDTO id(UUID id) { + this.id = id; + return this; + } - public void setName(String name) { - this.name = name; - } + /** + * Get id + * @return id + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + public UUID getId() { + return id; + } - public WorkFlowDefinitionResponseDTO parameters(Map> parameters) { - - this.parameters = parameters; - return this; - } + public void setId(UUID id) { + this.id = id; + } - public WorkFlowDefinitionResponseDTO putParametersItem(String key, Map parametersItem) { - if (this.parameters == null) { - this.parameters = new HashMap>(); - } - this.parameters.put(key, parametersItem); - return this; - } + public WorkFlowDefinitionResponseDTO modifyDate(Date modifyDate) { - /** - * Get parameters - * @return parameters - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + this.modifyDate = modifyDate; + return this; + } - public Map> getParameters() { - return parameters; - } + /** + * Get modifyDate + * @return modifyDate + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + public Date getModifyDate() { + return modifyDate; + } - public void setParameters(Map> parameters) { - this.parameters = parameters; - } + public void setModifyDate(Date modifyDate) { + this.modifyDate = modifyDate; + } - - public WorkFlowDefinitionResponseDTO processingType(String processingType) { - - this.processingType = processingType; - return this; - } - - /** - * Get processingType - * @return processingType - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getProcessingType() { - return processingType; - } - - - public void setProcessingType(String processingType) { - this.processingType = processingType; - } - - - public WorkFlowDefinitionResponseDTO properties(WorkFlowPropertiesDefinitionDTO properties) { - - this.properties = properties; - return this; - } - - /** - * Get properties - * @return properties - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public WorkFlowPropertiesDefinitionDTO getProperties() { - return properties; - } - - - public void setProperties(WorkFlowPropertiesDefinitionDTO properties) { - this.properties = properties; - } - - - public WorkFlowDefinitionResponseDTO type(String type) { - - this.type = type; - return this; - } - - /** - * Get type - * @return type - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getType() { - return type; - } - - - public void setType(String type) { - this.type = type; - } - - - public WorkFlowDefinitionResponseDTO works(List works) { - - this.works = works; - return this; - } - - public WorkFlowDefinitionResponseDTO addWorksItem(WorkDefinitionResponseDTO worksItem) { - if (this.works == null) { - this.works = new ArrayList(); - } - this.works.add(worksItem); - return this; - } - - /** - * Get works - * @return works - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public List getWorks() { - return works; - } - - - public void setWorks(List works) { - this.works = works; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - WorkFlowDefinitionResponseDTO workFlowDefinitionResponseDTO = (WorkFlowDefinitionResponseDTO) o; - return Objects.equals(this.author, workFlowDefinitionResponseDTO.author) && - Objects.equals(this.createDate, workFlowDefinitionResponseDTO.createDate) && - Objects.equals(this.id, workFlowDefinitionResponseDTO.id) && - Objects.equals(this.modifyDate, workFlowDefinitionResponseDTO.modifyDate) && - Objects.equals(this.name, workFlowDefinitionResponseDTO.name) && - Objects.equals(this.parameters, workFlowDefinitionResponseDTO.parameters) && - Objects.equals(this.processingType, workFlowDefinitionResponseDTO.processingType) && - Objects.equals(this.properties, workFlowDefinitionResponseDTO.properties) && - Objects.equals(this.type, workFlowDefinitionResponseDTO.type) && - Objects.equals(this.works, workFlowDefinitionResponseDTO.works); - } - - @Override - public int hashCode() { - return Objects.hash(author, createDate, id, modifyDate, name, parameters, processingType, properties, type, works); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class WorkFlowDefinitionResponseDTO {\n"); - sb.append(" author: ").append(toIndentedString(author)).append("\n"); - sb.append(" createDate: ").append(toIndentedString(createDate)).append("\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" modifyDate: ").append(toIndentedString(modifyDate)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" parameters: ").append(toIndentedString(parameters)).append("\n"); - sb.append(" processingType: ").append(toIndentedString(processingType)).append("\n"); - sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" works: ").append(toIndentedString(works)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } + public WorkFlowDefinitionResponseDTO name(String name) { + + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public WorkFlowDefinitionResponseDTO parameters(Map> parameters) { + + this.parameters = parameters; + return this; + } + + public WorkFlowDefinitionResponseDTO putParametersItem(String key, Map parametersItem) { + if (this.parameters == null) { + this.parameters = new HashMap>(); + } + this.parameters.put(key, parametersItem); + return this; + } + + /** + * Get parameters + * @return parameters + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public Map> getParameters() { + return parameters; + } + + public void setParameters(Map> parameters) { + this.parameters = parameters; + } + + public WorkFlowDefinitionResponseDTO processingType(String processingType) { + + this.processingType = processingType; + return this; + } + + /** + * Get processingType + * @return processingType + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getProcessingType() { + return processingType; + } + + public void setProcessingType(String processingType) { + this.processingType = processingType; + } + + public WorkFlowDefinitionResponseDTO properties(WorkFlowPropertiesDefinitionDTO properties) { + + this.properties = properties; + return this; + } + + /** + * Get properties + * @return properties + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public WorkFlowPropertiesDefinitionDTO getProperties() { + return properties; + } + + public void setProperties(WorkFlowPropertiesDefinitionDTO properties) { + this.properties = properties; + } + + public WorkFlowDefinitionResponseDTO type(String type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public WorkFlowDefinitionResponseDTO works(List works) { + + this.works = works; + return this; + } + + public WorkFlowDefinitionResponseDTO addWorksItem(WorkDefinitionResponseDTO worksItem) { + if (this.works == null) { + this.works = new ArrayList(); + } + this.works.add(worksItem); + return this; + } + + /** + * Get works + * @return works + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getWorks() { + return works; + } + + public void setWorks(List works) { + this.works = works; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WorkFlowDefinitionResponseDTO workFlowDefinitionResponseDTO = (WorkFlowDefinitionResponseDTO) o; + return Objects.equals(this.author, workFlowDefinitionResponseDTO.author) + && Objects.equals(this.createDate, workFlowDefinitionResponseDTO.createDate) + && Objects.equals(this.id, workFlowDefinitionResponseDTO.id) + && Objects.equals(this.modifyDate, workFlowDefinitionResponseDTO.modifyDate) + && Objects.equals(this.name, workFlowDefinitionResponseDTO.name) + && Objects.equals(this.parameters, workFlowDefinitionResponseDTO.parameters) + && Objects.equals(this.processingType, workFlowDefinitionResponseDTO.processingType) + && Objects.equals(this.properties, workFlowDefinitionResponseDTO.properties) + && Objects.equals(this.type, workFlowDefinitionResponseDTO.type) + && Objects.equals(this.works, workFlowDefinitionResponseDTO.works); + } + + @Override + public int hashCode() { + return Objects.hash(author, createDate, id, modifyDate, name, parameters, processingType, properties, type, + works); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WorkFlowDefinitionResponseDTO {\n"); + sb.append(" author: ").append(toIndentedString(author)).append("\n"); + sb.append(" createDate: ").append(toIndentedString(createDate)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" modifyDate: ").append(toIndentedString(modifyDate)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" parameters: ").append(toIndentedString(parameters)).append("\n"); + sb.append(" processingType: ").append(toIndentedString(processingType)).append("\n"); + sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" works: ").append(toIndentedString(works)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the + * first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } } - diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowOption.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowOption.java index b55eb2a54..1672fe12a 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowOption.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowOption.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import java.util.Objects; @@ -29,199 +28,196 @@ /** * WorkFlowOption */ -@lombok.Data @lombok.AllArgsConstructor @lombok.Builder +@lombok.Data +@lombok.AllArgsConstructor +@lombok.Builder @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class WorkFlowOption { - public static final String SERIALIZED_NAME_DESCRIPTION = "description"; - @SerializedName(SERIALIZED_NAME_DESCRIPTION) - private String description; - - public static final String SERIALIZED_NAME_DETAILS = "details"; - @SerializedName(SERIALIZED_NAME_DETAILS) - private List details = null; - - public static final String SERIALIZED_NAME_DISPLAY_NAME = "displayName"; - @SerializedName(SERIALIZED_NAME_DISPLAY_NAME) - private String displayName; - - public static final String SERIALIZED_NAME_IDENTIFIER = "identifier"; - @SerializedName(SERIALIZED_NAME_IDENTIFIER) - private String identifier; - - public static final String SERIALIZED_NAME_WORK_FLOW_NAME = "workFlowName"; - @SerializedName(SERIALIZED_NAME_WORK_FLOW_NAME) - private String workFlowName; - - public WorkFlowOption() { - } - public WorkFlowOption description(String description) { - - this.description = description; - return this; - } - - /** - * Get description - * @return description - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getDescription() { - return description; - } + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + private String description; - public void setDescription(String description) { - this.description = description; - } + public static final String SERIALIZED_NAME_DETAILS = "details"; + @SerializedName(SERIALIZED_NAME_DETAILS) + private List details = null; - public WorkFlowOption details(List details) { - - this.details = details; - return this; - } - - public WorkFlowOption addDetailsItem(String detailsItem) { - if (this.details == null) { - this.details = new ArrayList(); - } - this.details.add(detailsItem); - return this; - } - - /** - * Get details - * @return details - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public List getDetails() { - return details; - } - - - public void setDetails(List details) { - this.details = details; - } - - - public WorkFlowOption displayName(String displayName) { - - this.displayName = displayName; - return this; - } - - /** - * Get displayName - * @return displayName - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getDisplayName() { - return displayName; - } - - - public void setDisplayName(String displayName) { - this.displayName = displayName; - } - - - public WorkFlowOption identifier(String identifier) { - - this.identifier = identifier; - return this; - } - - /** - * Get identifier - * @return identifier - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getIdentifier() { - return identifier; - } - - - public void setIdentifier(String identifier) { - this.identifier = identifier; - } - - - public WorkFlowOption workFlowName(String workFlowName) { - - this.workFlowName = workFlowName; - return this; - } - - /** - * Get workFlowName - * @return workFlowName - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getWorkFlowName() { - return workFlowName; - } - - - public void setWorkFlowName(String workFlowName) { - this.workFlowName = workFlowName; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - WorkFlowOption workFlowOption = (WorkFlowOption) o; - return Objects.equals(this.description, workFlowOption.description) && - Objects.equals(this.details, workFlowOption.details) && - Objects.equals(this.displayName, workFlowOption.displayName) && - Objects.equals(this.identifier, workFlowOption.identifier) && - Objects.equals(this.workFlowName, workFlowOption.workFlowName); - } - - @Override - public int hashCode() { - return Objects.hash(description, details, displayName, identifier, workFlowName); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class WorkFlowOption {\n"); - sb.append(" description: ").append(toIndentedString(description)).append("\n"); - sb.append(" details: ").append(toIndentedString(details)).append("\n"); - sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); - sb.append(" identifier: ").append(toIndentedString(identifier)).append("\n"); - sb.append(" workFlowName: ").append(toIndentedString(workFlowName)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } + public static final String SERIALIZED_NAME_DISPLAY_NAME = "displayName"; -} + @SerializedName(SERIALIZED_NAME_DISPLAY_NAME) + private String displayName; + + public static final String SERIALIZED_NAME_IDENTIFIER = "identifier"; + + @SerializedName(SERIALIZED_NAME_IDENTIFIER) + private String identifier; + + public static final String SERIALIZED_NAME_WORK_FLOW_NAME = "workFlowName"; + + @SerializedName(SERIALIZED_NAME_WORK_FLOW_NAME) + private String workFlowName; + + public WorkFlowOption() { + } + public WorkFlowOption description(String description) { + + this.description = description; + return this; + } + + /** + * Get description + * @return description + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public WorkFlowOption details(List details) { + + this.details = details; + return this; + } + + public WorkFlowOption addDetailsItem(String detailsItem) { + if (this.details == null) { + this.details = new ArrayList(); + } + this.details.add(detailsItem); + return this; + } + + /** + * Get details + * @return details + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getDetails() { + return details; + } + + public void setDetails(List details) { + this.details = details; + } + + public WorkFlowOption displayName(String displayName) { + + this.displayName = displayName; + return this; + } + + /** + * Get displayName + * @return displayName + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public WorkFlowOption identifier(String identifier) { + + this.identifier = identifier; + return this; + } + + /** + * Get identifier + * @return identifier + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getIdentifier() { + return identifier; + } + + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + public WorkFlowOption workFlowName(String workFlowName) { + + this.workFlowName = workFlowName; + return this; + } + + /** + * Get workFlowName + * @return workFlowName + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getWorkFlowName() { + return workFlowName; + } + + public void setWorkFlowName(String workFlowName) { + this.workFlowName = workFlowName; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WorkFlowOption workFlowOption = (WorkFlowOption) o; + return Objects.equals(this.description, workFlowOption.description) + && Objects.equals(this.details, workFlowOption.details) + && Objects.equals(this.displayName, workFlowOption.displayName) + && Objects.equals(this.identifier, workFlowOption.identifier) + && Objects.equals(this.workFlowName, workFlowOption.workFlowName); + } + + @Override + public int hashCode() { + return Objects.hash(description, details, displayName, identifier, workFlowName); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WorkFlowOption {\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" details: ").append(toIndentedString(details)).append("\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append(" identifier: ").append(toIndentedString(identifier)).append("\n"); + sb.append(" workFlowName: ").append(toIndentedString(workFlowName)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the + * first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowOptions.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowOptions.java index e6ae56e0a..eb92b2099 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowOptions.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowOptions.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import java.util.Objects; @@ -30,289 +29,285 @@ /** * WorkFlowOptions */ -@lombok.Data @lombok.AllArgsConstructor @lombok.Builder +@lombok.Data +@lombok.AllArgsConstructor +@lombok.Builder @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class WorkFlowOptions { - public static final String SERIALIZED_NAME_CONTINUATION_OPTIONS = "continuationOptions"; - @SerializedName(SERIALIZED_NAME_CONTINUATION_OPTIONS) - private List continuationOptions = null; - - public static final String SERIALIZED_NAME_CURRENT_VERSION = "currentVersion"; - @SerializedName(SERIALIZED_NAME_CURRENT_VERSION) - private WorkFlowOption currentVersion; - - public static final String SERIALIZED_NAME_MIGRATION_OPTIONS = "migrationOptions"; - @SerializedName(SERIALIZED_NAME_MIGRATION_OPTIONS) - private List migrationOptions = null; - - public static final String SERIALIZED_NAME_NEW_OPTIONS = "newOptions"; - @SerializedName(SERIALIZED_NAME_NEW_OPTIONS) - private List newOptions = null; - - public static final String SERIALIZED_NAME_OPTIONS_AVAILABLE = "optionsAvailable"; - @SerializedName(SERIALIZED_NAME_OPTIONS_AVAILABLE) - private Boolean optionsAvailable; - - public static final String SERIALIZED_NAME_OTHER_OPTIONS = "otherOptions"; - @SerializedName(SERIALIZED_NAME_OTHER_OPTIONS) - private List otherOptions = null; - - public static final String SERIALIZED_NAME_UPGRADE_OPTIONS = "upgradeOptions"; - @SerializedName(SERIALIZED_NAME_UPGRADE_OPTIONS) - private List upgradeOptions = null; - - public WorkFlowOptions() { - } - - public WorkFlowOptions continuationOptions(List continuationOptions) { - - this.continuationOptions = continuationOptions; - return this; - } - - public WorkFlowOptions addContinuationOptionsItem(WorkFlowOption continuationOptionsItem) { - if (this.continuationOptions == null) { - this.continuationOptions = new ArrayList(); - } - this.continuationOptions.add(continuationOptionsItem); - return this; - } - - /** - * Get continuationOptions - * @return continuationOptions - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public List getContinuationOptions() { - return continuationOptions; - } - - - public void setContinuationOptions(List continuationOptions) { - this.continuationOptions = continuationOptions; - } - - - public WorkFlowOptions currentVersion(WorkFlowOption currentVersion) { - - this.currentVersion = currentVersion; - return this; - } - - /** - * Get currentVersion - * @return currentVersion - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public WorkFlowOption getCurrentVersion() { - return currentVersion; - } - - - public void setCurrentVersion(WorkFlowOption currentVersion) { - this.currentVersion = currentVersion; - } - - - public WorkFlowOptions migrationOptions(List migrationOptions) { - - this.migrationOptions = migrationOptions; - return this; - } - - public WorkFlowOptions addMigrationOptionsItem(WorkFlowOption migrationOptionsItem) { - if (this.migrationOptions == null) { - this.migrationOptions = new ArrayList(); - } - this.migrationOptions.add(migrationOptionsItem); - return this; - } - - /** - * Get migrationOptions - * @return migrationOptions - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public List getMigrationOptions() { - return migrationOptions; - } - - - public void setMigrationOptions(List migrationOptions) { - this.migrationOptions = migrationOptions; - } - - - public WorkFlowOptions newOptions(List newOptions) { - - this.newOptions = newOptions; - return this; - } - - public WorkFlowOptions addNewOptionsItem(WorkFlowOption newOptionsItem) { - if (this.newOptions == null) { - this.newOptions = new ArrayList(); - } - this.newOptions.add(newOptionsItem); - return this; - } - - /** - * Get newOptions - * @return newOptions - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public List getNewOptions() { - return newOptions; - } - - - public void setNewOptions(List newOptions) { - this.newOptions = newOptions; - } - - - public WorkFlowOptions optionsAvailable(Boolean optionsAvailable) { - - this.optionsAvailable = optionsAvailable; - return this; - } - - /** - * Get optionsAvailable - * @return optionsAvailable - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public Boolean getOptionsAvailable() { - return optionsAvailable; - } - - - public void setOptionsAvailable(Boolean optionsAvailable) { - this.optionsAvailable = optionsAvailable; - } - - - public WorkFlowOptions otherOptions(List otherOptions) { - - this.otherOptions = otherOptions; - return this; - } - - public WorkFlowOptions addOtherOptionsItem(WorkFlowOption otherOptionsItem) { - if (this.otherOptions == null) { - this.otherOptions = new ArrayList(); - } - this.otherOptions.add(otherOptionsItem); - return this; - } - - /** - * Get otherOptions - * @return otherOptions - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public List getOtherOptions() { - return otherOptions; - } - - - public void setOtherOptions(List otherOptions) { - this.otherOptions = otherOptions; - } - - - public WorkFlowOptions upgradeOptions(List upgradeOptions) { - - this.upgradeOptions = upgradeOptions; - return this; - } - - public WorkFlowOptions addUpgradeOptionsItem(WorkFlowOption upgradeOptionsItem) { - if (this.upgradeOptions == null) { - this.upgradeOptions = new ArrayList(); - } - this.upgradeOptions.add(upgradeOptionsItem); - return this; - } - - /** - * Get upgradeOptions - * @return upgradeOptions - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public List getUpgradeOptions() { - return upgradeOptions; - } - - - public void setUpgradeOptions(List upgradeOptions) { - this.upgradeOptions = upgradeOptions; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - WorkFlowOptions workFlowOptions = (WorkFlowOptions) o; - return Objects.equals(this.continuationOptions, workFlowOptions.continuationOptions) && - Objects.equals(this.currentVersion, workFlowOptions.currentVersion) && - Objects.equals(this.migrationOptions, workFlowOptions.migrationOptions) && - Objects.equals(this.newOptions, workFlowOptions.newOptions) && - Objects.equals(this.optionsAvailable, workFlowOptions.optionsAvailable) && - Objects.equals(this.otherOptions, workFlowOptions.otherOptions) && - Objects.equals(this.upgradeOptions, workFlowOptions.upgradeOptions); - } - - @Override - public int hashCode() { - return Objects.hash(continuationOptions, currentVersion, migrationOptions, newOptions, optionsAvailable, otherOptions, upgradeOptions); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class WorkFlowOptions {\n"); - sb.append(" continuationOptions: ").append(toIndentedString(continuationOptions)).append("\n"); - sb.append(" currentVersion: ").append(toIndentedString(currentVersion)).append("\n"); - sb.append(" migrationOptions: ").append(toIndentedString(migrationOptions)).append("\n"); - sb.append(" newOptions: ").append(toIndentedString(newOptions)).append("\n"); - sb.append(" optionsAvailable: ").append(toIndentedString(optionsAvailable)).append("\n"); - sb.append(" otherOptions: ").append(toIndentedString(otherOptions)).append("\n"); - sb.append(" upgradeOptions: ").append(toIndentedString(upgradeOptions)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} + public static final String SERIALIZED_NAME_CONTINUATION_OPTIONS = "continuationOptions"; + + @SerializedName(SERIALIZED_NAME_CONTINUATION_OPTIONS) + private List continuationOptions = null; + + public static final String SERIALIZED_NAME_CURRENT_VERSION = "currentVersion"; + + @SerializedName(SERIALIZED_NAME_CURRENT_VERSION) + private WorkFlowOption currentVersion; + + public static final String SERIALIZED_NAME_MIGRATION_OPTIONS = "migrationOptions"; + + @SerializedName(SERIALIZED_NAME_MIGRATION_OPTIONS) + private List migrationOptions = null; + + public static final String SERIALIZED_NAME_NEW_OPTIONS = "newOptions"; + + @SerializedName(SERIALIZED_NAME_NEW_OPTIONS) + private List newOptions = null; + + public static final String SERIALIZED_NAME_OPTIONS_AVAILABLE = "optionsAvailable"; + + @SerializedName(SERIALIZED_NAME_OPTIONS_AVAILABLE) + private Boolean optionsAvailable; + + public static final String SERIALIZED_NAME_OTHER_OPTIONS = "otherOptions"; + + @SerializedName(SERIALIZED_NAME_OTHER_OPTIONS) + private List otherOptions = null; + + public static final String SERIALIZED_NAME_UPGRADE_OPTIONS = "upgradeOptions"; + + @SerializedName(SERIALIZED_NAME_UPGRADE_OPTIONS) + private List upgradeOptions = null; + + public WorkFlowOptions() { + } + public WorkFlowOptions continuationOptions(List continuationOptions) { + + this.continuationOptions = continuationOptions; + return this; + } + + public WorkFlowOptions addContinuationOptionsItem(WorkFlowOption continuationOptionsItem) { + if (this.continuationOptions == null) { + this.continuationOptions = new ArrayList(); + } + this.continuationOptions.add(continuationOptionsItem); + return this; + } + + /** + * Get continuationOptions + * @return continuationOptions + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getContinuationOptions() { + return continuationOptions; + } + + public void setContinuationOptions(List continuationOptions) { + this.continuationOptions = continuationOptions; + } + + public WorkFlowOptions currentVersion(WorkFlowOption currentVersion) { + + this.currentVersion = currentVersion; + return this; + } + + /** + * Get currentVersion + * @return currentVersion + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public WorkFlowOption getCurrentVersion() { + return currentVersion; + } + + public void setCurrentVersion(WorkFlowOption currentVersion) { + this.currentVersion = currentVersion; + } + + public WorkFlowOptions migrationOptions(List migrationOptions) { + + this.migrationOptions = migrationOptions; + return this; + } + + public WorkFlowOptions addMigrationOptionsItem(WorkFlowOption migrationOptionsItem) { + if (this.migrationOptions == null) { + this.migrationOptions = new ArrayList(); + } + this.migrationOptions.add(migrationOptionsItem); + return this; + } + + /** + * Get migrationOptions + * @return migrationOptions + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getMigrationOptions() { + return migrationOptions; + } + + public void setMigrationOptions(List migrationOptions) { + this.migrationOptions = migrationOptions; + } + + public WorkFlowOptions newOptions(List newOptions) { + + this.newOptions = newOptions; + return this; + } + + public WorkFlowOptions addNewOptionsItem(WorkFlowOption newOptionsItem) { + if (this.newOptions == null) { + this.newOptions = new ArrayList(); + } + this.newOptions.add(newOptionsItem); + return this; + } + + /** + * Get newOptions + * @return newOptions + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getNewOptions() { + return newOptions; + } + + public void setNewOptions(List newOptions) { + this.newOptions = newOptions; + } + + public WorkFlowOptions optionsAvailable(Boolean optionsAvailable) { + + this.optionsAvailable = optionsAvailable; + return this; + } + + /** + * Get optionsAvailable + * @return optionsAvailable + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public Boolean getOptionsAvailable() { + return optionsAvailable; + } + + public void setOptionsAvailable(Boolean optionsAvailable) { + this.optionsAvailable = optionsAvailable; + } + + public WorkFlowOptions otherOptions(List otherOptions) { + + this.otherOptions = otherOptions; + return this; + } + + public WorkFlowOptions addOtherOptionsItem(WorkFlowOption otherOptionsItem) { + if (this.otherOptions == null) { + this.otherOptions = new ArrayList(); + } + this.otherOptions.add(otherOptionsItem); + return this; + } + + /** + * Get otherOptions + * @return otherOptions + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getOtherOptions() { + return otherOptions; + } + + public void setOtherOptions(List otherOptions) { + this.otherOptions = otherOptions; + } + + public WorkFlowOptions upgradeOptions(List upgradeOptions) { + + this.upgradeOptions = upgradeOptions; + return this; + } + + public WorkFlowOptions addUpgradeOptionsItem(WorkFlowOption upgradeOptionsItem) { + if (this.upgradeOptions == null) { + this.upgradeOptions = new ArrayList(); + } + this.upgradeOptions.add(upgradeOptionsItem); + return this; + } + + /** + * Get upgradeOptions + * @return upgradeOptions + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getUpgradeOptions() { + return upgradeOptions; + } + + public void setUpgradeOptions(List upgradeOptions) { + this.upgradeOptions = upgradeOptions; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WorkFlowOptions workFlowOptions = (WorkFlowOptions) o; + return Objects.equals(this.continuationOptions, workFlowOptions.continuationOptions) + && Objects.equals(this.currentVersion, workFlowOptions.currentVersion) + && Objects.equals(this.migrationOptions, workFlowOptions.migrationOptions) + && Objects.equals(this.newOptions, workFlowOptions.newOptions) + && Objects.equals(this.optionsAvailable, workFlowOptions.optionsAvailable) + && Objects.equals(this.otherOptions, workFlowOptions.otherOptions) + && Objects.equals(this.upgradeOptions, workFlowOptions.upgradeOptions); + } + + @Override + public int hashCode() { + return Objects.hash(continuationOptions, currentVersion, migrationOptions, newOptions, optionsAvailable, + otherOptions, upgradeOptions); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WorkFlowOptions {\n"); + sb.append(" continuationOptions: ").append(toIndentedString(continuationOptions)).append("\n"); + sb.append(" currentVersion: ").append(toIndentedString(currentVersion)).append("\n"); + sb.append(" migrationOptions: ").append(toIndentedString(migrationOptions)).append("\n"); + sb.append(" newOptions: ").append(toIndentedString(newOptions)).append("\n"); + sb.append(" optionsAvailable: ").append(toIndentedString(optionsAvailable)).append("\n"); + sb.append(" otherOptions: ").append(toIndentedString(otherOptions)).append("\n"); + sb.append(" upgradeOptions: ").append(toIndentedString(upgradeOptions)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the + * first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowPropertiesDefinitionDTO.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowPropertiesDefinitionDTO.java index f57e0bf02..3bfd8b98a 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowPropertiesDefinitionDTO.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowPropertiesDefinitionDTO.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import java.util.Objects; @@ -27,75 +26,76 @@ /** * WorkFlowPropertiesDefinitionDTO */ -@lombok.Data @lombok.AllArgsConstructor @lombok.Builder +@lombok.Data +@lombok.AllArgsConstructor +@lombok.Builder @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class WorkFlowPropertiesDefinitionDTO { - public static final String SERIALIZED_NAME_VERSION = "version"; - @SerializedName(SERIALIZED_NAME_VERSION) - private String version; - - public WorkFlowPropertiesDefinitionDTO() { - } - - public WorkFlowPropertiesDefinitionDTO version(String version) { - - this.version = version; - return this; - } - - /** - * Get version - * @return version - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getVersion() { - return version; - } - - - public void setVersion(String version) { - this.version = version; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - WorkFlowPropertiesDefinitionDTO workFlowPropertiesDefinitionDTO = (WorkFlowPropertiesDefinitionDTO) o; - return Objects.equals(this.version, workFlowPropertiesDefinitionDTO.version); - } - - @Override - public int hashCode() { - return Objects.hash(version); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class WorkFlowPropertiesDefinitionDTO {\n"); - sb.append(" version: ").append(toIndentedString(version)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} + public static final String SERIALIZED_NAME_VERSION = "version"; + + @SerializedName(SERIALIZED_NAME_VERSION) + private String version; + + public WorkFlowPropertiesDefinitionDTO() { + } + + public WorkFlowPropertiesDefinitionDTO version(String version) { + + this.version = version; + return this; + } + + /** + * Get version + * @return version + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WorkFlowPropertiesDefinitionDTO workFlowPropertiesDefinitionDTO = (WorkFlowPropertiesDefinitionDTO) o; + return Objects.equals(this.version, workFlowPropertiesDefinitionDTO.version); + } + + @Override + public int hashCode() { + return Objects.hash(version); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WorkFlowPropertiesDefinitionDTO {\n"); + sb.append(" version: ").append(toIndentedString(version)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the + * first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowRequestDTO.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowRequestDTO.java index 300b9fd86..73e7cc479 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowRequestDTO.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowRequestDTO.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import java.util.Objects; @@ -31,178 +30,176 @@ /** * WorkFlowRequestDTO */ -@lombok.Data @lombok.AllArgsConstructor @lombok.Builder +@lombok.Data +@lombok.AllArgsConstructor +@lombok.Builder @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class WorkFlowRequestDTO { - public static final String SERIALIZED_NAME_ARGUMENTS = "arguments"; - @SerializedName(SERIALIZED_NAME_ARGUMENTS) - private List arguments = null; - - public static final String SERIALIZED_NAME_PROJECT_ID = "projectId"; - @SerializedName(SERIALIZED_NAME_PROJECT_ID) - private String projectId; - - public static final String SERIALIZED_NAME_WORK_FLOW_NAME = "workFlowName"; - @SerializedName(SERIALIZED_NAME_WORK_FLOW_NAME) - private String workFlowName; - - public static final String SERIALIZED_NAME_WORKS = "works"; - @SerializedName(SERIALIZED_NAME_WORKS) - private List works = null; - - public WorkFlowRequestDTO() { - } - - public WorkFlowRequestDTO arguments(List arguments) { - - this.arguments = arguments; - return this; - } - - public WorkFlowRequestDTO addArgumentsItem(ArgumentRequestDTO argumentsItem) { - if (this.arguments == null) { - this.arguments = new ArrayList(); - } - this.arguments.add(argumentsItem); - return this; - } - - /** - * Get arguments - * @return arguments - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public List getArguments() { - return arguments; - } - - - public void setArguments(List arguments) { - this.arguments = arguments; - } - - - public WorkFlowRequestDTO projectId(String projectId) { - - this.projectId = projectId; - return this; - } - - /** - * Get projectId - * @return projectId - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getProjectId() { - return projectId; - } - - - public void setProjectId(String projectId) { - this.projectId = projectId; - } - - - public WorkFlowRequestDTO workFlowName(String workFlowName) { - - this.workFlowName = workFlowName; - return this; - } - - /** - * Get workFlowName - * @return workFlowName - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getWorkFlowName() { - return workFlowName; - } - - - public void setWorkFlowName(String workFlowName) { - this.workFlowName = workFlowName; - } - - - public WorkFlowRequestDTO works(List works) { - - this.works = works; - return this; - } - - public WorkFlowRequestDTO addWorksItem(WorkRequestDTO worksItem) { - if (this.works == null) { - this.works = new ArrayList(); - } - this.works.add(worksItem); - return this; - } - - /** - * Get works - * @return works - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public List getWorks() { - return works; - } - - - public void setWorks(List works) { - this.works = works; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - WorkFlowRequestDTO workFlowRequestDTO = (WorkFlowRequestDTO) o; - return Objects.equals(this.arguments, workFlowRequestDTO.arguments) && - Objects.equals(this.projectId, workFlowRequestDTO.projectId) && - Objects.equals(this.workFlowName, workFlowRequestDTO.workFlowName) && - Objects.equals(this.works, workFlowRequestDTO.works); - } - - @Override - public int hashCode() { - return Objects.hash(arguments, projectId, workFlowName, works); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class WorkFlowRequestDTO {\n"); - sb.append(" arguments: ").append(toIndentedString(arguments)).append("\n"); - sb.append(" projectId: ").append(toIndentedString(projectId)).append("\n"); - sb.append(" workFlowName: ").append(toIndentedString(workFlowName)).append("\n"); - sb.append(" works: ").append(toIndentedString(works)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} + public static final String SERIALIZED_NAME_ARGUMENTS = "arguments"; + + @SerializedName(SERIALIZED_NAME_ARGUMENTS) + private List arguments = null; + + public static final String SERIALIZED_NAME_PROJECT_ID = "projectId"; + + @SerializedName(SERIALIZED_NAME_PROJECT_ID) + private String projectId; + + public static final String SERIALIZED_NAME_WORK_FLOW_NAME = "workFlowName"; + + @SerializedName(SERIALIZED_NAME_WORK_FLOW_NAME) + private String workFlowName; + public static final String SERIALIZED_NAME_WORKS = "works"; + + @SerializedName(SERIALIZED_NAME_WORKS) + private List works = null; + + public WorkFlowRequestDTO() { + } + + public WorkFlowRequestDTO arguments(List arguments) { + + this.arguments = arguments; + return this; + } + + public WorkFlowRequestDTO addArgumentsItem(ArgumentRequestDTO argumentsItem) { + if (this.arguments == null) { + this.arguments = new ArrayList(); + } + this.arguments.add(argumentsItem); + return this; + } + + /** + * Get arguments + * @return arguments + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getArguments() { + return arguments; + } + + public void setArguments(List arguments) { + this.arguments = arguments; + } + + public WorkFlowRequestDTO projectId(String projectId) { + + this.projectId = projectId; + return this; + } + + /** + * Get projectId + * @return projectId + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getProjectId() { + return projectId; + } + + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + public WorkFlowRequestDTO workFlowName(String workFlowName) { + + this.workFlowName = workFlowName; + return this; + } + + /** + * Get workFlowName + * @return workFlowName + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getWorkFlowName() { + return workFlowName; + } + + public void setWorkFlowName(String workFlowName) { + this.workFlowName = workFlowName; + } + + public WorkFlowRequestDTO works(List works) { + + this.works = works; + return this; + } + + public WorkFlowRequestDTO addWorksItem(WorkRequestDTO worksItem) { + if (this.works == null) { + this.works = new ArrayList(); + } + this.works.add(worksItem); + return this; + } + + /** + * Get works + * @return works + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getWorks() { + return works; + } + + public void setWorks(List works) { + this.works = works; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WorkFlowRequestDTO workFlowRequestDTO = (WorkFlowRequestDTO) o; + return Objects.equals(this.arguments, workFlowRequestDTO.arguments) + && Objects.equals(this.projectId, workFlowRequestDTO.projectId) + && Objects.equals(this.workFlowName, workFlowRequestDTO.workFlowName) + && Objects.equals(this.works, workFlowRequestDTO.works); + } + + @Override + public int hashCode() { + return Objects.hash(arguments, projectId, workFlowName, works); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WorkFlowRequestDTO {\n"); + sb.append(" arguments: ").append(toIndentedString(arguments)).append("\n"); + sb.append(" projectId: ").append(toIndentedString(projectId)).append("\n"); + sb.append(" workFlowName: ").append(toIndentedString(workFlowName)).append("\n"); + sb.append(" works: ").append(toIndentedString(works)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the + * first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowResponseDTO.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowResponseDTO.java index f20109bcd..d645bc635 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowResponseDTO.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowResponseDTO.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import java.util.Objects; @@ -28,182 +27,189 @@ /** * WorkFlowResponseDTO */ -@lombok.Data @lombok.AllArgsConstructor @lombok.Builder +@lombok.Data +@lombok.AllArgsConstructor +@lombok.Builder @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class WorkFlowResponseDTO { - public static final String SERIALIZED_NAME_WORK_FLOW_EXECUTION_ID = "workFlowExecutionId"; - @SerializedName(SERIALIZED_NAME_WORK_FLOW_EXECUTION_ID) - private String workFlowExecutionId; - - public static final String SERIALIZED_NAME_WORK_FLOW_OPTIONS = "workFlowOptions"; - @SerializedName(SERIALIZED_NAME_WORK_FLOW_OPTIONS) - private WorkFlowOptions workFlowOptions; - - /** - * Gets or Sets workStatus - */ - @JsonAdapter(WorkStatusEnum.Adapter.class) - public enum WorkStatusEnum { - FAILED("FAILED"), - - COMPLETED("COMPLETED"), - - IN_PROGRESS("IN_PROGRESS"); - - private String value; - - WorkStatusEnum(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - public static WorkStatusEnum fromValue(String value) { - for (WorkStatusEnum b : WorkStatusEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final WorkStatusEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public WorkStatusEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return WorkStatusEnum.fromValue(value); - } - } - } - - public static final String SERIALIZED_NAME_WORK_STATUS = "workStatus"; - @SerializedName(SERIALIZED_NAME_WORK_STATUS) - private WorkStatusEnum workStatus; - - public WorkFlowResponseDTO() { - } - - public WorkFlowResponseDTO workFlowExecutionId(String workFlowExecutionId) { - - this.workFlowExecutionId = workFlowExecutionId; - return this; - } - - /** - * Get workFlowExecutionId - * @return workFlowExecutionId - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getWorkFlowExecutionId() { - return workFlowExecutionId; - } - - - public void setWorkFlowExecutionId(String workFlowExecutionId) { - this.workFlowExecutionId = workFlowExecutionId; - } - - - public WorkFlowResponseDTO workFlowOptions(WorkFlowOptions workFlowOptions) { - - this.workFlowOptions = workFlowOptions; - return this; - } - - /** - * Get workFlowOptions - * @return workFlowOptions - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public WorkFlowOptions getWorkFlowOptions() { - return workFlowOptions; - } - - - public void setWorkFlowOptions(WorkFlowOptions workFlowOptions) { - this.workFlowOptions = workFlowOptions; - } - - - public WorkFlowResponseDTO workStatus(WorkStatusEnum workStatus) { - - this.workStatus = workStatus; - return this; - } - - /** - * Get workStatus - * @return workStatus - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public WorkStatusEnum getWorkStatus() { - return workStatus; - } - - - public void setWorkStatus(WorkStatusEnum workStatus) { - this.workStatus = workStatus; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - WorkFlowResponseDTO workFlowResponseDTO = (WorkFlowResponseDTO) o; - return Objects.equals(this.workFlowExecutionId, workFlowResponseDTO.workFlowExecutionId) && - Objects.equals(this.workFlowOptions, workFlowResponseDTO.workFlowOptions) && - Objects.equals(this.workStatus, workFlowResponseDTO.workStatus); - } - - @Override - public int hashCode() { - return Objects.hash(workFlowExecutionId, workFlowOptions, workStatus); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class WorkFlowResponseDTO {\n"); - sb.append(" workFlowExecutionId: ").append(toIndentedString(workFlowExecutionId)).append("\n"); - sb.append(" workFlowOptions: ").append(toIndentedString(workFlowOptions)).append("\n"); - sb.append(" workStatus: ").append(toIndentedString(workStatus)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} + public static final String SERIALIZED_NAME_WORK_FLOW_EXECUTION_ID = "workFlowExecutionId"; + + @SerializedName(SERIALIZED_NAME_WORK_FLOW_EXECUTION_ID) + private String workFlowExecutionId; + + public static final String SERIALIZED_NAME_WORK_FLOW_OPTIONS = "workFlowOptions"; + + @SerializedName(SERIALIZED_NAME_WORK_FLOW_OPTIONS) + private WorkFlowOptions workFlowOptions; + + /** + * Gets or Sets workStatus + */ + @JsonAdapter(WorkStatusEnum.Adapter.class) + public enum WorkStatusEnum { + + FAILED("FAILED"), + + COMPLETED("COMPLETED"), + + IN_PROGRESS("IN_PROGRESS"), + + REJECTED("REJECTED"), + + PENDING("PENDING"); + private String value; + + WorkStatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static WorkStatusEnum fromValue(String value) { + for (WorkStatusEnum b : WorkStatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write(final JsonWriter jsonWriter, final WorkStatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public WorkStatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return WorkStatusEnum.fromValue(value); + } + + } + + } + + public static final String SERIALIZED_NAME_WORK_STATUS = "workStatus"; + + @SerializedName(SERIALIZED_NAME_WORK_STATUS) + private WorkStatusEnum workStatus; + + public WorkFlowResponseDTO() { + } + + public WorkFlowResponseDTO workFlowExecutionId(String workFlowExecutionId) { + + this.workFlowExecutionId = workFlowExecutionId; + return this; + } + + /** + * Get workFlowExecutionId + * @return workFlowExecutionId + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getWorkFlowExecutionId() { + return workFlowExecutionId; + } + + public void setWorkFlowExecutionId(String workFlowExecutionId) { + this.workFlowExecutionId = workFlowExecutionId; + } + + public WorkFlowResponseDTO workFlowOptions(WorkFlowOptions workFlowOptions) { + + this.workFlowOptions = workFlowOptions; + return this; + } + + /** + * Get workFlowOptions + * @return workFlowOptions + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public WorkFlowOptions getWorkFlowOptions() { + return workFlowOptions; + } + + public void setWorkFlowOptions(WorkFlowOptions workFlowOptions) { + this.workFlowOptions = workFlowOptions; + } + + public WorkFlowResponseDTO workStatus(WorkStatusEnum workStatus) { + + this.workStatus = workStatus; + return this; + } + + /** + * Get workStatus + * @return workStatus + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public WorkStatusEnum getWorkStatus() { + return workStatus; + } + + public void setWorkStatus(WorkStatusEnum workStatus) { + this.workStatus = workStatus; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WorkFlowResponseDTO workFlowResponseDTO = (WorkFlowResponseDTO) o; + return Objects.equals(this.workFlowExecutionId, workFlowResponseDTO.workFlowExecutionId) + && Objects.equals(this.workFlowOptions, workFlowResponseDTO.workFlowOptions) + && Objects.equals(this.workStatus, workFlowResponseDTO.workStatus); + } + + @Override + public int hashCode() { + return Objects.hash(workFlowExecutionId, workFlowOptions, workStatus); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WorkFlowResponseDTO {\n"); + sb.append(" workFlowExecutionId: ").append(toIndentedString(workFlowExecutionId)).append("\n"); + sb.append(" workFlowOptions: ").append(toIndentedString(workFlowOptions)).append("\n"); + sb.append(" workStatus: ").append(toIndentedString(workStatus)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the + * first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowStatusResponseDTO.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowStatusResponseDTO.java index f61467b1b..8c0670bb4 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowStatusResponseDTO.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkFlowStatusResponseDTO.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import java.util.Objects; @@ -30,170 +29,168 @@ /** * WorkFlowStatusResponseDTO */ -@lombok.Data @lombok.AllArgsConstructor @lombok.Builder +@lombok.Data +@lombok.AllArgsConstructor +@lombok.Builder @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class WorkFlowStatusResponseDTO { - public static final String SERIALIZED_NAME_STATUS = "status"; - @SerializedName(SERIALIZED_NAME_STATUS) - private String status; - - public static final String SERIALIZED_NAME_WORK_FLOW_EXECUTION_ID = "workFlowExecutionId"; - @SerializedName(SERIALIZED_NAME_WORK_FLOW_EXECUTION_ID) - private String workFlowExecutionId; - - public static final String SERIALIZED_NAME_WORK_FLOW_NAME = "workFlowName"; - @SerializedName(SERIALIZED_NAME_WORK_FLOW_NAME) - private String workFlowName; - - public static final String SERIALIZED_NAME_WORKS = "works"; - @SerializedName(SERIALIZED_NAME_WORKS) - private List works = null; - - public WorkFlowStatusResponseDTO() { - } - public WorkFlowStatusResponseDTO status(String status) { - - this.status = status; - return this; - } - - /** - * Get status - * @return status - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getStatus() { - return status; - } - - - public void setStatus(String status) { - this.status = status; - } - - - public WorkFlowStatusResponseDTO workFlowExecutionId(String workFlowExecutionId) { - - this.workFlowExecutionId = workFlowExecutionId; - return this; - } - - /** - * Get workFlowExecutionId - * @return workFlowExecutionId - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getWorkFlowExecutionId() { - return workFlowExecutionId; - } - - - public void setWorkFlowExecutionId(String workFlowExecutionId) { - this.workFlowExecutionId = workFlowExecutionId; - } - - - public WorkFlowStatusResponseDTO workFlowName(String workFlowName) { - - this.workFlowName = workFlowName; - return this; - } - - /** - * Get workFlowName - * @return workFlowName - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getWorkFlowName() { - return workFlowName; - } - - - public void setWorkFlowName(String workFlowName) { - this.workFlowName = workFlowName; - } - - - public WorkFlowStatusResponseDTO works(List works) { - - this.works = works; - return this; - } - - public WorkFlowStatusResponseDTO addWorksItem(WorkStatusResponseDTO worksItem) { - if (this.works == null) { - this.works = new ArrayList(); - } - this.works.add(worksItem); - return this; - } - - /** - * Get works - * @return works - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public List getWorks() { - return works; - } - - - public void setWorks(List works) { - this.works = works; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - WorkFlowStatusResponseDTO workFlowStatusResponseDTO = (WorkFlowStatusResponseDTO) o; - return Objects.equals(this.status, workFlowStatusResponseDTO.status) && - Objects.equals(this.workFlowExecutionId, workFlowStatusResponseDTO.workFlowExecutionId) && - Objects.equals(this.workFlowName, workFlowStatusResponseDTO.workFlowName) && - Objects.equals(this.works, workFlowStatusResponseDTO.works); - } - - @Override - public int hashCode() { - return Objects.hash(status, workFlowExecutionId, workFlowName, works); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class WorkFlowStatusResponseDTO {\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" workFlowExecutionId: ").append(toIndentedString(workFlowExecutionId)).append("\n"); - sb.append(" workFlowName: ").append(toIndentedString(workFlowName)).append("\n"); - sb.append(" works: ").append(toIndentedString(works)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } + public static final String SERIALIZED_NAME_STATUS = "status"; -} + @SerializedName(SERIALIZED_NAME_STATUS) + private String status; + + public static final String SERIALIZED_NAME_WORK_FLOW_EXECUTION_ID = "workFlowExecutionId"; + + @SerializedName(SERIALIZED_NAME_WORK_FLOW_EXECUTION_ID) + private String workFlowExecutionId; + + public static final String SERIALIZED_NAME_WORK_FLOW_NAME = "workFlowName"; + + @SerializedName(SERIALIZED_NAME_WORK_FLOW_NAME) + private String workFlowName; + public static final String SERIALIZED_NAME_WORKS = "works"; + + @SerializedName(SERIALIZED_NAME_WORKS) + private List works = null; + + public WorkFlowStatusResponseDTO() { + } + + public WorkFlowStatusResponseDTO status(String status) { + + this.status = status; + return this; + } + + /** + * Get status + * @return status + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public WorkFlowStatusResponseDTO workFlowExecutionId(String workFlowExecutionId) { + + this.workFlowExecutionId = workFlowExecutionId; + return this; + } + + /** + * Get workFlowExecutionId + * @return workFlowExecutionId + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getWorkFlowExecutionId() { + return workFlowExecutionId; + } + + public void setWorkFlowExecutionId(String workFlowExecutionId) { + this.workFlowExecutionId = workFlowExecutionId; + } + + public WorkFlowStatusResponseDTO workFlowName(String workFlowName) { + + this.workFlowName = workFlowName; + return this; + } + + /** + * Get workFlowName + * @return workFlowName + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getWorkFlowName() { + return workFlowName; + } + + public void setWorkFlowName(String workFlowName) { + this.workFlowName = workFlowName; + } + + public WorkFlowStatusResponseDTO works(List works) { + + this.works = works; + return this; + } + + public WorkFlowStatusResponseDTO addWorksItem(WorkStatusResponseDTO worksItem) { + if (this.works == null) { + this.works = new ArrayList(); + } + this.works.add(worksItem); + return this; + } + + /** + * Get works + * @return works + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getWorks() { + return works; + } + + public void setWorks(List works) { + this.works = works; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WorkFlowStatusResponseDTO workFlowStatusResponseDTO = (WorkFlowStatusResponseDTO) o; + return Objects.equals(this.status, workFlowStatusResponseDTO.status) + && Objects.equals(this.workFlowExecutionId, workFlowStatusResponseDTO.workFlowExecutionId) + && Objects.equals(this.workFlowName, workFlowStatusResponseDTO.workFlowName) + && Objects.equals(this.works, workFlowStatusResponseDTO.works); + } + + @Override + public int hashCode() { + return Objects.hash(status, workFlowExecutionId, workFlowName, works); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WorkFlowStatusResponseDTO {\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" workFlowExecutionId: ").append(toIndentedString(workFlowExecutionId)).append("\n"); + sb.append(" workFlowName: ").append(toIndentedString(workFlowName)).append("\n"); + sb.append(" works: ").append(toIndentedString(works)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the + * first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkRequestDTO.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkRequestDTO.java index c46f30986..80a8900d4 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkRequestDTO.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkRequestDTO.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import java.util.Objects; @@ -30,141 +29,140 @@ /** * WorkRequestDTO */ -@lombok.Data @lombok.AllArgsConstructor @lombok.Builder +@lombok.Data +@lombok.AllArgsConstructor +@lombok.Builder @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class WorkRequestDTO { - public static final String SERIALIZED_NAME_ARGUMENTS = "arguments"; - @SerializedName(SERIALIZED_NAME_ARGUMENTS) - private List arguments = null; - - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) - private String type; - - public static final String SERIALIZED_NAME_WORK_NAME = "workName"; - @SerializedName(SERIALIZED_NAME_WORK_NAME) - private String workName; - - public WorkRequestDTO() { - } - - public WorkRequestDTO arguments(List arguments) { - - this.arguments = arguments; - return this; - } - - public WorkRequestDTO addArgumentsItem(ArgumentRequestDTO argumentsItem) { - if (this.arguments == null) { - this.arguments = new ArrayList(); - } - this.arguments.add(argumentsItem); - return this; - } - - /** - * Get arguments - * @return arguments - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public List getArguments() { - return arguments; - } - - - public void setArguments(List arguments) { - this.arguments = arguments; - } - - - public WorkRequestDTO type(String type) { - - this.type = type; - return this; - } - - /** - * Get type - * @return type - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getType() { - return type; - } - - - public void setType(String type) { - this.type = type; - } - - - public WorkRequestDTO workName(String workName) { - - this.workName = workName; - return this; - } - - /** - * Get workName - * @return workName - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getWorkName() { - return workName; - } - - - public void setWorkName(String workName) { - this.workName = workName; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - WorkRequestDTO workRequestDTO = (WorkRequestDTO) o; - return Objects.equals(this.arguments, workRequestDTO.arguments) && - Objects.equals(this.type, workRequestDTO.type) && - Objects.equals(this.workName, workRequestDTO.workName); - } - - @Override - public int hashCode() { - return Objects.hash(arguments, type, workName); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class WorkRequestDTO {\n"); - sb.append(" arguments: ").append(toIndentedString(arguments)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" workName: ").append(toIndentedString(workName)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} + public static final String SERIALIZED_NAME_ARGUMENTS = "arguments"; + + @SerializedName(SERIALIZED_NAME_ARGUMENTS) + private List arguments = null; + + public static final String SERIALIZED_NAME_TYPE = "type"; + + @SerializedName(SERIALIZED_NAME_TYPE) + private String type; + + public static final String SERIALIZED_NAME_WORK_NAME = "workName"; + + @SerializedName(SERIALIZED_NAME_WORK_NAME) + private String workName; + + public WorkRequestDTO() { + } + + public WorkRequestDTO arguments(List arguments) { + + this.arguments = arguments; + return this; + } + + public WorkRequestDTO addArgumentsItem(ArgumentRequestDTO argumentsItem) { + if (this.arguments == null) { + this.arguments = new ArrayList(); + } + this.arguments.add(argumentsItem); + return this; + } + + /** + * Get arguments + * @return arguments + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getArguments() { + return arguments; + } + + public void setArguments(List arguments) { + this.arguments = arguments; + } + + public WorkRequestDTO type(String type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public WorkRequestDTO workName(String workName) { + + this.workName = workName; + return this; + } + + /** + * Get workName + * @return workName + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getWorkName() { + return workName; + } + + public void setWorkName(String workName) { + this.workName = workName; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WorkRequestDTO workRequestDTO = (WorkRequestDTO) o; + return Objects.equals(this.arguments, workRequestDTO.arguments) + && Objects.equals(this.type, workRequestDTO.type) + && Objects.equals(this.workName, workRequestDTO.workName); + } + + @Override + public int hashCode() { + return Objects.hash(arguments, type, workName); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WorkRequestDTO {\n"); + sb.append(" arguments: ").append(toIndentedString(arguments)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" workName: ").append(toIndentedString(workName)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the + * first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkStatusResponseDTO.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkStatusResponseDTO.java index 05bdd6655..cbf8a4f28 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkStatusResponseDTO.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/model/WorkStatusResponseDTO.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import java.util.Objects; @@ -27,231 +26,238 @@ /** * WorkStatusResponseDTO */ -@lombok.Data @lombok.AllArgsConstructor @lombok.Builder +@lombok.Data +@lombok.AllArgsConstructor +@lombok.Builder @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class WorkStatusResponseDTO { - public static final String SERIALIZED_NAME_NAME = "name"; - @SerializedName(SERIALIZED_NAME_NAME) - private String name; - - /** - * Gets or Sets status - */ - @JsonAdapter(StatusEnum.Adapter.class) - public enum StatusEnum { - FAILED("FAILED"), - - COMPLETED("COMPLETED"), - - PENDING("PENDING"), - - IN_PROGRESS("IN_PROGRESS"); - - private String value; - - StatusEnum(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - public static StatusEnum fromValue(String value) { - for (StatusEnum b : StatusEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public StatusEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return StatusEnum.fromValue(value); - } - } - } - - public static final String SERIALIZED_NAME_STATUS = "status"; - @SerializedName(SERIALIZED_NAME_STATUS) - private StatusEnum status; - - /** - * Gets or Sets type - */ - @JsonAdapter(TypeEnum.Adapter.class) - public enum TypeEnum { - TASK("TASK"), - - WORKFLOW("WORKFLOW"); - - private String value; - - TypeEnum(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - public static TypeEnum fromValue(String value) { - for (TypeEnum b : TypeEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } - } - - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) - private TypeEnum type; - - public WorkStatusResponseDTO() { - } - - public WorkStatusResponseDTO name(String name) { - - this.name = name; - return this; - } - - /** - * Get name - * @return name - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public String getName() { - return name; - } - - - public void setName(String name) { - this.name = name; - } - - - public WorkStatusResponseDTO status(StatusEnum status) { - - this.status = status; - return this; - } - - /** - * Get status - * @return status - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public StatusEnum getStatus() { - return status; - } - - - public void setStatus(StatusEnum status) { - this.status = status; - } - - - public WorkStatusResponseDTO type(TypeEnum type) { - - this.type = type; - return this; - } - - /** - * Get type - * @return type - **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") - - public TypeEnum getType() { - return type; - } - - - public void setType(TypeEnum type) { - this.type = type; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - WorkStatusResponseDTO workStatusResponseDTO = (WorkStatusResponseDTO) o; - return Objects.equals(this.name, workStatusResponseDTO.name) && - Objects.equals(this.status, workStatusResponseDTO.status) && - Objects.equals(this.type, workStatusResponseDTO.type); - } - - @Override - public int hashCode() { - return Objects.hash(name, status, type); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class WorkStatusResponseDTO {\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + /** + * Gets or Sets status + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + + FAILED("FAILED"), + + COMPLETED("COMPLETED"), + + PENDING("PENDING"), + + IN_PROGRESS("IN_PROGRESS"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + + @SerializedName(SERIALIZED_NAME_STATUS) + private StatusEnum status; + + /** + * Gets or Sets type + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + + TASK("TASK"), + + WORKFLOW("WORKFLOW"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + + } + + } + + public static final String SERIALIZED_NAME_TYPE = "type"; + + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type; + + public WorkStatusResponseDTO() { + } + + public WorkStatusResponseDTO name(String name) { + + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public WorkStatusResponseDTO status(StatusEnum status) { + + this.status = status; + return this; + } + + /** + * Get status + * @return status + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public StatusEnum getStatus() { + return status; + } + + public void setStatus(StatusEnum status) { + this.status = status; + } + + public WorkStatusResponseDTO type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WorkStatusResponseDTO workStatusResponseDTO = (WorkStatusResponseDTO) o; + return Objects.equals(this.name, workStatusResponseDTO.name) + && Objects.equals(this.status, workStatusResponseDTO.status) + && Objects.equals(this.type, workStatusResponseDTO.type); + } + + @Override + public int hashCode() { + return Objects.hash(name, status, type); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WorkStatusResponseDTO {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the + * first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/api/LoginApiTest.java b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/api/LoginApiTest.java index 7de3edf0c..b0db3ac86 100644 --- a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/api/LoginApiTest.java +++ b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/api/LoginApiTest.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.api; import com.redhat.parodos.sdk.api.ApiException; @@ -28,21 +27,16 @@ @Ignore public class LoginApiTest { - private final LoginApi api = new LoginApi(); + private final LoginApi api = new LoginApi(); + + /** + * Login + * @throws ApiException if the Api call fails + */ + @Test + public void loginTest() throws ApiException { + api.login(); + // TODO: test validations + } - - /** - * Login - * - * - * - * @throws ApiException - * if the Api call fails - */ - @Test - public void loginTest() throws ApiException { - api.login(); - // TODO: test validations - } - } diff --git a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/api/ProjectApiTest.java b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/api/ProjectApiTest.java index 31842ba25..be8b8485e 100644 --- a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/api/ProjectApiTest.java +++ b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/api/ProjectApiTest.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.api; import com.redhat.parodos.sdk.api.ApiException; @@ -30,51 +29,38 @@ @Ignore public class ProjectApiTest { - private final ProjectApi api = new ProjectApi(); + private final ProjectApi api = new ProjectApi(); + + /** + * Creates a new project + * @throws ApiException if the Api call fails + */ + @Test + public void createProjectTest() throws ApiException { + ProjectRequestDTO projectRequestDTO = null; + ProjectResponseDTO response = api.createProject(projectRequestDTO); + // TODO: test validations + } + + /** + * Returns information about a specified project + * @throws ApiException if the Api call fails + */ + @Test + public void getProjectByIdTest() throws ApiException { + String id = null; + ProjectResponseDTO response = api.getProjectById(id); + // TODO: test validations + } + + /** + * Returns a list of project + * @throws ApiException if the Api call fails + */ + @Test + public void getProjectsTest() throws ApiException { + List response = api.getProjects(); + // TODO: test validations + } - - /** - * Creates a new project - * - * - * - * @throws ApiException - * if the Api call fails - */ - @Test - public void createProjectTest() throws ApiException { - ProjectRequestDTO projectRequestDTO = null; - ProjectResponseDTO response = api.createProject(projectRequestDTO); - // TODO: test validations - } - - /** - * Returns information about a specified project - * - * - * - * @throws ApiException - * if the Api call fails - */ - @Test - public void getProjectByIdTest() throws ApiException { - String id = null; - ProjectResponseDTO response = api.getProjectById(id); - // TODO: test validations - } - - /** - * Returns a list of project - * - * - * - * @throws ApiException - * if the Api call fails - */ - @Test - public void getProjectsTest() throws ApiException { - List response = api.getProjects(); - // TODO: test validations - } - } diff --git a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/api/WorkflowApiTest.java b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/api/WorkflowApiTest.java index 5af0d5f21..94f2d92f7 100644 --- a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/api/WorkflowApiTest.java +++ b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/api/WorkflowApiTest.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.api; import com.redhat.parodos.sdk.api.ApiException; @@ -32,54 +31,42 @@ @Ignore public class WorkflowApiTest { - private final WorkflowApi api = new WorkflowApi(); + private final WorkflowApi api = new WorkflowApi(); + + /** + * Executes a workflow + * @throws ApiException if the Api call fails + */ + @Test + public void executeTest() throws ApiException { + WorkFlowRequestDTO workFlowRequestDTO = null; + WorkFlowResponseDTO response = api.execute(workFlowRequestDTO); + // TODO: test validations + } + + /** + * Returns a workflow status + * @throws ApiException if the Api call fails + */ + @Test + public void getStatusTest() throws ApiException { + String workFlowExecutionId = null; + WorkFlowStatusResponseDTO response = api.getStatus(workFlowExecutionId); + // TODO: test validations + } + + /** + * Updates a workflow checker task status + * @throws ApiException if the Api call fails + */ + @Test + public void updateWorkFlowCheckerTaskStatusTest() throws ApiException { + String workFlowExecutionId = null; + String workFlowCheckerTaskName = null; + WorkFlowCheckerTaskRequestDTO workFlowCheckerTaskRequestDTO = null; + String response = api.updateWorkFlowCheckerTaskStatus(workFlowExecutionId, workFlowCheckerTaskName, + workFlowCheckerTaskRequestDTO); + // TODO: test validations + } - - /** - * Executes a workflow - * - * - * - * @throws ApiException - * if the Api call fails - */ - @Test - public void executeTest() throws ApiException { - WorkFlowRequestDTO workFlowRequestDTO = null; - WorkFlowResponseDTO response = api.execute(workFlowRequestDTO); - // TODO: test validations - } - - /** - * Returns a workflow status - * - * - * - * @throws ApiException - * if the Api call fails - */ - @Test - public void getStatusTest() throws ApiException { - String workFlowExecutionId = null; - WorkFlowStatusResponseDTO response = api.getStatus(workFlowExecutionId); - // TODO: test validations - } - - /** - * Updates a workflow checker task status - * - * - * - * @throws ApiException - * if the Api call fails - */ - @Test - public void updateWorkFlowCheckerTaskStatusTest() throws ApiException { - String workFlowExecutionId = null; - String workFlowCheckerTaskName = null; - WorkFlowCheckerTaskRequestDTO workFlowCheckerTaskRequestDTO = null; - String response = api.updateWorkFlowCheckerTaskStatus(workFlowExecutionId, workFlowCheckerTaskName, workFlowCheckerTaskRequestDTO); - // TODO: test validations - } - } diff --git a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/api/WorkflowDefinitionApiTest.java b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/api/WorkflowDefinitionApiTest.java index 68ed72d65..2e78f0019 100644 --- a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/api/WorkflowDefinitionApiTest.java +++ b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/api/WorkflowDefinitionApiTest.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.api; import com.redhat.parodos.sdk.api.ApiException; @@ -29,37 +28,28 @@ @Ignore public class WorkflowDefinitionApiTest { - private final WorkflowDefinitionApi api = new WorkflowDefinitionApi(); + private final WorkflowDefinitionApi api = new WorkflowDefinitionApi(); + + /** + * Returns information about a workflow definition by id + * @throws ApiException if the Api call fails + */ + @Test + public void getWorkFlowDefinitionByIdTest() throws ApiException { + String id = null; + WorkFlowDefinitionResponseDTO response = api.getWorkFlowDefinitionById(id); + // TODO: test validations + } + + /** + * Returns a list of workflow definition + * @throws ApiException if the Api call fails + */ + @Test + public void getWorkFlowDefinitionsTest() throws ApiException { + String name = null; + List response = api.getWorkFlowDefinitions(name); + // TODO: test validations + } - - /** - * Returns information about a workflow definition by id - * - * - * - * @throws ApiException - * if the Api call fails - */ - @Test - public void getWorkFlowDefinitionByIdTest() throws ApiException { - String id = null; - WorkFlowDefinitionResponseDTO response = api.getWorkFlowDefinitionById(id); - // TODO: test validations - } - - /** - * Returns a list of workflow definition - * - * - * - * @throws ApiException - * if the Api call fails - */ - @Test - public void getWorkFlowDefinitionsTest() throws ApiException { - String name = null; - List response = api.getWorkFlowDefinitions(name); - // TODO: test validations - } - } diff --git a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/ArgumentRequestDTOTest.java b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/ArgumentRequestDTOTest.java index 527102e25..e12324c11 100644 --- a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/ArgumentRequestDTOTest.java +++ b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/ArgumentRequestDTOTest.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import com.google.gson.TypeAdapter; @@ -25,35 +24,35 @@ import org.junit.Ignore; import org.junit.Test; - /** * Model tests for ArgumentRequestDTO */ public class ArgumentRequestDTOTest { - private final ArgumentRequestDTO model = new ArgumentRequestDTO(); - - /** - * Model tests for ArgumentRequestDTO - */ - @Test - public void testArgumentRequestDTO() { - // TODO: test ArgumentRequestDTO - } - - /** - * Test the property 'key' - */ - @Test - public void keyTest() { - // TODO: test key - } - - /** - * Test the property 'value' - */ - @Test - public void valueTest() { - // TODO: test value - } + + private final ArgumentRequestDTO model = new ArgumentRequestDTO(); + + /** + * Model tests for ArgumentRequestDTO + */ + @Test + public void testArgumentRequestDTO() { + // TODO: test ArgumentRequestDTO + } + + /** + * Test the property 'key' + */ + @Test + public void keyTest() { + // TODO: test key + } + + /** + * Test the property 'value' + */ + @Test + public void valueTest() { + // TODO: test value + } } diff --git a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/ProjectRequestDTOTest.java b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/ProjectRequestDTOTest.java index fce4e94cc..719cf9289 100644 --- a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/ProjectRequestDTOTest.java +++ b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/ProjectRequestDTOTest.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import com.google.gson.TypeAdapter; @@ -25,35 +24,35 @@ import org.junit.Ignore; import org.junit.Test; - /** * Model tests for ProjectRequestDTO */ public class ProjectRequestDTOTest { - private final ProjectRequestDTO model = new ProjectRequestDTO(); - - /** - * Model tests for ProjectRequestDTO - */ - @Test - public void testProjectRequestDTO() { - // TODO: test ProjectRequestDTO - } - - /** - * Test the property 'description' - */ - @Test - public void descriptionTest() { - // TODO: test description - } - - /** - * Test the property 'name' - */ - @Test - public void nameTest() { - // TODO: test name - } + + private final ProjectRequestDTO model = new ProjectRequestDTO(); + + /** + * Model tests for ProjectRequestDTO + */ + @Test + public void testProjectRequestDTO() { + // TODO: test ProjectRequestDTO + } + + /** + * Test the property 'description' + */ + @Test + public void descriptionTest() { + // TODO: test description + } + + /** + * Test the property 'name' + */ + @Test + public void nameTest() { + // TODO: test name + } } diff --git a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/ProjectResponseDTOTest.java b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/ProjectResponseDTOTest.java index 40ea158b9..8f16865ce 100644 --- a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/ProjectResponseDTOTest.java +++ b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/ProjectResponseDTOTest.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import com.google.gson.TypeAdapter; @@ -26,67 +25,67 @@ import org.junit.Ignore; import org.junit.Test; - /** * Model tests for ProjectResponseDTO */ public class ProjectResponseDTOTest { - private final ProjectResponseDTO model = new ProjectResponseDTO(); - /** - * Model tests for ProjectResponseDTO - */ - @Test - public void testProjectResponseDTO() { - // TODO: test ProjectResponseDTO - } + private final ProjectResponseDTO model = new ProjectResponseDTO(); + + /** + * Model tests for ProjectResponseDTO + */ + @Test + public void testProjectResponseDTO() { + // TODO: test ProjectResponseDTO + } - /** - * Test the property 'createDate' - */ - @Test - public void createDateTest() { - // TODO: test createDate - } + /** + * Test the property 'createDate' + */ + @Test + public void createDateTest() { + // TODO: test createDate + } - /** - * Test the property 'description' - */ - @Test - public void descriptionTest() { - // TODO: test description - } + /** + * Test the property 'description' + */ + @Test + public void descriptionTest() { + // TODO: test description + } - /** - * Test the property 'id' - */ - @Test - public void idTest() { - // TODO: test id - } + /** + * Test the property 'id' + */ + @Test + public void idTest() { + // TODO: test id + } - /** - * Test the property 'modifyDate' - */ - @Test - public void modifyDateTest() { - // TODO: test modifyDate - } + /** + * Test the property 'modifyDate' + */ + @Test + public void modifyDateTest() { + // TODO: test modifyDate + } - /** - * Test the property 'name' - */ - @Test - public void nameTest() { - // TODO: test name - } + /** + * Test the property 'name' + */ + @Test + public void nameTest() { + // TODO: test name + } - /** - * Test the property 'username' - */ - @Test - public void usernameTest() { - // TODO: test username - } + /** + * Test the property 'username' + */ + @Test + public void usernameTest() { + // TODO: test username + } } diff --git a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkDefinitionResponseDTOTest.java b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkDefinitionResponseDTOTest.java index 36250d927..dee6c4735 100644 --- a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkDefinitionResponseDTOTest.java +++ b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkDefinitionResponseDTOTest.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import com.google.gson.TypeAdapter; @@ -29,83 +28,83 @@ import org.junit.Ignore; import org.junit.Test; - /** * Model tests for WorkDefinitionResponseDTO */ public class WorkDefinitionResponseDTOTest { - private final WorkDefinitionResponseDTO model = new WorkDefinitionResponseDTO(); - /** - * Model tests for WorkDefinitionResponseDTO - */ - @Test - public void testWorkDefinitionResponseDTO() { - // TODO: test WorkDefinitionResponseDTO - } + private final WorkDefinitionResponseDTO model = new WorkDefinitionResponseDTO(); + + /** + * Model tests for WorkDefinitionResponseDTO + */ + @Test + public void testWorkDefinitionResponseDTO() { + // TODO: test WorkDefinitionResponseDTO + } - /** - * Test the property 'author' - */ - @Test - public void authorTest() { - // TODO: test author - } + /** + * Test the property 'author' + */ + @Test + public void authorTest() { + // TODO: test author + } - /** - * Test the property 'id' - */ - @Test - public void idTest() { - // TODO: test id - } + /** + * Test the property 'id' + */ + @Test + public void idTest() { + // TODO: test id + } - /** - * Test the property 'name' - */ - @Test - public void nameTest() { - // TODO: test name - } + /** + * Test the property 'name' + */ + @Test + public void nameTest() { + // TODO: test name + } - /** - * Test the property 'outputs' - */ - @Test - public void outputsTest() { - // TODO: test outputs - } + /** + * Test the property 'outputs' + */ + @Test + public void outputsTest() { + // TODO: test outputs + } - /** - * Test the property 'parameters' - */ - @Test - public void parametersTest() { - // TODO: test parameters - } + /** + * Test the property 'parameters' + */ + @Test + public void parametersTest() { + // TODO: test parameters + } - /** - * Test the property 'processingType' - */ - @Test - public void processingTypeTest() { - // TODO: test processingType - } + /** + * Test the property 'processingType' + */ + @Test + public void processingTypeTest() { + // TODO: test processingType + } - /** - * Test the property 'workType' - */ - @Test - public void workTypeTest() { - // TODO: test workType - } + /** + * Test the property 'workType' + */ + @Test + public void workTypeTest() { + // TODO: test workType + } - /** - * Test the property 'works' - */ - @Test - public void worksTest() { - // TODO: test works - } + /** + * Test the property 'works' + */ + @Test + public void worksTest() { + // TODO: test works + } } diff --git a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowCheckerTaskRequestDTOTest.java b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowCheckerTaskRequestDTOTest.java index e5f0d79c7..171f50860 100644 --- a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowCheckerTaskRequestDTOTest.java +++ b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowCheckerTaskRequestDTOTest.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import com.google.gson.TypeAdapter; @@ -25,27 +24,27 @@ import org.junit.Ignore; import org.junit.Test; - /** * Model tests for WorkFlowCheckerTaskRequestDTO */ public class WorkFlowCheckerTaskRequestDTOTest { - private final WorkFlowCheckerTaskRequestDTO model = new WorkFlowCheckerTaskRequestDTO(); - - /** - * Model tests for WorkFlowCheckerTaskRequestDTO - */ - @Test - public void testWorkFlowCheckerTaskRequestDTO() { - // TODO: test WorkFlowCheckerTaskRequestDTO - } - /** - * Test the property 'status' - */ - @Test - public void statusTest() { - // TODO: test status - } + private final WorkFlowCheckerTaskRequestDTO model = new WorkFlowCheckerTaskRequestDTO(); + + /** + * Model tests for WorkFlowCheckerTaskRequestDTO + */ + @Test + public void testWorkFlowCheckerTaskRequestDTO() { + // TODO: test WorkFlowCheckerTaskRequestDTO + } + + /** + * Test the property 'status' + */ + @Test + public void statusTest() { + // TODO: test status + } } diff --git a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowDefinitionResponseDTOTest.java b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowDefinitionResponseDTOTest.java index 47937bc36..56f6eae78 100644 --- a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowDefinitionResponseDTOTest.java +++ b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowDefinitionResponseDTOTest.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import com.google.gson.TypeAdapter; @@ -33,99 +32,99 @@ import org.junit.Ignore; import org.junit.Test; - /** * Model tests for WorkFlowDefinitionResponseDTO */ public class WorkFlowDefinitionResponseDTOTest { - private final WorkFlowDefinitionResponseDTO model = new WorkFlowDefinitionResponseDTO(); - - /** - * Model tests for WorkFlowDefinitionResponseDTO - */ - @Test - public void testWorkFlowDefinitionResponseDTO() { - // TODO: test WorkFlowDefinitionResponseDTO - } - - /** - * Test the property 'author' - */ - @Test - public void authorTest() { - // TODO: test author - } - - /** - * Test the property 'createDate' - */ - @Test - public void createDateTest() { - // TODO: test createDate - } - - /** - * Test the property 'id' - */ - @Test - public void idTest() { - // TODO: test id - } - - /** - * Test the property 'modifyDate' - */ - @Test - public void modifyDateTest() { - // TODO: test modifyDate - } - - /** - * Test the property 'name' - */ - @Test - public void nameTest() { - // TODO: test name - } - - /** - * Test the property 'parameters' - */ - @Test - public void parametersTest() { - // TODO: test parameters - } - - /** - * Test the property 'processingType' - */ - @Test - public void processingTypeTest() { - // TODO: test processingType - } - - /** - * Test the property 'properties' - */ - @Test - public void propertiesTest() { - // TODO: test properties - } - - /** - * Test the property 'type' - */ - @Test - public void typeTest() { - // TODO: test type - } - - /** - * Test the property 'works' - */ - @Test - public void worksTest() { - // TODO: test works - } + + private final WorkFlowDefinitionResponseDTO model = new WorkFlowDefinitionResponseDTO(); + + /** + * Model tests for WorkFlowDefinitionResponseDTO + */ + @Test + public void testWorkFlowDefinitionResponseDTO() { + // TODO: test WorkFlowDefinitionResponseDTO + } + + /** + * Test the property 'author' + */ + @Test + public void authorTest() { + // TODO: test author + } + + /** + * Test the property 'createDate' + */ + @Test + public void createDateTest() { + // TODO: test createDate + } + + /** + * Test the property 'id' + */ + @Test + public void idTest() { + // TODO: test id + } + + /** + * Test the property 'modifyDate' + */ + @Test + public void modifyDateTest() { + // TODO: test modifyDate + } + + /** + * Test the property 'name' + */ + @Test + public void nameTest() { + // TODO: test name + } + + /** + * Test the property 'parameters' + */ + @Test + public void parametersTest() { + // TODO: test parameters + } + + /** + * Test the property 'processingType' + */ + @Test + public void processingTypeTest() { + // TODO: test processingType + } + + /** + * Test the property 'properties' + */ + @Test + public void propertiesTest() { + // TODO: test properties + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'works' + */ + @Test + public void worksTest() { + // TODO: test works + } } diff --git a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowOptionTest.java b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowOptionTest.java index 9931182a7..a448bac2b 100644 --- a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowOptionTest.java +++ b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowOptionTest.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import com.google.gson.TypeAdapter; @@ -27,59 +26,59 @@ import org.junit.Ignore; import org.junit.Test; - /** * Model tests for WorkFlowOption */ public class WorkFlowOptionTest { - private final WorkFlowOption model = new WorkFlowOption(); - /** - * Model tests for WorkFlowOption - */ - @Test - public void testWorkFlowOption() { - // TODO: test WorkFlowOption - } + private final WorkFlowOption model = new WorkFlowOption(); + + /** + * Model tests for WorkFlowOption + */ + @Test + public void testWorkFlowOption() { + // TODO: test WorkFlowOption + } - /** - * Test the property 'description' - */ - @Test - public void descriptionTest() { - // TODO: test description - } + /** + * Test the property 'description' + */ + @Test + public void descriptionTest() { + // TODO: test description + } - /** - * Test the property 'details' - */ - @Test - public void detailsTest() { - // TODO: test details - } + /** + * Test the property 'details' + */ + @Test + public void detailsTest() { + // TODO: test details + } - /** - * Test the property 'displayName' - */ - @Test - public void displayNameTest() { - // TODO: test displayName - } + /** + * Test the property 'displayName' + */ + @Test + public void displayNameTest() { + // TODO: test displayName + } - /** - * Test the property 'identifier' - */ - @Test - public void identifierTest() { - // TODO: test identifier - } + /** + * Test the property 'identifier' + */ + @Test + public void identifierTest() { + // TODO: test identifier + } - /** - * Test the property 'workFlowName' - */ - @Test - public void workFlowNameTest() { - // TODO: test workFlowName - } + /** + * Test the property 'workFlowName' + */ + @Test + public void workFlowNameTest() { + // TODO: test workFlowName + } } diff --git a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowOptionsTest.java b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowOptionsTest.java index ea5061476..9c47e3ac2 100644 --- a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowOptionsTest.java +++ b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowOptionsTest.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import com.google.gson.TypeAdapter; @@ -28,75 +27,75 @@ import org.junit.Ignore; import org.junit.Test; - /** * Model tests for WorkFlowOptions */ public class WorkFlowOptionsTest { - private final WorkFlowOptions model = new WorkFlowOptions(); - /** - * Model tests for WorkFlowOptions - */ - @Test - public void testWorkFlowOptions() { - // TODO: test WorkFlowOptions - } + private final WorkFlowOptions model = new WorkFlowOptions(); + + /** + * Model tests for WorkFlowOptions + */ + @Test + public void testWorkFlowOptions() { + // TODO: test WorkFlowOptions + } - /** - * Test the property 'continuationOptions' - */ - @Test - public void continuationOptionsTest() { - // TODO: test continuationOptions - } + /** + * Test the property 'continuationOptions' + */ + @Test + public void continuationOptionsTest() { + // TODO: test continuationOptions + } - /** - * Test the property 'currentVersion' - */ - @Test - public void currentVersionTest() { - // TODO: test currentVersion - } + /** + * Test the property 'currentVersion' + */ + @Test + public void currentVersionTest() { + // TODO: test currentVersion + } - /** - * Test the property 'migrationOptions' - */ - @Test - public void migrationOptionsTest() { - // TODO: test migrationOptions - } + /** + * Test the property 'migrationOptions' + */ + @Test + public void migrationOptionsTest() { + // TODO: test migrationOptions + } - /** - * Test the property 'newOptions' - */ - @Test - public void newOptionsTest() { - // TODO: test newOptions - } + /** + * Test the property 'newOptions' + */ + @Test + public void newOptionsTest() { + // TODO: test newOptions + } - /** - * Test the property 'optionsAvailable' - */ - @Test - public void optionsAvailableTest() { - // TODO: test optionsAvailable - } + /** + * Test the property 'optionsAvailable' + */ + @Test + public void optionsAvailableTest() { + // TODO: test optionsAvailable + } - /** - * Test the property 'otherOptions' - */ - @Test - public void otherOptionsTest() { - // TODO: test otherOptions - } + /** + * Test the property 'otherOptions' + */ + @Test + public void otherOptionsTest() { + // TODO: test otherOptions + } - /** - * Test the property 'upgradeOptions' - */ - @Test - public void upgradeOptionsTest() { - // TODO: test upgradeOptions - } + /** + * Test the property 'upgradeOptions' + */ + @Test + public void upgradeOptionsTest() { + // TODO: test upgradeOptions + } } diff --git a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowPropertiesDefinitionDTOTest.java b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowPropertiesDefinitionDTOTest.java index c1c2d68fa..f9e6a3e5a 100644 --- a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowPropertiesDefinitionDTOTest.java +++ b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowPropertiesDefinitionDTOTest.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import com.google.gson.TypeAdapter; @@ -25,27 +24,27 @@ import org.junit.Ignore; import org.junit.Test; - /** * Model tests for WorkFlowPropertiesDefinitionDTO */ public class WorkFlowPropertiesDefinitionDTOTest { - private final WorkFlowPropertiesDefinitionDTO model = new WorkFlowPropertiesDefinitionDTO(); - - /** - * Model tests for WorkFlowPropertiesDefinitionDTO - */ - @Test - public void testWorkFlowPropertiesDefinitionDTO() { - // TODO: test WorkFlowPropertiesDefinitionDTO - } - /** - * Test the property 'version' - */ - @Test - public void versionTest() { - // TODO: test version - } + private final WorkFlowPropertiesDefinitionDTO model = new WorkFlowPropertiesDefinitionDTO(); + + /** + * Model tests for WorkFlowPropertiesDefinitionDTO + */ + @Test + public void testWorkFlowPropertiesDefinitionDTO() { + // TODO: test WorkFlowPropertiesDefinitionDTO + } + + /** + * Test the property 'version' + */ + @Test + public void versionTest() { + // TODO: test version + } } diff --git a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowRequestDTOTest.java b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowRequestDTOTest.java index 62e996784..a04b9b98d 100644 --- a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowRequestDTOTest.java +++ b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowRequestDTOTest.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import com.google.gson.TypeAdapter; @@ -29,51 +28,51 @@ import org.junit.Ignore; import org.junit.Test; - /** * Model tests for WorkFlowRequestDTO */ public class WorkFlowRequestDTOTest { - private final WorkFlowRequestDTO model = new WorkFlowRequestDTO(); - /** - * Model tests for WorkFlowRequestDTO - */ - @Test - public void testWorkFlowRequestDTO() { - // TODO: test WorkFlowRequestDTO - } + private final WorkFlowRequestDTO model = new WorkFlowRequestDTO(); + + /** + * Model tests for WorkFlowRequestDTO + */ + @Test + public void testWorkFlowRequestDTO() { + // TODO: test WorkFlowRequestDTO + } - /** - * Test the property 'arguments' - */ - @Test - public void argumentsTest() { - // TODO: test arguments - } + /** + * Test the property 'arguments' + */ + @Test + public void argumentsTest() { + // TODO: test arguments + } - /** - * Test the property 'projectId' - */ - @Test - public void projectIdTest() { - // TODO: test projectId - } + /** + * Test the property 'projectId' + */ + @Test + public void projectIdTest() { + // TODO: test projectId + } - /** - * Test the property 'workFlowName' - */ - @Test - public void workFlowNameTest() { - // TODO: test workFlowName - } + /** + * Test the property 'workFlowName' + */ + @Test + public void workFlowNameTest() { + // TODO: test workFlowName + } - /** - * Test the property 'works' - */ - @Test - public void worksTest() { - // TODO: test works - } + /** + * Test the property 'works' + */ + @Test + public void worksTest() { + // TODO: test works + } } diff --git a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowResponseDTOTest.java b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowResponseDTOTest.java index 8d22a6977..70b0add9d 100644 --- a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowResponseDTOTest.java +++ b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowResponseDTOTest.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import com.google.gson.TypeAdapter; @@ -26,43 +25,43 @@ import org.junit.Ignore; import org.junit.Test; - /** * Model tests for WorkFlowResponseDTO */ public class WorkFlowResponseDTOTest { - private final WorkFlowResponseDTO model = new WorkFlowResponseDTO(); - /** - * Model tests for WorkFlowResponseDTO - */ - @Test - public void testWorkFlowResponseDTO() { - // TODO: test WorkFlowResponseDTO - } + private final WorkFlowResponseDTO model = new WorkFlowResponseDTO(); + + /** + * Model tests for WorkFlowResponseDTO + */ + @Test + public void testWorkFlowResponseDTO() { + // TODO: test WorkFlowResponseDTO + } - /** - * Test the property 'workFlowExecutionId' - */ - @Test - public void workFlowExecutionIdTest() { - // TODO: test workFlowExecutionId - } + /** + * Test the property 'workFlowExecutionId' + */ + @Test + public void workFlowExecutionIdTest() { + // TODO: test workFlowExecutionId + } - /** - * Test the property 'workFlowOptions' - */ - @Test - public void workFlowOptionsTest() { - // TODO: test workFlowOptions - } + /** + * Test the property 'workFlowOptions' + */ + @Test + public void workFlowOptionsTest() { + // TODO: test workFlowOptions + } - /** - * Test the property 'workStatus' - */ - @Test - public void workStatusTest() { - // TODO: test workStatus - } + /** + * Test the property 'workStatus' + */ + @Test + public void workStatusTest() { + // TODO: test workStatus + } } diff --git a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowStatusResponseDTOTest.java b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowStatusResponseDTOTest.java index fa9dbe9d6..813ba1681 100644 --- a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowStatusResponseDTOTest.java +++ b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkFlowStatusResponseDTOTest.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import com.google.gson.TypeAdapter; @@ -28,51 +27,51 @@ import org.junit.Ignore; import org.junit.Test; - /** * Model tests for WorkFlowStatusResponseDTO */ public class WorkFlowStatusResponseDTOTest { - private final WorkFlowStatusResponseDTO model = new WorkFlowStatusResponseDTO(); - /** - * Model tests for WorkFlowStatusResponseDTO - */ - @Test - public void testWorkFlowStatusResponseDTO() { - // TODO: test WorkFlowStatusResponseDTO - } + private final WorkFlowStatusResponseDTO model = new WorkFlowStatusResponseDTO(); + + /** + * Model tests for WorkFlowStatusResponseDTO + */ + @Test + public void testWorkFlowStatusResponseDTO() { + // TODO: test WorkFlowStatusResponseDTO + } - /** - * Test the property 'status' - */ - @Test - public void statusTest() { - // TODO: test status - } + /** + * Test the property 'status' + */ + @Test + public void statusTest() { + // TODO: test status + } - /** - * Test the property 'workFlowExecutionId' - */ - @Test - public void workFlowExecutionIdTest() { - // TODO: test workFlowExecutionId - } + /** + * Test the property 'workFlowExecutionId' + */ + @Test + public void workFlowExecutionIdTest() { + // TODO: test workFlowExecutionId + } - /** - * Test the property 'workFlowName' - */ - @Test - public void workFlowNameTest() { - // TODO: test workFlowName - } + /** + * Test the property 'workFlowName' + */ + @Test + public void workFlowNameTest() { + // TODO: test workFlowName + } - /** - * Test the property 'works' - */ - @Test - public void worksTest() { - // TODO: test works - } + /** + * Test the property 'works' + */ + @Test + public void worksTest() { + // TODO: test works + } } diff --git a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkRequestDTOTest.java b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkRequestDTOTest.java index 2def893af..c48c50593 100644 --- a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkRequestDTOTest.java +++ b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkRequestDTOTest.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import com.google.gson.TypeAdapter; @@ -28,43 +27,43 @@ import org.junit.Ignore; import org.junit.Test; - /** * Model tests for WorkRequestDTO */ public class WorkRequestDTOTest { - private final WorkRequestDTO model = new WorkRequestDTO(); - /** - * Model tests for WorkRequestDTO - */ - @Test - public void testWorkRequestDTO() { - // TODO: test WorkRequestDTO - } + private final WorkRequestDTO model = new WorkRequestDTO(); + + /** + * Model tests for WorkRequestDTO + */ + @Test + public void testWorkRequestDTO() { + // TODO: test WorkRequestDTO + } - /** - * Test the property 'arguments' - */ - @Test - public void argumentsTest() { - // TODO: test arguments - } + /** + * Test the property 'arguments' + */ + @Test + public void argumentsTest() { + // TODO: test arguments + } - /** - * Test the property 'type' - */ - @Test - public void typeTest() { - // TODO: test type - } + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } - /** - * Test the property 'workName' - */ - @Test - public void workNameTest() { - // TODO: test workName - } + /** + * Test the property 'workName' + */ + @Test + public void workNameTest() { + // TODO: test workName + } } diff --git a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkStatusResponseDTOTest.java b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkStatusResponseDTOTest.java index af80e6b21..2d7b65207 100644 --- a/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkStatusResponseDTOTest.java +++ b/workflow-service-sdk/src/test/java/com/redhat/parodos/sdk/model/WorkStatusResponseDTOTest.java @@ -3,14 +3,13 @@ * This is the API documentation for the Parodos Workflow Service. It provides operations to execute assessments to determine infrastructure options (tooling + environments). Also executes infrastructure task workflows to call downstream systems to stand-up an infrastructure option. * * The version of the OpenAPI document: v1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package com.redhat.parodos.sdk.model; import com.google.gson.TypeAdapter; @@ -25,43 +24,43 @@ import org.junit.Ignore; import org.junit.Test; - /** * Model tests for WorkStatusResponseDTO */ public class WorkStatusResponseDTOTest { - private final WorkStatusResponseDTO model = new WorkStatusResponseDTO(); - /** - * Model tests for WorkStatusResponseDTO - */ - @Test - public void testWorkStatusResponseDTO() { - // TODO: test WorkStatusResponseDTO - } + private final WorkStatusResponseDTO model = new WorkStatusResponseDTO(); + + /** + * Model tests for WorkStatusResponseDTO + */ + @Test + public void testWorkStatusResponseDTO() { + // TODO: test WorkStatusResponseDTO + } - /** - * Test the property 'name' - */ - @Test - public void nameTest() { - // TODO: test name - } + /** + * Test the property 'name' + */ + @Test + public void nameTest() { + // TODO: test name + } - /** - * Test the property 'status' - */ - @Test - public void statusTest() { - // TODO: test status - } + /** + * Test the property 'status' + */ + @Test + public void statusTest() { + // TODO: test status + } - /** - * Test the property 'type' - */ - @Test - public void typeTest() { - // TODO: test type - } + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } } diff --git a/workflow-service/generated/openapi/openapi.json b/workflow-service/generated/openapi/openapi.json index 183e7402e..0c0a1b07e 100644 --- a/workflow-service/generated/openapi/openapi.json +++ b/workflow-service/generated/openapi/openapi.json @@ -416,7 +416,7 @@ "properties" : { "status" : { "type" : "string", - "enum" : [ "FAILED", "COMPLETED", "IN_PROGRESS", "PENDING" ] + "enum" : [ "FAILED", "COMPLETED", "IN_PROGRESS", "PENDING", "REJECTED" ] } } }, @@ -573,7 +573,7 @@ }, "workStatus" : { "type" : "string", - "enum" : [ "FAILED", "COMPLETED", "IN_PROGRESS" ] + "enum" : [ "FAILED", "COMPLETED", "IN_PROGRESS", "REJECTED", "PENDING" ] } } }, diff --git a/workflow-service/pom.xml b/workflow-service/pom.xml index 36ea4d6b5..e27c24e23 100644 --- a/workflow-service/pom.xml +++ b/workflow-service/pom.xml @@ -55,7 +55,6 @@ org.springframework.boot spring-boot-starter-security
    - org.springframework.security spring-security-ldap @@ -68,7 +67,6 @@ com.unboundid unboundid-ldapsdk - @@ -99,6 +97,15 @@ spring-boot-starter-actuator + + + + io.micrometer + micrometer-registry-prometheus + runtime + + + org.springframework.cloud diff --git a/workflow-service/src/main/java/com/redhat/parodos/common/AbstractEntity.java b/workflow-service/src/main/java/com/redhat/parodos/common/AbstractEntity.java index 14f935ad2..97cd86bd4 100644 --- a/workflow-service/src/main/java/com/redhat/parodos/common/AbstractEntity.java +++ b/workflow-service/src/main/java/com/redhat/parodos/common/AbstractEntity.java @@ -37,7 +37,8 @@ public class AbstractEntity { @Column(columnDefinition = "uuid") private UUID id; - @Version + // TODO: disabled temporarily as optimistic locking issue + // @Version @JsonIgnore private Long objectVersion; diff --git a/workflow-service/src/main/java/com/redhat/parodos/config/MetricsConfig.java b/workflow-service/src/main/java/com/redhat/parodos/config/MetricsConfig.java new file mode 100644 index 000000000..af7110194 --- /dev/null +++ b/workflow-service/src/main/java/com/redhat/parodos/config/MetricsConfig.java @@ -0,0 +1,16 @@ +package com.redhat.parodos.config; + +import io.micrometer.core.instrument.MeterRegistry; +import io.micrometer.core.instrument.simple.SimpleMeterRegistry; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class MetricsConfig { + + @Bean + public MeterRegistry meterRegistry() { + return new SimpleMeterRegistry(); + } + +} diff --git a/workflow-service/src/main/java/com/redhat/parodos/workflow/WorkFlowDelegate.java b/workflow-service/src/main/java/com/redhat/parodos/workflow/WorkFlowDelegate.java index 99502cad3..4ad1f8846 100644 --- a/workflow-service/src/main/java/com/redhat/parodos/workflow/WorkFlowDelegate.java +++ b/workflow-service/src/main/java/com/redhat/parodos/workflow/WorkFlowDelegate.java @@ -16,6 +16,8 @@ package com.redhat.parodos.workflow; import com.redhat.parodos.workflow.context.WorkContextDelegate; +import com.redhat.parodos.workflow.definition.dto.WorkDefinitionResponseDTO; +import com.redhat.parodos.workflow.definition.dto.WorkFlowDefinitionResponseDTO; import com.redhat.parodos.workflow.enums.WorkType; import com.redhat.parodos.workflow.execution.dto.WorkFlowRequestDTO; import com.redhat.parodos.workflow.registry.BeanWorkFlowRegistryImpl; @@ -23,6 +25,9 @@ import com.redhat.parodos.workflows.work.WorkContext; import com.redhat.parodos.workflows.workflow.WorkFlow; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.Optional; /** * Provides functionality that is common to any WorkFlow composition in Parodos @@ -41,7 +46,8 @@ public WorkFlowDelegate(BeanWorkFlowRegistryImpl beanWorkFlowRegistry) { this.beanWorkFlowRegistry = beanWorkFlowRegistry; } - public WorkContext initWorkFlowContext(WorkFlowRequestDTO workFlowRequestDTO) { + public WorkContext initWorkFlowContext(WorkFlowRequestDTO workFlowRequestDTO, + WorkFlowDefinitionResponseDTO masterWorkFlowDefinitionDto) { WorkContext workContext = new WorkContext(); if (workFlowRequestDTO.getArguments() != null && !workFlowRequestDTO.getArguments().isEmpty()) { @@ -49,26 +55,32 @@ public WorkContext initWorkFlowContext(WorkFlowRequestDTO workFlowRequestDTO) { workFlowRequestDTO.getWorkFlowName(), WorkContextDelegate.Resource.ARGUMENTS, WorkFlowDTOUtil.convertArgumentListToMap(workFlowRequestDTO.getArguments())); } - if (workFlowRequestDTO.getWorks() != null) - workFlowRequestDTO.getWorks() - .forEach(work -> initWorkContext(workContext, work, workFlowRequestDTO.getWorkFlowName())); + if (masterWorkFlowDefinitionDto.getWorks() != null && !masterWorkFlowDefinitionDto.getWorks().isEmpty()) + masterWorkFlowDefinitionDto.getWorks().forEach( + work -> initWorkContext(workContext, workFlowRequestDTO.findFirstWorkByName(work.getName()), work, + masterWorkFlowDefinitionDto.getName())); return workContext; } private void initWorkContext(WorkContext workContext, WorkFlowRequestDTO.WorkRequestDTO workRequestDTO, - String parentWorkflowName) { + WorkDefinitionResponseDTO workDefinitionResponseDTO, String parentWorkflowName) { WorkContextDelegate.write(workContext, WorkContextDelegate.ProcessType.WORKFLOW_EXECUTION, - workRequestDTO.getWorkName(), WorkContextDelegate.Resource.PARENT_WORKFLOW, parentWorkflowName); - if (workRequestDTO.getArguments() != null && !workRequestDTO.getArguments().isEmpty()) { - WorkContextDelegate.write(workContext, - WorkType.WORKFLOW.name().equals(workRequestDTO.getType()) - ? WorkContextDelegate.ProcessType.WORKFLOW_EXECUTION - : WorkContextDelegate.ProcessType.WORKFLOW_TASK_EXECUTION, - workRequestDTO.getWorkName(), WorkContextDelegate.Resource.ARGUMENTS, - WorkFlowDTOUtil.convertArgumentListToMap(workRequestDTO.getArguments())); - } - if (workRequestDTO.getWorks() != null) - workRequestDTO.getWorks().forEach(work -> initWorkContext(workContext, work, workRequestDTO.getWorkName())); + workDefinitionResponseDTO.getName(), WorkContextDelegate.Resource.PARENT_WORKFLOW, parentWorkflowName); + + Optional.ofNullable(workRequestDTO).filter(dto -> !CollectionUtils.isEmpty(dto.getArguments())) + .ifPresent(dto -> WorkContextDelegate.write(workContext, + WorkType.WORKFLOW.name().equalsIgnoreCase(dto.getType()) + ? WorkContextDelegate.ProcessType.WORKFLOW_EXECUTION + : WorkContextDelegate.ProcessType.WORKFLOW_TASK_EXECUTION, + workRequestDTO.getWorkName(), WorkContextDelegate.Resource.ARGUMENTS, + WorkFlowDTOUtil.convertArgumentListToMap(workRequestDTO.getArguments()))); + + if (workDefinitionResponseDTO.getWorks() != null) + workDefinitionResponseDTO.getWorks() + .forEach(work -> initWorkContext( + workContext, Optional.ofNullable(workRequestDTO) + .map(dto -> dto.findFirstWorkByName(work.getName())).orElse(null), + work, workDefinitionResponseDTO.getName())); } public WorkFlow getWorkFlowExecutionByName(String workFlowName) { diff --git a/workflow-service/src/main/java/com/redhat/parodos/workflow/definition/dto/WorkDefinitionResponseDTO.java b/workflow-service/src/main/java/com/redhat/parodos/workflow/definition/dto/WorkDefinitionResponseDTO.java index f9f4e0ba7..5600fa4a2 100644 --- a/workflow-service/src/main/java/com/redhat/parodos/workflow/definition/dto/WorkDefinitionResponseDTO.java +++ b/workflow-service/src/main/java/com/redhat/parodos/workflow/definition/dto/WorkDefinitionResponseDTO.java @@ -19,8 +19,13 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.type.TypeReference; +import com.redhat.parodos.workflow.definition.entity.WorkFlowDefinition; +import com.redhat.parodos.workflow.definition.entity.WorkFlowTaskDefinition; +import com.redhat.parodos.workflow.definition.entity.WorkFlowWorkDefinition; +import com.redhat.parodos.workflow.enums.WorkType; import com.redhat.parodos.workflow.task.enums.WorkFlowTaskOutput; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -29,6 +34,7 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; /** * Workflow task definition response dto @@ -82,4 +88,18 @@ public WorkDefinitionResponseDTOBuilder parameterFromString(String parameters) { } + public static WorkDefinitionResponseDTO fromWorkFlowDefinitionEntity(WorkFlowDefinition wd, + List dependencies) { + return WorkDefinitionResponseDTO.builder().id(wd.getId().toString()).workType(WorkType.WORKFLOW.name()) + .name(wd.getName()).parameterFromString(wd.getParameters()).processingType(wd.getProcessingType()) + .works(new ArrayList<>()).numberOfWorkUnits(dependencies.size()).build(); + } + + public static WorkDefinitionResponseDTO fromWorkFlowTaskDefinition(WorkFlowTaskDefinition wdt) { + return WorkDefinitionResponseDTO.builder().id(wdt.getId().toString()).workType(WorkType.TASK.name()) + .name(wdt.getName()).parameterFromString(wdt.getParameters()) + .outputs(WorkFlowDTOUtil.readStringAsObject(wdt.getOutputs(), new TypeReference<>() { + }, List.of())).build(); + } + } diff --git a/workflow-service/src/main/java/com/redhat/parodos/workflow/definition/dto/WorkFlowDefinitionResponseDTO.java b/workflow-service/src/main/java/com/redhat/parodos/workflow/definition/dto/WorkFlowDefinitionResponseDTO.java index 18f3643de..4319e1f9b 100644 --- a/workflow-service/src/main/java/com/redhat/parodos/workflow/definition/dto/WorkFlowDefinitionResponseDTO.java +++ b/workflow-service/src/main/java/com/redhat/parodos/workflow/definition/dto/WorkFlowDefinitionResponseDTO.java @@ -23,6 +23,7 @@ import java.util.Map; import java.util.UUID; +import com.redhat.parodos.workflow.definition.entity.WorkFlowDefinition; import com.redhat.parodos.workflow.util.WorkFlowDTOUtil; import lombok.AllArgsConstructor; import lombok.Builder; @@ -81,4 +82,14 @@ public WorkFlowDefinitionResponseDTOBuilder parameterFromString(String parameter } + public static WorkFlowDefinitionResponseDTO fromEntity(WorkFlowDefinition workFlowDefinition, + List works) { + return WorkFlowDefinitionResponseDTO.builder().id(workFlowDefinition.getId()).name(workFlowDefinition.getName()) + .properties(WorkFlowPropertiesDefinitionDTO.fromEntity(workFlowDefinition.getProperties())) + .parameterFromString(workFlowDefinition.getParameters()).author(workFlowDefinition.getAuthor()) + .createDate(workFlowDefinition.getCreateDate()).modifyDate(workFlowDefinition.getModifyDate()) + .type(workFlowDefinition.getType().toString()).processingType(workFlowDefinition.getProcessingType()) + .works(works).build(); + } + } \ No newline at end of file diff --git a/workflow-service/src/main/java/com/redhat/parodos/workflow/definition/service/WorkFlowDefinitionServiceImpl.java b/workflow-service/src/main/java/com/redhat/parodos/workflow/definition/service/WorkFlowDefinitionServiceImpl.java index c761a034e..854ad449c 100644 --- a/workflow-service/src/main/java/com/redhat/parodos/workflow/definition/service/WorkFlowDefinitionServiceImpl.java +++ b/workflow-service/src/main/java/com/redhat/parodos/workflow/definition/service/WorkFlowDefinitionServiceImpl.java @@ -16,10 +16,10 @@ package com.redhat.parodos.workflow.definition.service; import com.fasterxml.jackson.core.type.TypeReference; +import com.redhat.parodos.common.AbstractEntity; import com.redhat.parodos.workflow.definition.dto.WorkDefinitionResponseDTO; import com.redhat.parodos.workflow.definition.dto.WorkFlowCheckerDTO; import com.redhat.parodos.workflow.definition.dto.WorkFlowDefinitionResponseDTO; -import com.redhat.parodos.workflow.definition.dto.WorkFlowPropertiesDefinitionDTO; import com.redhat.parodos.workflow.definition.entity.WorkFlowCheckerMappingDefinition; import com.redhat.parodos.workflow.definition.entity.WorkFlowDefinition; import com.redhat.parodos.workflow.definition.entity.WorkFlowTaskDefinition; @@ -48,7 +48,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.Optional; import java.util.UUID; import java.util.concurrent.CopyOnWriteArrayList; @@ -106,35 +105,31 @@ public WorkFlowDefinitionResponseDTO save(String workFlowName, WorkFlowType work .writeObjectValueAsString(convertWorkFlowParameters(workFlowParameters)); // set and save workflow definition - WorkFlowDefinition workFlowDefinition = workFlowDefinitionRepository.findFirstByName(workFlowName); WorkFlowPropertiesDefinition propertiesDefinition = WorkFlowPropertiesDefinition.builder().build(); if (properties != null) { propertiesDefinition.setVersion(properties.getVersion()); } - if (workFlowDefinition == null || !(Objects.equals(works.size(), workFlowDefinition.getNumberOfWorks()) - && Objects.equals(workFlowType, workFlowDefinition.getType()) - && Objects.equals(stringifyParameters, workFlowDefinition.getParameters()) - && Objects.equals(workFlowProcessingType.name(), workFlowDefinition.getProcessingType()))) { - // update the workflow if its properties changed - workFlowDefinition = workFlowDefinitionRepository - .save(Optional.ofNullable(workFlowDefinition).map(foundWorkflowDefinition -> { - foundWorkflowDefinition.setType(workFlowType); - foundWorkflowDefinition.setParameters(stringifyParameters); - foundWorkflowDefinition.setModifyDate(new Date()); - foundWorkflowDefinition.setProperties(propertiesDefinition); - foundWorkflowDefinition.setProcessingType(workFlowProcessingType.name()); - foundWorkflowDefinition.setNumberOfWorks(works.size()); - return foundWorkflowDefinition; - }).orElse(WorkFlowDefinition.builder().name(workFlowName).type(workFlowType).createDate(new Date()) - .parameters(stringifyParameters).modifyDate(new Date()).properties(propertiesDefinition) - .numberOfWorks(works.size()).processingType(workFlowProcessingType.name()).build())); + WorkFlowDefinition workFlowDefinition = workFlowDefinitionRepository.findFirstByName(workFlowName); + if (workFlowDefinition == null) { + // It's not created, so we created the minimal entity to update it + workFlowDefinition = WorkFlowDefinition.builder().name(workFlowName).createDate(new Date()).build(); } + + workFlowDefinition.setType(workFlowType); + workFlowDefinition.setParameters(stringifyParameters); + workFlowDefinition.setModifyDate(new Date()); + workFlowDefinition.setProperties(propertiesDefinition); + workFlowDefinition.setProcessingType(workFlowProcessingType.name()); + workFlowDefinition.setNumberOfWorks(works.size()); + + workFlowDefinition = workFlowDefinitionRepository.save(workFlowDefinition); + // save workflow tasks and set works List workFlowWorkDefinitions = new ArrayList<>(); WorkFlowDefinition finalWorkFlowDefinition = workFlowDefinition; works.forEach(work -> { - UUID workId; + UUID workId = null; if (work instanceof WorkFlow) { // WorkFlow // A workflow in works should already been stored workId = workFlowDefinitionRepository.findFirstByName(work.getName()).getId(); @@ -167,14 +162,16 @@ public WorkFlowDefinitionResponseDTO save(String workFlowName, WorkFlowType work .workFlowDefinition(finalWorkFlowDefinition).createDate(new Date()) .modifyDate(new Date()).build())) .getId(); - workFlowWorkDefinitions.add( - WorkFlowWorkDefinition.builder().workDefinitionId(workId).workDefinitionType(WorkType.TASK) - .workFlowDefinition(finalWorkFlowDefinition).createDate(new Date()).build()); } + workFlowWorkDefinitions.add(WorkFlowWorkDefinition.builder() + .workDefinitionId(workFlowTaskDefinitionOptional.map(AbstractEntity::getId).orElse(workId)) + .workDefinitionType(WorkType.TASK).workFlowDefinition(finalWorkFlowDefinition) + .createDate(new Date()).build()); } }); - finalWorkFlowDefinition.setWorkFlowWorkDefinitions(workFlowWorkDefinitions); - return modelMapper.map(workFlowDefinitionRepository.save(finalWorkFlowDefinition), + + workFlowDefinition.setWorkFlowWorkDefinitions(workFlowWorkDefinitions); + return modelMapper.map(workFlowDefinitionRepository.save(workFlowDefinition), WorkFlowDefinitionResponseDTO.class); } @@ -182,16 +179,9 @@ public WorkFlowDefinitionResponseDTO save(String workFlowName, WorkFlowType work public List getWorkFlowDefinitions() { List workFlowDefinitionResponseDTOs = new ArrayList<>(); workFlowDefinitionRepository.findByTypeIsNot(WorkFlowType.CHECKER).forEach(workFlowDefinition -> { - workFlowDefinitionResponseDTOs.add(WorkFlowDefinitionResponseDTO.builder().id(workFlowDefinition.getId()) - .name(workFlowDefinition.getName()) - .properties(WorkFlowPropertiesDefinitionDTO.fromEntity(workFlowDefinition.getProperties())) - .parameterFromString(workFlowDefinition.getParameters()).author(workFlowDefinition.getAuthor()) - .createDate(workFlowDefinition.getCreateDate()).modifyDate(workFlowDefinition.getModifyDate()) - .type(workFlowDefinition.getType().name()).processingType(workFlowDefinition.getProcessingType()) - .works(buildWorkFlowWorksDTOs(workFlowDefinition, - workFlowWorkRepository - .findByWorkFlowDefinitionIdOrderByCreateDateAsc(workFlowDefinition.getId()))) - .build()); + workFlowDefinitionResponseDTOs.add(WorkFlowDefinitionResponseDTO.fromEntity(workFlowDefinition, + buildWorkFlowWorksDTOs(workFlowDefinition, workFlowWorkRepository + .findByWorkFlowDefinitionIdOrderByCreateDateAsc(workFlowDefinition.getId())))); }); return workFlowDefinitionResponseDTOs; } @@ -203,12 +193,8 @@ public WorkFlowDefinitionResponseDTO getWorkFlowDefinitionById(UUID id) { List workFlowWorkDependencies = workFlowWorkRepository .findByWorkFlowDefinitionIdOrderByCreateDateAsc(workFlowDefinition.getId()).stream() .sorted(Comparator.comparing(WorkFlowWorkDefinition::getCreateDate)).collect(Collectors.toList()); - return WorkFlowDefinitionResponseDTO.builder().id(workFlowDefinition.getId()).name(workFlowDefinition.getName()) - .properties(WorkFlowPropertiesDefinitionDTO.fromEntity(workFlowDefinition.getProperties())) - .parameterFromString(workFlowDefinition.getParameters()).author(workFlowDefinition.getAuthor()) - .createDate(workFlowDefinition.getCreateDate()).modifyDate(workFlowDefinition.getModifyDate()) - .type(workFlowDefinition.getType().toString()).processingType(workFlowDefinition.getProcessingType()) - .works(buildWorkFlowWorksDTOs(workFlowDefinition, workFlowWorkDependencies)).build(); + return WorkFlowDefinitionResponseDTO.fromEntity(workFlowDefinition, + buildWorkFlowWorksDTOs(workFlowDefinition, workFlowWorkDependencies)); } @Override @@ -220,12 +206,9 @@ public WorkFlowDefinitionResponseDTO getWorkFlowDefinitionByName(String name) { List workFlowWorkDependencies = workFlowWorkRepository .findByWorkFlowDefinitionIdOrderByCreateDateAsc(workFlowDefinition.getId()).stream() .sorted(Comparator.comparing(WorkFlowWorkDefinition::getCreateDate)).collect(Collectors.toList()); - return WorkFlowDefinitionResponseDTO.builder().id(workFlowDefinition.getId()).name(workFlowDefinition.getName()) - .properties(WorkFlowPropertiesDefinitionDTO.fromEntity(workFlowDefinition.getProperties())) - .parameterFromString(workFlowDefinition.getParameters()).author(workFlowDefinition.getAuthor()) - .createDate(workFlowDefinition.getCreateDate()).modifyDate(workFlowDefinition.getModifyDate()) - .type(workFlowDefinition.getType().name()).processingType(workFlowDefinition.getProcessingType()) - .works(buildWorkFlowWorksDTOs(workFlowDefinition, workFlowWorkDependencies)).build(); + + return WorkFlowDefinitionResponseDTO.fromEntity(workFlowDefinition, + buildWorkFlowWorksDTOs(workFlowDefinition, workFlowWorkDependencies)); } @Override @@ -249,6 +232,43 @@ public void saveWorkFlowChecker(String workFlowTaskName, String workFlowCheckerN } } + private void getWorksFromWorkDefinition(List workFlowWorkDefinitions, + CopyOnWriteArrayList responseDTOs) { + workFlowWorkDefinitions.forEach(workFlowWorkDefinition -> { + WorkType workType = workFlowWorkDefinition.getWorkDefinitionType(); + if (workType == null) { + return; + } + switch (workType) { + case TASK: + Optional wdt = workFlowTaskDefinitionRepository + .findById(workFlowWorkDefinition.getWorkDefinitionId()); + if (wdt.isEmpty()) { + log.error("Cannot find the task definition with id " + + workFlowWorkDefinition.getWorkDefinitionId()); + return; + } + responseDTOs.add(WorkDefinitionResponseDTO.fromWorkFlowTaskDefinition(wdt.get())); + case WORKFLOW: + Optional wd = workFlowDefinitionRepository + .findById(workFlowWorkDefinition.getWorkDefinitionId()); + if (wd.isEmpty()) { + log.error("Cannot find work flow definition with id {}", + workFlowWorkDefinition.getWorkDefinitionId()); + return; + } + List wdWorkFlowWorkDependencies = workFlowWorkRepository + .findByWorkFlowDefinitionIdOrderByCreateDateAsc(wd.get().getId()); + + responseDTOs.add(WorkDefinitionResponseDTO.fromWorkFlowDefinitionEntity(wd.get(), + wdWorkFlowWorkDependencies)); + default: + return; + } + }); + + } + private List buildWorkFlowWorksDTOs(WorkFlowDefinition workFlowDefinition, List workFlowWorkDefinitions) { CopyOnWriteArrayList workDefinitionResponseDTOs = new CopyOnWriteArrayList<>(); @@ -263,26 +283,7 @@ private List buildWorkFlowWorksDTOs(WorkFlowDefinitio workFlowWorksStartIndex.put(workFlowDefinition.getName(), 1); // add workflowWorkUnits - workFlowWorkDefinitions.forEach(workFlowWorkDefinition -> { - if (workFlowWorkDefinition.getWorkDefinitionType().equals(WorkType.TASK)) { // Task - WorkFlowTaskDefinition wdt = workFlowTaskDefinitionRepository - .findById(workFlowWorkDefinition.getWorkDefinitionId()).get(); - workDefinitionResponseDTOs.add(WorkDefinitionResponseDTO.builder().id(wdt.getId().toString()) - .workType(WorkType.TASK.name()).name(wdt.getName()).parameterFromString(wdt.getParameters()) - .outputs(WorkFlowDTOUtil.readStringAsObject(wdt.getOutputs(), new TypeReference<>() { - }, List.of())).build()); - } - else { // WorkFlow - WorkFlowDefinition wd = workFlowDefinitionRepository - .findById(workFlowWorkDefinition.getWorkDefinitionId()).get(); - List wdWorkFlowWorkDependencies = workFlowWorkRepository - .findByWorkFlowDefinitionIdOrderByCreateDateAsc(wd.getId()); - workDefinitionResponseDTOs.add(WorkDefinitionResponseDTO.builder().id(wd.getId().toString()) - .workType(WorkType.WORKFLOW.name()).name(wd.getName()).parameterFromString(wd.getParameters()) - .processingType(wd.getProcessingType()).works(new ArrayList<>()) - .numberOfWorkUnits(wdWorkFlowWorkDependencies.size()).build()); - } - }); + this.getWorksFromWorkDefinition(workFlowWorkDefinitions, workDefinitionResponseDTOs); // fill in subsequent workUnits for (int i = 1; i < workDefinitionResponseDTOs.size(); i++) { @@ -297,29 +298,7 @@ private List buildWorkFlowWorksDTOs(WorkFlowDefinitio .stream().sorted(Comparator.comparing(WorkFlowWorkDefinition::getCreateDate)) .collect(Collectors.toList()); - workFlowWorkUnits1Definition.forEach(wwdt1 -> { - if (wwdt1.getWorkDefinitionType().equals(WorkType.TASK)) { // Task - WorkFlowTaskDefinition wdt1 = workFlowTaskDefinitionRepository - .findById(wwdt1.getWorkDefinitionId()).get(); - workDefinitionResponseDTOs.add(WorkDefinitionResponseDTO.builder().id(wdt1.getId().toString()) - .workType(WorkType.TASK.name()).name(wdt1.getName()) - .parameterFromString(wdt1.getParameters()) - .outputs(WorkFlowDTOUtil.readStringAsObject(wdt1.getOutputs(), new TypeReference<>() { - }, List.of())).build()); - } - else { // WorkFlow - WorkFlowDefinition wd1 = workFlowDefinitionRepository.findById(wwdt1.getWorkDefinitionId()) - .get(); - List wd1WorkFlowWorkDefinitions = workFlowWorkRepository - .findByWorkFlowDefinitionIdOrderByCreateDateAsc(wd1.getId()).stream() - .sorted(Comparator.comparing(WorkFlowWorkDefinition::getCreateDate)) - .collect(Collectors.toList()); - workDefinitionResponseDTOs.add(WorkDefinitionResponseDTO.builder().id(wd1.getId().toString()) - .workType(WorkType.WORKFLOW.name()).name(wd1.getName()).works(new ArrayList<>()) - .processingType(wd1.getProcessingType()) - .numberOfWorkUnits(wd1WorkFlowWorkDefinitions.size()).build()); - } - }); + this.getWorksFromWorkDefinition(workFlowWorkUnits1Definition, workDefinitionResponseDTOs); } } diff --git a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/aspect/AssessmentInfrastructureWorkFlowPostInterceptor.java b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/aspect/AssessmentInfrastructureWorkFlowPostInterceptor.java index 71ba43c79..46f8dde65 100644 --- a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/aspect/AssessmentInfrastructureWorkFlowPostInterceptor.java +++ b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/aspect/AssessmentInfrastructureWorkFlowPostInterceptor.java @@ -1,12 +1,5 @@ package com.redhat.parodos.workflow.execution.aspect; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; - -import static com.redhat.parodos.workflow.execution.aspect.WorkFlowExecutionFactory.isMasterWorkFlow; - import com.redhat.parodos.workflow.definition.entity.WorkFlowCheckerMappingDefinition; import com.redhat.parodos.workflow.definition.entity.WorkFlowDefinition; import com.redhat.parodos.workflow.definition.entity.WorkFlowTaskDefinition; @@ -21,6 +14,15 @@ import com.redhat.parodos.workflows.work.WorkStatus; import lombok.extern.slf4j.Slf4j; +import java.util.Date; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +import static com.redhat.parodos.workflow.execution.aspect.WorkFlowExecutionFactory.isMasterWorkFlow; + @Slf4j public class AssessmentInfrastructureWorkFlowPostInterceptor implements WorkFlowPostInterceptor { @@ -58,6 +60,10 @@ public WorkReport handlePostWorkFlowExecution() { .workContext(workContext).build())); } + if (workFlowExecution.getStatus().equals(WorkFlowStatus.FAILED)) { + workFlowService.updateWorkFlow(workFlowExecution); + return null; + } /* * if this is infrastructure/assessment workflow, fail it and persist as 'pending' * if any of its sub work's execution is pending @@ -66,16 +72,26 @@ public WorkReport handlePostWorkFlowExecution() { .getWorkFlowTaskDefinitions().stream().map(WorkFlowTaskDefinition::getWorkFlowCheckerMappingDefinition) .filter(Objects::nonNull).collect(Collectors.toSet()); - if (workFlowCheckerMappingDefinitions.stream() + List checkerExecutions = workFlowCheckerMappingDefinitions.stream() .map(workFlowCheckerDefinition -> workFlowRepository .findFirstByWorkFlowDefinitionIdAndMasterWorkFlowExecution( workFlowCheckerDefinition.getCheckWorkFlow().getId(), masterWorkFlowExecution)) - .anyMatch(checkerExecution -> checkerExecution == null - || !WorkFlowStatus.COMPLETED.equals(checkerExecution.getStatus()))) { - log.info("fail workflow: {} because it has pending/running checker(s)", workFlowDefinition.getName()); - workFlowExecution.setStatus(WorkFlowStatus.PENDING); - report = new DefaultWorkReport(WorkStatus.IN_PROGRESS, workContext); - } + .collect(Collectors.toList()); + + for (WorkFlowExecution checkerExecution : checkerExecutions) + if (checkerExecution != null && checkerExecution.getStatus().isRejected()) { + log.info("fail workflow: {} because it has declined checker(s)", workFlowDefinition.getName()); + workFlowExecution.setStatus(WorkFlowStatus.FAILED); + report = new DefaultWorkReport(WorkStatus.FAILED, workContext); + break; + } + else if (checkerExecution == null || checkerExecution.getStatus().isFailed()) { + log.info("workflow: {} has a pending/running checker: {}", workFlowDefinition.getName(), + checkerExecution == null ? "checker is pending" + : checkerExecution.getWorkFlowDefinitionId().toString()); + workFlowExecution.setStatus(WorkFlowStatus.IN_PROGRESS); + report = new DefaultWorkReport(WorkStatus.IN_PROGRESS, workContext); + } workFlowService.updateWorkFlow(workFlowExecution); return report; diff --git a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/aspect/CheckerWorkFlowPostInterceptor.java b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/aspect/CheckerWorkFlowPostInterceptor.java index 35aa831d1..db8895eeb 100644 --- a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/aspect/CheckerWorkFlowPostInterceptor.java +++ b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/aspect/CheckerWorkFlowPostInterceptor.java @@ -3,6 +3,7 @@ import com.redhat.parodos.workflow.context.WorkContextDelegate; import com.redhat.parodos.workflow.definition.entity.WorkFlowCheckerMappingDefinition; import com.redhat.parodos.workflow.definition.entity.WorkFlowDefinition; +import com.redhat.parodos.workflow.enums.WorkFlowStatus; import com.redhat.parodos.workflow.execution.continuation.WorkFlowContinuationServiceImpl; import com.redhat.parodos.workflow.execution.entity.WorkFlowExecution; import com.redhat.parodos.workflow.execution.scheduler.WorkFlowSchedulerServiceImpl; @@ -64,25 +65,45 @@ public WorkReport handlePostWorkFlowExecution() { private void startOrStopWorkFlowCheckerOnSchedule(WorkFlow workFlow, WorkFlowCheckerMappingDefinition workFlowCheckerMappingDefinition, WorkStatus workStatus, WorkContext workContext, String projectId, WorkFlowExecution masterWorkFlowExecution) { - if (workStatus != WorkStatus.COMPLETED) { - log.info("Schedule workflow checker: {} to run per cron expression: {}", workFlow.getName(), - workFlowCheckerMappingDefinition.getCronExpression()); - workFlowSchedulerService.schedule(workFlow, workContext, - workFlowCheckerMappingDefinition.getCronExpression()); + /* + * if this workflow is a checker, schedule workflow checker for dynamic run on + * cron expression or stop if done + */ + if (!workStatus.equals(WorkStatus.COMPLETED)) { + /* + * decide if checker-workflow is rejected by filtering rejected checker-task + */ + if (!workStatus.equals(WorkStatus.REJECTED)) { + log.info("Schedule workflow checker: {} to run per cron expression: {}", workFlow.getName(), + workFlowCheckerMappingDefinition.getCronExpression()); + workFlowSchedulerService.schedule(projectId, workFlow, workContext, + workFlowCheckerMappingDefinition.getCronExpression()); + + } + else { + log.info("Stop rejected workflow checker: {} schedule", workFlow.getName()); + workFlowSchedulerService.stop(projectId, workFlow); + + masterWorkFlowExecution.setStatus(WorkFlowStatus.FAILED); + workFlowService.updateWorkFlow(masterWorkFlowExecution); + } return; } log.info("Stop workflow checker: {} schedule", workFlow.getName()); - workFlowSchedulerService.stop(workFlow); + workFlowSchedulerService.stop(projectId, workFlow); String masterWorkFlowName = WorkContextDelegate.read(workContext, WorkContextDelegate.ProcessType.WORKFLOW_DEFINITION, WorkContextDelegate.Resource.NAME).toString(); + /* - * if this workflow is checker, and it's successful, call continuation service to - * restart master workflow execution with same execution ID + * if this workflow is checker and it's successful, call continuation service to + * restart master workflow execution with same execution Id when there is no other + * active checkers */ - workFlowContinuationServiceImpl.continueWorkFlow(projectId, masterWorkFlowName, workContext, - masterWorkFlowExecution.getId()); + if (workFlowService.findRunningChecker(masterWorkFlowExecution).isEmpty()) + workFlowContinuationServiceImpl.continueWorkFlow(projectId, masterWorkFlowName, workContext, + masterWorkFlowExecution.getId()); } } diff --git a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/aspect/WorkFlowExecutionAspect.java b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/aspect/WorkFlowExecutionAspect.java index b7155f394..98b74913b 100644 --- a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/aspect/WorkFlowExecutionAspect.java +++ b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/aspect/WorkFlowExecutionAspect.java @@ -89,8 +89,10 @@ public WorkReport executeAroundAdvice(ProceedingJoinPoint proceedingJoinPoint, W if (workFlowExecution.getStatus().equals(WorkFlowStatus.COMPLETED)) { // skip the workflow if it is already successful if (workFlowDefinition.getType().equals(WorkFlowType.CHECKER)) { - workFlowSchedulerService.stop((WorkFlow) proceedingJoinPoint.getTarget()); + workFlowSchedulerService.stop(workFlowExecution.getProjectId().toString(), + (WorkFlow) proceedingJoinPoint.getTarget()); } + log.info("skipping workflow: {} is already completed", workFlowDefinition.getName()); return new DefaultWorkReport(WorkStatus.COMPLETED, workContext); } try { diff --git a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/aspect/WorkFlowExecutionInterceptor.java b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/aspect/WorkFlowExecutionInterceptor.java index 313148954..a80d14ed1 100644 --- a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/aspect/WorkFlowExecutionInterceptor.java +++ b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/aspect/WorkFlowExecutionInterceptor.java @@ -1,8 +1,5 @@ package com.redhat.parodos.workflow.execution.aspect; -import java.util.Date; -import java.util.UUID; - import com.redhat.parodos.workflow.context.WorkContextDelegate; import com.redhat.parodos.workflow.definition.entity.WorkFlowDefinition; import com.redhat.parodos.workflow.enums.WorkFlowStatus; @@ -17,6 +14,9 @@ import com.redhat.parodos.workflows.work.WorkStatus; import com.redhat.parodos.workflows.workflow.WorkFlow; +import java.util.Date; +import java.util.UUID; + public abstract class WorkFlowExecutionInterceptor implements WorkFlowInterceptor { protected final WorkFlowServiceImpl workFlowService; @@ -91,6 +91,7 @@ private WorkFlowPostInterceptor createPostExecutor(WorkFlow workFlow, WorkStatus workFlowSchedulerService, workFlowContinuationServiceImpl, workFlowExecution, getMasterWorkFlowExecution(), workFlow, workStatus); default: + workFlowService.updateWorkFlow(workFlowExecution); break; } return null; diff --git a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/aspect/WorkFlowTaskExecutionAspect.java b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/aspect/WorkFlowTaskExecutionAspect.java index 5be9a49f0..7c1199617 100644 --- a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/aspect/WorkFlowTaskExecutionAspect.java +++ b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/aspect/WorkFlowTaskExecutionAspect.java @@ -91,7 +91,7 @@ public void pointcutScopeTask() { */ @Around("pointcutScopeTask() && args(workContext)") public WorkReport executeAroundAdviceTask(ProceedingJoinPoint proceedingJoinPoint, WorkContext workContext) { - WorkReport report = null; + WorkReport report; String workFlowTaskName = ((WorkFlowTask) proceedingJoinPoint.getTarget()).getName(); log.info("Before invoking execute() on workflow task name: {}", workFlowTaskName); @@ -113,23 +113,22 @@ public WorkReport executeAroundAdviceTask(ProceedingJoinPoint proceedingJoinPoin if (workFlowTaskExecution == null) { workFlowTaskExecution = workFlowService.saveWorkFlowTask( // @formatter:off - WorkFlowDTOUtil.writeObjectValueAsString(WorkContextDelegate.read( - workContext, - WorkContextDelegate.ProcessType.WORKFLOW_TASK_EXECUTION, - workFlowTaskName, - WorkContextDelegate.Resource.ARGUMENTS)), - workFlowTaskDefinition.getId(), - workFlowExecution.getId(), - WorkFlowTaskStatus.IN_PROGRESS); - // @formatter:on + WorkFlowDTOUtil.writeObjectValueAsString(WorkContextDelegate.read( + workContext, + WorkContextDelegate.ProcessType.WORKFLOW_TASK_EXECUTION, + workFlowTaskName, + WorkContextDelegate.Resource.ARGUMENTS)), + workFlowTaskDefinition.getId(), + workFlowExecution.getId(), + WorkFlowTaskStatus.IN_PROGRESS); + // @formatter:on } - else if (WorkFlowTaskStatus.IN_PROGRESS.equals(workFlowTaskExecution.getStatus())) + else if (!WorkFlowTaskStatus.FAILED.equals(workFlowTaskExecution.getStatus())) { // fail the task if it's processed by other thread - return new DefaultWorkReport(WorkStatus.FAILED, workContext); - else if (WorkFlowTaskStatus.COMPLETED.equals(workFlowTaskExecution.getStatus())) - // skip the task if it's already successful - return new DefaultWorkReport(WorkStatus.COMPLETED, workContext); - + // skip the task if it's already successful/rejected + log.info("skipping task: {} with status {}", workFlowTaskName, workFlowTaskExecution.getStatus().name()); + return new DefaultWorkReport(WorkStatus.valueOf(workFlowTaskExecution.getStatus().name()), workContext); + } try { report = (WorkReport) proceedingJoinPoint.proceed(); if (report == null || report.getStatus() == null) @@ -154,7 +153,7 @@ else if (WorkFlowTaskStatus.COMPLETED.equals(workFlowTaskExecution.getStatus())) if (WorkStatus.COMPLETED.equals(report.getStatus()) && workFlowTaskDefinition.getWorkFlowCheckerMappingDefinition() != null) { handleChecker(proceedingJoinPoint, workContext, workFlowTaskDefinition, masterWorkFlowExecution); - return new DefaultWorkReport(WorkStatus.FAILED, workContext); + return new DefaultWorkReport(WorkStatus.PENDING, workContext); } return report; } @@ -171,7 +170,7 @@ private void handleChecker(ProceedingJoinPoint proceedingJoinPoint, WorkContext // schedule workflow checker for dynamic run on cron expression List checkerWorkFlows = ((BaseWorkFlowTask) proceedingJoinPoint.getTarget()) .getWorkFlowCheckers(); - startCheckerOnSchedule( + startCheckerOnSchedule(masterWorkFlowExecution.getProjectId().toString(), workFlowTaskDefinition.getWorkFlowCheckerMappingDefinition().getCheckWorkFlow().getName(), checkerWorkFlows, workFlowTaskDefinition.getWorkFlowCheckerMappingDefinition(), workContext); } @@ -191,12 +190,12 @@ private WorkFlowExecution handleParentWorkflowUseCase(WorkContext workContext, // Iterate through the all the Checkers in the workflow and start them based on their // schedules - private void startCheckerOnSchedule(String workFlowName, List workFlows, + private void startCheckerOnSchedule(String projectId, String workFlowName, List workFlows, WorkFlowCheckerMappingDefinition workFlowCheckerMappingDefinition, WorkContext workContext) { log.info("Schedule workflow checker: {} to run per cron expression: {}", workFlowName, workFlowCheckerMappingDefinition.getCronExpression()); for (WorkFlow workFlow : workFlows) { - workFlowSchedulerService.schedule(workFlow, workContext, + workFlowSchedulerService.schedule(projectId, workFlow, workContext, workFlowCheckerMappingDefinition.getCronExpression()); } diff --git a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/continuation/WorkFlowContinuationServiceImpl.java b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/continuation/WorkFlowContinuationServiceImpl.java index 5796df574..8eb0c2c98 100644 --- a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/continuation/WorkFlowContinuationServiceImpl.java +++ b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/continuation/WorkFlowContinuationServiceImpl.java @@ -61,18 +61,18 @@ public WorkFlowContinuationServiceImpl(WorkFlowDefinitionRepository workFlowDefi public void workFlowRunAfterStartup() { log.info("Looking up all IN PROGRESS workflows for "); List workFlowExecutions = workFlowRepository - .findByStatusIn(List.of(WorkFlowStatus.IN_PROGRESS, WorkFlowStatus.PENDING)); - log.info("Number of IN PROGRESS or PENDING workflows for : {}", workFlowExecutions.size()); - workFlowExecutions.stream().filter(workFlowExecution -> workFlowExecution.getMasterWorkFlowExecution() == null) - .forEach(workFlowExecution -> { - WorkFlowDefinition workFlowDefinition = workFlowDefinitionRepository - .findById(workFlowExecution.getWorkFlowDefinitionId()).get(); + .findByStatusInAndIsMaster(List.of(WorkFlowStatus.IN_PROGRESS, WorkFlowStatus.PENDING)); + log.info("Number of IN PROGRESS or PENDING master workflows is : {}", workFlowExecutions.size()); + workFlowExecutions.forEach(workFlowExecution -> { + WorkFlowDefinition workFlowDefinition = workFlowDefinitionRepository + .findById(workFlowExecution.getWorkFlowDefinitionId()).get(); - // continue with the same execution id - continueWorkFlow(workFlowExecution.getProjectId().toString(), workFlowDefinition.getName(), - workFlowExecution.getWorkFlowExecutionContext().getWorkContext(), - workFlowExecution.getId()); - }); + // continue with the same execution id + continueWorkFlow(workFlowExecution.getProjectId().toString(), workFlowDefinition.getName(), + workFlowExecution.getWorkFlowExecutionContext().getWorkContext(), workFlowExecution.getId()); + + // TODO: continue 'FAILED' Checkers in this master workflow execution + }); } public void continueWorkFlow(String projectId, String workflowName, WorkContext workContext, UUID executionId) { diff --git a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/dto/WorkFlowRequestDTO.java b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/dto/WorkFlowRequestDTO.java index af0e93d9d..7ba2f4f54 100644 --- a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/dto/WorkFlowRequestDTO.java +++ b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/dto/WorkFlowRequestDTO.java @@ -16,6 +16,8 @@ package com.redhat.parodos.workflow.execution.dto; import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; import lombok.AllArgsConstructor; import lombok.Builder; @@ -43,6 +45,10 @@ public class WorkFlowRequestDTO { private List works; + public WorkFlowRequestDTO.WorkRequestDTO findFirstWorkByName(String name) { + return findWorks(works, name).stream().findFirst().orElse(null); + } + @Data @Builder @AllArgsConstructor @@ -58,6 +64,10 @@ public static class WorkRequestDTO { // recursive works List works; + public WorkFlowRequestDTO.WorkRequestDTO findFirstWorkByName(String name) { + return findWorks(works, name).stream().findFirst().orElse(null); + } + @Data @Builder @AllArgsConstructor @@ -72,4 +82,10 @@ public static class ArgumentRequestDTO { } + private static List findWorks(List works, String name) { + return Optional.ofNullable(works) + .map(ws -> ws.stream().filter(work -> name.equals(work.getWorkName())).collect(Collectors.toList())) + .orElse(List.of()); + } + } diff --git a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/entity/WorkFlowExecution.java b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/entity/WorkFlowExecution.java index 63699f173..8f60deec1 100644 --- a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/entity/WorkFlowExecution.java +++ b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/entity/WorkFlowExecution.java @@ -17,12 +17,6 @@ import com.redhat.parodos.common.AbstractEntity; import com.redhat.parodos.workflow.enums.WorkFlowStatus; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -35,6 +29,11 @@ import java.util.Date; import java.util.List; import java.util.UUID; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; /** * Workflow execution entity @@ -73,7 +72,7 @@ public class WorkFlowExecution extends AbstractEntity { @OneToMany(mappedBy = "masterWorkFlowExecution", cascade = { CascadeType.ALL }, fetch = FetchType.LAZY) private List subWorkFlowExecution = new ArrayList<>(); - @OneToOne(mappedBy = "masterWorkFlowExecution", cascade = CascadeType.ALL) + @OneToOne(mappedBy = "masterWorkFlowExecution", cascade = { CascadeType.ALL }, orphanRemoval = true) private WorkFlowExecutionContext workFlowExecutionContext; } diff --git a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/repository/WorkFlowRepository.java b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/repository/WorkFlowRepository.java index 744672892..a2d935f7a 100644 --- a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/repository/WorkFlowRepository.java +++ b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/repository/WorkFlowRepository.java @@ -15,15 +15,15 @@ */ package com.redhat.parodos.workflow.execution.repository; -import java.util.List; -import java.util.UUID; - import com.redhat.parodos.workflow.enums.WorkFlowStatus; import com.redhat.parodos.workflow.execution.entity.WorkFlowExecution; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; +import java.util.List; +import java.util.UUID; + /** * workflow execution repository * @@ -41,7 +41,13 @@ WorkFlowExecution findFirstByWorkFlowDefinitionIdAndMasterWorkFlowExecution(UUID WorkFlowExecution findFirstByMasterWorkFlowExecutionAndWorkFlowDefinitionId( WorkFlowExecution masterWorkFlowExecution, UUID workFlowDefinitionId); - @Query("SELECT w FROM workflow_execution w WHERE w.status IN :statuses") - List findByStatusIn(@Param("statuses") List statuses); + @Query("SELECT w FROM workflow_execution w WHERE w.status IN :statuses AND w.masterWorkFlowExecution IS NULL") + List findByStatusInAndIsMaster(@Param("statuses") List statuses); + + @Query("SELECT w FROM workflow_execution w WHERE w.status = com.redhat.parodos.workflow.enums.WorkFlowStatus.FAILED and w.masterWorkFlowExecution.id = :masterWorkflowId and EXISTS (SELECT f.type FROM workflow_definition f WHERE f.id = w.workFlowDefinitionId AND f.type = com.redhat.parodos.workflow.enums.WorkFlowType.CHECKER)") + List findRunningCheckersById(@Param("masterWorkflowId") UUID masterWorkflowId); + + @Query("SELECT w FROM workflow_execution w WHERE w.masterWorkFlowExecution.id = :masterWorkflowId and EXISTS (SELECT f.type FROM workflow_definition f WHERE f.id = w.workFlowDefinitionId AND f.type = com.redhat.parodos.workflow.enums.WorkFlowType.CHECKER)") + List findCheckers(@Param("masterWorkflowId") UUID masterWorkflowId); } diff --git a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/scheduler/WorkFlowSchedulerService.java b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/scheduler/WorkFlowSchedulerService.java index ed7d8ed53..e50b8e190 100644 --- a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/scheduler/WorkFlowSchedulerService.java +++ b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/scheduler/WorkFlowSchedulerService.java @@ -27,8 +27,8 @@ public interface WorkFlowSchedulerService { - void schedule(WorkFlow workFlow, WorkContext workContext, String cronExpression); + void schedule(String projectId, WorkFlow workFlow, WorkContext workContext, String cronExpression); - boolean stop(WorkFlow workFlow); + boolean stop(String projectId, WorkFlow workFlow); } diff --git a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/scheduler/WorkFlowSchedulerServiceImpl.java b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/scheduler/WorkFlowSchedulerServiceImpl.java index d83d29923..81f13adf7 100644 --- a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/scheduler/WorkFlowSchedulerServiceImpl.java +++ b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/scheduler/WorkFlowSchedulerServiceImpl.java @@ -20,6 +20,7 @@ import java.util.HashMap; import java.util.Map; import java.util.TimeZone; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import lombok.extern.slf4j.Slf4j; import org.springframework.scheduling.TaskScheduler; @@ -39,36 +40,40 @@ public class WorkFlowSchedulerServiceImpl implements WorkFlowSchedulerService { private final TaskScheduler taskScheduler; - private final Map> hm = new HashMap<>(); + private final Map>> hm = new ConcurrentHashMap<>(); public WorkFlowSchedulerServiceImpl(TaskScheduler taskScheduler) { this.taskScheduler = taskScheduler; } @Override - public void schedule(WorkFlow workFlow, WorkContext workContext, String cronExpression) { - if (!hm.containsKey(workFlow.getName())) { - log.info("Scheduling workflow: {} to be executed following cron expression: {}", workFlow.getName(), - cronExpression); + public void schedule(String projectId, WorkFlow workFlow, WorkContext workContext, String cronExpression) { + hm.computeIfAbsent(projectId, key -> new HashMap<>()); + if (!hm.get(projectId).containsKey(workFlow.getName())) { + log.info("Scheduling workflow: {} for project: {} to be executed following cron expression: {}", + workFlow.getName(), projectId, cronExpression); ScheduledFuture scheduledTask = taskScheduler.schedule(() -> workFlow.execute(workContext), new CronTrigger(cronExpression, TimeZone.getTimeZone(TimeZone.getDefault().getID()))); - hm.put(workFlow.getName(), scheduledTask); + hm.get(projectId).put(workFlow.getName(), scheduledTask); } else { - log.info("Workflow: {} is already scheduled!", hm.get(workFlow.getName())); + log.info("Workflow: {} is already scheduled for project: {}!", workFlow.getName(), projectId); } } @Override - public boolean stop(WorkFlow workFlow) { - if (hm.containsKey(workFlow.getName())) { - log.info("Stopping workflow: {}", workFlow.getName()); - boolean stopped = hm.get(workFlow.getName()).cancel(false); - if (stopped) - hm.remove(workFlow.getName()); + public boolean stop(String projectId, WorkFlow workFlow) { + if (hm.containsKey(projectId) && hm.get(projectId).containsKey(workFlow.getName())) { + log.info("Stopping workflow: {} for project: {}", workFlow.getName(), projectId); + boolean stopped = hm.get(projectId).get(workFlow.getName()).cancel(false); + if (stopped) { + hm.get(projectId).remove(workFlow.getName()); + if (hm.get(projectId).isEmpty()) + hm.remove(projectId); + } return stopped; } - log.info("Workflow: {} has not been scheduled!", hm.get(workFlow.getName())); + log.info("Workflow: {} has not been scheduled for project: {}!", workFlow.getName(), projectId); return false; } diff --git a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/service/WorkFlowServiceImpl.java b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/service/WorkFlowServiceImpl.java index 0f7f3d616..0dcd62816 100644 --- a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/service/WorkFlowServiceImpl.java +++ b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/service/WorkFlowServiceImpl.java @@ -16,12 +16,15 @@ package com.redhat.parodos.workflow.execution.service; import com.redhat.parodos.workflow.WorkFlowDelegate; +import io.micrometer.core.instrument.Counter; +import io.micrometer.core.instrument.MeterRegistry; import com.redhat.parodos.workflow.context.WorkContextDelegate; import com.redhat.parodos.workflow.definition.entity.WorkFlowDefinition; import com.redhat.parodos.workflow.definition.entity.WorkFlowTaskDefinition; import com.redhat.parodos.workflow.definition.repository.WorkFlowDefinitionRepository; import com.redhat.parodos.workflow.definition.repository.WorkFlowTaskDefinitionRepository; import com.redhat.parodos.workflow.definition.repository.WorkFlowWorkRepository; +import com.redhat.parodos.workflow.definition.service.WorkFlowDefinitionService; import com.redhat.parodos.workflow.enums.WorkFlowStatus; import com.redhat.parodos.workflow.enums.WorkFlowType; import com.redhat.parodos.workflow.exceptions.WorkflowPersistenceFailedException; @@ -50,6 +53,7 @@ import java.util.Date; import java.util.List; import java.util.UUID; +import java.util.stream.Collectors; import static java.util.Objects.isNull; @@ -78,10 +82,15 @@ public class WorkFlowServiceImpl implements WorkFlowService { private final WorkFlowWorkRepository workFlowWorkRepository; + private final WorkFlowDefinitionService workFlowDefinitionService; + + private final MeterRegistry metricRegistry; + public WorkFlowServiceImpl(WorkFlowDelegate workFlowDelegate, WorkFlowServiceDelegate workFlowServiceDelegate, WorkFlowDefinitionRepository workFlowDefinitionRepository, WorkFlowTaskDefinitionRepository workFlowTaskDefinitionRepository, WorkFlowRepository workFlowRepository, - WorkFlowTaskRepository workFlowTaskRepository, WorkFlowWorkRepository workFlowWorkRepository) { + WorkFlowTaskRepository workFlowTaskRepository, WorkFlowWorkRepository workFlowWorkRepository, + WorkFlowDefinitionService workFlowDefinitionService, MeterRegistry metricRegistry) { this.workFlowDelegate = workFlowDelegate; this.workFlowServiceDelegate = workFlowServiceDelegate; this.workFlowDefinitionRepository = workFlowDefinitionRepository; @@ -89,6 +98,16 @@ public WorkFlowServiceImpl(WorkFlowDelegate workFlowDelegate, WorkFlowServiceDel this.workFlowRepository = workFlowRepository; this.workFlowTaskRepository = workFlowTaskRepository; this.workFlowWorkRepository = workFlowWorkRepository; + this.workFlowDefinitionService = workFlowDefinitionService; + this.metricRegistry = metricRegistry; + } + + private void statusCounterWithStatus(WorkFlowStatus status) { + if (status == null) { + return; + } + Counter.builder("workflow.executions").tag("status", status.toString()) + .description("Workflow executions phases by status update").register(this.metricRegistry).increment(); } @Override @@ -101,7 +120,8 @@ public WorkReport execute(WorkFlowRequestDTO workFlowRequestDTO) { return new DefaultWorkReport(WorkStatus.FAILED, new WorkContext(), new Throwable(validationFailedMsg)); } - WorkContext workContext = workFlowDelegate.initWorkFlowContext(workFlowRequestDTO); + WorkContext workContext = workFlowDelegate.initWorkFlowContext(workFlowRequestDTO, + workFlowDefinitionService.getWorkFlowDefinitionByName(workflowName)); String projectId = workFlowRequestDTO.getProjectId(); return execute(projectId, workflowName, workContext, null); @@ -126,9 +146,10 @@ public WorkFlowExecution getWorkFlowById(UUID workFlowExecutionId) { } @Override - public synchronized WorkFlowExecution saveWorkFlow(UUID projectId, UUID workFlowDefinitionId, - WorkFlowStatus workFlowStatus, WorkFlowExecution masterWorkFlowExecution, String arguments) { + public WorkFlowExecution saveWorkFlow(UUID projectId, UUID workFlowDefinitionId, WorkFlowStatus workFlowStatus, + WorkFlowExecution masterWorkFlowExecution, String arguments) { try { + this.statusCounterWithStatus(workFlowStatus); return workFlowRepository.save(WorkFlowExecution.builder().workFlowDefinitionId(workFlowDefinitionId) .projectId(projectId).status(workFlowStatus).startDate(new Date()).arguments(arguments) .masterWorkFlowExecution(masterWorkFlowExecution).build()); @@ -142,6 +163,7 @@ public synchronized WorkFlowExecution saveWorkFlow(UUID projectId, UUID workFlow @Override public synchronized WorkFlowExecution updateWorkFlow(WorkFlowExecution workFlowExecution) { + this.statusCounterWithStatus(workFlowExecution.getStatus()); return workFlowRepository.save(workFlowExecution); } @@ -182,7 +204,7 @@ public WorkFlowTaskExecution getWorkFlowTask(UUID workFlowExecutionId, UUID work } @Override - public synchronized WorkFlowTaskExecution saveWorkFlowTask(String arguments, UUID workFlowTaskDefinitionId, + public WorkFlowTaskExecution saveWorkFlowTask(String arguments, UUID workFlowTaskDefinitionId, UUID workFlowExecutionId, WorkFlowTaskStatus workFlowTaskStatus) { try { return workFlowTaskRepository.save(WorkFlowTaskExecution.builder().workFlowExecutionId(workFlowExecutionId) @@ -246,6 +268,10 @@ public void updateWorkFlowCheckerTaskStatus(UUID workFlowExecutionId, String wor workFlowTaskRepository.save(workFlowTaskExecution); } + public List findRunningChecker(WorkFlowExecution masterWorkflow) { + return workFlowRepository.findRunningCheckersById(masterWorkflow.getId()); + } + private String validateWorkflow(String workflowName, WorkFlow workFlow) { // validate if workflow exists if (workFlow == null) { diff --git a/workflow-service/src/main/resources/application-local.yml b/workflow-service/src/main/resources/application-local.yml index c57f3a97c..f220a6748 100644 --- a/workflow-service/src/main/resources/application-local.yml +++ b/workflow-service/src/main/resources/application-local.yml @@ -31,4 +31,5 @@ logging: # Application specific properties # Add your own application properties here, see the # ApplicationProperties class to have type-safe configuration -# =================================================================== \ No newline at end of file +# =================================================================== + diff --git a/workflow-service/src/main/resources/application.yml b/workflow-service/src/main/resources/application.yml index 77d5de95c..71cd42435 100644 --- a/workflow-service/src/main/resources/application.yml +++ b/workflow-service/src/main/resources/application.yml @@ -51,16 +51,24 @@ spring: config: enabled: false management: + metrics: + export: + prometheus: + enabled: true endpoint: shutdown: enabled: true health: enabled: true + prometheus: + enabled: true + metrics: + enabled: true endpoints: enabled-by-default: false web: exposure: - include: "health,shutdown" + include: "health,shutdown,prometheus" server: shutdown: "graceful" diff --git a/workflow-service/src/test/java/com/redhat/parodos/workflow/WorkFlowDelegateTest.java b/workflow-service/src/test/java/com/redhat/parodos/workflow/WorkFlowDelegateTest.java index 0dad62ac1..02409527e 100644 --- a/workflow-service/src/test/java/com/redhat/parodos/workflow/WorkFlowDelegateTest.java +++ b/workflow-service/src/test/java/com/redhat/parodos/workflow/WorkFlowDelegateTest.java @@ -18,6 +18,8 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.redhat.parodos.workflow.context.WorkContextDelegate; +import com.redhat.parodos.workflow.definition.dto.WorkDefinitionResponseDTO; +import com.redhat.parodos.workflow.definition.dto.WorkFlowDefinitionResponseDTO; import com.redhat.parodos.workflow.enums.WorkType; import com.redhat.parodos.workflow.execution.dto.WorkFlowRequestDTO; import com.redhat.parodos.workflow.registry.BeanWorkFlowRegistryImpl; @@ -84,7 +86,10 @@ class WorkFlowDelegateTest { @Test void initWorkFlowContext_when_workflowParameterIsFound_thenReturn_success() { - WorkContext workContext = workFlowDelegate.initWorkFlowContext(workFlowRequestDTO); + WorkFlowDefinitionResponseDTO workFlowDefinitionResponseDTO = sampleWorkflowDefinitionResponse(); + + WorkContext workContext = workFlowDelegate.initWorkFlowContext(workFlowRequestDTO, + workFlowDefinitionResponseDTO); assertThat(new ObjectMapper().convertValue( WorkContextDelegate.read(workContext, WorkContextDelegate.ProcessType.WORKFLOW_EXECUTION, @@ -105,4 +110,14 @@ void initWorkFlowContext_when_workflowParameterIsFound_thenReturn_success() { })).containsEntry(TEST_TASK_ARG_KEY, TEST_TASK_ARG_VALUE); } + private WorkFlowDefinitionResponseDTO sampleWorkflowDefinitionResponse() { + return WorkFlowDefinitionResponseDTO.builder().name(TEST_WORKFLOW_NAME) + .works(List + .of(WorkDefinitionResponseDTO.builder().name(TEST_SUB_WORKFLOW_NAME) + .workType(WorkType.WORKFLOW.name()).works(List.of(WorkDefinitionResponseDTO.builder() + .name(TEST_TASK_NAME).workType(WorkType.TASK.name()).build())) + .build())) + .build(); + } + } diff --git a/workflow-service/src/test/java/com/redhat/parodos/workflow/definition/dto/WorkDefinitionResponseDTOTest.java b/workflow-service/src/test/java/com/redhat/parodos/workflow/definition/dto/WorkDefinitionResponseDTOTest.java new file mode 100644 index 000000000..8b339afe2 --- /dev/null +++ b/workflow-service/src/test/java/com/redhat/parodos/workflow/definition/dto/WorkDefinitionResponseDTOTest.java @@ -0,0 +1,85 @@ +package com.redhat.parodos.workflow.definition.dto; + +import com.redhat.parodos.workflow.definition.entity.WorkFlowDefinition; +import com.redhat.parodos.workflow.definition.entity.WorkFlowTaskDefinition; +import com.redhat.parodos.workflow.definition.entity.WorkFlowWorkDefinition; +import com.redhat.parodos.workflow.enums.WorkType; +import com.redhat.parodos.workflow.task.enums.WorkFlowTaskOutput; +import com.redhat.parodos.workflow.util.WorkFlowDTOUtil; +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.UUID; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +class WorkDefinitionResponseDTOTest { + + @Test + public void testFromWorkFlowTaskDefinition() { + // given + UUID id = UUID.randomUUID(); + WorkFlowTaskDefinition wdt = new WorkFlowTaskDefinition(); + wdt.setId(id); + wdt.setName("foo"); + wdt.setParameters(getWorkFlowParameter()); + wdt.setOutputs(WorkFlowDTOUtil.writeObjectValueAsString(getWorkFlowTaskOutput())); + + // when + WorkDefinitionResponseDTO result = WorkDefinitionResponseDTO.fromWorkFlowTaskDefinition(wdt); + + // then + assertEquals(result.getId(), id.toString()); + assertEquals(result.getWorkType(), WorkType.TASK.name()); + assertEquals(result.getName(), "foo"); + + assertEquals(result.getParameters().size(), 1); + assertEquals(result.getParameters().get("key").get("format"), "text"); + assertEquals(result.getParameters().get("key").get("type"), "string"); + assertEquals(result.getParameters().get("key").get("required"), true); + + assertNotNull(result.getOutputs()); + assertEquals(result.getOutputs().size(), 1); + assertEquals(result.getOutputs().get(0), WorkFlowTaskOutput.HTTP2XX); + } + + @Test + public void testFromWorkFlowTaskDefinitionWithParameters() { + // given + UUID id = UUID.randomUUID(); + WorkFlowDefinition wd = new WorkFlowDefinition(); + wd.setId(id); + wd.setName("foo"); + wd.setParameters(getWorkFlowParameter()); + wd.setProcessingType("BATCH"); + + List dependencies = List.of(new WorkFlowWorkDefinition()); + // when + WorkDefinitionResponseDTO result = WorkDefinitionResponseDTO.fromWorkFlowDefinitionEntity(wd, dependencies); + + // then + assertEquals(result.getId(), id.toString()); + assertEquals(result.getWorkType(), WorkType.WORKFLOW.name()); + assertEquals(result.getName(), "foo"); + + assertEquals(result.getParameters().size(), 1); + assertEquals(result.getParameters().get("key").get("format"), "text"); + assertEquals(result.getParameters().get("key").get("type"), "string"); + assertEquals(result.getParameters().get("key").get("required"), true); + assertEquals(result.getNumberOfWorkUnits(), dependencies.size()); + assertEquals(result.getProcessingType(), "BATCH"); + assertEquals(result.getWorks().size(), 0); + } + + private String getWorkFlowParameter() { + return "{\n" + " \"key\" : {\n" + " \"format\" : \"text\",\n" + + " \"description\" : \"The app id\",\n" + " \"type\" : \"string\",\n" + + " \"required\" : true\n" + " }\n" + "}"; + } + + private List getWorkFlowTaskOutput() { + return List.of(WorkFlowTaskOutput.HTTP2XX); + } + +} \ No newline at end of file diff --git a/workflow-service/src/test/java/com/redhat/parodos/workflow/definition/service/WorkFlowDefinitionServiceImplTest.java b/workflow-service/src/test/java/com/redhat/parodos/workflow/definition/service/WorkFlowDefinitionServiceImplTest.java index 868883445..df18bbf55 100644 --- a/workflow-service/src/test/java/com/redhat/parodos/workflow/definition/service/WorkFlowDefinitionServiceImplTest.java +++ b/workflow-service/src/test/java/com/redhat/parodos/workflow/definition/service/WorkFlowDefinitionServiceImplTest.java @@ -167,7 +167,7 @@ public void simpleSaveTest_skipSave_when_sameWorkflowFoundInDB() { assertNotNull(workFlowDefinitionResponseDTO.getId()); assertEquals(workFlowDefinitionResponseDTO.getName(), workFlowName); - Mockito.verify(this.workFlowDefinitionRepository, Mockito.times(1)).save(workFlowDefinition); + Mockito.verify(this.workFlowDefinitionRepository, Mockito.times(2)).save(workFlowDefinition); Mockito.verify(this.workFlowTaskDefinitionRepository, Mockito.never()).save(any()); } diff --git a/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/aspect/WorkFlowExecutionAspectTest.java b/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/aspect/WorkFlowExecutionAspectTest.java index 51cc8482b..e7971da31 100644 --- a/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/aspect/WorkFlowExecutionAspectTest.java +++ b/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/aspect/WorkFlowExecutionAspectTest.java @@ -130,7 +130,7 @@ public void ExecuteAroundAdviceWithValidDataTest() { assertEquals(workReport.getStatus().toString(), COMPLETED); assertEquals(workReport.getWorkContext().get(WORKFLOW_DEFINITION_NAME), TEST_WORK_FLOW); assertEquals(workReport.getWorkContext().get(PROJECT_ID), projectID); - Mockito.verify(this.workFlowSchedulerService, Mockito.times(1)).stop(Mockito.any()); + Mockito.verify(this.workFlowSchedulerService, Mockito.times(1)).stop(Mockito.any(), Mockito.any()); Mockito.verify(this.workFlowService, Mockito.times(1)) .updateWorkFlow(Mockito.argThat(w -> w.getStatus().toString().equals(COMPLETED))); } @@ -179,7 +179,7 @@ void ExecuteAroundAdviceWithInProgressWorkFlowTest() { assertNull(workReport.getWorkContext().get(WORKFLOW_DEFINITION_ID)); assertEquals(workReport.getWorkContext().get(PROJECT_ID), projectID); Mockito.verify(this.workFlowSchedulerService, Mockito.times(1)).schedule(Mockito.any(), Mockito.any(), - Mockito.any()); + Mockito.any(), Mockito.any()); Mockito.verify(this.workFlowService, Mockito.times(1)) .updateWorkFlow(Mockito.argThat(w -> w.getStatus().toString().equals(FAILED))); } diff --git a/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/aspect/WorkFlowExecutionInterceptorTest.java b/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/aspect/WorkFlowExecutionInterceptorTest.java index f095f8d43..71a1f23e6 100644 --- a/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/aspect/WorkFlowExecutionInterceptorTest.java +++ b/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/aspect/WorkFlowExecutionInterceptorTest.java @@ -104,8 +104,8 @@ public void testHandleIncompletePostWorkFlowExecution() { // then verify(workFlowService, Mockito.times(0)).saveWorkFlow(any(UUID.class), any(UUID.class), eq(WorkFlowStatus.IN_PROGRESS), any(), anyString()); - verify(workFlowSchedulerService, Mockito.times(1)).schedule(Mockito.any(), Mockito.any(WorkContext.class), - Mockito.any()); + verify(workFlowSchedulerService, Mockito.times(1)).schedule(Mockito.any(), Mockito.any(), + Mockito.any(WorkContext.class), Mockito.any()); assertEquals(result.getStatus(), report.getStatus()); } @@ -133,7 +133,7 @@ public void testHandleCompletePostWorkFlowExecution() { // then verify(workFlowService, Mockito.times(0)).saveWorkFlow(any(UUID.class), any(UUID.class), eq(WorkFlowStatus.IN_PROGRESS), any(), anyString()); - verify(workFlowSchedulerService, Mockito.times(1)).stop(Mockito.any(WorkFlow.class)); + verify(workFlowSchedulerService, Mockito.times(1)).stop(Mockito.any(), Mockito.any(WorkFlow.class)); verify(workFlowContinuationServiceImpl, Mockito.times(1)).continueWorkFlow(Mockito.anyString(), Mockito.anyString(), Mockito.any(WorkContext.class), Mockito.any(UUID.class)); assertEquals(result.getStatus(), report.getStatus()); diff --git a/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/aspect/WorkFlowTaskExecutionAspectTest.java b/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/aspect/WorkFlowTaskExecutionAspectTest.java index b3b1b1938..6ec08653d 100644 --- a/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/aspect/WorkFlowTaskExecutionAspectTest.java +++ b/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/aspect/WorkFlowTaskExecutionAspectTest.java @@ -194,7 +194,7 @@ WorkFlowTaskExecution getSampleWorkFlowTaskExecution() { return new WorkFlowTaskExecution() { { setId(UUID.randomUUID()); - setStatus(WorkFlowTaskStatus.PENDING); + setStatus(WorkFlowTaskStatus.FAILED); setWorkFlowExecutionId(getSampleWorkFlowExecution().getId()); setWorkFlowTaskDefinitionId(getSampleWorkFlowTaskDefinition(TEST_TASK).getId()); } diff --git a/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/continuation/WorkFlowContinuationServiceImplTest.java b/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/continuation/WorkFlowContinuationServiceImplTest.java index d6c3aa4b4..772501960 100644 --- a/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/continuation/WorkFlowContinuationServiceImplTest.java +++ b/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/continuation/WorkFlowContinuationServiceImplTest.java @@ -59,13 +59,13 @@ void initEach() { @Test void workFlowSkipCompletedJobs() { // given - Mockito.when(this.workFlowRepository.findByStatusIn(workFlowStatuses)).thenReturn(Arrays.asList()); + Mockito.when(this.workFlowRepository.findByStatusInAndIsMaster(workFlowStatuses)).thenReturn(Arrays.asList()); // when this.service.workFlowRunAfterStartup(); // then - Mockito.verify(this.workFlowRepository, Mockito.times(1)).findByStatusIn(workFlowStatuses); + Mockito.verify(this.workFlowRepository, Mockito.times(1)).findByStatusInAndIsMaster(workFlowStatuses); Mockito.verify(this.asyncWorkFlowContinuer, Mockito.times(0)).executeAsync(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()); } @@ -74,14 +74,15 @@ void workFlowSkipCompletedJobs() { void workFlowCompleteInProgress() { // given WorkFlowExecution workFlowExecution = this.sampleWorkFlowExecution(WorkFlowStatus.IN_PROGRESS); - Mockito.when(this.workFlowRepository.findByStatusIn(workFlowStatuses)).thenReturn(List.of(workFlowExecution)); + Mockito.when(this.workFlowRepository.findByStatusInAndIsMaster(workFlowStatuses)) + .thenReturn(List.of(workFlowExecution)); Mockito.when(this.workFlowDefinitionRepository.findById(Mockito.any())) .thenReturn(Optional.of(sampleWorkFlowDefinition())); // when this.service.workFlowRunAfterStartup(); // then - Mockito.verify(this.workFlowRepository, Mockito.times(1)).findByStatusIn(workFlowStatuses); + Mockito.verify(this.workFlowRepository, Mockito.times(1)).findByStatusInAndIsMaster(workFlowStatuses); Mockito.verify(this.asyncWorkFlowContinuer, Mockito.times(1)).executeAsync( Mockito.eq(workFlowExecution.getProjectId().toString()), Mockito.eq(TEST_WORKFLOW), Mockito.any(), Mockito.any()); @@ -91,14 +92,15 @@ void workFlowCompleteInProgress() { void workFlowCompletePending() { // given WorkFlowExecution workFlowExecution = this.sampleWorkFlowExecution(WorkFlowStatus.PENDING); - Mockito.when(this.workFlowRepository.findByStatusIn(workFlowStatuses)).thenReturn(List.of(workFlowExecution)); + Mockito.when(this.workFlowRepository.findByStatusInAndIsMaster(workFlowStatuses)) + .thenReturn(List.of(workFlowExecution)); Mockito.when(this.workFlowDefinitionRepository.findById(Mockito.any())) .thenReturn(Optional.of(sampleWorkFlowDefinition())); // when this.service.workFlowRunAfterStartup(); // then - Mockito.verify(this.workFlowRepository, Mockito.times(1)).findByStatusIn(workFlowStatuses); + Mockito.verify(this.workFlowRepository, Mockito.times(1)).findByStatusInAndIsMaster(workFlowStatuses); Mockito.verify(this.asyncWorkFlowContinuer, Mockito.times(1)).executeAsync( Mockito.eq(workFlowExecution.getProjectId().toString()), Mockito.eq(TEST_WORKFLOW), Mockito.any(), Mockito.any()); @@ -108,7 +110,8 @@ void workFlowCompletePending() { void workFlowCompleteWithTaskExecutions() { // given WorkFlowExecution workFlowExecution = this.sampleWorkFlowExecution(WorkFlowStatus.IN_PROGRESS); - Mockito.when(this.workFlowRepository.findByStatusIn(workFlowStatuses)).thenReturn(List.of(workFlowExecution)); + Mockito.when(this.workFlowRepository.findByStatusInAndIsMaster(workFlowStatuses)) + .thenReturn(List.of(workFlowExecution)); Mockito.when(this.workFlowDefinitionRepository.findById(Mockito.any())) .thenReturn(Optional.of(sampleWorkFlowDefinition())); WorkFlowTaskDefinition workFlowTaskDefinition = sampleWorkFlowTaskDefinition(); @@ -127,7 +130,7 @@ void workFlowCompleteWithTaskExecutions() { this.service.workFlowRunAfterStartup(); // then - Mockito.verify(this.workFlowRepository, Mockito.times(1)).findByStatusIn(workFlowStatuses); + Mockito.verify(this.workFlowRepository, Mockito.times(1)).findByStatusInAndIsMaster(workFlowStatuses); Mockito.verify(this.asyncWorkFlowContinuer, Mockito.times(1)).executeAsync( Mockito.eq(workFlowExecution.getProjectId().toString()), Mockito.eq(TEST_WORKFLOW), Mockito.any(), Mockito.any()); @@ -137,7 +140,8 @@ void workFlowCompleteWithTaskExecutions() { void workFlowCompleteWithInvalidJson() { // given WorkFlowExecution wfExecution = this.sampleWorkFlowExecution(WorkFlowStatus.IN_PROGRESS); - Mockito.when(this.workFlowRepository.findByStatusIn(workFlowStatuses)).thenReturn(List.of(wfExecution)); + Mockito.when(this.workFlowRepository.findByStatusInAndIsMaster(workFlowStatuses)) + .thenReturn(List.of(wfExecution)); Mockito.when(this.workFlowDefinitionRepository.findById(Mockito.any())) .thenReturn(Optional.of(sampleWorkFlowDefinition())); WorkFlowTaskDefinition wfTaskDef = sampleWorkFlowTaskDefinition(); @@ -161,7 +165,7 @@ void workFlowCompleteWithInvalidJson() { assertNotNull(exception); assertTrue(exception.getMessage().contains("JsonParseException")); - Mockito.verify(this.workFlowRepository, Mockito.times(1)).findByStatusIn(workFlowStatuses); + Mockito.verify(this.workFlowRepository, Mockito.times(1)).findByStatusInAndIsMaster(workFlowStatuses); Mockito.verify(this.asyncWorkFlowContinuer, Mockito.times(1)).executeAsync(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()); } diff --git a/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/dto/WorkFlowRequestDTOTest.java b/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/dto/WorkFlowRequestDTOTest.java new file mode 100644 index 000000000..0fc689d4d --- /dev/null +++ b/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/dto/WorkFlowRequestDTOTest.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2022 Red Hat Developer + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.redhat.parodos.workflow.execution.dto; + +import com.redhat.parodos.workflow.enums.WorkType; +import org.junit.jupiter.api.Test; + +import java.util.Arrays; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +/** + * Workflow request dto test + * + * @author Richard Wang (Github: richardw98) + */ + +class WorkFlowRequestDTOTest { + + private static final String TEST_WORK_TASK = "test-work-task"; + + private static final String TEST_WORKFLOW_EXECUTION_REQUEST = "test-workflow-execution-request"; + + private static final String MASTER_WORKFLOW_PARAM_1_KEY = "master-workflow-param-1-key"; + + private static final String MASTER_WORKFLOW_PARAM_1_VALUE = "master-workflow-param-1-value"; + + private static final String TEST_WORKFLOW = "test-workflow"; + + private static final String WORK_PARAM_TASK_KEY = "work-param-task-key"; + + private static final String WORK_PARAM_TASK_VALUE = "work-param-task-value"; + + @Test + void findWorkByName_whenWorkIsFound_then_shouldReturnWork() { + WorkFlowRequestDTO request = getSimpleWorkFlowRequestDTO(); + WorkFlowRequestDTO.WorkRequestDTO subWorkflow = request.findFirstWorkByName(TEST_WORKFLOW); + + WorkFlowRequestDTO.WorkRequestDTO task = subWorkflow.findFirstWorkByName(TEST_WORK_TASK); + + assertNull(request.findFirstWorkByName("test")); + assertNull(subWorkflow.findFirstWorkByName("test")); + + assertThat(subWorkflow).isNotNull().satisfies(work -> { + assertEquals(WorkType.WORKFLOW.name(), work.getType()); + assertEquals(0, work.getArguments().size()); + }); + + assertThat(task).isNotNull().satisfies(work -> { + assertEquals(WorkType.TASK.name(), work.getType()); + assertEquals(1, work.getArguments().size()); + }); + } + + private WorkFlowRequestDTO getSimpleWorkFlowRequestDTO() { + return WorkFlowRequestDTO.builder().workFlowName(TEST_WORKFLOW_EXECUTION_REQUEST) + .arguments(List.of(WorkFlowRequestDTO.WorkRequestDTO.ArgumentRequestDTO.builder() + .key(MASTER_WORKFLOW_PARAM_1_KEY).value(MASTER_WORKFLOW_PARAM_1_VALUE).build())) + .works(List + .of(getSimpleWorkRequestDTO(TEST_WORKFLOW, WorkType.WORKFLOW.name(), List.of(), + getSimpleWorkRequestDTO(TEST_WORK_TASK, WorkType.TASK.name(), + List.of(WorkFlowRequestDTO.WorkRequestDTO.ArgumentRequestDTO.builder() + .key(WORK_PARAM_TASK_KEY).value(WORK_PARAM_TASK_VALUE).build()))))) + .build(); + } + + private WorkFlowRequestDTO.WorkRequestDTO getSimpleWorkRequestDTO(String workName, String type, + List arguments, + WorkFlowRequestDTO.WorkRequestDTO... works) { + return WorkFlowRequestDTO.WorkRequestDTO.builder().workName(workName).arguments(arguments).type(type) + .works(WorkType.WORKFLOW.name().equals(type) ? Arrays.asList(works) : null).build(); + } + +} diff --git a/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/scheduler/WorkFlowSchedulerServiceImplTest.java b/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/scheduler/WorkFlowSchedulerServiceImplTest.java index 483656031..8a9dd39d6 100644 --- a/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/scheduler/WorkFlowSchedulerServiceImplTest.java +++ b/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/scheduler/WorkFlowSchedulerServiceImplTest.java @@ -9,6 +9,7 @@ import org.springframework.scheduling.TaskScheduler; import org.springframework.scheduling.support.CronTrigger; +import java.util.UUID; import java.util.concurrent.ScheduledFuture; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -42,7 +43,7 @@ void scheduleWithValidData() { Mockito.when(this.taskScheduler.schedule(Mockito.any(Runnable.class), Mockito.any(CronTrigger.class))) .thenReturn(null); // when - this.service.schedule(this.workFlow, new WorkContext(), CRON_EXPRESSION); + this.service.schedule(UUID.randomUUID().toString(), this.workFlow, new WorkContext(), CRON_EXPRESSION); // then Mockito.verify(this.taskScheduler, Mockito.times(1)).schedule(Mockito.any(Runnable.class), Mockito.any(CronTrigger.class)); @@ -50,13 +51,14 @@ void scheduleWithValidData() { @Test void workFlowIsNotScheduledTwice() { + String projectId = UUID.randomUUID().toString(); // given Mockito.when(this.taskScheduler.schedule(Mockito.any(Runnable.class), Mockito.any(CronTrigger.class))) .thenReturn(null); - this.service.schedule(this.workFlow, new WorkContext(), CRON_EXPRESSION); + this.service.schedule(projectId, this.workFlow, new WorkContext(), CRON_EXPRESSION); // when - this.service.schedule(this.workFlow, new WorkContext(), CRON_EXPRESSION); + this.service.schedule(projectId, this.workFlow, new WorkContext(), CRON_EXPRESSION); // then Mockito.verify(this.taskScheduler, Mockito.times(1)).schedule(Mockito.any(Runnable.class), @@ -66,15 +68,16 @@ void workFlowIsNotScheduledTwice() { @SuppressWarnings("unchecked") @Test void workFlowCanBeCancel() { + String projectId = UUID.randomUUID().toString(); // given var mockScheduledFuture = Mockito.mock(ScheduledFuture.class); Mockito.when(mockScheduledFuture.cancel(false)).thenReturn(true); Mockito.when(this.taskScheduler.schedule(Mockito.any(Runnable.class), Mockito.any(CronTrigger.class))) .thenReturn(mockScheduledFuture); - this.service.schedule(this.workFlow, new WorkContext(), CRON_EXPRESSION); + this.service.schedule(projectId, this.workFlow, new WorkContext(), CRON_EXPRESSION); // when - this.service.stop(this.workFlow); + this.service.stop(projectId, this.workFlow); // then Mockito.verify(mockScheduledFuture, Mockito.times(1)).cancel(Mockito.anyBoolean()); @@ -87,7 +90,7 @@ void workFlowIsNotCalledIfNoPresent() { ScheduledFuture mockScheduledFuture = Mockito.mock(ScheduledFuture.class); Mockito.when(mockScheduledFuture.cancel(Mockito.anyBoolean())).thenReturn(true); // when - boolean res = this.service.stop(this.workFlow); + boolean res = this.service.stop(UUID.randomUUID().toString(), this.workFlow); // then assertFalse(res); diff --git a/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/service/WorkFlowServiceImplTest.java b/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/service/WorkFlowServiceImplTest.java index b317b4085..6aba44e59 100644 --- a/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/service/WorkFlowServiceImplTest.java +++ b/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/service/WorkFlowServiceImplTest.java @@ -7,6 +7,7 @@ import com.redhat.parodos.workflow.definition.repository.WorkFlowDefinitionRepository; import com.redhat.parodos.workflow.definition.repository.WorkFlowTaskDefinitionRepository; import com.redhat.parodos.workflow.definition.repository.WorkFlowWorkRepository; +import com.redhat.parodos.workflow.definition.service.WorkFlowDefinitionServiceImpl; import com.redhat.parodos.workflow.enums.WorkFlowStatus; import com.redhat.parodos.workflow.enums.WorkType; @@ -24,9 +25,13 @@ import com.redhat.parodos.workflows.work.WorkReport; import com.redhat.parodos.workflows.work.WorkStatus; import com.redhat.parodos.workflows.workflow.SequentialFlow; +import io.micrometer.core.instrument.MeterRegistry; +import io.micrometer.core.instrument.search.MeterNotFoundException; +import io.micrometer.core.instrument.simple.SimpleMeterRegistry; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; +import org.mockito.Mock; import org.mockito.Mockito; import org.springframework.web.server.ResponseStatusException; @@ -44,6 +49,9 @@ class WorkFlowServiceImplTest { + @Mock + private MeterRegistry meterRegistry; + private WorkFlowDelegate workFlowDelegate; private WorkFlowServiceDelegate workFlowServiceDelegate; @@ -60,6 +68,10 @@ class WorkFlowServiceImplTest { private WorkFlowServiceImpl workFlowService; + private WorkFlowDefinitionServiceImpl workFlowDefinitionService; + + private MeterRegistry metricRegistry; + @BeforeEach void initEach() { this.workFlowDelegate = Mockito.mock(WorkFlowDelegate.class); @@ -69,10 +81,13 @@ void initEach() { this.workFlowTaskDefinitionRepository = Mockito.mock(WorkFlowTaskDefinitionRepository.class); this.workFlowTaskRepository = Mockito.mock(WorkFlowTaskRepository.class); this.workFlowWorkRepository = Mockito.mock(WorkFlowWorkRepository.class); + this.workFlowDefinitionService = Mockito.mock(WorkFlowDefinitionServiceImpl.class); + this.metricRegistry = new SimpleMeterRegistry(); this.workFlowService = new WorkFlowServiceImpl(this.workFlowDelegate, this.workFlowServiceDelegate, this.workFlowDefinitionRepository, this.workFlowTaskDefinitionRepository, this.workFlowRepository, - this.workFlowTaskRepository, this.workFlowWorkRepository); + this.workFlowTaskRepository, this.workFlowWorkRepository, this.workFlowDefinitionService, + this.metricRegistry); } @Test @@ -88,7 +103,8 @@ void executeTestWithValidData() { } })); Mockito.when(this.workFlowDelegate.getWorkFlowExecutionByName("test-workflow")).thenReturn(workFlow); - Mockito.when(this.workFlowDelegate.initWorkFlowContext(Mockito.any())).thenReturn(new WorkContext()); + Mockito.when(this.workFlowDelegate.initWorkFlowContext(Mockito.any(), Mockito.any())) + .thenReturn(new WorkContext()); Mockito.when(this.workFlowDefinitionRepository.findFirstByName(Mockito.any())) .thenReturn(this.sampleWorkflowDefinition("test")); @@ -124,7 +140,7 @@ void executeTestWithNoValidWorkflow() { assertNotNull(report.getWorkContext()); Mockito.verify(this.workFlowDelegate, Mockito.times(1)).getWorkFlowExecutionByName(Mockito.any()); - Mockito.verify(this.workFlowDelegate, Mockito.times(0)).initWorkFlowContext(Mockito.any()); + Mockito.verify(this.workFlowDelegate, Mockito.times(0)).initWorkFlowContext(Mockito.any(), Mockito.any()); Mockito.verify(this.workFlowDefinitionRepository, Mockito.times(0)).findFirstByName(Mockito.any()); } @@ -142,7 +158,8 @@ void executeWithDTOWithValidData() { Mockito.when(this.workFlowDefinitionRepository.findFirstByName(Mockito.any())) .thenReturn(this.sampleWorkflowDefinition("test")); Mockito.when(this.workFlowWorkRepository.findByWorkDefinitionId(Mockito.any())).thenReturn(List.of()); - Mockito.when(this.workFlowDelegate.initWorkFlowContext(Mockito.any())).thenReturn(new WorkContext()); + Mockito.when(this.workFlowDelegate.initWorkFlowContext(Mockito.any(), Mockito.any())) + .thenReturn(new WorkContext()); Mockito.when(this.workFlowDelegate.getWorkFlowExecutionByName("test-workflow")).thenReturn(workFlow); // when @@ -156,7 +173,7 @@ void executeWithDTOWithValidData() { assertNotNull(report.getWorkContext()); Mockito.verify(this.workFlowDelegate, Mockito.times(2)).getWorkFlowExecutionByName(Mockito.any()); - Mockito.verify(this.workFlowDelegate, Mockito.times(1)).initWorkFlowContext(Mockito.any()); + Mockito.verify(this.workFlowDelegate, Mockito.times(1)).initWorkFlowContext(Mockito.any(), Mockito.any()); Mockito.verify(this.workFlowDefinitionRepository, Mockito.times(1)).findFirstByName(Mockito.any()); } @@ -183,7 +200,7 @@ void executeWithDTOWithNoMasterWorkFlow() { assertNotNull(report.getWorkContext()); Mockito.verify(this.workFlowDelegate, Mockito.times(1)).getWorkFlowExecutionByName(Mockito.any()); - Mockito.verify(this.workFlowDelegate, Mockito.times(0)).initWorkFlowContext(Mockito.any()); + Mockito.verify(this.workFlowDelegate, Mockito.times(0)).initWorkFlowContext(Mockito.any(), Mockito.any()); Mockito.verify(this.workFlowDefinitionRepository, Mockito.times(1)).findFirstByName(Mockito.any()); } @@ -206,7 +223,7 @@ void executeWithDTOWithNoWorkFlowDefinition() { assertNotNull(report.getWorkContext()); Mockito.verify(this.workFlowDelegate, Mockito.times(1)).getWorkFlowExecutionByName(Mockito.any()); - Mockito.verify(this.workFlowDelegate, Mockito.never()).initWorkFlowContext(Mockito.any()); + Mockito.verify(this.workFlowDelegate, Mockito.never()).initWorkFlowContext(Mockito.any(), Mockito.any()); Mockito.verify(this.workFlowDefinitionRepository, Mockito.times(1)).findFirstByName(Mockito.any()); Mockito.verify(this.workFlowWorkRepository, Mockito.never()).findByWorkDefinitionId(Mockito.any()); } @@ -295,6 +312,14 @@ void testUpdateWorkflowWithValidData() { assertEquals(argument.getValue().getStatus().toString(), "COMPLETED"); assertEquals(argument.getValue().getProjectId().toString(), projectId.toString()); assertEquals(argument.getValue().getWorkFlowDefinitionId().toString(), workflowDefID.toString()); + + assertEquals(this.metricRegistry.get("workflow.executions").tag("status", "COMPLETED").counter().count(), 1); + // No other tags are created under workflow.executions metrics + assertEquals(this.metricRegistry.get("workflow.executions").counter().count(), 1); + // check that IN_PROGESS tag was not addded + assertThrows(MeterNotFoundException.class, () -> { + this.metricRegistry.get("workflow.executions").tag("status", "IN_PROGRESS").counter(); + }); } @Test