diff --git a/.classpath b/.classpath
index f0257c5..edb6621 100644
--- a/.classpath
+++ b/.classpath
@@ -26,17 +26,11 @@
-
-
-
-
-
-
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index 90f7a5b..5f32a47 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -1,9 +1,12 @@
eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.processAnnotations=enabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
diff --git a/pom.xml b/pom.xml
index 6b77a1c..71130e1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.talend
tmc_rest_api
- 2.2.0
+ 2.6.8
@@ -31,7 +31,6 @@
src/main/resources
- log4j.properties
@@ -40,32 +39,27 @@
com.fasterxml.jackson.core
jackson-core
- 2.9.9
+ 2.13.2
com.fasterxml.jackson.core
jackson-annotations
- 2.9.9
+ 2.13.1
com.fasterxml.jackson.core
jackson-databind
- 2.9.10.1
+ 2.13.1
org.springframework
spring-web
- 4.3.3.RELEASE
-
-
- org.apache.logging.log4j
- log4j-core
- 2.13.0
+ 5.2.13.RELEASE
org.apache.cxf
cxf-rt-rs-extension-search
- 3.3.4
+ 3.5.2
junit
@@ -80,4 +74,4 @@
provided
-
\ No newline at end of file
+
diff --git a/src/main/java/com/talend/tmc/dom/Artifact.java b/src/main/java/com/talend/tmc/dom/Artifact.java
new file mode 100644
index 0000000..9d4a1e5
--- /dev/null
+++ b/src/main/java/com/talend/tmc/dom/Artifact.java
@@ -0,0 +1,15 @@
+package com.talend.tmc.dom;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+
+@Data
+public class Artifact {
+ private String id;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private String name;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private String[] versions;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private String type;
+}
diff --git a/src/main/java/com/talend/tmc/dom/Artifacts.java b/src/main/java/com/talend/tmc/dom/Artifacts.java
new file mode 100644
index 0000000..90cfed2
--- /dev/null
+++ b/src/main/java/com/talend/tmc/dom/Artifacts.java
@@ -0,0 +1,17 @@
+package com.talend.tmc.dom;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import lombok.Data;
+
+@Data
+public class Artifacts {
+ @JsonProperty("items")
+ private Artifact[] items;
+ @JsonProperty("limits")
+ private int limits;
+ @JsonProperty("offset")
+ private int offset;
+ @JsonProperty("total")
+ private int total;
+}
diff --git a/src/main/java/com/talend/tmc/dom/Engine.java b/src/main/java/com/talend/tmc/dom/Engine.java
index 4fad178..977e36d 100644
--- a/src/main/java/com/talend/tmc/dom/Engine.java
+++ b/src/main/java/com/talend/tmc/dom/Engine.java
@@ -7,56 +7,56 @@
@Data
public class Engine {
@JsonInclude(JsonInclude.Include.NON_NULL)
- @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String id;
@JsonInclude(JsonInclude.Include.NON_NULL)
- @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String targetId;
@JsonInclude(JsonInclude.Include.NON_NULL)
- @JsonProperty(access = JsonProperty.Access.READ_WRITE)
+// @JsonProperty(access = JsonProperty.Access.READ_WRITE)
private String name;
@JsonInclude(JsonInclude.Include.NON_NULL)
- @JsonProperty(access = JsonProperty.Access.READ_WRITE)
+// @JsonProperty(access = JsonProperty.Access.READ_WRITE)
private String description;
@JsonInclude(JsonInclude.Include.NON_NULL)
- @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String createDate;
@JsonInclude(JsonInclude.Include.NON_NULL)
- @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String updateDate;
@JsonInclude(JsonInclude.Include.NON_NULL)
- @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String runtimeId;
@JsonInclude(JsonInclude.Include.NON_NULL)
- @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String availability;
@JsonInclude(JsonInclude.Include.NON_NULL)
- @JsonProperty(access = JsonProperty.Access.READ_WRITE)
+// @JsonProperty(access = JsonProperty.Access.READ_WRITE)
private String environmentId;
@JsonInclude(JsonInclude.Include.NON_NULL)
- @JsonProperty(access = JsonProperty.Access.READ_WRITE)
+// @JsonProperty(access = JsonProperty.Access.READ_WRITE)
private String workspaceId;
@JsonInclude(JsonInclude.Include.NON_NULL)
- @JsonProperty(access = JsonProperty.Access.READ_WRITE)
+// @JsonProperty(access = JsonProperty.Access.READ_WRITE)
private String[] runProfiles;
private String status;
@JsonInclude(JsonInclude.Include.NON_NULL)
- @JsonProperty(access = JsonProperty.Access.READ_WRITE)
+// @JsonProperty(access = JsonProperty.Access.READ_WRITE)
private Debug debug;
@JsonInclude(JsonInclude.Include.NON_NULL)
- @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String clusterId;
@JsonInclude(JsonInclude.Include.NON_NULL)
- @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String preAuthorizedKey;
@JsonInclude(JsonInclude.Include.NON_NULL)
- @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String type;
@JsonInclude(JsonInclude.Include.NON_NULL)
- @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
private Report analyzeReport;
@JsonInclude(JsonInclude.Include.NON_NULL)
- @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
private Report promotionReport;
}
diff --git a/src/main/java/com/talend/tmc/dom/Executable.java b/src/main/java/com/talend/tmc/dom/Executable.java
index 550a5ab..d8f15cc 100644
--- a/src/main/java/com/talend/tmc/dom/Executable.java
+++ b/src/main/java/com/talend/tmc/dom/Executable.java
@@ -9,15 +9,9 @@ public class Executable {
@JsonInclude(JsonInclude.Include.NON_NULL)
private String name;
@JsonInclude(JsonInclude.Include.NON_NULL)
- private String description;
- @JsonInclude(JsonInclude.Include.NON_NULL)
- private String version;
- @JsonInclude(JsonInclude.Include.NON_NULL)
- private String[] parameterNames;
- @JsonInclude(JsonInclude.Include.NON_NULL)
private Workspace workspace;
@JsonInclude(JsonInclude.Include.NON_NULL)
- private Environment sourceEnvironment;
+ private String artifactId;
@JsonInclude(JsonInclude.Include.NON_NULL)
- private Environment targetEnvironment;
+ private Runtime runtime;
}
diff --git a/src/main/java/com/talend/tmc/dom/Items.java b/src/main/java/com/talend/tmc/dom/ExecutableItems.java
similarity index 67%
rename from src/main/java/com/talend/tmc/dom/Items.java
rename to src/main/java/com/talend/tmc/dom/ExecutableItems.java
index 89630e6..b3c268d 100644
--- a/src/main/java/com/talend/tmc/dom/Items.java
+++ b/src/main/java/com/talend/tmc/dom/ExecutableItems.java
@@ -1,13 +1,11 @@
package com.talend.tmc.dom;
-import java.util.List;
-
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
-public class Items {
- @JsonProperty("items")
+public class ExecutableItems {
+ @JsonProperty("items")
private Executable[] executables;
}
diff --git a/src/main/java/com/talend/tmc/dom/ExecutionItems.java b/src/main/java/com/talend/tmc/dom/ExecutionItems.java
new file mode 100644
index 0000000..aa220f7
--- /dev/null
+++ b/src/main/java/com/talend/tmc/dom/ExecutionItems.java
@@ -0,0 +1,11 @@
+package com.talend.tmc.dom;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import lombok.Data;
+
+@Data
+public class ExecutionItems {
+ @JsonProperty("items")
+ private Execution[] executions;
+}
diff --git a/src/main/java/com/talend/tmc/dom/ExecutionPromotionRequest.java b/src/main/java/com/talend/tmc/dom/ExecutionPromotionRequest.java
index 6331cfd..8da7e4a 100644
--- a/src/main/java/com/talend/tmc/dom/ExecutionPromotionRequest.java
+++ b/src/main/java/com/talend/tmc/dom/ExecutionPromotionRequest.java
@@ -2,12 +2,11 @@
import lombok.Data;
-import java.util.HashMap;
-
@Data
public class ExecutionPromotionRequest {
private String executable;
private boolean keepTargetResources;
+ private boolean keepTargetRunProfiles;
private Advanced advanced;
}
diff --git a/src/main/java/com/talend/tmc/dom/ExecutionRequest.java b/src/main/java/com/talend/tmc/dom/ExecutionRequest.java
index c166e35..631f4d3 100644
--- a/src/main/java/com/talend/tmc/dom/ExecutionRequest.java
+++ b/src/main/java/com/talend/tmc/dom/ExecutionRequest.java
@@ -2,10 +2,10 @@
import lombok.Data;
-import java.util.Hashtable;
+import java.util.Map;
@Data
public class ExecutionRequest {
private String executable;
- private Hashtable parameters;
+ private Map parameters;
}
diff --git a/src/main/java/com/talend/tmc/dom/Parameter.java b/src/main/java/com/talend/tmc/dom/Parameter.java
new file mode 100644
index 0000000..84e0baf
--- /dev/null
+++ b/src/main/java/com/talend/tmc/dom/Parameter.java
@@ -0,0 +1,9 @@
+package com.talend.tmc.dom;
+
+import lombok.Data;
+
+@Data
+public class Parameter {
+ private String key;
+ private String value;
+}
diff --git a/src/main/java/com/talend/tmc/dom/PipelineEngine.java b/src/main/java/com/talend/tmc/dom/PipelineEngine.java
new file mode 100644
index 0000000..46dc4fb
--- /dev/null
+++ b/src/main/java/com/talend/tmc/dom/PipelineEngine.java
@@ -0,0 +1,85 @@
+package com.talend.tmc.dom;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+@Data
+public class PipelineEngine {
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+ private String id;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+// @JsonProperty(access = JsonProperty.Access.READ_WRITE)
+ private String name;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+// @JsonProperty(access = JsonProperty.Access.READ_WRITE)
+ private String description;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+ private String createDate;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+ private String updateDate;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+ private String runtimeId;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+ private String availability;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+ private boolean managed;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+// @JsonProperty(access = JsonProperty.Access.READ_WRITE)
+ private WorkspaceInfo workspaceInfo;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+// @JsonProperty(access = JsonProperty.Access.READ_WRITE)
+ private String[] runProfiles;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+ private String status;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+ private String preAuthorizedKey;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+ private boolean cloudRunner;
+}
+
+@Data
+class WorkspaceInfo {
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+ private String id;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+ private String name;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+ private String description;
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+ private String owner;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+ /* ['shared', 'personal', 'custom'], */
+ private String type;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+ private EnvironmentInfo environmentInfo;
+}
+
+@Data
+class EnvironmentInfo {
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+ private String id;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+//@JsonProperty(access = JsonProperty.Access.READ_ONLY)
+ private String name;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+//@JsonProperty(access = JsonProperty.Access.READ_ONLY)
+ private String description;
+ @JsonProperty("default")
+ private boolean isDefault;
+}
diff --git a/src/main/java/com/talend/tmc/dom/PipelineEngineRequest.java b/src/main/java/com/talend/tmc/dom/PipelineEngineRequest.java
new file mode 100644
index 0000000..97a9c84
--- /dev/null
+++ b/src/main/java/com/talend/tmc/dom/PipelineEngineRequest.java
@@ -0,0 +1,21 @@
+package com.talend.tmc.dom;
+
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+
+@Data
+public class PipelineEngineRequest {
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+// @JsonProperty(access = JsonProperty.Access.READ_WRITE)
+ private String name;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+// @JsonProperty(access = JsonProperty.Access.READ_WRITE)
+ private String environmentId;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+//@JsonProperty(access = JsonProperty.Access.READ_WRITE)
+ private String workspaceId;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+//@JsonProperty(access = JsonProperty.Access.READ_WRITE)
+ private String description;
+}
diff --git a/src/main/java/com/talend/tmc/dom/Promotion.java b/src/main/java/com/talend/tmc/dom/Promotion.java
new file mode 100644
index 0000000..a902439
--- /dev/null
+++ b/src/main/java/com/talend/tmc/dom/Promotion.java
@@ -0,0 +1,12 @@
+package com.talend.tmc.dom;
+
+import lombok.Data;
+
+@Data
+public class Promotion {
+ private String executable;
+ private String name;
+ private String description;
+ private Environment sourceEnvironment;
+ private Environment targetEnvironment;
+}
diff --git a/src/main/java/com/talend/tmc/dom/RunConfig.java b/src/main/java/com/talend/tmc/dom/RunConfig.java
new file mode 100644
index 0000000..5e2408e
--- /dev/null
+++ b/src/main/java/com/talend/tmc/dom/RunConfig.java
@@ -0,0 +1,17 @@
+package com.talend.tmc.dom;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+import lombok.Data;
+
+@Data
+public class RunConfig {
+ private Trigger trigger;
+ private Runtime runtime;
+ @JsonInclude(JsonInclude.Include.NON_EMPTY)
+ private String parallelExecutionAllowed;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private String logLevel;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private String remoteRunAsUser;
+}
diff --git a/src/main/java/com/talend/tmc/dom/Runtime.java b/src/main/java/com/talend/tmc/dom/Runtime.java
new file mode 100644
index 0000000..864349d
--- /dev/null
+++ b/src/main/java/com/talend/tmc/dom/Runtime.java
@@ -0,0 +1,28 @@
+package com.talend.tmc.dom;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+
+@Data
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class Runtime {
+ //Type of runtime = ['CLOUD', 'REMOTE_ENGINE', 'REMOTE_ENGINE_CLUSTER', 'CLOUD_EXCLUSIVE'],
+ private String type;
+ // Runtime id
+ private String id;
+ //Remote engine id
+ private String engineId;
+ //Remote engine cluster id
+ private String clusterId;
+ //Pipeline engine run profile id
+ private String runProfileId;
+}
+
+/*
+ * TODO: implement enum for RuntimeType
+ */
+/*
+public enum RuntimeType {
+ CLOUD, REMOTE_ENGINE, REMOTE_ENGINE_CLUSTER, CLOUD_EXCLUSIVE
+}
+*/
\ No newline at end of file
diff --git a/src/main/java/com/talend/tmc/dom/Task.java b/src/main/java/com/talend/tmc/dom/Task.java
new file mode 100644
index 0000000..a42b8dd
--- /dev/null
+++ b/src/main/java/com/talend/tmc/dom/Task.java
@@ -0,0 +1,31 @@
+package com.talend.tmc.dom;
+
+import java.util.Map;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+
+@Data
+public class Task {
+ private String id;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private String executable;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private String name;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private String description;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private Workspace workspace;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private String version;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private Artifact artifact;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private String[] tags;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private Map parameters;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private Map AutoUpgradeInfo;
+
+ // resources missing
+}
diff --git a/src/main/java/com/talend/tmc/dom/TaskNew.java b/src/main/java/com/talend/tmc/dom/TaskNew.java
new file mode 100644
index 0000000..c506ee8
--- /dev/null
+++ b/src/main/java/com/talend/tmc/dom/TaskNew.java
@@ -0,0 +1,28 @@
+package com.talend.tmc.dom;
+
+import java.util.Map;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+
+@Data
+public class TaskNew {
+ private String workspaceId;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private String environmentId;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private String name;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private String description;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private Map artifact;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private String[] tags;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private Map parameters;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private Map AutoUpgradeInfo;
+
+ // resources missing
+ // connections missing
+}
diff --git a/src/main/java/com/talend/tmc/dom/Tasks.java b/src/main/java/com/talend/tmc/dom/Tasks.java
new file mode 100644
index 0000000..e12bcc5
--- /dev/null
+++ b/src/main/java/com/talend/tmc/dom/Tasks.java
@@ -0,0 +1,17 @@
+package com.talend.tmc.dom;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import lombok.Data;
+
+@Data
+public class Tasks {
+ @JsonProperty("items")
+ private Task[] items;
+ @JsonProperty("limits")
+ private int limits;
+ @JsonProperty("offset")
+ private int offset;
+ @JsonProperty("total")
+ private int total;
+}
diff --git a/src/main/java/com/talend/tmc/dom/Trigger.java b/src/main/java/com/talend/tmc/dom/Trigger.java
new file mode 100644
index 0000000..7b4e170
--- /dev/null
+++ b/src/main/java/com/talend/tmc/dom/Trigger.java
@@ -0,0 +1,21 @@
+package com.talend.tmc.dom;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+
+@Data
+public class Trigger {
+ // Type of schedule = ['ONCE', 'DAILY', 'WEEKLY', 'MONTHLY', 'WEBHOOK', 'MANUAL'],
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private String type;
+ // Interval between task/plan running in days/weeks/months, required only if type of schedule is not equal to 'ONCE') ,
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private String interval;
+ // Date when the task should start to run
+ // format: "2019-09-25"
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private String startDate;
+ // Time zone for task schedule
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private String timeZone;
+}
diff --git a/src/main/java/com/talend/tmc/dom/enums/ArtifactType.java b/src/main/java/com/talend/tmc/dom/enums/ArtifactType.java
new file mode 100644
index 0000000..d62eed3
--- /dev/null
+++ b/src/main/java/com/talend/tmc/dom/enums/ArtifactType.java
@@ -0,0 +1,18 @@
+package com.talend.tmc.dom.enums;
+
+/*
+ * ArtifactType
+ * Used when adding a PromotionExecution
+ *
+ * Advanced Promotion Artifact Type. In the following list of allowed values,
+ * 'ACTION' refers to Artifacts,
+ * 'FLOW' refers to Tasks,
+ * 'PLAN' refers to Plans
+ * 'WORKSPACE' refers to Workspaces
+ */
+public enum ArtifactType {
+ WORKSPACE,
+ PLAN,
+ FLOW,
+ ACTION
+}
diff --git a/src/main/java/com/talend/tmc/services/TalendApiClient.java b/src/main/java/com/talend/tmc/services/TalendApiClient.java
index ffd6be6..c3fb141 100644
--- a/src/main/java/com/talend/tmc/services/TalendApiClient.java
+++ b/src/main/java/com/talend/tmc/services/TalendApiClient.java
@@ -1,18 +1,19 @@
package com.talend.tmc.services;
+import java.util.Base64;
+import java.util.Hashtable;
+
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;
-import java.util.Base64;
-import java.util.Hashtable;
-
public class TalendApiClient {
private static TalendApiClient instance = null;
private HttpHeaders httpHeaders;
- private final TalendCredentials credentials;
+ @SuppressWarnings("unused")
+ private final TalendCredentials credentials;
private RestTemplate rest;
private TalendApiClient(TalendCredentials credentials)
diff --git a/src/main/java/com/talend/tmc/services/TalendCloudRegion.java b/src/main/java/com/talend/tmc/services/TalendCloudRegion.java
index 2afaa67..899a60d 100644
--- a/src/main/java/com/talend/tmc/services/TalendCloudRegion.java
+++ b/src/main/java/com/talend/tmc/services/TalendCloudRegion.java
@@ -4,22 +4,22 @@ public enum TalendCloudRegion {
AWS_USA_EAST {
public String toString() {
- return "https://api.us.cloud.talend.com/tmc/v2.2/";
+ return "https://api.us.cloud.talend.com/tmc/v2.6/";
}
},
AWS_EMEA {
public String toString() {
- return "https://api.eu.cloud.talend.com/tmc/v2.2/";
+ return "https://api.eu.cloud.talend.com/tmc/v2.6/";
}
},
AWS_APAC {
public String toString() {
- return "https://api.ap.cloud.talend.com/tmc/v2.2/";
+ return "https://api.ap.cloud.talend.com/tmc/v2.6/";
}
},
AZURE_USA_WEST {
public String toString() {
- return "https://api.us-west.cloud.talend.com/tmc/v2.2/";
+ return "https://api.us-west.cloud.talend.com/tmc/v2.6/";
}
}
}
diff --git a/src/main/java/com/talend/tmc/services/TalendService.java b/src/main/java/com/talend/tmc/services/TalendService.java
index 73e2389..6317ea6 100644
--- a/src/main/java/com/talend/tmc/services/TalendService.java
+++ b/src/main/java/com/talend/tmc/services/TalendService.java
@@ -1,7 +1,5 @@
package com.talend.tmc.services;
-import com.talend.tmc.services.executables.ExecutableService;
-
public interface TalendService {
default T instance(TalendCredentials credentials, TalendCloudRegion region) {
if (region == null) throw new NullPointerException("TalendCloudRegion cannot be null");
diff --git a/src/main/java/com/talend/tmc/services/artifacts/ArtifactService.java b/src/main/java/com/talend/tmc/services/artifacts/ArtifactService.java
new file mode 100644
index 0000000..fcb673d
--- /dev/null
+++ b/src/main/java/com/talend/tmc/services/artifacts/ArtifactService.java
@@ -0,0 +1,140 @@
+package com.talend.tmc.services.artifacts;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.talend.tmc.dom.Artifact;
+import com.talend.tmc.dom.Artifacts;
+import com.talend.tmc.services.*;
+import org.springframework.http.HttpMethod;
+
+import java.io.IOException;
+import java.util.Hashtable;
+
+/**
+ * @author reinier
+ *
+ */
+/**
+ * @author reinier
+ *
+ */
+/**
+ * @author reinier
+ *
+ */
+public class ArtifactService {
+ private final String path = "artifacts";
+ private final TalendApiClient client;
+ private final TalendCloudRegion region;
+ private ObjectMapper mapper;
+
+ public static ArtifactService instance(TalendCredentials credentials, TalendCloudRegion region) throws NullPointerException
+ {
+ if (region == null) throw new NullPointerException("TalendCloudRegion cannot be null");
+ if (credentials == null) throw new NullPointerException("TalendCredentials cannot be null");
+ ArtifactService _instance = new ArtifactService(credentials, region);
+
+ return _instance;
+ }
+
+ private ArtifactService(TalendCredentials credentials, TalendCloudRegion region)
+ {
+ client = TalendApiClient.createNewInstance(credentials);
+ this.region = region;
+ // Set ObjectMapper
+ this.mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ }
+
+ /**
+ * @param id
+ * @return
+ * @throws TalendRestException
+ * @throws IOException
+ * @throws NullPointerException
+ */
+ public Artifact getById(String id) throws TalendRestException,
+ IOException, NullPointerException
+ {
+ if (id == null) throw new NullPointerException("Value of id cannot be null");
+ return get(id);
+ }
+
+ /**
+ * @param query
+ * @return
+ * @throws TalendRestException
+ * @throws IOException
+ */
+public Artifact[] getByQuery(String query) throws TalendRestException,
+ IOException
+ {
+ Artifacts artifacts= null;
+
+ StringBuilder uri = new StringBuilder();
+ uri.append(region.toString()+path);
+ uri.append("?" + query);
+
+ Hashtable response = client.call(HttpMethod.GET, uri.toString(), null);
+
+ for (Integer httpStatus : response.keySet())
+ {
+ String payload = response.get(httpStatus);
+ if (httpStatus != 200)
+ {
+
+ TalendError error = mapper.readValue(payload, TalendError.class);
+ throw new TalendRestException(error.toString());
+ } else {
+ artifacts = mapper.readValue(payload, Artifacts.class);
+ }
+ }
+
+ return artifacts.getItems();
+
+ }
+
+ /**
+ * @param name Name of the Artifact
+ * @param workspace Id of the Workspace
+ * @return
+ * @throws TalendRestException
+ * @throws IOException
+ */
+ public Artifact[] getByName(String name, String workspace) throws TalendRestException,
+ IOException
+ {
+ String query = "name=" + name;
+
+ query = workspace != null ? query + "&workspaceId=" + workspace : query;
+
+ return getByQuery(query);
+ }
+
+ private Artifact get(String id) throws TalendRestException,
+ IOException
+ {
+ Artifact artifact= null;
+
+ StringBuilder uri = new StringBuilder();
+ uri.append(region.toString()+path);
+ if (id != null)
+ uri.append("/" + id);
+
+ Hashtable response = client.call(HttpMethod.GET, uri.toString(), null);
+
+ for (Integer httpStatus : response.keySet())
+ {
+ String payload = response.get(httpStatus);
+ if (httpStatus != 200)
+ {
+ TalendError error = mapper.readValue(payload, TalendError.class);
+ throw new TalendRestException(error.toString());
+ } else {
+ artifact = mapper.readValue(payload, Artifact.class);
+ }
+ }
+
+ return artifact;
+ }
+}
diff --git a/src/main/java/com/talend/tmc/services/executables/ExecutablePlanService.java b/src/main/java/com/talend/tmc/services/executables/ExecutablePlanService.java
index 326b3c3..c5068b4 100644
--- a/src/main/java/com/talend/tmc/services/executables/ExecutablePlanService.java
+++ b/src/main/java/com/talend/tmc/services/executables/ExecutablePlanService.java
@@ -4,9 +4,8 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.talend.tmc.dom.Executable;
import com.talend.tmc.dom.ExecutablePlanDetail;
+import com.talend.tmc.dom.ExecutableItems;
import com.talend.tmc.services.*;
-import org.apache.cxf.jaxrs.ext.search.SearchParseException;
-import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser;
import org.springframework.http.HttpMethod;
import java.io.IOException;
@@ -37,7 +36,7 @@ private ExecutablePlanService(TalendCredentials credentials, TalendCloudRegion r
}
public ExecutablePlanDetail getById(String id) throws TalendRestException,
- SearchParseException, IOException, NullPointerException
+ IOException, NullPointerException
{
if (id == null) throw new NullPointerException("Value of id cannot be null");
@@ -65,15 +64,11 @@ public ExecutablePlanDetail getById(String id) throws TalendRestException,
}
public Executable[] getByQuery(String fiqlQuery) throws TalendRestException,
- SearchParseException, IOException
+ IOException
{
- //Validates the fiqlQuery to meet the FIQL Spec. If not throw exception immediately
- if (fiqlQuery != null) {
- FiqlParser parser = new FiqlParser<>(Executable.class);
- parser.parse(fiqlQuery);
- }
- Executable[] executables = null;
+ ExecutableItems items = null;
+ Executable[] returnValue = null;
StringBuilder uri = new StringBuilder();
uri.append(region.toString()+path);
if (fiqlQuery != null) {
@@ -90,12 +85,13 @@ public Executable[] getByQuery(String fiqlQuery) throws TalendRestException,
TalendError error = mapper.readValue(payload, TalendError.class);
throw new TalendRestException(error.toString());
} else {
- executables = mapper.readValue(payload, Executable[].class);
+ items = mapper.readValue(payload, ExecutableItems.class);
+ returnValue = items.getExecutables();
}
}
- return executables;
+ return returnValue;
}
}
diff --git a/src/main/java/com/talend/tmc/services/executables/ExecutablePromotionService.java b/src/main/java/com/talend/tmc/services/executables/ExecutablePromotionService.java
index 63c4bd1..a579433 100644
--- a/src/main/java/com/talend/tmc/services/executables/ExecutablePromotionService.java
+++ b/src/main/java/com/talend/tmc/services/executables/ExecutablePromotionService.java
@@ -2,11 +2,8 @@
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.talend.tmc.dom.Executable;
-import com.talend.tmc.dom.ExecutablePlanDetail;
+import com.talend.tmc.dom.Promotion;
import com.talend.tmc.services.*;
-import org.apache.cxf.jaxrs.ext.search.SearchParseException;
-import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser;
import org.springframework.http.HttpMethod;
import java.io.IOException;
@@ -36,12 +33,12 @@ private ExecutablePromotionService(TalendCredentials credentials, TalendCloudReg
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
- public Executable getById(String id) throws TalendRestException,
- SearchParseException, IOException, NullPointerException
+ public Promotion getById(String id) throws TalendRestException,
+ IOException, NullPointerException
{
if (id == null) throw new NullPointerException("Value of id cannot be null");
- Executable executable = null;
+ Promotion promotion = null;
StringBuilder uri = new StringBuilder();
uri.append(region.toString()+path);
uri.append("/"+id);
@@ -56,24 +53,19 @@ public Executable getById(String id) throws TalendRestException,
TalendError error = mapper.readValue(payload, TalendError.class);
throw new TalendRestException(error.toString());
} else {
- executable = mapper.readValue(payload, Executable.class);
+ promotion = mapper.readValue(payload, Promotion.class);
}
}
- return executable;
+ return promotion;
}
- public Executable[] getByQuery(String fiqlQuery) throws TalendRestException,
- SearchParseException, IOException
+ public Promotion[] getByQuery(String fiqlQuery) throws TalendRestException,
+ IOException
{
- //Validates the fiqlQuery to meet the FIQL Spec. If not throw exception immediately
- if (fiqlQuery != null) {
- FiqlParser parser = new FiqlParser<>(Executable.class);
- parser.parse(fiqlQuery);
- }
- Executable[] executables = null;
+ Promotion[] promotions = null;
StringBuilder uri = new StringBuilder();
uri.append(region.toString()+path);
if (fiqlQuery != null) {
@@ -90,12 +82,12 @@ public Executable[] getByQuery(String fiqlQuery) throws TalendRestException,
TalendError error = mapper.readValue(payload, TalendError.class);
throw new TalendRestException(error.toString());
} else {
- executables = mapper.readValue(payload, Executable[].class);
+ promotions = mapper.readValue(payload, Promotion[].class);
}
}
- return executables;
+ return promotions;
}
}
diff --git a/src/main/java/com/talend/tmc/services/executables/ExecutableRunConfig.java b/src/main/java/com/talend/tmc/services/executables/ExecutableRunConfig.java
new file mode 100644
index 0000000..ca21c88
--- /dev/null
+++ b/src/main/java/com/talend/tmc/services/executables/ExecutableRunConfig.java
@@ -0,0 +1,100 @@
+package com.talend.tmc.services.executables;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.Hashtable;
+
+import org.springframework.http.HttpMethod;
+import com.talend.tmc.dom.RunConfig;
+import com.talend.tmc.services.TalendApiClient;
+import com.talend.tmc.services.TalendCloudRegion;
+import com.talend.tmc.services.TalendCredentials;
+import com.talend.tmc.services.TalendError;
+import com.talend.tmc.services.TalendRestException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+
+public class ExecutableRunConfig {
+ private final String path = "executables";
+ private final TalendApiClient client;
+ private final TalendCloudRegion region;
+ private ObjectMapper mapper;
+
+ public static ExecutableRunConfig instance(TalendCredentials credentials, TalendCloudRegion region)
+ throws NullPointerException {
+ if (region == null)
+ throw new NullPointerException("TalendCloudRegion cannot be null");
+ if (credentials == null)
+ throw new NullPointerException("TalendCredentials cannot be null");
+ ExecutableRunConfig _instance = new ExecutableRunConfig(credentials, region);
+
+ return _instance;
+ }
+
+ private ExecutableRunConfig(TalendCredentials credentials, TalendCloudRegion region) {
+ client = TalendApiClient.createNewInstance(credentials);
+ this.region = region;
+ // Set ObjectMapper
+ this.mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ }
+
+ public void update(String executableType, String id, RunConfig runConfig)
+ throws TalendRestException, IOException, NullPointerException, Exception {
+
+ Writer jsonWriter = new StringWriter();
+ mapper.writeValue(jsonWriter, runConfig);
+ jsonWriter.flush();
+
+ String url = getUrl(executableType, id);
+
+ Hashtable response = this.client.call(HttpMethod.PUT, url, jsonWriter.toString());
+
+ for (Integer httpStatus : response.keySet()) {
+ String payload = response.get(httpStatus);
+ if (httpStatus != 200) {
+
+ TalendError error = mapper.readValue(payload, TalendError.class);
+ throw new TalendRestException(error.toString());
+ }
+ }
+ }
+
+ private String getUrl(String executableType, String id) throws NullPointerException, Exception {
+ if (id == null)
+ throw new NullPointerException("Value of id cannot be null");
+ String baseurl = this.region.toString() + path + "/";
+ if (executableType == "task") {
+ executableType ="tasks/";
+ } else if (executableType == "plan") {
+ executableType = "plans/";
+ } else {
+ throw new Exception("type should be 'task' or 'plan'.");
+ }
+ StringBuilder uri = new StringBuilder();
+
+ uri.append(baseurl + executableType + id + "/run-config");
+ return uri.toString();
+ }
+
+ public RunConfig get(String type, String id) throws TalendRestException, IOException, Exception {
+ RunConfig runConfig = null;
+
+ String url = getUrl(type, id);
+ Hashtable response = client.call(HttpMethod.GET, url, null);
+
+ for (Integer httpStatus : response.keySet()) {
+ String payload = response.get(httpStatus);
+ if (httpStatus != 200) {
+ TalendError error = mapper.readValue(payload, TalendError.class);
+ throw new TalendRestException(error.toString());
+ } else {
+ runConfig = mapper.readValue(payload, RunConfig.class);
+ }
+ }
+
+ return runConfig;
+ }
+}
diff --git a/src/main/java/com/talend/tmc/services/executables/ExecutableService.java b/src/main/java/com/talend/tmc/services/executables/ExecutableService.java
index 29a636e..35d2fe5 100644
--- a/src/main/java/com/talend/tmc/services/executables/ExecutableService.java
+++ b/src/main/java/com/talend/tmc/services/executables/ExecutableService.java
@@ -3,10 +3,8 @@
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.talend.tmc.dom.Executable;
-import com.talend.tmc.dom.Items;
+import com.talend.tmc.dom.ExecutableItems;
import com.talend.tmc.services.*;
-import org.apache.cxf.jaxrs.ext.search.SearchParseException;
-import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser;
import org.springframework.http.HttpMethod;
import java.io.IOException;
@@ -37,52 +35,65 @@ private ExecutableService(TalendCredentials credentials, TalendCloudRegion regio
}
public Executable[] getById(String id) throws TalendRestException,
- SearchParseException, IOException, NullPointerException
+ IOException, NullPointerException
{
if (id == null) throw new NullPointerException("Value of id cannot be null");
return get( null, id);
}
- public Executable[] getByQuery(String fiqlQuery) throws TalendRestException,
- SearchParseException, IOException
+ public Executable[] getByQuery(String query) throws TalendRestException,
+ IOException
{
- return get(fiqlQuery, null);
+ return get(query, null);
}
- private Executable[] get(String fiqlQuery, String id) throws TalendRestException,
- SearchParseException, IOException
+ public Executable[] getByName(String name, String workspace) throws TalendRestException,
+ IOException
{
- //Validates the fiqlQuery to meet the FIQL Spec. If not throw exception immediately
- //if (fiqlQuery != null) {
- // FiqlParser parser = new FiqlParser<>(Executable.class);
- // parser.parse(fiqlQuery);
- //}
- Items items = null;
-
+ String query = "name=" + name;
+
+ query = workspace != null ? query + "&workspaceId=" + workspace : query;
+
+ return get(query, null);
+ }
+
+ private Executable[] get(String query, String id) throws TalendRestException,
+ IOException
+ {
+ ExecutableItems items = null;
+ Executable executable = null;
+ Executable[] returnValue = null;
+
StringBuilder uri = new StringBuilder();
uri.append(region.toString()+path);
- if (fiqlQuery != null) {
- //uri.append("?_s="+fiqlQuery); Remove since v2.0
- uri.append("?"+fiqlQuery);
+ if (query != null) {
+ uri.append("?" + query);
}
if (id != null)
- uri.append("/"+id);
+ uri.append("/" + id);
Hashtable response = client.call(HttpMethod.GET, uri.toString(), null);
-
+
for (Integer httpStatus : response.keySet())
{
String payload = response.get(httpStatus);
if (httpStatus != 200)
{
- TalendError error = mapper.readValue(payload, TalendError.class);
+ TalendError error = mapper.readValue(payload, TalendError.class);
throw new TalendRestException(error.toString());
} else {
- items = mapper.readValue(payload, Items.class);
+ if (id == null) {
+ items = mapper.readValue(payload, ExecutableItems.class);
+ returnValue = items.getExecutables();
+ } else {
+ executable = mapper.readValue(payload, Executable.class);
+ returnValue= new Executable[1];
+ returnValue[0] = executable;
+ }
}
}
- return items.getExecutables();
+ return returnValue;
}
}
diff --git a/src/main/java/com/talend/tmc/services/executables/ExecutableTask.java b/src/main/java/com/talend/tmc/services/executables/ExecutableTask.java
new file mode 100644
index 0000000..2447585
--- /dev/null
+++ b/src/main/java/com/talend/tmc/services/executables/ExecutableTask.java
@@ -0,0 +1,149 @@
+package com.talend.tmc.services.executables;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.talend.tmc.dom.Task;
+import com.talend.tmc.dom.TaskNew;
+import com.talend.tmc.dom.Tasks;
+import com.talend.tmc.services.*;
+import org.springframework.http.HttpMethod;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.Hashtable;
+
+public class ExecutableTask {
+ private final String path = "executables/tasks";
+ private final TalendApiClient client;
+ private final TalendCloudRegion region;
+ private ObjectMapper mapper;
+
+ public static ExecutableTask instance(TalendCredentials credentials, TalendCloudRegion region) throws NullPointerException
+ {
+ if (region == null) throw new NullPointerException("TalendCloudRegion cannot be null");
+ if (credentials == null) throw new NullPointerException("TalendCredentials cannot be null");
+ ExecutableTask _instance = new ExecutableTask(credentials, region);
+
+ return _instance;
+ }
+
+ private ExecutableTask(TalendCredentials credentials, TalendCloudRegion region)
+ {
+ client = TalendApiClient.createNewInstance(credentials);
+ this.region = region;
+ // Set ObjectMapper
+ this.mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ }
+
+ public Task create(TaskNew newTask) throws TalendRestException,
+ IOException, NullPointerException
+ {
+ Task task = null;
+
+ Writer jsonWriter = new StringWriter();
+ mapper.writeValue(jsonWriter, newTask);
+ jsonWriter.flush();
+
+ StringBuilder uri = new StringBuilder();
+ uri.append(region.toString()+path);
+
+ Hashtable response = client.call(HttpMethod.POST, uri.toString(), jsonWriter.toString());
+
+ for (Integer httpStatus : response.keySet())
+ {
+ String payload = response.get(httpStatus);
+ if (httpStatus != 201)
+ {
+
+ TalendError error = mapper.readValue(payload, TalendError.class);
+ throw new TalendRestException(error.toString());
+ } else {
+ task = mapper.readValue(payload, Task.class);
+ }
+ }
+
+ return task;
+
+ }
+
+ public Task getById(String id) throws TalendRestException,
+ IOException, NullPointerException
+ {
+ if (id == null) throw new NullPointerException("Value of id cannot be null");
+ return get(id);
+ }
+
+ public Task[] getByQuery(String query) throws TalendRestException,
+ IOException
+ {
+ Tasks tasks= null;
+
+ StringBuilder uri = new StringBuilder();
+ uri.append(region.toString()+path);
+ uri.append("?" + query);
+
+ Hashtable response = client.call(HttpMethod.GET, uri.toString(), null);
+
+ for (Integer httpStatus : response.keySet())
+ {
+ String payload = response.get(httpStatus);
+ if (httpStatus != 200)
+ {
+
+ TalendError error = mapper.readValue(payload, TalendError.class);
+ throw new TalendRestException(error.toString());
+ } else {
+ tasks = mapper.readValue(payload, Tasks.class);
+ }
+ }
+
+ return tasks.getItems();
+
+ }
+
+ /**
+ * @param name Name of the Job
+ * @param workspace Id of the Workspace
+ * @return
+ * @throws TalendRestException
+ * @throws IOException
+ */
+ public Task[] getByName(String name, String workspace) throws TalendRestException,
+ IOException
+ {
+ String query = "name=" + name;
+
+ query = workspace != null ? query + "&workspaceId=" + workspace : query;
+
+ return getByQuery(query);
+ }
+
+ private Task get(String id) throws TalendRestException,
+ IOException
+ {
+ Task task= null;
+
+ StringBuilder uri = new StringBuilder();
+ uri.append(region.toString()+path);
+ if (id != null)
+ uri.append("/" + id);
+
+ Hashtable response = client.call(HttpMethod.GET, uri.toString(), null);
+
+ for (Integer httpStatus : response.keySet())
+ {
+ String payload = response.get(httpStatus);
+ if (httpStatus != 200)
+ {
+ TalendError error = mapper.readValue(payload, TalendError.class);
+ throw new TalendRestException(error.toString());
+ } else {
+ task = mapper.readValue(payload, Task.class);
+ }
+ }
+
+ return task;
+ }
+}
diff --git a/src/main/java/com/talend/tmc/services/executables/ExecutableTaskService.java b/src/main/java/com/talend/tmc/services/executables/ExecutableTaskService.java
new file mode 100644
index 0000000..8cd7614
--- /dev/null
+++ b/src/main/java/com/talend/tmc/services/executables/ExecutableTaskService.java
@@ -0,0 +1,99 @@
+package com.talend.tmc.services.executables;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.talend.tmc.dom.Executable;
+import com.talend.tmc.dom.ExecutableItems;
+import com.talend.tmc.services.*;
+import org.springframework.http.HttpMethod;
+
+import java.io.IOException;
+import java.util.Hashtable;
+
+public class ExecutableTaskService {
+ private final String path = "executables/tasks";
+ private final TalendApiClient client;
+ private final TalendCloudRegion region;
+ private ObjectMapper mapper;
+
+ public static ExecutableTaskService instance(TalendCredentials credentials, TalendCloudRegion region) throws NullPointerException
+ {
+ if (region == null) throw new NullPointerException("TalendCloudRegion cannot be null");
+ if (credentials == null) throw new NullPointerException("TalendCredentials cannot be null");
+ ExecutableTaskService _instance = new ExecutableTaskService(credentials, region);
+
+ return _instance;
+ }
+
+ private ExecutableTaskService(TalendCredentials credentials, TalendCloudRegion region)
+ {
+ client = TalendApiClient.createNewInstance(credentials);
+ this.region = region;
+ // Set ObjectMapper
+ this.mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ }
+
+ public Executable[] getById(String id) throws TalendRestException,
+ IOException, NullPointerException
+ {
+ if (id == null) throw new NullPointerException("Value of id cannot be null");
+ return get( null, id);
+ }
+
+ public Executable[] getByQuery(String query) throws TalendRestException,
+ IOException
+ {
+ return get(query, null);
+ }
+
+ public Executable[] getByName(String name, String workspace) throws TalendRestException,
+ IOException
+ {
+ String query = "name=" + name;
+
+ query = workspace != null ? query + "&workspaceId=" + workspace : query;
+
+ return get(query, null);
+ }
+
+ private Executable[] get(String query, String id) throws TalendRestException,
+ IOException
+ {
+ ExecutableItems items = null;
+ Executable executable = null;
+ Executable[] returnValue = null;
+
+ StringBuilder uri = new StringBuilder();
+ uri.append(region.toString()+path);
+ if (query != null) {
+ uri.append("?" + query);
+ }
+ if (id != null)
+ uri.append("/" + id);
+
+ Hashtable response = client.call(HttpMethod.GET, uri.toString(), null);
+
+ for (Integer httpStatus : response.keySet())
+ {
+ String payload = response.get(httpStatus);
+ if (httpStatus != 200)
+ {
+ TalendError error = mapper.readValue(payload, TalendError.class);
+ throw new TalendRestException(error.toString());
+ } else {
+ if (id == null) {
+ items = mapper.readValue(payload, ExecutableItems.class);
+ returnValue = items.getExecutables();
+ } else {
+ executable = mapper.readValue(payload, Executable.class);
+ returnValue= new Executable[1];
+ returnValue[0] = executable;
+ }
+ }
+
+ }
+
+ return returnValue;
+ }
+}
diff --git a/src/main/java/com/talend/tmc/services/executions/ExecutionService.java b/src/main/java/com/talend/tmc/services/executions/ExecutionService.java
index 2c35afc..f0b4755 100644
--- a/src/main/java/com/talend/tmc/services/executions/ExecutionService.java
+++ b/src/main/java/com/talend/tmc/services/executions/ExecutionService.java
@@ -60,7 +60,6 @@ public ExecutionResponse post(ExecutionRequest request) throws TalendRestExcepti
} else {
executionResponse = mapper.readValue(payload, ExecutionResponse.class);
}
-
}
return executionResponse;
diff --git a/src/main/java/com/talend/tmc/services/executions/TaskExecutionService.java b/src/main/java/com/talend/tmc/services/executions/TaskExecutionService.java
new file mode 100644
index 0000000..ea8bb23
--- /dev/null
+++ b/src/main/java/com/talend/tmc/services/executions/TaskExecutionService.java
@@ -0,0 +1,63 @@
+package com.talend.tmc.services.executions;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.talend.tmc.dom.Execution;
+import com.talend.tmc.dom.ExecutionItems;
+import com.talend.tmc.services.*;
+import org.springframework.http.HttpMethod;
+
+import java.io.IOException;
+import java.util.Hashtable;
+
+public class TaskExecutionService {
+ private final String path = "executables/tasks/";
+ private final TalendApiClient client;
+ private final TalendCloudRegion region;
+ private ObjectMapper mapper;
+
+ public static TaskExecutionService instance(TalendCredentials credentials, TalendCloudRegion region) throws NullPointerException
+ {
+ if (region == null) throw new NullPointerException("TalendCloudRegion cannot be null");
+ if (credentials == null) throw new NullPointerException("TalendCredentials cannot be null");
+ TaskExecutionService _instance = new TaskExecutionService(credentials, region);
+
+ return _instance;
+ }
+
+ private TaskExecutionService(TalendCredentials credentials, TalendCloudRegion region) {
+ this.client = TalendApiClient.createNewInstance(credentials);
+ this.region = region;
+ // Set ObjectMapper
+ this.mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ }
+
+ public Execution[] get(String id) throws TalendRestException, IOException,
+ NullPointerException
+ {
+ Execution[] executions = null;
+ ExecutionItems items = null;
+ if (id == null) throw new NullPointerException("id of Execution Job cannot be null");
+ StringBuilder uri = new StringBuilder();
+ uri.append(region.toString()+path+id+"/executions");
+
+ Hashtable response = client.call(HttpMethod.GET, uri.toString(), null);
+
+ for (Integer httpStatus : response.keySet())
+ {
+ String payload = response.get(httpStatus);
+ if (httpStatus != 200)
+ {
+ TalendError error = mapper.readValue(payload, TalendError.class);
+ throw new TalendRestException(error.toString());
+ } else {
+ items = mapper.readValue(payload, ExecutionItems.class);
+ executions = items.getExecutions();
+ }
+
+ }
+
+ return executions;
+ }
+}
diff --git a/src/main/java/com/talend/tmc/services/runtime/ClusterService.java b/src/main/java/com/talend/tmc/services/runtime/ClusterService.java
index 59799fc..8d688d2 100644
--- a/src/main/java/com/talend/tmc/services/runtime/ClusterService.java
+++ b/src/main/java/com/talend/tmc/services/runtime/ClusterService.java
@@ -119,16 +119,16 @@ public Cluster[] get(String fiqlQuery) throws TalendRestException, IOException,
NullPointerException
{
//Validates the fiqlQuery to meet the FIQL Spec. If not throw exception immediately
- if (fiqlQuery != null) {
+/* kjdfkerhg if (fiqlQuery != null) {
FiqlParser parser = new FiqlParser<>(Executable.class);
parser.parse(fiqlQuery);
- }
+ }*/
Cluster[] clusters = null;
StringBuilder uri = new StringBuilder();
uri.append(region.toString()+path);
if (fiqlQuery != null) {
- uri.append("?_s="+fiqlQuery);
+ uri.append("?query="+fiqlQuery);
}
Hashtable response = client.call(HttpMethod.GET, uri.toString(), null);
diff --git a/src/main/java/com/talend/tmc/services/runtime/EngineService.java b/src/main/java/com/talend/tmc/services/runtime/EngineService.java
index bcfd8ba..81e5f65 100644
--- a/src/main/java/com/talend/tmc/services/runtime/EngineService.java
+++ b/src/main/java/com/talend/tmc/services/runtime/EngineService.java
@@ -2,12 +2,8 @@
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.talend.tmc.dom.Cluster;
-import com.talend.tmc.dom.ClusterRequest;
import com.talend.tmc.dom.Engine;
-import com.talend.tmc.dom.Executable;
import com.talend.tmc.services.*;
-import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser;
import org.springframework.http.HttpMethod;
import java.io.IOException;
@@ -113,11 +109,6 @@ private boolean action(String engineId, boolean unpair) throws TalendRestExcepti
public Engine[] get(String fiqlQuery) throws TalendRestException, IOException,
NullPointerException
{
- //Validates the fiqlQuery to meet the FIQL Spec. If not throw exception immediately
- if (fiqlQuery != null) {
- FiqlParser parser = new FiqlParser<>(Executable.class);
- parser.parse(fiqlQuery);
- }
Engine[] engines = null;
StringBuilder uri = new StringBuilder();
diff --git a/src/main/java/com/talend/tmc/services/runtime/PipelineEngineService.java b/src/main/java/com/talend/tmc/services/runtime/PipelineEngineService.java
new file mode 100644
index 0000000..2ba0687
--- /dev/null
+++ b/src/main/java/com/talend/tmc/services/runtime/PipelineEngineService.java
@@ -0,0 +1,167 @@
+package com.talend.tmc.services.runtime;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.talend.tmc.dom.PipelineEngine;
+import com.talend.tmc.dom.PipelineEngineRequest;
+import com.talend.tmc.dom.Engine;
+import com.talend.tmc.services.*;
+import org.springframework.http.HttpMethod;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.Hashtable;
+
+public class PipelineEngineService {
+ private final String path = "runtimes/pipeline-engines";
+ private final TalendApiClient client;
+ private final TalendCloudRegion region;
+ private ObjectMapper mapper;
+
+ public static PipelineEngineService instance(TalendCredentials credentials, TalendCloudRegion region) throws NullPointerException
+ {
+ if (region == null) throw new NullPointerException("TalendCloudRegion cannot be null");
+ if (credentials == null) throw new NullPointerException("TalendCredentials cannot be null");
+ PipelineEngineService _instance = new PipelineEngineService(credentials, region);
+
+ return _instance;
+ }
+
+ private PipelineEngineService(TalendCredentials credentials, TalendCloudRegion region) {
+ this.client = TalendApiClient.createNewInstance(credentials);
+ this.region = region;
+ // Set ObjectMapper
+ this.mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ }
+
+ public Engine post(PipelineEngineRequest request) throws TalendRestException, IOException,
+ NullPointerException
+ {
+ if (request == null) throw new NullPointerException("Engine Request cannot be null");
+ Writer jsonWriter = new StringWriter();
+ mapper.writeValue(jsonWriter, request);
+ jsonWriter.flush();
+ StringBuilder uri = new StringBuilder();
+ uri.append(region.toString()+path);
+
+ Engine engine = null;
+
+ Hashtable response = client.call(HttpMethod.POST, uri.toString(), jsonWriter.toString());
+
+ for (Integer httpStatus : response.keySet())
+ {
+ String payload = response.get(httpStatus);
+ if (httpStatus != 201)
+ {
+ TalendError error = mapper.readValue(payload, TalendError.class);
+ throw new TalendRestException(error.toString());
+ } else {
+ engine = mapper.readValue(payload, Engine.class);
+ }
+
+ }
+
+ return engine;
+ }
+
+ public boolean delete(String engineId) throws TalendRestException, IOException,
+ NullPointerException
+ {
+ if (engineId == null) throw new NullPointerException("engineId cannot be null");
+ return action(engineId, false);
+ }
+
+ public boolean unpair(String engineId) throws TalendRestException, IOException,
+ NullPointerException
+ {
+ if (engineId == null) throw new NullPointerException("engineId cannot be null");
+ return action(engineId, true);
+ }
+
+
+ private boolean action(String engineId, boolean unpair) throws TalendRestException, IOException,
+ NullPointerException
+ {
+ boolean isDeleted = false;
+
+ StringBuilder uri = new StringBuilder();
+ uri.append(region.toString()+path+"/"+engineId);
+ if (unpair)
+ uri.append("/pairing");
+
+ Hashtable response = client.call(HttpMethod.DELETE, uri.toString(), null);
+
+ for (Integer httpStatus : response.keySet())
+ {
+ String payload = response.get(httpStatus);
+ if (httpStatus == 200 || httpStatus == 204){
+ isDeleted = true;
+ } else {
+ TalendError error = mapper.readValue(payload, TalendError.class);
+ throw new TalendRestException(error.toString());
+ }
+
+ }
+
+ return isDeleted;
+ }
+
+ public PipelineEngine[] get(String fiqlQuery) throws TalendRestException, IOException,
+ NullPointerException
+ {
+ PipelineEngine[] engines = null;
+
+ StringBuilder uri = new StringBuilder();
+ uri.append(region.toString()+path);
+ if (fiqlQuery != null) {
+ uri.append("?query="+fiqlQuery);
+ }
+
+ Hashtable response = client.call(HttpMethod.GET, uri.toString(), null);
+
+ for (Integer httpStatus : response.keySet())
+ {
+ String payload = response.get(httpStatus);
+ if (httpStatus != 200)
+ {
+ TalendError error = mapper.readValue(payload, TalendError.class);
+ throw new TalendRestException(error.toString());
+ } else {
+ engines = mapper.readValue(payload, PipelineEngine[].class);
+ }
+
+ }
+
+ return engines;
+ }
+
+ public PipelineEngine getById(String engineId) throws TalendRestException, IOException,
+ NullPointerException
+ {
+ if (engineId == null) throw new NullPointerException("engineId cannot be null");
+ PipelineEngine engine = null;
+
+ StringBuilder uri = new StringBuilder();
+ uri.append(region.toString()+path+"/"+engineId);
+
+
+ Hashtable response = client.call(HttpMethod.GET, uri.toString(), null);
+
+ for (Integer httpStatus : response.keySet())
+ {
+ String payload = response.get(httpStatus);
+ if (httpStatus != 200)
+ {
+ TalendError error = mapper.readValue(payload, TalendError.class);
+ throw new TalendRestException(error.toString());
+ } else {
+ engine = mapper.readValue(payload, PipelineEngine.class);
+ }
+
+ }
+
+ return engine;
+ }
+}
diff --git a/src/main/java/com/talend/tmc/services/workspaces/WorkspaceService.java b/src/main/java/com/talend/tmc/services/workspaces/WorkspaceService.java
index 9848afb..5977ddf 100644
--- a/src/main/java/com/talend/tmc/services/workspaces/WorkspaceService.java
+++ b/src/main/java/com/talend/tmc/services/workspaces/WorkspaceService.java
@@ -1,16 +1,20 @@
package com.talend.tmc.services.workspaces;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.talend.tmc.dom.Workspace;
-import com.talend.tmc.services.*;
+import java.io.IOException;
+import java.util.Hashtable;
+
import org.apache.cxf.jaxrs.ext.search.SearchParseException;
-import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser;
import org.springframework.http.HttpMethod;
-import java.io.IOException;
-import java.util.Hashtable;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.talend.tmc.dom.Workspace;
+import com.talend.tmc.services.TalendApiClient;
+import com.talend.tmc.services.TalendCloudRegion;
+import com.talend.tmc.services.TalendCredentials;
+import com.talend.tmc.services.TalendError;
+import com.talend.tmc.services.TalendRestException;
public class WorkspaceService {
@@ -36,13 +40,11 @@ private WorkspaceService(TalendCredentials credentials, TalendCloudRegion region
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
- public Workspace[] get(String fiqlQuery) throws TalendRestException, SearchParseException, IOException {
+ public Workspace[] get() throws TalendRestException, SearchParseException, IOException {
+ return get(null);
+ }
- //Validates the fiqlQuery to meet the FIQL Spec. If not throw exception immediately
- if (fiqlQuery != null) {
- FiqlParser parser = new FiqlParser<>(Workspace.class);
- parser.parse(fiqlQuery);
- }
+ public Workspace[] get(String fiqlQuery) throws TalendRestException, SearchParseException, IOException {
Workspace[] workspace = null;
StringBuilder uri = new StringBuilder();