diff --git a/agent/pom.xml b/agent/pom.xml
index 2b28147746..064c6061c6 100644
--- a/agent/pom.xml
+++ b/agent/pom.xml
@@ -29,7 +29,7 @@
com.walmartlabs.concord
- concord-client
+ concord-client2
com.walmartlabs.concord
@@ -105,11 +105,6 @@
org.apache.commons
commons-compress
-
- com.squareup.okhttp
- okhttp
- 2.7.5
-
org.jboss.spec.javax.ws.rs
jboss-jaxrs-api_2.0_spec
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/Agent.java b/agent/src/main/java/com/walmartlabs/concord/agent/Agent.java
index c2c1e5c04f..17414d5663 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/Agent.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/Agent.java
@@ -28,7 +28,7 @@
import com.walmartlabs.concord.agent.guice.WorkerModule;
import com.walmartlabs.concord.agent.mmode.MaintenanceModeListener;
import com.walmartlabs.concord.agent.mmode.MaintenanceModeNotifier;
-import com.walmartlabs.concord.client.ProcessEntry.StatusEnum;
+import com.walmartlabs.concord.client2.ProcessEntry.StatusEnum;
import com.walmartlabs.concord.common.IOUtils;
import com.walmartlabs.concord.server.queueclient.QueueClient;
import com.walmartlabs.concord.server.queueclient.message.ProcessRequest;
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/DefaultStateFetcher.java b/agent/src/main/java/com/walmartlabs/concord/agent/DefaultStateFetcher.java
index c8129a4119..2e6c6f7b8f 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/DefaultStateFetcher.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/DefaultStateFetcher.java
@@ -20,21 +20,16 @@
* =====
*/
-import com.walmartlabs.concord.client.ClientUtils;
-import com.walmartlabs.concord.client.ProcessApi;
+import com.walmartlabs.concord.client2.ClientUtils;
+import com.walmartlabs.concord.client2.ProcessApi;
import com.walmartlabs.concord.common.IOUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import javax.inject.Inject;
-import java.io.File;
-import java.nio.file.Path;
+import java.io.InputStream;
import java.nio.file.StandardCopyOption;
public class DefaultStateFetcher implements StateFetcher {
- private static final Logger log = LoggerFactory.getLogger(DefaultStateFetcher.class);
-
private final ProcessApi processApi;
@Inject
@@ -44,26 +39,9 @@ public DefaultStateFetcher(ProcessApi processApi) {
@Override
public void downloadState(JobRequest job) throws Exception {
- File payload = null;
- try {
- payload = ClientUtils.withRetry(AgentConstants.API_CALL_MAX_RETRIES, AgentConstants.API_CALL_RETRY_DELAY, () -> processApi.downloadState(job.getInstanceId()));
- IOUtils.unzip(payload.toPath(), job.getPayloadDir(), StandardCopyOption.REPLACE_EXISTING);
- } finally {
- if (payload != null) {
- delete(payload.toPath());
- }
- }
- }
-
- private static void delete(Path dir) {
- if (dir == null) {
- return;
- }
-
- try {
- IOUtils.deleteRecursively(dir);
- } catch (Exception e) {
- log.warn("delete ['{}'] -> error", dir, e);
+ try (InputStream is = ClientUtils.withRetry(AgentConstants.API_CALL_MAX_RETRIES, AgentConstants.API_CALL_RETRY_DELAY, () -> processApi.downloadState(job.getInstanceId()))){
+ IOUtils.unzip(is, job.getPayloadDir(), StandardCopyOption.REPLACE_EXISTING);
}
}
}
+
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/RepositoryManager.java b/agent/src/main/java/com/walmartlabs/concord/agent/RepositoryManager.java
index 1c74dd240b..43415a71bb 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/RepositoryManager.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/RepositoryManager.java
@@ -23,7 +23,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.walmartlabs.concord.agent.cfg.GitConfiguration;
import com.walmartlabs.concord.agent.cfg.RepositoryCacheConfiguration;
-import com.walmartlabs.concord.client.SecretClient;
+import com.walmartlabs.concord.client2.SecretClient;
import com.walmartlabs.concord.imports.Import.SecretDefinition;
import com.walmartlabs.concord.repository.*;
import com.walmartlabs.concord.sdk.Secret;
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/Worker.java b/agent/src/main/java/com/walmartlabs/concord/agent/Worker.java
index a669a4bd8b..c5218430fc 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/Worker.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/Worker.java
@@ -24,7 +24,7 @@
import com.walmartlabs.concord.agent.guice.AgentImportManager;
import com.walmartlabs.concord.agent.logging.ProcessLog;
import com.walmartlabs.concord.agent.remote.ProcessStatusUpdater;
-import com.walmartlabs.concord.client.ProcessEntry.StatusEnum;
+import com.walmartlabs.concord.client2.ProcessEntry.StatusEnum;
import com.walmartlabs.concord.common.IOUtils;
import com.walmartlabs.concord.imports.Import.SecretDefinition;
import org.slf4j.Logger;
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/AgentConfiguration.java b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/AgentConfiguration.java
index 4c5c99a486..32e34df457 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/AgentConfiguration.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/AgentConfiguration.java
@@ -58,6 +58,8 @@ public class AgentConfiguration {
private final long pollInterval;
private final int maintenanceModeListenerPort;
+ private final boolean explicitlyResolveV1Client;
+
@Inject
public AgentConfiguration(Config cfg) {
this.agentId = getStringOrDefault(cfg, "id", () -> UUID.randomUUID().toString());
@@ -82,6 +84,8 @@ public AgentConfiguration(Config cfg) {
this.maintenanceModeListenerPort = cfg.getInt("maintenanceModeListenerPort");
this.pollInterval = cfg.getDuration("pollInterval", TimeUnit.MILLISECONDS);
+
+ this.explicitlyResolveV1Client = cfg.getBoolean("explicitlyResolveV1Client");
}
public String getAgentId() {
@@ -139,4 +143,8 @@ public long getPollInterval() {
public int getMaintenanceModeListenerPort() {
return maintenanceModeListenerPort;
}
+
+ public boolean isExplicitlyResolveV1Client() {
+ return explicitlyResolveV1Client;
+ }
}
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/GitConfiguration.java b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/GitConfiguration.java
index 85bdcab673..95b5e21b5b 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/GitConfiguration.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/GitConfiguration.java
@@ -23,8 +23,6 @@
import com.typesafe.config.Config;
import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
import java.time.Duration;
import static com.walmartlabs.concord.agent.cfg.Utils.getStringOrDefault;
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/guice/AgentDependencyManagerConfigurationProvider.java b/agent/src/main/java/com/walmartlabs/concord/agent/guice/AgentDependencyManagerConfigurationProvider.java
index 0e7e41d1a5..49765637d3 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/guice/AgentDependencyManagerConfigurationProvider.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/guice/AgentDependencyManagerConfigurationProvider.java
@@ -43,6 +43,7 @@ public DependencyManagerConfiguration get() {
.cacheDir(cfg.getDependencyCacheDir())
.strictRepositories(cfg.dependencyStrictRepositories())
.exclusions(cfg.dependencyExclusions())
+ .explicitlyResolveV1Client(cfg.isExplicitlyResolveV1Client())
.build();
}
}
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/guice/WorkerModule.java b/agent/src/main/java/com/walmartlabs/concord/agent/guice/WorkerModule.java
index 593c41ce4c..f4d57a398e 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/guice/WorkerModule.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/guice/WorkerModule.java
@@ -24,14 +24,12 @@
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.google.inject.multibindings.Multibinder;
-import com.walmartlabs.concord.ApiClient;
+import com.walmartlabs.concord.client2.*;
import com.walmartlabs.concord.agent.DefaultStateFetcher;
import com.walmartlabs.concord.agent.StateFetcher;
import com.walmartlabs.concord.agent.logging.*;
import com.walmartlabs.concord.agent.remote.ApiClientFactory;
import com.walmartlabs.concord.agent.remote.ProcessStatusUpdater;
-import com.walmartlabs.concord.client.ProcessApi;
-import com.walmartlabs.concord.client.SecretClient;
import com.walmartlabs.concord.dependencymanager.DependencyManagerConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/logging/LogSegmentStats.java b/agent/src/main/java/com/walmartlabs/concord/agent/logging/LogSegmentStats.java
index 11306ea02c..785b6820dd 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/logging/LogSegmentStats.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/logging/LogSegmentStats.java
@@ -23,7 +23,7 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.walmartlabs.concord.client.LogSegmentUpdateRequest;
+import com.walmartlabs.concord.client2.LogSegmentUpdateRequest;
import org.immutables.value.Value;
import javax.annotation.Nullable;
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/logging/RemoteLogAppender.java b/agent/src/main/java/com/walmartlabs/concord/agent/logging/RemoteLogAppender.java
index f33dac66cb..3542f07999 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/logging/RemoteLogAppender.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/logging/RemoteLogAppender.java
@@ -9,9 +9,9 @@
* 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
- *
+ *
* http://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.
@@ -20,17 +20,13 @@
* =====
*/
-import com.walmartlabs.concord.ApiClient;
-import com.walmartlabs.concord.ApiException;
import com.walmartlabs.concord.agent.AgentConstants;
-import com.walmartlabs.concord.client.ClientUtils;
-import com.walmartlabs.concord.client.LogSegmentUpdateRequest;
-import com.walmartlabs.concord.client.ProcessApi;
-import com.walmartlabs.concord.client.ProcessLogV2Api;
+import com.walmartlabs.concord.client2.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
+import java.io.ByteArrayInputStream;
import java.util.UUID;
public class RemoteLogAppender implements LogAppender {
@@ -48,11 +44,9 @@ public RemoteLogAppender(ApiClient apiClient) {
@Override
public void appendLog(UUID instanceId, byte[] ab) {
- String path = "/api/v1/process/" + instanceId + "/log";
-
try {
ClientUtils.withRetry(AgentConstants.API_CALL_MAX_RETRIES, AgentConstants.API_CALL_RETRY_DELAY, () -> {
- ClientUtils.postData(processApi.getApiClient(), path, ab);
+ processApi.appendProcessLog(instanceId, new ByteArrayInputStream(ab));
return null;
});
} catch (ApiException e) {
@@ -63,11 +57,9 @@ public void appendLog(UUID instanceId, byte[] ab) {
@Override
public boolean appendLog(UUID instanceId, long segmentId, byte[] ab) {
- String path = "/api/v2/process/" + instanceId + "/log/segment/" + segmentId + "/data";
-
try {
ClientUtils.withRetry(AgentConstants.API_CALL_MAX_RETRIES, AgentConstants.API_CALL_RETRY_DELAY, () -> {
- ClientUtils.postData(processApi.getApiClient(), path, ab);
+ processLogV2Api.appendProcessLogSegment(instanceId, segmentId, new ByteArrayInputStream(ab));
return null;
});
return true;
@@ -81,17 +73,17 @@ public boolean appendLog(UUID instanceId, long segmentId, byte[] ab) {
@Override
public boolean updateSegment(UUID instanceId, long segmentId, LogSegmentStats stats) {
LogSegmentUpdateRequest request = new LogSegmentUpdateRequest()
- .setStatus(stats.status())
- .setWarnings(stats.warnings())
- .setErrors(stats.errors());
+ .status(stats.status())
+ .warnings(stats.warnings())
+ .errors(stats.errors());
try {
ClientUtils.withRetry(AgentConstants.API_CALL_MAX_RETRIES, AgentConstants.API_CALL_RETRY_DELAY,
- () -> processLogV2Api.updateSegment(instanceId, segmentId, request));
+ () -> processLogV2Api.updateProcessLogSegment(instanceId, segmentId, request));
return true;
} catch (Exception e) {
log.warn("updateSegment ['{}', '{}', '{}'] -> error: {}", instanceId, segmentId, stats, e.getMessage());
}
return false;
}
-}
+}
\ No newline at end of file
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/logging/SegmentedLogsConsumer.java b/agent/src/main/java/com/walmartlabs/concord/agent/logging/SegmentedLogsConsumer.java
index a44f3be059..4f74503350 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/logging/SegmentedLogsConsumer.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/logging/SegmentedLogsConsumer.java
@@ -20,7 +20,7 @@
* =====
*/
-import com.walmartlabs.concord.client.LogSegmentUpdateRequest;
+import com.walmartlabs.concord.client2.LogSegmentUpdateRequest;
import java.util.*;
import java.util.function.Consumer;
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/remote/ApiClientFactory.java b/agent/src/main/java/com/walmartlabs/concord/agent/remote/ApiClientFactory.java
index 0b2403c212..8757496c37 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/remote/ApiClientFactory.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/remote/ApiClientFactory.java
@@ -9,9 +9,9 @@
* 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
- *
+ *
* http://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.
@@ -20,90 +20,50 @@
* =====
*/
-import com.squareup.okhttp.Interceptor;
-import com.squareup.okhttp.OkHttpClient;
-import com.squareup.okhttp.Request;
-import com.squareup.okhttp.Response;
-import com.walmartlabs.concord.ApiClient;
+import com.walmartlabs.concord.client2.*;
import com.walmartlabs.concord.agent.cfg.ServerConfiguration;
-import com.walmartlabs.concord.client.ConcordApiClient;
-import com.walmartlabs.concord.common.IOUtils;
import javax.inject.Inject;
import java.io.IOException;
-import java.nio.file.Path;
+import java.time.Duration;
+import java.time.temporal.ChronoUnit;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.TimeUnit;
public class ApiClientFactory {
private static final String SESSION_COOKIE_NAME = "JSESSIONID";
private final ServerConfiguration cfg;
- private final Path tmpPath;
+
+ private final DefaultApiClientFactory clientFactory;
@Inject
- public ApiClientFactory(ServerConfiguration cfg) throws IOException {
+ public ApiClientFactory(ServerConfiguration cfg) throws Exception {
this.cfg = cfg;
- this.tmpPath = IOUtils.createTempDir("agent-client");
+ this.clientFactory = new DefaultApiClientFactory(cfg.getApiBaseUrl(), Duration.of(cfg.getConnectTimeout(), ChronoUnit.MILLIS), cfg.isVerifySsl());
}
public ApiClient create(String sessionToken) throws IOException {
- OkHttpClient ok = new OkHttpClient();
- ok.setReadTimeout(cfg.getReadTimeout(), TimeUnit.MILLISECONDS);
- ok.setConnectTimeout(cfg.getConnectTimeout(), TimeUnit.MILLISECONDS);
-
- Map cookieJar = new HashMap<>();
- ok.interceptors().add(new AddCookiesInterceptor(cookieJar));
- ok.interceptors().add(new ReceivedCookiesInterceptor(cookieJar));
+ ImmutableApiClientConfiguration.Builder clientCfgBuilder = ApiClientConfiguration.builder()
+ .baseUrl(cfg.getApiBaseUrl());
- ConcordApiClient client = new ConcordApiClient(cfg.getApiBaseUrl(), ok);
- client.setTempFolderPath(tmpPath.toString());
if (sessionToken != null) {
- client.setSessionToken(sessionToken);
+ clientCfgBuilder.sessionToken(sessionToken);
} else {
- client.setApiKey(cfg.getApiKey());
- }
- client.setUserAgent(cfg.getUserAgent());
- client.setVerifyingSsl(cfg.isVerifySsl());
- return client;
- }
-
- private static class AddCookiesInterceptor implements Interceptor {
-
- private final Map cookieJar;
-
- private AddCookiesInterceptor(Map cookieJar) {
- this.cookieJar = cookieJar;
- }
-
- @Override
- public Response intercept(Chain chain) throws IOException {
- Request.Builder builder = chain.request().newBuilder();
- for (Map.Entry cookie : cookieJar.entrySet()) {
- builder.addHeader("Cookie", cookie.getValue());
- }
- return chain.proceed(builder.build());
- }
- }
-
- private static class ReceivedCookiesInterceptor implements Interceptor {
-
- private final Map cookieJar;
-
- private ReceivedCookiesInterceptor(Map cookieJar) {
- this.cookieJar = cookieJar;
+ clientCfgBuilder.apiKey(cfg.getApiKey());
}
- @Override
- public Response intercept(Chain chain) throws IOException {
- Response resp = chain.proceed(chain.request());
+ ApiClient client = clientFactory.create(clientCfgBuilder.build())
+ .setReadTimeout(Duration.of(cfg.getReadTimeout(), ChronoUnit.MILLIS))
+ .setUserAgent(cfg.getUserAgent());
- List cookies = resp.headers("Set-Cookie");
+ Map cookieJar = new HashMap<>();
+ client.setResponseInterceptor(response -> {
+ List cookies = response.headers().allValues("Set-Cookie");
if (cookies.isEmpty()) {
- return resp;
+ return;
}
for (String cookie : cookies) {
@@ -111,8 +71,14 @@ public Response intercept(Chain chain) throws IOException {
cookieJar.put(SESSION_COOKIE_NAME, cookie);
}
}
+ });
- return resp;
- }
+ client.setRequestInterceptor(builder -> {
+ for (Map.Entry cookie : cookieJar.entrySet()) {
+ builder.header("Cookie", cookie.getValue());
+ }
+ });
+
+ return client;
}
-}
+}
\ No newline at end of file
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/remote/AttachmentsUploader.java b/agent/src/main/java/com/walmartlabs/concord/agent/remote/AttachmentsUploader.java
index 1ce52ca474..8a3c4dec08 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/remote/AttachmentsUploader.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/remote/AttachmentsUploader.java
@@ -20,9 +20,8 @@
* =====
*/
-import com.walmartlabs.concord.ApiClient;
import com.walmartlabs.concord.agent.AgentConstants;
-import com.walmartlabs.concord.client.ClientUtils;
+import com.walmartlabs.concord.client2.*;
import com.walmartlabs.concord.common.IOUtils;
import com.walmartlabs.concord.common.TemporaryPath;
import com.walmartlabs.concord.sdk.Constants;
@@ -53,10 +52,9 @@ public void upload(UUID instanceId, Path workDir) throws Exception {
IOUtils.zip(zip, attachmentsDir);
}
- String path = "/api/v1/process/" + instanceId + "/attachment";
-
+ ProcessApi api = new ProcessApi(apiClient);
ClientUtils.withRetry(AgentConstants.API_CALL_MAX_RETRIES, AgentConstants.API_CALL_RETRY_DELAY, () -> {
- ClientUtils.postData(apiClient, path, tmp.path().toFile());
+ api.uploadProcessAttachments(instanceId, Files.newInputStream(tmp.path()));
return null;
});
}
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/remote/ProcessStatusUpdater.java b/agent/src/main/java/com/walmartlabs/concord/agent/remote/ProcessStatusUpdater.java
index 9cdaa78bbe..525d65b1da 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/remote/ProcessStatusUpdater.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/remote/ProcessStatusUpdater.java
@@ -20,11 +20,8 @@
* =====
*/
-import com.walmartlabs.concord.ApiException;
import com.walmartlabs.concord.agent.AgentConstants;
-import com.walmartlabs.concord.client.ClientUtils;
-import com.walmartlabs.concord.client.ProcessApi;
-import com.walmartlabs.concord.client.ProcessEntry;
+import com.walmartlabs.concord.client2.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/agent/src/main/resources/concord-agent.conf b/agent/src/main/resources/concord-agent.conf
index addaf911bd..e12fad21b2 100644
--- a/agent/src/main/resources/concord-agent.conf
+++ b/agent/src/main/resources/concord-agent.conf
@@ -35,6 +35,9 @@ concord-agent {
# artifact exclude patterns
dependencyExclusions = []
+ # explicitly resolve v1 version of the concord HTTP client
+ explicitlyResolveV1Client = true
+
# base directory to store the process payload
# created automatically if not specified
payloadDir = "payload"
diff --git a/client/pom.xml b/client/pom.xml
index a3c12448e2..1163df2634 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -26,6 +26,12 @@
com.walmartlabs.concord.server
concord-server
provided
+
+
+ commons-logging
+ commons-logging
+
+
com.walmartlabs.concord
@@ -36,6 +42,10 @@
com.walmartlabs.concord
concord-sdk
+
+ com.walmartlabs.concord.runtime.v2
+ concord-runtime-sdk-v2
+
com.squareup.okhttp
okhttp
@@ -191,6 +201,9 @@
-
java.method.returnTypeTypeParametersChanged
+ -
+
java.class.externalClassExposedInAPI
+
diff --git a/client/src/main/java/com/walmartlabs/concord/client/ApiClientFactoryImpl.java b/client/src/main/java/com/walmartlabs/concord/client/ApiClientFactoryImpl.java
new file mode 100644
index 0000000000..23ee1549e0
--- /dev/null
+++ b/client/src/main/java/com/walmartlabs/concord/client/ApiClientFactoryImpl.java
@@ -0,0 +1,120 @@
+package com.walmartlabs.concord.client;
+
+/*-
+ * *****
+ * Concord
+ * -----
+ * Copyright (C) 2017 - 2023 Walmart Inc.
+ * -----
+ * 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
+ *
+ * http://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.
+ * =====
+ */
+
+import com.squareup.okhttp.OkHttpClient;
+import com.walmartlabs.concord.ApiClient;
+import com.walmartlabs.concord.sdk.ApiConfiguration;
+import com.walmartlabs.concord.sdk.Constants;
+import com.walmartlabs.concord.sdk.Context;
+import com.walmartlabs.concord.sdk.ContextUtils;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocketFactory;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+
+public class ApiClientFactoryImpl implements ApiClientFactory {
+
+ private final ApiConfiguration cfg;
+ private final Path tmpDir;
+ private final OkHttpClient httpClient;
+
+ public ApiClientFactoryImpl(ApiConfiguration cfg, Path workDir) throws Exception {
+ this.cfg = cfg;
+
+ Path tmpBase = Files.createDirectories(workDir.resolve(Constants.Files.CONCORD_TMP_DIR_NAME));
+ this.tmpDir = Files.createTempDirectory(tmpBase, "api-client");
+
+ OkHttpClient client = new OkHttpClient();
+
+ // init the SSL socket factory early to save time on the first request
+ client = withSslSocketFactory(client);
+
+ client.setConnectTimeout(cfg.connectTimeout(), TimeUnit.MILLISECONDS);
+ client.setReadTimeout(cfg.readTimeout(), TimeUnit.MILLISECONDS);
+ client.setWriteTimeout(30, TimeUnit.SECONDS);
+
+ this.httpClient = client;
+ }
+
+ @Override
+ public ApiClient create(ApiClientConfiguration overrides) {
+ String baseUrl = overrides.baseUrl() != null ? overrides.baseUrl() : cfg.getBaseUrl();
+
+ String sessionToken = null;
+ if (overrides.apiKey() == null) {
+ sessionToken = overrides.sessionToken();
+
+ Context ctx = overrides.context();
+ if (sessionToken == null && ctx != null) {
+ sessionToken = cfg.getSessionToken(ctx);
+ }
+ }
+
+ String apiKey = overrides.apiKey();
+ if (apiKey != null) {
+ sessionToken = null;
+ }
+
+ if (sessionToken == null && apiKey == null) {
+ throw new IllegalArgumentException("Session token or an API key is required");
+ }
+
+ ApiClient client = new ConcordApiClient(baseUrl, httpClient)
+ .setSessionToken(sessionToken)
+ .setApiKey(apiKey)
+ .addDefaultHeader("Accept", "*/*")
+ .setTempFolderPath(tmpDir.toString());
+
+ UUID txId = getTxId(overrides);
+
+ if (txId != null) {
+ client = client.setUserAgent("Concord-Runner: txId=" + txId);
+ }
+
+ return client;
+ }
+
+ @Deprecated
+ private static UUID getTxId(ApiClientConfiguration cfg) {
+ if (cfg.txId() != null) {
+ return cfg.txId();
+ }
+
+ if (cfg.context() != null) {
+ return ContextUtils.getTxId(cfg.context());
+ }
+
+ return null;
+ }
+
+ private static OkHttpClient withSslSocketFactory(OkHttpClient client) throws NoSuchAlgorithmException, KeyManagementException {
+ SSLContext sslContext = SSLContext.getInstance("TLS");
+ sslContext.init(null, null, null);
+ SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
+ return client.setSslSocketFactory(sslSocketFactory);
+ }
+}
diff --git a/client/src/main/java/com/walmartlabs/concord/client/ApiClientFactoryProvider.java b/client/src/main/java/com/walmartlabs/concord/client/ApiClientFactoryProvider.java
new file mode 100644
index 0000000000..a98bd5002a
--- /dev/null
+++ b/client/src/main/java/com/walmartlabs/concord/client/ApiClientFactoryProvider.java
@@ -0,0 +1,54 @@
+package com.walmartlabs.concord.client;
+
+/*-
+ * *****
+ * Concord
+ * -----
+ * Copyright (C) 2017 - 2023 Walmart Inc.
+ * -----
+ * 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
+ *
+ * http://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.
+ * =====
+ */
+
+import com.walmartlabs.concord.runtime.v2.sdk.WorkingDirectory;
+import com.walmartlabs.concord.sdk.ApiConfiguration;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+@Named
+@Singleton
+public class ApiClientFactoryProvider implements Provider {
+
+ private final ApiConfiguration cfg;
+ private final WorkingDirectory workDir;
+
+ @Inject
+ public ApiClientFactoryProvider(ApiConfiguration cfg, WorkingDirectory workDir) {
+ this.cfg = cfg;
+ this.workDir = workDir;
+ }
+
+ @Override
+ public ApiClientFactory get() {
+ try {
+ return new ApiClientFactoryImpl(cfg, workDir.getValue());
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/client/src/main/java/com/walmartlabs/concord/client/ApiClientProvider.java b/client/src/main/java/com/walmartlabs/concord/client/ApiClientProvider.java
new file mode 100644
index 0000000000..93a62879b7
--- /dev/null
+++ b/client/src/main/java/com/walmartlabs/concord/client/ApiClientProvider.java
@@ -0,0 +1,53 @@
+package com.walmartlabs.concord.client;
+
+/*-
+ * *****
+ * Concord
+ * -----
+ * Copyright (C) 2017 - 2019 Walmart Inc.
+ * -----
+ * 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
+ *
+ * http://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.
+ * =====
+ */
+
+import com.walmartlabs.concord.ApiClient;
+import com.walmartlabs.concord.runtime.v2.sdk.ProcessConfiguration;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+
+@Named
+public class ApiClientProvider implements Provider {
+
+ private final ApiClientFactory clientFactory;
+ private final ProcessConfiguration processCfg;
+
+ @Inject
+ public ApiClientProvider(ApiClientFactory clientFactory, ProcessConfiguration processCfg) {
+ this.clientFactory = clientFactory;
+ this.processCfg = processCfg;
+ }
+
+ @Override
+ public ApiClient get() {
+ String s = processCfg.processInfo().sessionToken();
+ if (s == null) {
+ throw new IllegalStateException("Can't initialize the API client: 'processInfo.sessionToken' is not defined.");
+ }
+
+ return clientFactory.create(ApiClientConfiguration.builder()
+ .sessionToken(s)
+ .build());
+ }
+}
diff --git a/client/src/main/java/com/walmartlabs/concord/client/CreateSecretRequestV2.java b/client/src/main/java/com/walmartlabs/concord/client/CreateSecretRequestV2.java
index e652b47c24..af7056b172 100644
--- a/client/src/main/java/com/walmartlabs/concord/client/CreateSecretRequestV2.java
+++ b/client/src/main/java/com/walmartlabs/concord/client/CreateSecretRequestV2.java
@@ -24,7 +24,6 @@
import org.immutables.value.Value;
import javax.annotation.Nullable;
-import java.nio.file.Path;
import java.util.List;
import java.util.UUID;
diff --git a/client2/pom.xml b/client2/pom.xml
index 983b440c44..3f47e2e68d 100644
--- a/client2/pom.xml
+++ b/client2/pom.xml
@@ -19,11 +19,6 @@
concord-server
provided
-
- com.walmartlabs.concord
- concord-common
- provided
-
org.slf4j
slf4j-api
@@ -53,16 +48,6 @@
value
provided
-
- com.google.code.findbugs
- jsr305
- provided
-
-
- com.google.errorprone
- error_prone_annotations
- provided
-
@@ -153,17 +138,13 @@
org.revapi
revapi-maven-plugin
- true
-
-
java.field.serialVersionUIDUnchanged
-
- -
-
java.method.parameterTypeParameterChanged
+ java.class.nonPublicPartOfAPI
-
-
java.method.returnTypeTypeParametersChanged
+ java.class.removed
diff --git a/client2/src/main/java/com/walmartlabs/concord/client2/impl/HttpEntity.java b/client2/src/main/java/com/walmartlabs/concord/client2/impl/HttpEntity.java
index 6dc56c8b0a..eb81cbb698 100644
--- a/client2/src/main/java/com/walmartlabs/concord/client2/impl/HttpEntity.java
+++ b/client2/src/main/java/com/walmartlabs/concord/client2/impl/HttpEntity.java
@@ -22,7 +22,6 @@
import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStream;
public interface HttpEntity {
diff --git a/client2/src/main/template/libraries/native/ApiClient.mustache b/client2/src/main/template/libraries/native/ApiClient.mustache
index 5a58a59fcc..95904f07a0 100644
--- a/client2/src/main/template/libraries/native/ApiClient.mustache
+++ b/client2/src/main/template/libraries/native/ApiClient.mustache
@@ -193,7 +193,7 @@ public class ApiClient {
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false);
- mapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false);
+ mapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, true);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
diff --git a/client2/src/main/template/libraries/native/api.mustache b/client2/src/main/template/libraries/native/api.mustache
index 93691d39d8..2fa54480ed 100644
--- a/client2/src/main/template/libraries/native/api.mustache
+++ b/client2/src/main/template/libraries/native/api.mustache
@@ -101,27 +101,6 @@ public class {{classname}} {
{{#operation}}
{{#vendorExtensions.x-group-parameters}}
{{#hasParams}}
- /**
- * {{summary}}
- * {{notes}}
- * @param apiRequest {@link API{{operationId}}Request}
- {{#returnType}}
- * @return {{#asyncNative}}CompletableFuture<{{/asyncNative}}{{returnType}}{{#asyncNative}}>{{/asyncNative}}
- {{/returnType}}
- {{^returnType}}
- {{#asyncNative}}
- * @return CompletableFuture<Void>
- {{/asyncNative}}
- {{/returnType}}
- * @throws ApiException if fails to make API call
- {{#isDeprecated}}
- * @deprecated
- {{/isDeprecated}}
- {{#externalDocs}}
- * {{description}}
- * @see {{summary}} Documentation
- {{/externalDocs}}
- */
{{#isDeprecated}}
@Deprecated
{{/isDeprecated}}
@@ -132,20 +111,6 @@ public class {{classname}} {
{{#returnType}}return {{/returnType}}{{^returnType}}{{#asyncNative}}return {{/asyncNative}}{{/returnType}}{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
}
- /**
- * {{summary}}
- * {{notes}}
- * @param apiRequest {@link API{{operationId}}Request}
- * @return {{#asyncNative}}CompletableFuture<{{/asyncNative}}ApiResponse<{{returnType}}{{^returnType}}Void{{/returnType}}>{{#asyncNative}}>{{/asyncNative}}
- * @throws ApiException if fails to make API call
- {{#isDeprecated}}
- * @deprecated
- {{/isDeprecated}}
- {{#externalDocs}}
- * {{description}}
- * @see {{summary}} Documentation
- {{/externalDocs}}
- */
{{#isDeprecated}}
@Deprecated
{{/isDeprecated}}
@@ -158,38 +123,6 @@ public class {{classname}} {
{{/hasParams}}
{{/vendorExtensions.x-group-parameters}}
- /**
- * {{summary}}
- * {{notes}}
- {{#isMultipart}}
- {{#allParams}}
- {{^isFormParam}}
- * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/isContainer}}{{/required}}
- {{/isFormParam}}
- {{/allParams}}
- {{/isMultipart}}
- {{^isMultipart}}
- {{#allParams}}
- * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/isContainer}}{{/required}}
- {{/allParams}}
- {{/isMultipart}}
- {{#returnType}}
- * @return {{#asyncNative}}CompletableFuture<{{/asyncNative}}{{returnType}}{{#asyncNative}}>{{/asyncNative}}
- {{/returnType}}
- {{^returnType}}
- {{#asyncNative}}
- * @return CompletableFuture<Void>
- {{/asyncNative}}
- {{/returnType}}
- * @throws ApiException if fails to make API call
- {{#isDeprecated}}
- * @deprecated
- {{/isDeprecated}}
- {{#externalDocs}}
- * {{description}}
- * @see {{summary}} Documentation
- {{/externalDocs}}
- */
{{#isDeprecated}}
@Deprecated
{{/isDeprecated}}
@@ -237,31 +170,6 @@ public class {{classname}} {
{{/asyncNative}}
}
- /**
- * {{summary}}
- * {{notes}}
- {{#isMultipart}}
- {{#allParams}}
- {{^isFormParam}}
- * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/isContainer}}{{/required}}
- {{/isFormParam}}
- {{/allParams}}
- {{/isMultipart}}
- {{^isMultipart}}
- {{#allParams}}
- * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/isContainer}}{{/required}}
- {{/allParams}}
- {{/isMultipart}}
- * @return {{#asyncNative}}CompletableFuture<{{/asyncNative}}ApiResponse<{{returnType}}{{^returnType}}Void{{/returnType}}>{{#asyncNative}}>{{/asyncNative}}
- * @throws ApiException if fails to make API call
- {{#isDeprecated}}
- * @deprecated
- {{/isDeprecated}}
- {{#externalDocs}}
- * {{description}}
- * @see {{summary}} Documentation
- {{/externalDocs}}
- */
{{#isDeprecated}}
@Deprecated
{{/isDeprecated}}
diff --git a/client2/src/main/template/libraries/native/pojo.mustache b/client2/src/main/template/libraries/native/pojo.mustache
index 5dd97018f5..48b780e470 100644
--- a/client2/src/main/template/libraries/native/pojo.mustache
+++ b/client2/src/main/template/libraries/native/pojo.mustache
@@ -87,7 +87,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{/isContainer}}
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
- private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
+ private {{{datatypeWithEnum}}} {{name}};
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{/vars}}
diff --git a/client2/src/test/java/com/walmartlabs/concord/client2/ApiClientJsonTest.java b/client2/src/test/java/com/walmartlabs/concord/client2/ApiClientJsonTest.java
index 56b3afe081..051ad56734 100644
--- a/client2/src/test/java/com/walmartlabs/concord/client2/ApiClientJsonTest.java
+++ b/client2/src/test/java/com/walmartlabs/concord/client2/ApiClientJsonTest.java
@@ -26,6 +26,7 @@
import java.text.SimpleDateFormat;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
+import java.util.Collections;
import java.util.Date;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -58,4 +59,14 @@ public void testObjectSerialize() throws Exception {
String str = ApiClient.createDefaultObjectMapper().writeValueAsString(project);
assertEquals("{\"name\":\"\"}", str);
}
+
+ @Test
+ public void testEmptyCollectionSerialize() throws Exception {
+ CreateUserRequest user = new CreateUserRequest()
+ .username("test")
+ .roles(Collections.emptySet());
+
+ String str = ApiClient.createDefaultObjectMapper().writeValueAsString(user);
+ assertEquals("{\"username\":\"test\",\"roles\":[]}", str);
+ }
}
diff --git a/dependency-manager/src/main/java/com/walmartlabs/concord/dependencymanager/DependencyManager.java b/dependency-manager/src/main/java/com/walmartlabs/concord/dependencymanager/DependencyManager.java
index a849e98fd1..28b390c368 100644
--- a/dependency-manager/src/main/java/com/walmartlabs/concord/dependencymanager/DependencyManager.java
+++ b/dependency-manager/src/main/java/com/walmartlabs/concord/dependencymanager/DependencyManager.java
@@ -26,6 +26,8 @@
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.artifact.DefaultArtifact;
import org.eclipse.aether.collection.CollectRequest;
+import org.eclipse.aether.collection.DependencyCollectionContext;
+import org.eclipse.aether.collection.DependencySelector;
import org.eclipse.aether.graph.Dependency;
import org.eclipse.aether.repository.LocalRepository;
import org.eclipse.aether.repository.Proxy;
@@ -37,6 +39,9 @@
import org.eclipse.aether.transfer.TransferEvent;
import org.eclipse.aether.util.artifact.JavaScopes;
import org.eclipse.aether.util.filter.ExclusionsDependencyFilter;
+import org.eclipse.aether.util.graph.selector.AndDependencySelector;
+import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector;
+import org.eclipse.aether.util.graph.selector.OptionalDependencySelector;
import org.eclipse.aether.util.repository.AuthenticationBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -71,6 +76,8 @@ public class DependencyManager {
private final List defaultExclusions;
+ private final boolean explicitlyResolveV1Client;
+
@Inject
public DependencyManager(DependencyManagerConfiguration cfg) throws IOException {
this.cacheDir = cfg.cacheDir();
@@ -84,6 +91,7 @@ public DependencyManager(DependencyManagerConfiguration cfg) throws IOException
this.maven = RepositorySystemFactory.create();
this.strictRepositories = cfg.strictRepositories();
this.defaultExclusions = cfg.exclusions();
+ this.explicitlyResolveV1Client = cfg.explicitlyResolveV1Client();
}
public Collection resolve(Collection items) throws IOException {
@@ -157,8 +165,8 @@ private DependencyList categorize(List items) throws IOException {
Artifact artifact = new DefaultArtifact(id);
Map> cfg = splitQuery(item);
- String scope = getSingleValue(cfg,"scope", JavaScopes.COMPILE);
- boolean transitive = Boolean.parseBoolean(getSingleValue(cfg,"transitive", "true"));
+ String scope = getSingleValue(cfg, "scope", JavaScopes.COMPILE);
+ boolean transitive = Boolean.parseBoolean(getSingleValue(cfg, "transitive", "true"));
if (transitive) {
mavenTransitiveDependencies.add(new MavenDependency(artifact, scope));
@@ -285,6 +293,15 @@ private DefaultRepositorySystemSession newRepositorySystemSession(RepositorySyst
session.setChecksumPolicy(RepositoryPolicy.CHECKSUM_POLICY_IGNORE);
session.setIgnoreArtifactDescriptorRepositories(strictRepositories);
+ if (explicitlyResolveV1Client) {
+ DependencySelector selector = new AndDependencySelector(
+ new ClientDepSelector(),
+ new OptionalDependencySelector(),
+ new ExclusionDependencySelector());
+
+ session.setDependencySelector(selector);
+ }
+
LocalRepository localRepo = new LocalRepository(localCacheDir.toFile());
session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));
session.setTransferListener(new AbstractTransferListener() {
@@ -389,6 +406,48 @@ private static Map> splitQuery(URI uri) throws UnsupportedE
return m;
}
+ private static class ClientDepSelector implements DependencySelector {
+
+ private static final String CONCORD_CLIENT_GROUP_ID = "com.walmartlabs.concord";
+ private static final String CONCORD_CLIENT_ARTIFACT_ID = "concord-client";
+
+ private final boolean transitive;
+ private final Collection excluded;
+
+ public ClientDepSelector() {
+ this(false, Arrays.asList("test", "provided"));
+ }
+
+ public ClientDepSelector(boolean transitive, Collection excluded) {
+ this.transitive = transitive;
+ this.excluded = excluded;
+ }
+
+ @Override
+ public boolean selectDependency(Dependency dependency) {
+ if (CONCORD_CLIENT_GROUP_ID.equals(dependency.getArtifact().getGroupId()) &&
+ CONCORD_CLIENT_ARTIFACT_ID.equals(dependency.getArtifact().getArtifactId())) {
+ return true;
+ }
+
+ if (!transitive) {
+ return true;
+ }
+
+ String scope = dependency.getScope();
+ return !excluded.contains(scope);
+ }
+
+ @Override
+ public DependencySelector deriveChildSelector(DependencyCollectionContext context) {
+ if (this.transitive || context.getDependency() == null) {
+ return this;
+ }
+
+ return new ClientDepSelector(true, excluded);
+ }
+ }
+
private static final class DependencyList {
private final List mavenTransitiveDependencies;
diff --git a/dependency-manager/src/main/java/com/walmartlabs/concord/dependencymanager/DependencyManagerConfiguration.java b/dependency-manager/src/main/java/com/walmartlabs/concord/dependencymanager/DependencyManagerConfiguration.java
index ae06e1114d..8ca39e0aa3 100644
--- a/dependency-manager/src/main/java/com/walmartlabs/concord/dependencymanager/DependencyManagerConfiguration.java
+++ b/dependency-manager/src/main/java/com/walmartlabs/concord/dependencymanager/DependencyManagerConfiguration.java
@@ -60,6 +60,11 @@ default List exclusions() {
return Collections.emptyList();
}
+ @Value.Default
+ default boolean explicitlyResolveV1Client() {
+ return false;
+ }
+
static ImmutableDependencyManagerConfiguration.Builder builder() {
return ImmutableDependencyManagerConfiguration.builder();
}
diff --git a/docker-images/agent/pom.xml b/docker-images/agent/pom.xml
index b1e5a3521c..3da211f05d 100644
--- a/docker-images/agent/pom.xml
+++ b/docker-images/agent/pom.xml
@@ -29,7 +29,7 @@
com.walmartlabs.concord
- concord-client
+ concord-client2
${project.version}
diff --git a/it/common/pom.xml b/it/common/pom.xml
index b0f140cf92..db7b50d299 100644
--- a/it/common/pom.xml
+++ b/it/common/pom.xml
@@ -16,7 +16,7 @@
com.walmartlabs.concord
- concord-client
+ concord-client2
com.walmartlabs.concord
@@ -46,16 +46,6 @@
org.apache.commons
commons-compress
-
- com.squareup.okhttp
- okhttp
- 2.7.5
-
-
- com.google.code.gson
- gson
- 2.10
-
org.apache.sshd
sshd-core
diff --git a/it/common/src/main/java/com/walmartlabs/concord/it/common/ServerClient.java b/it/common/src/main/java/com/walmartlabs/concord/it/common/ServerClient.java
index f03b6d8f8c..65890305f2 100644
--- a/it/common/src/main/java/com/walmartlabs/concord/it/common/ServerClient.java
+++ b/it/common/src/main/java/com/walmartlabs/concord/it/common/ServerClient.java
@@ -20,17 +20,12 @@
* =====
*/
-import com.google.gson.reflect.TypeToken;
-import com.squareup.okhttp.Call;
-import com.squareup.okhttp.OkHttpClient;
-import com.walmartlabs.concord.ApiClient;
-import com.walmartlabs.concord.ApiException;
-import com.walmartlabs.concord.ApiResponse;
-import com.walmartlabs.concord.client.*;
+import com.walmartlabs.concord.client2.*;
import org.intellij.lang.annotations.Language;
import java.io.IOException;
-import java.lang.reflect.Type;
+import java.io.InputStream;
+import java.time.Duration;
import java.util.*;
import java.util.stream.Collectors;
@@ -67,26 +62,12 @@ public void setGithubKey(String githubKey) {
}
public StartProcessResponse start(Map input) throws ApiException {
- return request("/api/v1/process", input, StartProcessResponse.class);
- }
-
- public T request(String uri, Map input, Class entityType) throws ApiException {
- ApiResponse resp = ClientUtils.postData(client, uri, input, entityType);
-
- int code = resp.getStatusCode();
- if (code < 200 || code >= 300) {
- if (code == 403) {
- throw new ForbiddenException("Forbidden!", resp.getData());
- }
-
- throw new ApiException("Request error: " + code);
- }
-
- return resp.getData();
+ return new ProcessApi(client).startProcess(input);
}
public SecretOperationResponse postSecret(String orgName, Map input) throws ApiException {
- return request("/api/v1/org/" + orgName + "/secret", input, SecretOperationResponse.class);
+ SecretsApi api = new SecretsApi(client);
+ return api.createSecret(orgName, input);
}
public SecretOperationResponse generateKeyPair(String orgName, String projectName, String name,
@@ -95,7 +76,7 @@ public SecretOperationResponse generateKeyPair(String orgName, String projectNam
Map m = new HashMap<>();
m.put("name", name);
m.put("generatePassword", generatePassword);
- m.put("type", SecretEntry.TypeEnum.KEY_PAIR.toString());
+ m.put("type", SecretEntryV2.TypeEnum.KEY_PAIR.toString());
if (storePassword != null) {
m.put("storePassword", storePassword);
}
@@ -112,7 +93,7 @@ public SecretOperationResponse generateKeyPair(String orgName, Set proje
Map m = new HashMap<>();
m.put("name", name);
m.put("generatePassword", generatePassword);
- m.put("type", SecretEntry.TypeEnum.KEY_PAIR.toString());
+ m.put("type", SecretEntryV2.TypeEnum.KEY_PAIR.toString());
if (storePassword != null) {
m.put("storePassword", storePassword);
}
@@ -130,7 +111,7 @@ public SecretOperationResponse addPlainSecret(String orgName, String name, Strin
byte[] secret) throws ApiException {
Map m = new HashMap<>();
m.put("name", name);
- m.put("type", SecretEntry.TypeEnum.DATA.toString());
+ m.put("type", SecretEntryV2.TypeEnum.DATA.toString());
m.put("generatePassword", generatePassword);
if (projectName != null && !projectName.isEmpty()) {
@@ -149,7 +130,7 @@ public SecretOperationResponse addPlainSecret(String orgName, String name, Set m = new HashMap<>();
m.put("name", name);
- m.put("type", SecretEntry.TypeEnum.DATA.toString());
+ m.put("type", SecretEntryV2.TypeEnum.DATA.toString());
m.put("generatePassword", generatePassword);
if (projectIds != null && !projectIds.isEmpty()) {
@@ -170,7 +151,7 @@ public SecretOperationResponse addUsernamePassword(String orgName, String projec
String password) throws ApiException {
Map m = new HashMap<>();
m.put("name", name);
- m.put("type", SecretEntry.TypeEnum.USERNAME_PASSWORD.toString());
+ m.put("type", SecretEntryV2.TypeEnum.USERNAME_PASSWORD.toString());
m.put("generatePassword", generatePassword);
m.put("username", username);
m.put("password", password);
@@ -184,26 +165,24 @@ public SecretOperationResponse addUsernamePassword(String orgName, String projec
return postSecret(orgName, m);
}
- public byte[] getLog(String logFileName) throws ApiException {
- Set auths = client.getAuthentications().keySet();
- String[] authNames = auths.toArray(new String[0]);
-
- Call c = client.buildCall("/logs/" + logFileName, "GET", new ArrayList<>(), new ArrayList<>(),
- null, new HashMap<>(), new HashMap<>(), authNames, null);
-
- Type t = new TypeToken() {
- }.getType();
- return client.execute(c, t).getData();
+ public byte[] getLog(UUID instanceId) throws ApiException {
+ try (InputStream is = new ProcessApi(client).getProcessLog(instanceId, null)) {
+ return is.readAllBytes();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
- public static ProcessEntry waitForStatus(ProcessApi api, UUID instanceId,
+ public static ProcessEntry waitForStatus(ApiClient apiClient, UUID instanceId,
ProcessEntry.StatusEnum status, ProcessEntry.StatusEnum... more) throws InterruptedException {
int retries = 10;
+ ProcessV2Api apiV2 = new ProcessV2Api(apiClient);
+
ProcessEntry pir;
while (true) {
try {
- pir = api.get(instanceId);
+ pir = apiV2.getProcess(instanceId, Collections.singleton("childrenIds"));
if (pir.getStatus() == ProcessEntry.StatusEnum.FINISHED || pir.getStatus() == ProcessEntry.StatusEnum.FAILED || pir.getStatus() == ProcessEntry.StatusEnum.CANCELLED) {
return pir;
}
@@ -268,8 +247,8 @@ private static ProcessEntry findByKindAndStatus(Collection c, Proc
return null;
}
- public static ProcessEntry waitForCompletion(ProcessApi api, UUID instanceId) throws InterruptedException {
- return waitForStatus(api, instanceId, ProcessEntry.StatusEnum.FAILED, ProcessEntry.StatusEnum.FINISHED);
+ public static ProcessEntry waitForCompletion(ApiClient apiClient, UUID instanceId) throws InterruptedException {
+ return waitForStatus(apiClient, instanceId, ProcessEntry.StatusEnum.FAILED, ProcessEntry.StatusEnum.FINISHED);
}
public static void assertLog(@Language("RegExp") String pattern, byte[] ab) throws IOException {
@@ -293,11 +272,11 @@ public static void assertLogAtLeast(@Language("RegExp") String pattern, int time
assertTrue(times <= matches, "Expected to find " + pattern + " at least " + times + " time(s), found only " + matches);
}
- public void waitForLog(String logFileName, @Language("RegExp") String pattern) throws ApiException, IOException, InterruptedException {
+ public void waitForLog(UUID instanceId, @Language("RegExp") String pattern) throws ApiException, IOException, InterruptedException {
int retries = 5;
while (true) {
- byte[] ab = getLog(logFileName);
+ byte[] ab = getLog(instanceId);
if (!grep(pattern, ab).isEmpty()) {
break;
}
@@ -327,17 +306,14 @@ private static boolean isSame(ProcessEntry.StatusEnum status, ProcessEntry.Statu
}
private static ApiClient createClient(String baseUrl, String apiKey, String gitHubKey) {
- ApiClient c = new ConcordApiClient(baseUrl, new OkHttpClient());
- c.setReadTimeout(60000);
- c.setConnectTimeout(10000);
- c.setWriteTimeout(60000);
+ ApiClient c = new DefaultApiClientFactory(baseUrl, Duration.ofMillis(10000))
+ .create(ApiClientConfiguration.builder()
+ .apiKey(apiKey)
+ .build());
+ c.setReadTimeout(Duration.ofMillis(60000));
c.addDefaultHeader("X-Concord-Trace-Enabled", "true");
- if (apiKey != null) {
- c.setApiKey(apiKey);
- }
-
if (gitHubKey != null) {
c.addDefaultHeader("X-Hub-Signature", gitHubKey);
}
diff --git a/it/compat/pom.xml b/it/compat/pom.xml
index ff9240fca5..48fce56c2e 100644
--- a/it/compat/pom.xml
+++ b/it/compat/pom.xml
@@ -52,7 +52,7 @@
com.walmartlabs.concord
- concord-client
+ concord-client2
test
diff --git a/it/compat/src/test/java/com/walmartlabs/concord/it/compat/LocalModeIT.java b/it/compat/src/test/java/com/walmartlabs/concord/it/compat/LocalModeIT.java
index bdefbd9b00..9c96a9b51b 100644
--- a/it/compat/src/test/java/com/walmartlabs/concord/it/compat/LocalModeIT.java
+++ b/it/compat/src/test/java/com/walmartlabs/concord/it/compat/LocalModeIT.java
@@ -24,7 +24,7 @@
import ca.ibodrov.concord.testcontainers.ConcordProcess;
import ca.ibodrov.concord.testcontainers.Payload;
import ca.ibodrov.concord.testcontainers.junit5.ConcordRule;
-import com.walmartlabs.concord.client.ProcessEntry;
+import com.walmartlabs.concord.client2.ProcessEntry;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
diff --git a/it/compat/src/test/java/com/walmartlabs/concord/it/compat/OldAgentIT.java b/it/compat/src/test/java/com/walmartlabs/concord/it/compat/OldAgentIT.java
index df452f8eb4..83884268b7 100644
--- a/it/compat/src/test/java/com/walmartlabs/concord/it/compat/OldAgentIT.java
+++ b/it/compat/src/test/java/com/walmartlabs/concord/it/compat/OldAgentIT.java
@@ -23,7 +23,7 @@
import ca.ibodrov.concord.testcontainers.ConcordProcess;
import ca.ibodrov.concord.testcontainers.Payload;
import ca.ibodrov.concord.testcontainers.junit5.ConcordRule;
-import com.walmartlabs.concord.client.ProcessEntry;
+import com.walmartlabs.concord.client2.ProcessEntry;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.api.extension.RegisterExtension;
diff --git a/it/console/pom.xml b/it/console/pom.xml
index d77bd4e437..40098ddfd5 100644
--- a/it/console/pom.xml
+++ b/it/console/pom.xml
@@ -38,7 +38,7 @@
com.walmartlabs.concord
- concord-client
+ concord-client2
test
@@ -91,18 +91,6 @@
org.eclipse.jgit
test
-
- com.google.code.gson
- gson
- 2.10
- test
-
-
- com.squareup.okhttp
- okhttp
- 2.7.5
- test
-
diff --git a/it/console/src/test/java/com/walmartlabs/concord/it/console/ConcordServerRule.java b/it/console/src/test/java/com/walmartlabs/concord/it/console/ConcordServerRule.java
index c6373282a4..477a5d9e55 100644
--- a/it/console/src/test/java/com/walmartlabs/concord/it/console/ConcordServerRule.java
+++ b/it/console/src/test/java/com/walmartlabs/concord/it/console/ConcordServerRule.java
@@ -20,26 +20,17 @@
* =====
*/
-import com.google.gson.reflect.TypeToken;
-import com.squareup.okhttp.Call;
-import com.walmartlabs.concord.ApiClient;
-import com.walmartlabs.concord.ApiException;
-import com.walmartlabs.concord.ApiResponse;
-import com.walmartlabs.concord.client.ClientUtils;
-import com.walmartlabs.concord.client.ConcordApiClient;
-import com.walmartlabs.concord.client.StartProcessResponse;
-import com.walmartlabs.concord.it.common.ForbiddenException;
+import com.walmartlabs.concord.client2.*;
import com.walmartlabs.concord.it.common.JGitUtils;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.HashMap;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.Map;
-import java.util.Set;
+import java.util.UUID;
import static com.walmartlabs.concord.it.console.Utils.env;
@@ -63,43 +54,24 @@ public ApiClient getClient() {
}
public StartProcessResponse start(Map input) throws ApiException {
- return request("/api/v1/process", input, StartProcessResponse.class);
+ return new ProcessApi(client).startProcess(input);
}
- public T request(String uri, Map input, Class entityType) throws ApiException {
- ApiResponse resp = ClientUtils.postData(client, uri, input, entityType);
-
- int code = resp.getStatusCode();
- if (code < 200 || code >= 300) {
- if (code == 403) {
- throw new ForbiddenException("Forbidden!", resp.getData());
- }
-
- throw new ApiException("Request error: " + code);
+ public byte[] getLog(UUID instanceId) throws ApiException {
+ try (InputStream is = new ProcessApi(client).getProcessLog(instanceId, null)) {
+ return is.readAllBytes();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
}
-
- return resp.getData();
- }
-
- public byte[] getLog(String logFileName) throws ApiException {
- Set auths = client.getAuthentications().keySet();
- String[] authNames = auths.toArray(new String[0]);
-
- Call c = client.buildCall("/logs/" + logFileName, "GET", new ArrayList<>(), new ArrayList<>(),
- null, new HashMap<>(), new HashMap<>(), authNames, null);
-
- Type t = new TypeToken() {
- }.getType();
- return client.execute(c, t).getData();
}
@Override
- public void beforeEach(ExtensionContext context) throws Exception {
+ public void beforeEach(ExtensionContext context) {
setUp();
}
private void setUp() {
- this.client = new ConcordApiClient(baseUrl)
- .setApiKey(Concord.ADMIN_API_KEY);
+ this.client = new DefaultApiClientFactory(baseUrl)
+ .create(ApiClientConfiguration.builder().apiKey(Concord.ADMIN_API_KEY).build());
}
}
diff --git a/it/console/src/test/java/com/walmartlabs/concord/it/console/CustomFormsIT.java b/it/console/src/test/java/com/walmartlabs/concord/it/console/CustomFormsIT.java
index 631757714b..f03cc01a22 100644
--- a/it/console/src/test/java/com/walmartlabs/concord/it/console/CustomFormsIT.java
+++ b/it/console/src/test/java/com/walmartlabs/concord/it/console/CustomFormsIT.java
@@ -20,8 +20,7 @@
* =====
*/
-import com.walmartlabs.concord.ApiClient;
-import com.walmartlabs.concord.client.*;
+import com.walmartlabs.concord.client2.*;
import com.walmartlabs.concord.it.common.ITUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
@@ -66,17 +65,17 @@ public void test() throws Exception {
String orgName = "org_" + ITUtils.randomString();
OrganizationsApi organizationsApi = new OrganizationsApi(client);
- organizationsApi.createOrUpdate(new OrganizationEntry().setName(orgName));
+ organizationsApi.createOrUpdateOrg(new OrganizationEntry().name(orgName));
String projectName = "project_" + ITUtils.randomString();
String repoName = "test";
ProjectsApi projectsApi = new ProjectsApi(client);
- projectsApi.createOrUpdate(orgName, new ProjectEntry()
- .setName(projectName)
- .setRepositories(Collections.singletonMap(repoName, new RepositoryEntry()
- .setUrl(gitUrl)
- .setBranch("master"))));
+ projectsApi.createOrUpdateProject(orgName, new ProjectEntry()
+ .name(projectName)
+ .repositories(Collections.singletonMap(repoName, new RepositoryEntry()
+ .url(gitUrl)
+ .branch("master"))));
// ---
@@ -92,11 +91,10 @@ public void test() throws Exception {
input.put("repo", repoName);
input.put("arguments.testValue", testValue);
- ProcessApi processApi = new ProcessApi(client);
StartProcessResponse spr = serverRule.start(input);
assertNotNull(spr.getInstanceId());
- ProcessEntry pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED);
+ ProcessEntry pir = waitForStatus(client, spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED);
String url = "/#/process/" + spr.getInstanceId() + "/wizard";
consoleRule.navigateToRelative(url);
@@ -117,9 +115,9 @@ public void test() throws Exception {
// -- validate log output
- pir = waitForCompletion(processApi, pir.getInstanceId());
+ pir = waitForCompletion(client, pir.getInstanceId());
- byte[] ab = serverRule.getLog(pir.getLogFileName());
+ byte[] ab = serverRule.getLog(pir.getInstanceId());
assertLog(".*uploaded contents: \\{hello=world\\}.*", ab);
}
}
diff --git a/it/console/src/test/java/com/walmartlabs/concord/it/console/FormsIT.java b/it/console/src/test/java/com/walmartlabs/concord/it/console/FormsIT.java
index f9de5d1d10..bcd0d20794 100644
--- a/it/console/src/test/java/com/walmartlabs/concord/it/console/FormsIT.java
+++ b/it/console/src/test/java/com/walmartlabs/concord/it/console/FormsIT.java
@@ -20,10 +20,8 @@
* =====
*/
-import com.walmartlabs.concord.client.ProcessApi;
-import com.walmartlabs.concord.client.ProcessEntry;
-import com.walmartlabs.concord.client.StartProcessResponse;
-import org.junit.jupiter.api.BeforeEach;
+import com.walmartlabs.concord.client2.ProcessEntry;
+import com.walmartlabs.concord.client2.StartProcessResponse;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -50,13 +48,6 @@ class FormsIT {
@RegisterExtension
public static ConcordConsoleRule consoleRule = new ConcordConsoleRule();
- private ProcessApi processApi;
-
- @BeforeEach
- void setup() {
- processApi = new ProcessApi(serverRule.getClient());
- }
-
@Test
void testDateTimeField() throws Exception {
ProcessEntry pir = startConsoleProcess("dateTimeField");
@@ -87,9 +78,9 @@ void testDateTimeField() throws Exception {
// ---
- pir = waitForCompletion(processApi, pir.getInstanceId());
+ pir = waitForCompletion(serverRule.getClient(), pir.getInstanceId());
- byte[] ab = serverRule.getLog(pir.getLogFileName());
+ byte[] ab = serverRule.getLog(pir.getInstanceId());
assertLog(".*dateField=2019-09-04.*", ab);
assertLog(".*dateTimeField=2019-09-04T05:05:00.000Z.*", ab);
}
@@ -151,9 +142,9 @@ void testStringValues() throws Exception {
// ---
- pir = waitForCompletion(processApi, pir.getInstanceId());
+ pir = waitForCompletion(serverRule.getClient(), pir.getInstanceId());
- byte[] ab = serverRule.getLog(pir.getLogFileName());
+ byte[] ab = serverRule.getLog(pir.getInstanceId());
assertLog(".*\"field0\" : \\[ \"second\", \"third\" ].*", ab);
assertLog(".*\"field1\" : \\[ \"first\", \"second\", \"third\" ].*", ab);
assertLog(".*\"field2\" : \\[ \"first\", \"third\", \"fourth\" ].*", ab);
@@ -169,6 +160,6 @@ private ProcessEntry startConsoleProcess(String res) throws Exception {
StartProcessResponse spr = serverRule.start(input);
assertNotNull(spr.getInstanceId());
- return waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED);
+ return waitForStatus(serverRule.getClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED);
}
}
diff --git a/it/runtime-v1/pom.xml b/it/runtime-v1/pom.xml
index 82037fc6a3..9e1ee4fd6b 100644
--- a/it/runtime-v1/pom.xml
+++ b/it/runtime-v1/pom.xml
@@ -25,7 +25,7 @@
com.walmartlabs.concord
- concord-client
+ concord-client2
test
diff --git a/it/runtime-v1/src/test/java/com/walmartlabs/concord/it/runtime/v1/ProcessIT.java b/it/runtime-v1/src/test/java/com/walmartlabs/concord/it/runtime/v1/ProcessIT.java
index 5fbf46b5c9..685b3f2fab 100644
--- a/it/runtime-v1/src/test/java/com/walmartlabs/concord/it/runtime/v1/ProcessIT.java
+++ b/it/runtime-v1/src/test/java/com/walmartlabs/concord/it/runtime/v1/ProcessIT.java
@@ -22,15 +22,14 @@
import ca.ibodrov.concord.testcontainers.ConcordProcess;
import ca.ibodrov.concord.testcontainers.Payload;
-import ca.ibodrov.concord.testcontainers.ProcessListQuery;
import ca.ibodrov.concord.testcontainers.junit5.ConcordRule;
import com.google.common.base.Charsets;
import com.google.common.io.Resources;
-import com.walmartlabs.concord.client.FormListEntry;
-import com.walmartlabs.concord.client.FormSubmitResponse;
-import com.walmartlabs.concord.client.ProcessCheckpointEntry;
-import com.walmartlabs.concord.client.ProcessEntry;
-import com.walmartlabs.concord.client.ProcessEntry.StatusEnum;
+import com.walmartlabs.concord.client2.FormListEntry;
+import com.walmartlabs.concord.client2.FormSubmitResponse;
+import com.walmartlabs.concord.client2.ProcessEntry;
+import com.walmartlabs.concord.client2.ProcessEntry.StatusEnum;
+import com.walmartlabs.concord.client2.ProcessListFilter;
import com.walmartlabs.concord.it.common.JGitUtils;
import com.walmartlabs.concord.sdk.Constants;
import org.junit.jupiter.api.BeforeAll;
@@ -238,10 +237,10 @@ public void testTags() throws Exception {
// ---
- l = concord.processes().list(ProcessListQuery.builder().addTags("xyz").build());
+ l = concord.processes().list(ProcessListFilter.builder().addTags("xyz").build());
assertTrue(l.isEmpty());
- l = concord.processes().list(ProcessListQuery.builder().addTags("IT").build());
+ l = concord.processes().list(ProcessListFilter.builder().addTags("IT").build());
assertEquals(1, l.size());
e = l.get(0);
@@ -407,7 +406,7 @@ public void testDisableProcess() throws Exception {
ProcessEntry pe = proc.disable();
- assertTrue(pe.isDisabled());
+ assertTrue(pe.getDisabled());
}
@Test
diff --git a/it/runtime-v2/pom.xml b/it/runtime-v2/pom.xml
index 00433176a2..2f7bb04529 100644
--- a/it/runtime-v2/pom.xml
+++ b/it/runtime-v2/pom.xml
@@ -25,7 +25,7 @@
com.walmartlabs.concord
- concord-client
+ concord-client2
test
@@ -117,7 +117,7 @@
com.walmartlabs.concord.server.plugins.noderoster
- concord-noderoster-plugin-client
+ concord-noderoster-plugin-client2
test
diff --git a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/AbstractTest.java b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/AbstractTest.java
index 3b79911eed..1b349f898b 100644
--- a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/AbstractTest.java
+++ b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/AbstractTest.java
@@ -21,8 +21,7 @@
*/
import ca.ibodrov.concord.testcontainers.ConcordProcess;
-import com.walmartlabs.concord.ApiException;
-import com.walmartlabs.concord.client.ProcessEntry;
+import com.walmartlabs.concord.client2.*;
import com.walmartlabs.concord.it.common.JGitUtils;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Timeout;
diff --git a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ConcordTaskIT.java b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ConcordTaskIT.java
index a20c94148a..ba6d483628 100644
--- a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ConcordTaskIT.java
+++ b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ConcordTaskIT.java
@@ -23,7 +23,7 @@
import ca.ibodrov.concord.testcontainers.ConcordProcess;
import ca.ibodrov.concord.testcontainers.Payload;
import ca.ibodrov.concord.testcontainers.junit5.ConcordRule;
-import com.walmartlabs.concord.client.*;
+import com.walmartlabs.concord.client2.*;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -63,13 +63,13 @@ public void testExternalApiToken() throws Exception {
String username = "user_" + randomString();
UsersApi usersApi = new UsersApi(concord.apiClient());
- usersApi.createOrUpdate(new CreateUserRequest()
- .setUsername(username)
- .setType(CreateUserRequest.TypeEnum.LOCAL));
+ usersApi.createOrUpdateUser(new CreateUserRequest()
+ .username(username)
+ .type(CreateUserRequest.TypeEnum.LOCAL));
ApiKeysApi apiKeysApi = new ApiKeysApi(concord.apiClient());
- CreateApiKeyResponse cakr = apiKeysApi.create(new CreateApiKeyRequest()
- .setUsername(username));
+ CreateApiKeyResponse cakr = apiKeysApi.createUserApiKey(new CreateApiKeyRequest()
+ .username(username));
// ---
Payload payload = new Payload()
@@ -117,7 +117,7 @@ public void testForkWithArguments() throws Exception {
// ---
assertEquals(1, processEntry.getChildrenIds().size());
- ConcordProcess child = concord.processes().get(processEntry.getChildrenIds().get(0));
+ ConcordProcess child = concord.processes().get(processEntry.getChildrenIds().iterator().next());
// ---
assertNotNull(child);
diff --git a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/CryptoIT.java b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/CryptoIT.java
index ba279e780e..cc138f5678 100644
--- a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/CryptoIT.java
+++ b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/CryptoIT.java
@@ -24,8 +24,7 @@
import ca.ibodrov.concord.testcontainers.NewSecretQuery;
import ca.ibodrov.concord.testcontainers.Payload;
import ca.ibodrov.concord.testcontainers.junit5.ConcordRule;
-import com.walmartlabs.concord.ApiClient;
-import com.walmartlabs.concord.client.*;
+import com.walmartlabs.concord.client2.*;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -50,12 +49,12 @@ public void test() throws Exception {
String projectName = "project_" + randomString();
OrganizationsApi orgApi = new OrganizationsApi(apiClient);
- orgApi.createOrUpdate(new OrganizationEntry().setName(orgName));
+ orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName));
ProjectsApi projectsApi = new ProjectsApi(apiClient);
- projectsApi.createOrUpdate(orgName, new ProjectEntry()
- .setName(projectName)
- .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.OWNERS));
+ projectsApi.createOrUpdateProject(orgName, new ProjectEntry()
+ .name(projectName)
+ .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.OWNERS));
// ---
@@ -125,7 +124,7 @@ public void test() throws Exception {
public void testCreate() throws Exception {
String orgName = "org_" + randomString();
OrganizationsApi orgApi = new OrganizationsApi(concord.apiClient());
- orgApi.createOrUpdate(new OrganizationEntry().setName(orgName));
+ orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName));
Payload payload = new Payload()
.arg("org", orgName)
@@ -149,12 +148,12 @@ public void testMasked() throws Exception {
String projectName = "project_" + randomString();
OrganizationsApi orgApi = new OrganizationsApi(apiClient);
- orgApi.createOrUpdate(new OrganizationEntry().setName(orgName));
+ orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName));
ProjectsApi projectsApi = new ProjectsApi(apiClient);
- projectsApi.createOrUpdate(orgName, new ProjectEntry()
- .setName(projectName)
- .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.OWNERS));
+ projectsApi.createOrUpdateProject(orgName, new ProjectEntry()
+ .name(projectName)
+ .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.OWNERS));
// ---
diff --git a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/FlowEventsIT.java b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/FlowEventsIT.java
index 0c79780fca..8ed7fd385a 100644
--- a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/FlowEventsIT.java
+++ b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/FlowEventsIT.java
@@ -23,9 +23,9 @@
import ca.ibodrov.concord.testcontainers.ConcordProcess;
import ca.ibodrov.concord.testcontainers.Payload;
import ca.ibodrov.concord.testcontainers.junit5.ConcordRule;
-import com.walmartlabs.concord.client.ProcessEntry;
-import com.walmartlabs.concord.client.ProcessEventEntry;
-import com.walmartlabs.concord.client.ProcessEventsApi;
+import com.walmartlabs.concord.client2.ProcessEntry;
+import com.walmartlabs.concord.client2.ProcessEventEntry;
+import com.walmartlabs.concord.client2.ProcessEventsApi;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -50,7 +50,7 @@ public void test() throws Exception {
// ---
ProcessEventsApi processEventsApi = new ProcessEventsApi(concord.apiClient());
- List events = processEventsApi.list(proc.instanceId(), "ELEMENT", null, null, null, null, null, null);
+ List events = processEventsApi.listProcessEvents(proc.instanceId(), "ELEMENT", null, null, null, null, null, null);
assertNotNull(events);
// ---
diff --git a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/FormIT.java b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/FormIT.java
index e18b4671fe..f652db0411 100644
--- a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/FormIT.java
+++ b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/FormIT.java
@@ -24,10 +24,10 @@
import ca.ibodrov.concord.testcontainers.Payload;
import ca.ibodrov.concord.testcontainers.junit5.ConcordRule;
import com.google.common.io.CharStreams;
-import com.walmartlabs.concord.client.FormListEntry;
-import com.walmartlabs.concord.client.FormSubmitResponse;
-import com.walmartlabs.concord.client.ProcessApi;
-import com.walmartlabs.concord.client.ProcessEntry;
+import com.walmartlabs.concord.client2.FormListEntry;
+import com.walmartlabs.concord.client2.FormSubmitResponse;
+import com.walmartlabs.concord.client2.ProcessApi;
+import com.walmartlabs.concord.client2.ProcessEntry;
import com.walmartlabs.concord.sdk.MapUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -72,7 +72,7 @@ public void test() throws Exception {
// ---
FormListEntry myForm = forms.get(0);
- assertFalse(myForm.isCustom());
+ assertFalse(myForm.getCustom());
String formName = myForm.getName();
@@ -86,7 +86,7 @@ public void test() throws Exception {
data.put("age", age);
FormSubmitResponse fsr = proc.submitForm(formName, data);
- assertTrue(fsr.isOk());
+ assertTrue(fsr.getOk());
assertTrue(fsr.getErrors() == null || fsr.getErrors().isEmpty());
assertEquals(0, proc.forms().size());
@@ -128,7 +128,7 @@ public void testFormOnCancel() throws Exception {
data.put("age", age);
FormSubmitResponse fsr = proc.submitForm(myForm.getName(), data);
- assertTrue(fsr.isOk());
+ assertTrue(fsr.getOk());
// ---
@@ -238,13 +238,13 @@ public void testSubmitInInvalidProcessState() throws Exception {
assertEquals(1, forms.size());
FormListEntry myForm = forms.get(0);
- assertFalse(myForm.isCustom());
+ assertFalse(myForm.getCustom());
String formName = myForm.getName();
assertEquals("myForm", formName);
FormSubmitResponse fsr = proc.submitForm(formName, data);
- assertTrue(fsr.isOk());
+ assertTrue(fsr.getOk());
assertTrue(fsr.getErrors() == null || fsr.getErrors().isEmpty());
expectStatus(proc, ProcessEntry.StatusEnum.FINISHED);
diff --git a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/GitHubTriggersV2IT.java b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/GitHubTriggersV2IT.java
index f9bd009162..ee9bf989a4 100644
--- a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/GitHubTriggersV2IT.java
+++ b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/GitHubTriggersV2IT.java
@@ -21,22 +21,22 @@
*/
import ca.ibodrov.concord.testcontainers.ConcordProcess;
-import ca.ibodrov.concord.testcontainers.ProcessListQuery;
import ca.ibodrov.concord.testcontainers.junit5.ConcordRule;
import com.google.common.collect.ImmutableMap;
-import com.walmartlabs.concord.ApiClient;
-import com.walmartlabs.concord.client.*;
+import com.walmartlabs.concord.client2.*;
import com.walmartlabs.concord.it.common.GitHubUtils;
import com.walmartlabs.concord.it.common.GitUtils;
import com.walmartlabs.concord.it.common.ITUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
+import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.OffsetDateTime;
import java.time.temporal.ChronoUnit;
import java.util.List;
+import java.util.Map;
import static com.walmartlabs.concord.it.common.ITUtils.randomString;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -215,13 +215,13 @@ private static Path initProjectAndRepo(String orgName, String projectName, Strin
ProjectsApi projectsApi = new ProjectsApi(apiClient());
RepositoryEntry repo = new RepositoryEntry()
- .setBranch(repoBranch != null ? repoBranch : "master")
- .setUrl(bareRepo.toAbsolutePath().toString());
+ .branch(repoBranch != null ? repoBranch : "master")
+ .url(bareRepo.toAbsolutePath().toString());
- projectsApi.createOrUpdate(orgName, new ProjectEntry()
- .setName(projectName)
- .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)
- .setRepositories(ImmutableMap.of(repoName, repo)));
+ projectsApi.createOrUpdateProject(orgName, new ProjectEntry()
+ .name(projectName)
+ .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)
+ .repositories(ImmutableMap.of(repoName, repo)));
return bareRepo;
}
@@ -231,7 +231,8 @@ private static void refreshRepo(String orgName, String projectName, String repoN
repoApi.refreshRepository(orgName, projectName, repoName, true);
}
- private static void sendEvent(String resource, String event, String... params) throws Exception {
+ @SuppressWarnings("unchecked")
+ private static void sendEvent(String resource, String eventName, String... params) throws Exception {
String payload = resourceToString(resource);
if (params != null) {
for (int i = 0; i < params.length; i += 2) {
@@ -241,11 +242,14 @@ private static void sendEvent(String resource, String event, String... params) t
}
}
+ Map event = apiClient().getObjectMapper().readValue(payload, Map.class);
+ payload = apiClient().getObjectMapper().writeValueAsString(event);
+
ApiClient client = apiClient();
client.addDefaultHeader("X-Hub-Signature", "sha1=" + GitHubUtils.sign(payload));
GitHubEventsApi eventsApi = new GitHubEventsApi(client);
- eventsApi.onEvent(payload, "abc", event);
+ eventsApi.onEvent( null, "abc", eventName, new ObjectMapper().readValue(payload, Map.class));
}
private static String resourceToString(String resource) throws Exception {
@@ -257,7 +261,7 @@ private static String toRepoName(Path p) {
}
private static ProcessEntry waitForAProcess(String orgName, String projectName, String initiator) throws Exception {
- ProcessListQuery q = ProcessListQuery.builder()
+ ProcessListFilter q = ProcessListFilter.builder()
.orgName(orgName)
.projectName(projectName)
.initiator(initiator)
@@ -283,7 +287,7 @@ private static boolean isFinished(ProcessEntry.StatusEnum status) {
}
private static void expectNoProcesses(String orgName, String projectName, OffsetDateTime afterCreatedAt) throws Exception {
- ProcessListQuery q = ProcessListQuery.builder()
+ ProcessListFilter q = ProcessListFilter.builder()
.orgName(orgName)
.projectName(projectName)
.afterCreatedAt(afterCreatedAt)
diff --git a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ImportsIT.java b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ImportsIT.java
index ce50e4087f..c59cc3289d 100644
--- a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ImportsIT.java
+++ b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ImportsIT.java
@@ -23,7 +23,7 @@
import ca.ibodrov.concord.testcontainers.ConcordProcess;
import ca.ibodrov.concord.testcontainers.Payload;
import ca.ibodrov.concord.testcontainers.junit5.ConcordRule;
-import com.walmartlabs.concord.client.ProcessEntry;
+import com.walmartlabs.concord.client2.ProcessEntry;
import com.walmartlabs.concord.common.Posix;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
diff --git a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/JsonStoreIT.java b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/JsonStoreIT.java
index 65cc54a98b..4143599edf 100644
--- a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/JsonStoreIT.java
+++ b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/JsonStoreIT.java
@@ -23,8 +23,7 @@
import ca.ibodrov.concord.testcontainers.ConcordProcess;
import ca.ibodrov.concord.testcontainers.Payload;
import ca.ibodrov.concord.testcontainers.junit5.ConcordRule;
-import com.walmartlabs.concord.ApiClient;
-import com.walmartlabs.concord.client.*;
+import com.walmartlabs.concord.client2.*;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -48,13 +47,13 @@ public void test() throws Exception {
String orgName = "org_" + randomString();
OrganizationsApi orgApi = new OrganizationsApi(apiClient);
- orgApi.createOrUpdate(new OrganizationEntry().setName(orgName));
+ orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName));
String projectName = "project_" + randomString();
ProjectsApi projectsApi = new ProjectsApi(apiClient);
- projectsApi.createOrUpdate(orgName, new ProjectEntry()
- .setName(projectName)
- .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.OWNERS));
+ projectsApi.createOrUpdateProject(orgName, new ProjectEntry()
+ .name(projectName)
+ .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.OWNERS));
String storeName = "store_" + randomString();
@@ -82,7 +81,7 @@ public void test() throws Exception {
// ---
JsonStoreDataApi jsonStoreDataApi = new JsonStoreDataApi(apiClient);
- Object test = jsonStoreDataApi.get(orgName, storeName, "test2");
+ Object test = jsonStoreDataApi.getJsonStoreData(orgName, storeName, "test2");
assertNotNull(test);
assertTrue(test instanceof Map);
diff --git a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/KvTaskIT.java b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/KvTaskIT.java
index 124b62c802..0798ceb330 100644
--- a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/KvTaskIT.java
+++ b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/KvTaskIT.java
@@ -23,8 +23,7 @@
import ca.ibodrov.concord.testcontainers.ConcordProcess;
import ca.ibodrov.concord.testcontainers.Payload;
import ca.ibodrov.concord.testcontainers.junit5.ConcordRule;
-import com.walmartlabs.concord.ApiClient;
-import com.walmartlabs.concord.client.*;
+import com.walmartlabs.concord.client2.*;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -46,12 +45,12 @@ public void test() throws Exception {
String projectName = "project_" + randomString();
OrganizationsApi orgApi = new OrganizationsApi(apiClient);
- orgApi.createOrUpdate(new OrganizationEntry().setName(orgName));
+ orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName));
ProjectsApi projectsApi = new ProjectsApi(apiClient);
- projectsApi.createOrUpdate(orgName, new ProjectEntry()
- .setName(projectName)
- .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.OWNERS));
+ projectsApi.createOrUpdateProject(orgName, new ProjectEntry()
+ .name(projectName)
+ .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.OWNERS));
// ---
diff --git a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/NodeRosterIT.java b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/NodeRosterIT.java
index 83e14ddf48..fd72198018 100644
--- a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/NodeRosterIT.java
+++ b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/NodeRosterIT.java
@@ -23,9 +23,9 @@
import ca.ibodrov.concord.testcontainers.ConcordProcess;
import ca.ibodrov.concord.testcontainers.Payload;
import ca.ibodrov.concord.testcontainers.junit5.ConcordRule;
-import com.walmartlabs.concord.client.HostEntry;
-import com.walmartlabs.concord.client.NodeRosterHostsApi;
-import com.walmartlabs.concord.client.ProcessEntry;
+import com.walmartlabs.concord.client2.HostEntry;
+import com.walmartlabs.concord.client2.NodeRosterHostsApi;
+import com.walmartlabs.concord.client2.ProcessEntry;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -58,7 +58,7 @@ public void test() throws Exception {
NodeRosterHostsApi hostsApi = new NodeRosterHostsApi(concord.apiClient());
while (true) {
- List l = hostsApi.list(null, null, pe.getInstanceId(), null, 10, 0);
+ List l = hostsApi.listKnownHosts(null, null, pe.getInstanceId(), null, 10, 0);
if (!l.isEmpty()) {
break;
}
diff --git a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ProcessIT.java b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ProcessIT.java
index 24fbb7798d..cc15d48b50 100644
--- a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ProcessIT.java
+++ b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ProcessIT.java
@@ -22,12 +22,8 @@
import ca.ibodrov.concord.testcontainers.ConcordProcess;
import ca.ibodrov.concord.testcontainers.Payload;
-import ca.ibodrov.concord.testcontainers.ProcessListQuery;
import ca.ibodrov.concord.testcontainers.junit5.ConcordRule;
-import com.walmartlabs.concord.client.FormListEntry;
-import com.walmartlabs.concord.client.FormSubmitResponse;
-import com.walmartlabs.concord.client.ProcessCheckpointEntry;
-import com.walmartlabs.concord.client.ProcessEntry;
+import com.walmartlabs.concord.client2.*;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -143,7 +139,7 @@ public void testMetaUpdate() throws Exception {
data.put("action", "Reject");
FormSubmitResponse fsr = proc.submitForm(forms.get(0).getName(), data);
- assertTrue(fsr.isOk());
+ assertTrue(fsr.getOk());
pe = expectStatus(proc, ProcessEntry.StatusEnum.FINISHED);
@@ -343,7 +339,7 @@ public void testForkCheckpoints() throws Exception {
// ---
- List children = concord.processes().list(ProcessListQuery.builder()
+ List children = concord.processes().list(ProcessListFilter.builder()
.parentInstanceId(parent.instanceId())
.limit(10)
.build());
@@ -351,7 +347,7 @@ public void testForkCheckpoints() throws Exception {
assertEquals(1, children.size());
ProcessEntry fork = children.get(0);
- assertEquals(fork.getTags().get(0), forkTag);
+ assertEquals(fork.getTags().iterator().next(), forkTag);
// ---
@@ -363,7 +359,7 @@ public void testForkCheckpoints() throws Exception {
// ---
- children = concord.processes().list(ProcessListQuery.builder()
+ children = concord.processes().list(ProcessListFilter.builder()
.parentInstanceId(parent.instanceId())
.limit(10)
.build());
diff --git a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ProfilesIT.java b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ProfilesIT.java
index 0ff65c3511..d38094c748 100644
--- a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ProfilesIT.java
+++ b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ProfilesIT.java
@@ -23,9 +23,9 @@
import ca.ibodrov.concord.testcontainers.ConcordProcess;
import ca.ibodrov.concord.testcontainers.Payload;
import ca.ibodrov.concord.testcontainers.junit5.ConcordRule;
-import com.walmartlabs.concord.client.FormListEntry;
-import com.walmartlabs.concord.client.FormSubmitResponse;
-import com.walmartlabs.concord.client.ProcessEntry;
+import com.walmartlabs.concord.client2.FormListEntry;
+import com.walmartlabs.concord.client2.FormSubmitResponse;
+import com.walmartlabs.concord.client2.ProcessEntry;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -89,7 +89,7 @@ public void testFormOverride() throws Exception {
data.put("firstName", firstName);
FormSubmitResponse fsr = proc.submitForm(myForm.getName(), data);
- assertTrue(fsr.isOk());
+ assertTrue(fsr.getOk());
assertTrue(fsr.getErrors() == null || fsr.getErrors().isEmpty());
expectStatus(proc, ProcessEntry.StatusEnum.FINISHED);
diff --git a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ResourceTaskIT.java b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ResourceTaskIT.java
index a6109f3706..39dedd416c 100644
--- a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ResourceTaskIT.java
+++ b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/ResourceTaskIT.java
@@ -23,8 +23,7 @@
import ca.ibodrov.concord.testcontainers.ConcordProcess;
import ca.ibodrov.concord.testcontainers.Payload;
import ca.ibodrov.concord.testcontainers.junit5.ConcordRule;
-import com.walmartlabs.concord.ApiException;
-import com.walmartlabs.concord.client.ProcessEntry;
+import com.walmartlabs.concord.client2.*;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
diff --git a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/SessionStateFilesIT.java b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/SessionStateFilesIT.java
index 538689e059..be91f2d801 100644
--- a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/SessionStateFilesIT.java
+++ b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/SessionStateFilesIT.java
@@ -24,17 +24,15 @@
import ca.ibodrov.concord.testcontainers.Payload;
import ca.ibodrov.concord.testcontainers.Processes;
import ca.ibodrov.concord.testcontainers.junit5.ConcordRule;
-import com.walmartlabs.concord.ApiClient;
-import com.walmartlabs.concord.ApiException;
-import com.walmartlabs.concord.client.*;
+import com.walmartlabs.concord.client2.*;
import com.walmartlabs.concord.common.IOUtils;
import com.walmartlabs.concord.sdk.Constants;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
-import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
@@ -54,13 +52,13 @@ public void testSessionFileAccess() throws Exception {
String username = "user_" + randomString();
UsersApi usersApi = new UsersApi(concord.apiClient());
- CreateUserResponse user = usersApi.createOrUpdate(new CreateUserRequest()
- .setUsername(username)
- .setType(CreateUserRequest.TypeEnum.LOCAL));
+ CreateUserResponse user = usersApi.createOrUpdateUser(new CreateUserRequest()
+ .username(username)
+ .type(CreateUserRequest.TypeEnum.LOCAL));
ApiKeysApi apiKeysApi = new ApiKeysApi(concord.apiClient());
- CreateApiKeyResponse cakr = apiKeysApi.create(new CreateApiKeyRequest()
- .setUserId(user.getId()));
+ CreateApiKeyResponse cakr = apiKeysApi.createUserApiKey(new CreateApiKeyRequest()
+ .userId(user.getId()));
// ---
Payload payload = new Payload()
@@ -107,8 +105,9 @@ private static void assertCantDownloadFile(ProcessApi processApi, UUID instanceI
String fullFileName = Constants.Files.JOB_ATTACHMENTS_DIR_NAME + "/" + Constants.Files.JOB_SESSION_FILES_DIR_NAME + "/" + file;
// ---
- File state = processApi.downloadState(instanceId);
- assertNoFileInState(fullFileName, state);
+ try (InputStream state = processApi.downloadState(instanceId)) {
+ assertNoFileInState(fullFileName, state);
+ }
// ---
try {
@@ -119,9 +118,9 @@ private static void assertCantDownloadFile(ProcessApi processApi, UUID instanceI
}
}
- private static void assertNoFileInState(String file, File state) throws IOException {
+ private static void assertNoFileInState(String file, InputStream state) throws IOException {
Path target = Files.createTempDirectory("state-unzip");
- IOUtils.unzip(state.toPath(), target, false, (sourceFile, dstFile) -> {
+ IOUtils.unzip(state, target, false, (sourceFile, dstFile) -> {
assertNotEquals(file, target.relativize(dstFile).toString());
});
}
diff --git a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/SmtpIT.java b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/SmtpIT.java
index 16a84670bc..453d05f349 100644
--- a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/SmtpIT.java
+++ b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/SmtpIT.java
@@ -27,7 +27,7 @@
import ca.ibodrov.concord.testcontainers.junit5.ConcordRule;
import com.icegreen.greenmail.junit5.GreenMailExtension;
import com.icegreen.greenmail.util.ServerSetup;
-import com.walmartlabs.concord.client.ProcessEntry;
+import com.walmartlabs.concord.client2.ProcessEntry;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.testcontainers.Testcontainers;
diff --git a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/TemplateIT.java b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/TemplateIT.java
index 064bcda9db..4b0171ff4b 100644
--- a/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/TemplateIT.java
+++ b/it/runtime-v2/src/test/java/com/walmartlabs/concord/it/runtime/v2/TemplateIT.java
@@ -27,7 +27,7 @@
import com.github.tomakehurst.wiremock.client.WireMock;
import com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer;
import com.github.tomakehurst.wiremock.junit5.WireMockExtension;
-import com.walmartlabs.concord.client.*;
+import com.walmartlabs.concord.client2.*;
import com.walmartlabs.concord.common.IOUtils;
import com.walmartlabs.concord.sdk.Constants;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
@@ -79,9 +79,9 @@ public void testTemplate() throws Exception {
String templateAlias = "template_" + randomString();
TemplateAliasApi templateAliasResource = new TemplateAliasApi(concord.apiClient());
- templateAliasResource.createOrUpdate(new TemplateAliasEntry()
- .setAlias(templateAlias)
- .setUrl(templateUrl));
+ templateAliasResource.createOrUpdateTemplate(new TemplateAliasEntry()
+ .alias(templateAlias)
+ .url(templateUrl));
// ---
@@ -94,10 +94,10 @@ public void testTemplate() throws Exception {
ProjectsApi projectsApi = new ProjectsApi(concord.apiClient());
Map cfg = new HashMap<>();
cfg.put(Constants.Request.TEMPLATE_KEY, templateAlias);
- projectsApi.createOrUpdate(orgName, new ProjectEntry()
- .setName(projectName)
- .setCfg(cfg)
- .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE));
+ projectsApi.createOrUpdateProject(orgName, new ProjectEntry()
+ .name(projectName)
+ .cfg(cfg)
+ .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE));
// ---
diff --git a/it/server/pom.xml b/it/server/pom.xml
index 74ca5c19e1..1779329581 100644
--- a/it/server/pom.xml
+++ b/it/server/pom.xml
@@ -43,17 +43,17 @@
com.walmartlabs.concord
- concord-client
+ concord-client2
test
com.walmartlabs.concord.server.plugins.ansible
- concord-ansible-plugin-client
+ concord-ansible-plugin-client2
test
com.walmartlabs.concord.server.plugins.noderoster
- concord-noderoster-plugin-client
+ concord-noderoster-plugin-client2
test
@@ -168,12 +168,6 @@
2.2
test
-
- com.google.code.gson
- gson
- 2.10
- test
-
org.eclipse.jetty
jetty-util
@@ -199,12 +193,6 @@
jackson-dataformat-yaml
test
-
- com.squareup.okhttp
- okhttp
- 2.7.5
- test
-
org.jetbrains
annotations
@@ -320,7 +308,7 @@
com.walmartlabs.concord.server.plugins.noderoster
- concord-noderoster-plugin-client
+ concord-noderoster-plugin-client2
${project.version}
diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/AbstractGeneralTriggerIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/AbstractGeneralTriggerIT.java
index d3302f5b2a..1b8d7f79f6 100644
--- a/it/server/src/test/java/com/walmartlabs/concord/it/server/AbstractGeneralTriggerIT.java
+++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/AbstractGeneralTriggerIT.java
@@ -20,10 +20,8 @@
* =====
*/
-import com.walmartlabs.concord.client.ProcessApi;
-import com.walmartlabs.concord.client.ProcessEntry;
-import com.walmartlabs.concord.client.TriggerEntry;
-import com.walmartlabs.concord.client.TriggersApi;
+import com.walmartlabs.concord.client2.*;
+import com.walmartlabs.concord.client2.ProcessListFilter;
import java.util.HashMap;
import java.util.List;
@@ -37,11 +35,16 @@ public class AbstractGeneralTriggerIT extends AbstractServerIT {
protected Map waitProcesses(
String orgName, String projectName, ProcessEntry.StatusEnum first, ProcessEntry.StatusEnum... more) throws Exception {
- ProcessApi processApi = new ProcessApi(getApiClient());
+ ProcessV2Api processApi = new ProcessV2Api(getApiClient());
+
+ ProcessListFilter filter = ProcessListFilter.builder()
+ .orgName(orgName)
+ .projectName(projectName)
+ .build();
List processes;
while (true) {
- processes = processApi.list(orgName, projectName, null, null, null, null, null, null, null, null, null);
+ processes = processApi.listProcesses(filter);
if (processes.size() == 1 + (more != null ? more.length : 0)) {
break;
@@ -51,7 +54,7 @@ protected Map waitProcesses(
Map ps = new HashMap<>();
for (ProcessEntry p : processes) {
- ProcessEntry pir = waitForStatus(processApi, p.getInstanceId(), first, more);
+ ProcessEntry pir = waitForStatus(getApiClient(), p.getInstanceId(), first, more);
ProcessEntry pe = ps.put(pir.getStatus(), pir);
if (pe != null) {
throw new RuntimeException("already got process with '" + pe.getStatus() + "' status, id: " + pe.getInstanceId());
@@ -62,14 +65,14 @@ protected Map waitProcesses(
protected void assertProcessLog(ProcessEntry pir, String log) throws Exception {
assertNotNull(pir);
- byte[] ab = getLog(pir.getLogFileName());
+ byte[] ab = getLog(pir.getInstanceId());
assertLog(log, ab);
}
protected List waitForTriggers(String orgName, String projectName, String repoName, int expectedCount) throws Exception {
TriggersApi triggerResource = new TriggersApi(getApiClient());
while (true) {
- List l = triggerResource.list(orgName, projectName, repoName);
+ List l = triggerResource.listTriggers(orgName, projectName, repoName);
if (l != null && l.size() == expectedCount) {
return l;
}
diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/AbstractGitHubTriggersIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/AbstractGitHubTriggersIT.java
index fc4bc3836e..1d4647004e 100644
--- a/it/server/src/test/java/com/walmartlabs/concord/it/server/AbstractGitHubTriggersIT.java
+++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/AbstractGitHubTriggersIT.java
@@ -21,10 +21,8 @@
*/
import com.google.common.collect.ImmutableMap;
-import com.google.gson.reflect.TypeToken;
-import com.walmartlabs.concord.*;
-import com.walmartlabs.concord.client.*;
-import com.walmartlabs.concord.client.ProcessEntry.StatusEnum;
+import com.walmartlabs.concord.client2.*;
+import com.walmartlabs.concord.client2.ProcessEntry.StatusEnum;
import com.walmartlabs.concord.common.IOUtils;
import com.walmartlabs.concord.it.common.GitHubUtils;
import com.walmartlabs.concord.it.common.GitUtils;
@@ -32,22 +30,19 @@
import com.walmartlabs.concord.it.common.ServerClient;
import org.eclipse.jgit.api.Git;
-import java.lang.reflect.Type;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.time.OffsetDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.*;
-import java.util.stream.Collectors;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
public abstract class AbstractGitHubTriggersIT extends AbstractServerIT {
- private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
-
protected static String toRepoName(Path p) {
return p.getParent().getFileName() + "/" + p.getFileName();
}
@@ -66,13 +61,13 @@ protected Path initProjectAndRepo(String orgName, String projectName, String rep
ProjectsApi projectsApi = new ProjectsApi(getApiClient());
RepositoryEntry repo = new RepositoryEntry()
- .setBranch(repoBranch != null ? repoBranch : "master")
- .setUrl(bareRepo.toAbsolutePath().toString());
+ .branch(repoBranch != null ? repoBranch : "master")
+ .url(bareRepo.toAbsolutePath().toString());
- projectsApi.createOrUpdate(orgName, new ProjectEntry()
- .setName(projectName)
- .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)
- .setRepositories(ImmutableMap.of(repoName, repo)));
+ projectsApi.createOrUpdateProject(orgName, new ProjectEntry()
+ .name(projectName)
+ .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)
+ .repositories(ImmutableMap.of(repoName, repo)));
return bareRepo;
}
@@ -114,11 +109,16 @@ protected void refreshRepo(String orgName, String projectName, String repoName)
repoApi.refreshRepository(orgName, projectName, repoName, true);
}
- protected ProcessEntry waitForAProcess(String orgName, String projectName, String initiator, ProcessEntry after) throws Exception {
+ protected ProcessEntry waitForAProcess(String orgName, String projectName, String initiator) throws Exception {
ProcessV2Api processApi = new ProcessV2Api(getApiClient());
+ ProcessListFilter filter = ProcessListFilter.builder()
+ .orgName(orgName)
+ .projectName(projectName)
+ .initiator(initiator)
+ .build();
+
while (!Thread.currentThread().isInterrupted()) {
- String afterCreatedAt = after != null ? after.getCreatedAt().format(DATE_TIME_FORMATTER) : null;
- List l = processApi.list(null, orgName, null, projectName, null, null, afterCreatedAt, null, null, null, initiator, null, null, null, null);
+ List l = processApi.listProcesses(filter);
if (l.size() == 1 && isFinished(l.get(0).getStatus())) {
return l.get(0);
}
@@ -132,7 +132,7 @@ protected ProcessEntry waitForAProcess(String orgName, String projectName, Strin
protected int waitForProcessesToFinish() throws Exception {
ProcessV2Api processApi = new ProcessV2Api(getApiClient());
while (true) {
- List l = processApi.list(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
+ List l = processApi.listProcesses(ProcessListFilter.builder().build());
boolean allDone = true;
for (ProcessEntry e : l) {
@@ -157,8 +157,13 @@ protected int waitForProcessesToFinish() throws Exception {
protected void expectNoProceses(String orgName, String projectName, OffsetDateTime afterCreatedAt) throws Exception {
ProcessV2Api processApi = new ProcessV2Api(getApiClient());
- String afterCreatedAtStr = afterCreatedAt != null ? afterCreatedAt.format(DATE_TIME_FORMATTER) : null;
- List l = processApi.list(null, orgName, null, projectName, null, null, afterCreatedAtStr, null, null, null, null, null, null, null, null);
+ ProcessListFilter filter = ProcessListFilter.builder()
+ .orgName(orgName)
+ .projectName(projectName)
+ .afterCreatedAt(afterCreatedAt)
+ .build();
+
+ List l = processApi.listProcesses(filter);
assertEquals(0, l.size());
}
@@ -166,6 +171,7 @@ protected String sendEvent(String resource, String event, String... params) thro
return sendEvent(resource, event, Collections.emptyMap(), params);
}
+ @SuppressWarnings("unchecked")
protected String sendEvent(String resource, String event, Map queryParams, String... params) throws Exception {
String payload = resourceToString(resource);
if (params != null) {
@@ -177,66 +183,36 @@ protected String sendEvent(String resource, String event, Map qu
}
ApiClient client = getApiClient();
+ Map payloadMap = client.getObjectMapper().readValue(payload, Map.class);
+ payload = client.getObjectMapper().writeValueAsString(payloadMap);
+
client.addDefaultHeader("X-Hub-Signature", "sha1=" + GitHubUtils.sign(payload));
GitHubEventsApi eventsApi = new GitHubEventsApi(client);
if (queryParams.isEmpty()) {
- return eventsApi.onEvent(payload, "abc", event);
+ return eventsApi.onEvent(Collections.emptyMap(), "abc", event, payloadMap);
} else {
- return sendWithQueryParams(eventsApi, payload, event, queryParams);
+ return sendWithQueryParams(eventsApi, payloadMap, event, queryParams);
}
}
- private String sendWithQueryParams(GitHubEventsApi eventsApi, String payload, String event, Map queryParams) throws ApiException {
- String localVarPath = "/events/github/webhook";
-
- List localVarQueryParams = queryParams.entrySet().stream()
- .map(e -> new Pair(e.getKey(), e.getValue()))
- .collect(Collectors.toList());
-
- Map localVarHeaderParams = new HashMap();
- localVarHeaderParams.put("X-GitHub-Delivery", eventsApi.getApiClient().parameterToString("abc"));
- localVarHeaderParams.put("X-GitHub-Event", eventsApi.getApiClient().parameterToString(event));
-
- Map localVarFormParams = new HashMap();
-
- String[] localVarAccepts = {
- "text/plain"
- };
- String localVarAccept = eventsApi.getApiClient().selectHeaderAccept(localVarAccepts);
- if (localVarAccept == null) {
- localVarAccept = "application/vnd.siesta-validation-errors-v1+json";
- } else {
- localVarAccept += ",application/vnd.siesta-validation-errors-v1+json";
- }
- localVarHeaderParams.put("Accept", localVarAccept);
-
- String[] localVarContentTypes = {
- "application/json"
- };
- String localVarContentType = eventsApi.getApiClient().selectHeaderContentType(localVarContentTypes);
- localVarHeaderParams.put("Content-Type", localVarContentType);
-
- String[] localVarAuthNames = new String[] { };
- com.squareup.okhttp.Call call = eventsApi.getApiClient().buildCall(localVarPath, "POST", localVarQueryParams, new ArrayList<>(), payload, localVarHeaderParams, localVarFormParams, localVarAuthNames, null);
- Type localVarReturnType = new TypeToken(){}.getType();
- ApiResponse resp = eventsApi.getApiClient().execute(call, localVarReturnType);
- return resp.getData();
+ private String sendWithQueryParams(GitHubEventsApi eventsApi, Map payload, String event, Map queryParams) throws ApiException {
+ GitHubEventsApi api = new GitHubEventsApi(getApiClient());
+ return api.onEvent(queryParams, "abc", event, payload);
}
protected void assertLog(ProcessEntry entry, String pattern) throws Exception {
- byte[] ab = getLog(entry.getLogFileName());
+ byte[] ab = getLog(entry.getInstanceId());
ServerClient.assertLog(pattern, ab);
}
protected void waitForCompletion(ProcessEntry entry) throws Exception {
- ProcessApi processApi = new ProcessApi(getApiClient());
- ServerClient.waitForCompletion(processApi, entry.getInstanceId());
+ ServerClient.waitForCompletion(getApiClient(), entry.getInstanceId());
}
protected void deleteOrg(String orgName) throws Exception {
OrganizationsApi orgApi = new OrganizationsApi(getApiClient());
- orgApi.delete(orgName, "yes");
+ orgApi.deleteOrg(orgName, "yes");
}
protected static String resourceToString(String resource) throws Exception {
diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/AbstractOneOpsTriggerIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/AbstractOneOpsTriggerIT.java
index da43a86133..242864fdc1 100644
--- a/it/server/src/test/java/com/walmartlabs/concord/it/server/AbstractOneOpsTriggerIT.java
+++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/AbstractOneOpsTriggerIT.java
@@ -20,14 +20,11 @@
* =====
*/
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableMap;
-import com.squareup.okhttp.MediaType;
-import com.squareup.okhttp.*;
-import com.walmartlabs.concord.ApiClient;
-import com.walmartlabs.concord.client.*;
+import com.walmartlabs.concord.client2.*;
import com.walmartlabs.concord.common.IOUtils;
import com.walmartlabs.concord.it.common.GitUtils;
-import com.walmartlabs.concord.it.common.ServerClient;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
@@ -45,38 +42,27 @@
public abstract class AbstractOneOpsTriggerIT extends AbstractServerIT {
protected void sendOneOpsEvent(String payloadPath) throws Exception {
- ApiClient apiClient = getApiClient();
- OkHttpClient httpClient = apiClient.getHttpClient();
-
- String payload = resourceToString(payloadPath);
- HttpUrl.Builder b = HttpUrl.parse(apiClient.getBasePath() + "/api/v1/events/oneops")
- .newBuilder();
-
- Request req = new Request.Builder()
- .url(b.build())
- .post(RequestBody.create(MediaType.parse("application/json"), payload))
- .header("Authorization", ServerClient.DEFAULT_API_KEY)
- .build();
-
- Response resp = httpClient.newCall(req).execute();
- if (!resp.isSuccessful()) {
- throw new RuntimeException("Request failed: " + resp);
- }
+ ExternalEventsApi api = new ExternalEventsApi(getApiClient());
+
+ api.externalEvent("oneops", resourceToMap(payloadPath));
}
protected void assertProcessLog(ProcessEntry pir, String log) throws Exception {
assertNotNull(pir);
- byte[] ab = getLog(pir.getLogFileName());
+ byte[] ab = getLog(pir.getInstanceId());
assertLog(log, ab);
}
protected Map waitProcesses(
String orgName, String projectName, ProcessEntry.StatusEnum first, ProcessEntry.StatusEnum... more) throws Exception {
- ProcessApi processApi = new ProcessApi(getApiClient());
+ ProcessV2Api processApi = new ProcessV2Api(getApiClient());
List processes;
while (true) {
- processes = processApi.list(orgName, projectName, null, null, null, null, null, null, null, null, null);
+ processes = processApi.listProcesses(ProcessListFilter.builder()
+ .orgName(orgName)
+ .projectName(projectName)
+ .build());
if (processes.size() == 1 + (more != null ? more.length : 0)) {
break;
}
@@ -85,7 +71,7 @@ protected Map waitProcesses(
Map ps = new HashMap<>();
for (ProcessEntry p : processes) {
- ProcessEntry pir = waitForStatus(processApi, p.getInstanceId(), first, more);
+ ProcessEntry pir = waitForStatus(getApiClient(), p.getInstanceId(), first, more);
ProcessEntry pe = ps.put(pir.getStatus(), pir);
if (pe != null) {
throw new RuntimeException("already got process with '" + pe.getStatus() + "' status, id: " + pe.getInstanceId());
@@ -95,7 +81,7 @@ protected Map waitProcesses(
}
protected static String resourceToString(String resource) throws Exception {
- URL url = OneOpsTriggerITV2.class.getResource(resource);
+ URL url = AbstractOneOpsTriggerIT.class.getResource(resource);
ByteArrayOutputStream out = new ByteArrayOutputStream();
try (InputStream in = url.openStream()) {
@@ -105,6 +91,14 @@ protected static String resourceToString(String resource) throws Exception {
return new String(out.toByteArray());
}
+ @SuppressWarnings("unchecked")
+ protected static Map resourceToMap(String resource) throws Exception {
+ URL url = AbstractOneOpsTriggerIT.class.getResource(resource);
+ try (InputStream in = url.openStream()) {
+ return new ObjectMapper().readValue(in, Map.class);
+ }
+ }
+
protected void refreshRepo(String orgName, String projectName, String repoName) throws Exception {
RepositoriesApi repoApi = new RepositoriesApi(getApiClient());
repoApi.refreshRepository(orgName, projectName, repoName, true);
@@ -119,14 +113,14 @@ protected Path initProjectAndRepo(String orgName, String projectName, String rep
ProjectsApi projectsApi = new ProjectsApi(getApiClient());
RepositoryEntry repo = new RepositoryEntry()
- .setBranch("master")
- .setUrl(bareRepo.toAbsolutePath().toString());
+ .branch("master")
+ .url(bareRepo.toAbsolutePath().toString());
- projectsApi.createOrUpdate(orgName, new ProjectEntry()
- .setName(projectName)
- .setVisibility(ProjectEntry.VisibilityEnum.PUBLIC)
- .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)
- .setRepositories(ImmutableMap.of(repoName, repo)));
+ projectsApi.createOrUpdateProject(orgName, new ProjectEntry()
+ .name(projectName)
+ .visibility(ProjectEntry.VisibilityEnum.PUBLIC)
+ .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)
+ .repositories(ImmutableMap.of(repoName, repo)));
return bareRepo;
}
@@ -134,7 +128,7 @@ protected Path initProjectAndRepo(String orgName, String projectName, String rep
protected List waitForTriggers(String orgName, String projectName, String repoName, int expectedCount) throws Exception {
TriggersApi triggerResource = new TriggersApi(getApiClient());
while (true) {
- List l = triggerResource.list(orgName, projectName, repoName);
+ List l = triggerResource.listTriggers(orgName, projectName, repoName);
if (l != null && l.size() == expectedCount) {
return l;
diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/AbstractServerIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/AbstractServerIT.java
index 9d715ed5c0..ca05a3e99d 100644
--- a/it/server/src/test/java/com/walmartlabs/concord/it/server/AbstractServerIT.java
+++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/AbstractServerIT.java
@@ -20,10 +20,10 @@
* =====
*/
-import com.walmartlabs.concord.ApiClient;
-import com.walmartlabs.concord.ApiException;
-import com.walmartlabs.concord.client.SecretOperationResponse;
-import com.walmartlabs.concord.client.StartProcessResponse;
+import com.walmartlabs.concord.client2.ApiClient;
+import com.walmartlabs.concord.client2.ApiException;
+import com.walmartlabs.concord.client2.SecretOperationResponse;
+import com.walmartlabs.concord.client2.StartProcessResponse;
import com.walmartlabs.concord.common.IOUtils;
import com.walmartlabs.concord.it.common.ITUtils;
import com.walmartlabs.concord.it.common.JGitUtils;
@@ -140,8 +140,8 @@ protected SecretOperationResponse generateKeyPairWithProjectIds(String orgName,
return serverClient.generateKeyPair(orgName, null, projectIds, name, generatePassword, storePassword);
}
- protected byte[] getLog(String logFileName) throws ApiException {
- return serverClient.getLog(logFileName);
+ protected byte[] getLog(UUID instanceId) throws ApiException {
+ return serverClient.getLog(instanceId);
}
protected void resetApiKey() {
@@ -156,12 +156,8 @@ protected void setGithubKey(String key) {
serverClient.setGithubKey(key);
}
- protected void waitForLog(String logFileName, String pattern) throws IOException, InterruptedException, ApiException {
- serverClient.waitForLog(logFileName, pattern);
- }
-
- protected T request(String uri, Map input, Class entityType) throws ApiException {
- return serverClient.request(uri, input, entityType);
+ protected void waitForLog(UUID instanceId, String pattern) throws IOException, InterruptedException, ApiException {
+ serverClient.waitForLog(instanceId, pattern);
}
protected static String randomString() {
@@ -187,10 +183,17 @@ protected Map fromJson(File f) throws IOException {
return fromJson(f, Map.class);
}
+ @SuppressWarnings("unchecked")
+ protected Map fromJson(InputStream is) throws IOException {
+ return getApiClient().getObjectMapper().readValue(is, Map.class);
+ }
+
protected T fromJson(File f, Class classOfT) throws IOException {
- try (Reader r = new FileReader(f)) {
- return getApiClient().getJSON().getGson().fromJson(r, classOfT);
- }
+ return getApiClient().getObjectMapper().readValue(f, classOfT);
+ }
+
+ protected T fromJson(InputStream is, Class classOfT) throws IOException {
+ return getApiClient().getObjectMapper().readValue(is, classOfT);
}
protected String createRepo(String resource) throws Exception {
diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleEventIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleEventIT.java
index 24a0177bca..3a04033513 100644
--- a/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleEventIT.java
+++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleEventIT.java
@@ -20,7 +20,7 @@
* =====
*/
-import com.walmartlabs.concord.client.*;
+import com.walmartlabs.concord.client2.*;
import org.junit.jupiter.api.Test;
import java.net.URI;
@@ -37,23 +37,22 @@ public class AnsibleEventIT extends AbstractServerIT {
@Test
@SuppressWarnings("unchecked")
public void testEvent() throws Exception {
- URI uri = ProcessIT.class.getResource("ansibleEvent").toURI();
+ URI uri = AnsibleEventIT.class.getResource("ansibleEvent").toURI();
byte[] payload = archive(uri, ITConstants.DEPENDENCIES_DIR);
// ---
- ProcessApi processApi = new ProcessApi(getApiClient());
StartProcessResponse spr = start(payload);
// ---
- ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId());
+ ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId());
assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus());
// ---
ProcessEventsApi eventsApi = new ProcessEventsApi(getApiClient());
- List l = eventsApi.list(pir.getInstanceId(), null, null, null, null, null, null, -1);
+ List l = eventsApi.listProcessEvents(pir.getInstanceId(), null, null, null, null, null, null, -1);
assertFalse(l.isEmpty());
long cnt = l.stream().filter(e -> {
@@ -81,23 +80,22 @@ public void testEvent() throws Exception {
@Test
public void testIgnoredFailures() throws Exception {
- URI uri = ProcessIT.class.getResource("ansibleIgnoredFailures").toURI();
+ URI uri = AnsibleEventIT.class.getResource("ansibleIgnoredFailures").toURI();
byte[] payload = archive(uri, ITConstants.DEPENDENCIES_DIR);
// ---
- ProcessApi processApi = new ProcessApi(getApiClient());
StartProcessResponse spr = start(payload);
// ---
- ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId());
+ ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId());
assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus());
// ---
ProcessEventsApi eventsApi = new ProcessEventsApi(getApiClient());
- List l = eventsApi.list(pir.getInstanceId(), null, null, null, null, null, null, -1);
+ List l = eventsApi.listProcessEvents(pir.getInstanceId(), null, null, null, null, null, null, -1);
assertFalse(l.isEmpty());
long cnt = l.stream().filter(e -> {
@@ -124,26 +122,25 @@ public void testIgnoredFailures() throws Exception {
*/
@Test
public void testFailedHosts() throws Exception {
- URI uri = ProcessIT.class.getResource("ansibleFailedHosts").toURI();
+ URI uri = AnsibleEventIT.class.getResource("ansibleFailedHosts").toURI();
byte[] payload = archive(uri, ITConstants.DEPENDENCIES_DIR);
// ---
StartProcessResponse spr = start(payload);
- ProcessApi processApi = new ProcessApi(getApiClient());
- ProcessEntry pe = waitForCompletion(processApi, spr.getInstanceId());
+ ProcessEntry pe = waitForCompletion(getApiClient(), spr.getInstanceId());
assertEquals(ProcessEntry.StatusEnum.FAILED, pe.getStatus());
// ---
- byte[] ab = getLog(pe.getLogFileName());
+ byte[] ab = getLog(pe.getInstanceId());
assertLog(".*'msg' is undefined.*", ab);
// ---
ProcessEventsApi eventsApi = new ProcessEventsApi(getApiClient());
- List l = eventsApi.list(pe.getInstanceId(), "ANSIBLE", null, null, null, "post", null, -1);
+ List l = eventsApi.listProcessEvents(pe.getInstanceId(), "ANSIBLE", null, null, null, "post", null, -1);
assertFalse(l.isEmpty());
for (ProcessEventEntry e : l) {
diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleEventProcessorIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleEventProcessorIT.java
index 2cb9f623e4..6abf241652 100644
--- a/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleEventProcessorIT.java
+++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleEventProcessorIT.java
@@ -20,7 +20,7 @@
* =====
*/
-import com.walmartlabs.concord.client.*;
+import com.walmartlabs.concord.client2.*;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -37,17 +37,16 @@ public class AnsibleEventProcessorIT extends AbstractServerIT {
@Test
public void test() throws Exception {
- URI uri = ProcessIT.class.getResource("ansibleEventProcessor").toURI();
+ URI uri = AnsibleEventProcessorIT.class.getResource("ansibleEventProcessor").toURI();
byte[] payload = archive(uri, ITConstants.DEPENDENCIES_DIR);
// ---
- ProcessApi processApi = new ProcessApi(getApiClient());
StartProcessResponse spr = start(payload);
// ---
- ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId());
+ ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId());
Assertions.assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus());
// ---
@@ -66,17 +65,16 @@ public void test() throws Exception {
@Test
public void testLongNames() throws Exception {
- URI uri = ProcessIT.class.getResource("ansibleEventProcessor").toURI();
+ URI uri = AnsibleEventProcessorIT.class.getResource("ansibleEventProcessor").toURI();
byte[] payload = archive(uri, ITConstants.DEPENDENCIES_DIR);
// ---
- ProcessApi processApi = new ProcessApi(getApiClient());
StartProcessResponse spr = start("emitLongNames", payload);
// ---
- ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId());
+ ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId());
Assertions.assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus());
// ---
diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleIT.java
index b87cd4a44b..b55f1ec803 100644
--- a/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleIT.java
+++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleIT.java
@@ -21,7 +21,7 @@
*/
import com.google.common.io.Files;
-import com.walmartlabs.concord.client.*;
+import com.walmartlabs.concord.client2.*;
import com.walmartlabs.concord.common.ConfigurationUtils;
import org.junit.jupiter.api.Test;
@@ -49,17 +49,16 @@ public void testHello() throws Exception {
// ---
- ProcessApi processApi = new ProcessApi(getApiClient());
StartProcessResponse spr = start(payload);
// ---
- ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId());
+ ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId());
assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus());
// ---
- byte[] ab = getLog(pir.getLogFileName());
+ byte[] ab = getLog(pir.getInstanceId());
assertLog(".*\"msg\":.*Hello, world.*", ab);
}
@@ -70,17 +69,16 @@ public void testSkipTags() throws Exception {
// ---
- ProcessApi processApi = new ProcessApi(getApiClient());
StartProcessResponse spr = start(payload);
// ---
- ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId());
+ ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId());
assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus());
// ---
- byte[] ab = getLog(pir.getLogFileName());
+ byte[] ab = getLog(pir.getInstanceId());
assertLog(".*\"msg\":.*Hello2, world.*", ab);
assertEquals(0, grep(".*Hello, world.*", ab).size(), "unexpected 'Hello, world' log");
}
@@ -92,19 +90,16 @@ public void testVault() throws Exception {
// ---
- ProcessApi processApi = new ProcessApi(getApiClient());
StartProcessResponse spr = start(payload);
// ---
- ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId());
-
- assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus(),
- new String(getLog(pir.getLogFileName())));
+ ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId());
+ assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus());
// ---
- byte[] ab = getLog(pir.getLogFileName());
+ byte[] ab = getLog(pir.getInstanceId());
assertLog(".*Hello, Concord.*", ab);
}
@@ -115,17 +110,16 @@ public void testVaultWithMultiplePasswords() throws Exception {
// ---
- ProcessApi processApi = new ProcessApi(getApiClient());
StartProcessResponse spr = start(payload);
// ---
- ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId());
+ ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId());
assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus());
// ---
- byte[] ab = getLog(pir.getLogFileName());
+ byte[] ab = getLog(pir.getInstanceId());
assertLog(".*Hello, Concord.*", ab);
}
@@ -136,17 +130,16 @@ public void testVaultWithMultiplePasswordFiles() throws Exception {
// ---
- ProcessApi processApi = new ProcessApi(getApiClient());
StartProcessResponse spr = start(payload);
// ---
- ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId());
+ ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId());
assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus());
// ---
- byte[] ab = getLog(pir.getLogFileName());
+ byte[] ab = getLog(pir.getInstanceId());
assertLog(".*Hello, Concord.*", ab);
}
@@ -165,29 +158,30 @@ public void testTwoAnsibleRuns() throws Exception {
// ---
ProcessApi processApi = new ProcessApi(getApiClient());
- ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId());
+ ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId());
assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus());
// ---
- byte[] ab = getLog(pir.getLogFileName());
+ byte[] ab = getLog(pir.getInstanceId());
assertLog(".*\"msg\":.*Hello!.*", ab);
assertLog(".*\"msg\":.*Bye-bye!.*", ab);
// ---
- File resp = processApi.downloadAttachment(spr.getInstanceId(), "ansible_stats_v2.json");
- assertNotNull(resp);
+ try (InputStream resp = processApi.downloadAttachment(spr.getInstanceId(), "ansible_stats_v2.json")) {
+ assertNotNull(resp);
- List