From e7bcfc41bec2d02eba30e0238ff6fe91295b5649 Mon Sep 17 00:00:00 2001 From: Yury Brigadirenko Date: Wed, 27 Dec 2023 14:36:53 +0100 Subject: [PATCH] project: switch to concord-client2 (#821) --- agent/pom.xml | 7 +- .../com/walmartlabs/concord/agent/Agent.java | 2 +- .../concord/agent/DefaultStateFetcher.java | 34 +- .../concord/agent/RepositoryManager.java | 2 +- .../com/walmartlabs/concord/agent/Worker.java | 2 +- .../concord/agent/cfg/AgentConfiguration.java | 8 + .../concord/agent/cfg/GitConfiguration.java | 2 - ...ependencyManagerConfigurationProvider.java | 1 + .../concord/agent/guice/WorkerModule.java | 4 +- .../agent/logging/LogSegmentStats.java | 2 +- .../agent/logging/RemoteLogAppender.java | 30 +- .../agent/logging/SegmentedLogsConsumer.java | 2 +- .../agent/remote/ApiClientFactory.java | 92 ++-- .../agent/remote/AttachmentsUploader.java | 8 +- .../agent/remote/ProcessStatusUpdater.java | 5 +- agent/src/main/resources/concord-agent.conf | 3 + client/pom.xml | 13 + .../concord/client/ApiClientFactoryImpl.java | 120 +++++ .../client/ApiClientFactoryProvider.java | 54 ++ .../concord/client/ApiClientProvider.java | 53 ++ .../concord/client/CreateSecretRequestV2.java | 1 - client2/pom.xml | 23 +- .../concord/client2/impl/HttpEntity.java | 1 - .../libraries/native/ApiClient.mustache | 2 +- .../template/libraries/native/api.mustache | 92 ---- .../template/libraries/native/pojo.mustache | 2 +- .../concord/client2/ApiClientJsonTest.java | 11 + .../dependencymanager/DependencyManager.java | 63 ++- .../DependencyManagerConfiguration.java | 5 + docker-images/agent/pom.xml | 2 +- it/common/pom.xml | 12 +- .../concord/it/common/ServerClient.java | 84 ++-- it/compat/pom.xml | 2 +- .../concord/it/compat/LocalModeIT.java | 2 +- .../concord/it/compat/OldAgentIT.java | 2 +- it/console/pom.xml | 14 +- .../concord/it/console/ConcordServerRule.java | 54 +- .../concord/it/console/CustomFormsIT.java | 22 +- .../concord/it/console/FormsIT.java | 23 +- it/runtime-v1/pom.xml | 2 +- .../concord/it/runtime/v1/ProcessIT.java | 17 +- it/runtime-v2/pom.xml | 4 +- .../concord/it/runtime/v2/AbstractTest.java | 3 +- .../concord/it/runtime/v2/ConcordTaskIT.java | 14 +- .../concord/it/runtime/v2/CryptoIT.java | 21 +- .../concord/it/runtime/v2/FlowEventsIT.java | 8 +- .../concord/it/runtime/v2/FormIT.java | 18 +- .../it/runtime/v2/GitHubTriggersV2IT.java | 30 +- .../concord/it/runtime/v2/ImportsIT.java | 2 +- .../concord/it/runtime/v2/JsonStoreIT.java | 13 +- .../concord/it/runtime/v2/KvTaskIT.java | 11 +- .../concord/it/runtime/v2/NodeRosterIT.java | 8 +- .../concord/it/runtime/v2/ProcessIT.java | 14 +- .../concord/it/runtime/v2/ProfilesIT.java | 8 +- .../concord/it/runtime/v2/ResourceTaskIT.java | 3 +- .../it/runtime/v2/SessionStateFilesIT.java | 25 +- .../concord/it/runtime/v2/SmtpIT.java | 2 +- .../concord/it/runtime/v2/TemplateIT.java | 16 +- it/server/pom.xml | 20 +- .../it/server/AbstractGeneralTriggerIT.java | 21 +- .../it/server/AbstractGitHubTriggersIT.java | 102 ++-- .../it/server/AbstractOneOpsTriggerIT.java | 64 ++- .../concord/it/server/AbstractServerIT.java | 33 +- .../concord/it/server/AnsibleEventIT.java | 25 +- .../it/server/AnsibleEventProcessorIT.java | 12 +- .../concord/it/server/AnsibleIT.java | 161 +++--- .../concord/it/server/AnsibleLookupIT.java | 65 ++- .../concord/it/server/AnsiblePolicyIT.java | 28 +- .../server/AnsiblePolicyVerboseLimitIT.java | 51 +- .../concord/it/server/AnsibleProjectIT.java | 75 ++- .../concord/it/server/AnsibleRetryIT.java | 15 +- .../concord/it/server/ApiKeyIT.java | 25 +- .../concord/it/server/AttachmentRbacIT.java | 102 ++-- .../concord/it/server/CheckpointsIT.java | 86 ++-- .../it/server/ClasspathIsolationIT.java | 10 +- .../concord/it/server/ClasspathRepoIT.java | 23 +- .../server/ConcordTaskForkFromGitRepoIT.java | 31 +- .../concord/it/server/ConcordTaskIT.java | 243 +++++---- .../it/server/ConfigurableResourcesIT.java | 29 +- .../walmartlabs/concord/it/server/CronIT.java | 76 +-- .../walmartlabs/concord/it/server/CrudIT.java | 461 +++++++++-------- .../concord/it/server/CryptoIT.java | 134 +++-- .../it/server/DefaultProcessVariablesIT.java | 17 +- .../concord/it/server/DependenciesIT.java | 17 +- .../it/server/DependencyManagerIT.java | 10 +- .../concord/it/server/DispatcherIT.java | 18 +- .../concord/it/server/DockerAnsibleIT.java | 21 +- .../concord/it/server/DockerIT.java | 44 +- .../concord/it/server/DynamicFormIT.java | 19 +- .../concord/it/server/DynamicTaskIT.java | 10 +- .../it/server/EntityOwnerPolicyIT.java | 39 +- .../it/server/EscapeGitCommitMessageIT.java | 21 +- .../concord/it/server/ExclusiveProcessIT.java | 20 +- .../it/server/ExpressionResolveOrderIT.java | 12 +- .../concord/it/server/ExternalImportsIT.java | 107 ++-- .../concord/it/server/FailureHandlingIT.java | 60 +-- .../concord/it/server/FilePermissionsIT.java | 10 +- .../concord/it/server/ForceSuspendIT.java | 16 +- .../walmartlabs/concord/it/server/FormIT.java | 173 ++++--- .../concord/it/server/GeneralTriggerIT.java | 62 +-- .../concord/it/server/GeneralTriggerV2IT.java | 31 +- .../concord/it/server/GitBranchesIT.java | 37 +- .../it/server/GitHubNonOrgEventIt.java | 43 +- .../concord/it/server/GitHubTriggersV2IT.java | 90 ++-- .../concord/it/server/GitRepositoryIT.java | 19 +- .../concord/it/server/GroovyIT.java | 17 +- .../concord/it/server/HttpTaskIT.java | 105 ++-- .../concord/it/server/InitiatorIT.java | 17 +- .../concord/it/server/InventoryIT.java | 25 +- .../concord/it/server/InventoryQueryIT.java | 58 ++- .../concord/it/server/JsonStoreIT.java | 45 +- .../concord/it/server/JsonStoreTaskIT.java | 32 +- .../concord/it/server/KvPolicyIT.java | 27 +- .../concord/it/server/KvServiceIT.java | 38 +- .../walmartlabs/concord/it/server/LdapIT.java | 25 +- .../it/server/MultipleProjectFilesIT.java | 12 +- .../concord/it/server/NodeRosterIT.java | 29 +- .../concord/it/server/OneOpsTriggerIT.java | 18 +- .../concord/it/server/OneOpsTriggerITV2.java | 17 +- .../concord/it/server/OutVariablesIT.java | 21 +- .../it/server/OutVariablesProjectIT.java | 35 +- .../concord/it/server/PermissionIT.java | 100 ++-- .../concord/it/server/PolicyIT.java | 116 ++--- .../concord/it/server/PortalIT.java | 31 +- .../it/server/PrincipalPermissionIT.java | 16 +- .../concord/it/server/ProcessContainerIT.java | 12 +- .../concord/it/server/ProcessCountIT.java | 41 +- .../concord/it/server/ProcessEventsIT.java | 50 +- .../concord/it/server/ProcessIT.java | 142 +++--- .../concord/it/server/ProcessLocksIT.java | 23 +- .../concord/it/server/ProcessMetadataIT.java | 64 +-- .../concord/it/server/ProcessRbacIT.java | 54 +- .../concord/it/server/ProcessStateIT.java | 17 +- .../concord/it/server/ProjectDeleteIT.java | 24 +- .../concord/it/server/ProjectFileIT.java | 37 +- .../concord/it/server/ProjectIT.java | 104 ++-- .../concord/it/server/ProjectInfoIT.java | 13 +- .../concord/it/server/ProjectTaskIT.java | 12 +- .../concord/it/server/PublicFlowsIT.java | 20 +- .../it/server/RawPayloadProjectIT.java | 11 +- .../it/server/RepositoryRefreshIT.java | 7 +- .../concord/it/server/RequirementsIT.java | 23 +- .../concord/it/server/ResourceIT.java | 10 +- .../concord/it/server/RunAsIT.java | 95 ++-- .../concord/it/server/SecretIT.java | 173 +++---- .../concord/it/server/SecretProjectsIT.java | 63 ++- .../concord/it/server/SecretsTaskIT.java | 15 +- .../concord/it/server/SerializationIT.java | 20 +- .../walmartlabs/concord/it/server/SmtpIT.java | 13 +- .../concord/it/server/SuspendIT.java | 43 +- .../concord/it/server/TaskRetryIT.java | 20 +- .../concord/it/server/TeamRbacIT.java | 471 +++++++++--------- .../concord/it/server/TemplateIT.java | 56 +-- .../concord/it/server/TemplateMergeIT.java | 15 +- .../it/server/ThrowExceptionTaskIT.java | 15 +- .../concord/it/server/TimeoutHandlingIT.java | 12 +- .../concord/it/server/TriggerIT.java | 49 +- .../concord/it/server/TriggersRefreshIT.java | 38 +- .../concord/it/server/UserManagementIT.java | 71 ++- .../concord/it/server/ValidationIT.java | 18 +- .../concord/it/server/VariablesIT.java | 53 +- .../it/server/VariablesInjectionIT.java | 10 +- .../concord/it/server/WithItemsIT.java | 47 +- .../concord/it/server/WorkspacePolicyIT.java | 28 +- .../it/tasks/suspendtest/Client1TestTask.java | 1 - plugins/tasks/ansible/pom.xml | 2 +- .../plugins/ansible/AnsibleCallbacks.java | 2 +- .../concord/plugins/ansible/AnsibleTask.java | 3 +- .../concord/plugins/ansible/EventSender.java | 6 +- .../plugins/ansible/v1/AnsibleTaskV1.java | 2 +- .../plugins/ansible/v1/RunPlaybookTask2.java | 8 +- .../plugins/ansible/v2/AnsibleTaskV2.java | 4 +- plugins/tasks/concord/pom.xml | 7 +- .../concord/client/AbstractConcordTask.java | 76 +-- .../concord/client/ConcordTask.java | 29 +- .../concord/client/ConcordTaskCommon.java | 26 +- .../concord/client/InventoryTask.java | 3 +- .../concord/client/JsonStoreTaskCommon.java | 23 +- .../concord/client/ProjectTaskCommon.java | 4 +- .../concord/client/ProjectTaskParams.java | 1 + .../client/RepositoryRefreshTaskCommon.java | 5 +- .../concord/client/RequestUtils.java | 127 ----- .../concord/client/SecretsTask.java | 8 +- .../concord/client/SecretsTaskCommon.java | 40 +- .../concord/client/SecretsTaskParams.java | 7 +- .../concord/client/v2/ConcordTaskV2.java | 1 + .../concord/client/v2/JsonStoreTaskV2.java | 2 +- .../concord/client/v2/ProjectTaskV2.java | 2 +- .../client/v2/RepositoryRefreshTaskV2.java | 2 +- .../concord/client/v2/SecretsTaskV2.java | 2 +- .../concord/plugins/file/v2/FilesTaskV2.java | 1 - plugins/tasks/kv/pom.xml | 2 +- .../concord/plugins/kv/KvTask.java | 8 +- .../concord/plugins/kv/KvTaskUtils.java | 16 +- .../concord/plugins/kv/KvTaskV2.java | 4 +- plugins/tasks/lock/pom.xml | 2 +- .../concord/plugins/lock/LockTask.java | 17 +- .../concord/plugins/lock/LockTaskCommon.java | 6 +- .../concord/plugins/lock/v2/LockTaskV2.java | 2 +- .../concord/plugins/lock/v2/UnlockTaskV2.java | 2 +- .../concord/plugins/log/LoggingTaskV2.java | 1 - plugins/tasks/noderoster/pom.xml | 4 +- .../plugins/noderoster/NodeRosterTask.java | 3 +- .../noderoster/NodeRosterTaskUtils.java | 6 +- .../plugins/noderoster/NodeRosterTaskV2.java | 3 +- .../plugins/resource/ResourceTaskCommon.java | 5 +- plugins/tasks/sleep/pom.xml | 2 +- .../concord/plugins/sleep/SleepTask.java | 8 +- .../concord/plugins/sleep/Suspender.java | 8 +- .../concord/plugins/sleep/v2/SleepTaskV2.java | 2 +- .../concord/policyengine/RuntimePolicy.java | 1 - .../concord/policyengine/RuntimeRule.java | 1 - pom.xml | 4 +- .../repository/GitClientFetchTest.java | 2 - runtime/common/pom.xml | 2 +- .../runtime/common/ProcessHeartbeat.java | 6 +- .../common/cfg/LoggingConfiguration.java | 2 - .../process/loader/model/SourceMap.java | 1 - runtime/v1/impl/pom.xml | 16 +- .../concord/runner/ApiClientFactoryImpl.java | 91 +--- .../runner/ApiClientFactoryProvider.java | 8 +- .../concord/runner/LockServiceImpl.java | 19 +- .../com/walmartlabs/concord/runner/Main.java | 12 +- .../concord/runner/ObjectStorageImpl.java | 16 +- .../concord/runner/ProcessApiClient.java | 14 +- .../concord/runner/SecretServiceImpl.java | 61 +-- .../concord/runner/WorkingDirectory.java | 36 -- .../engine/DefaultElementEventProcessor.java | 9 +- .../concord/runner/engine/EngineFactory.java | 2 +- .../engine/ProcessMetadataProcessor.java | 11 +- runtime/v2/runner/pom.xml | 7 +- .../runtime/v2/runner/DefaultLockService.java | 10 +- .../v2/runner/DefaultSecretService.java | 27 +- .../concord/runtime/v2/runner/Main.java | 2 +- .../runtime/v2/runner/MetadataProcessor.java | 5 +- .../v2/runner/StackTraceCollector.java | 1 - .../DefaultCheckpointUploader.java | 5 +- .../v2/runner/guice/DefaultRunnerModule.java | 2 +- .../runner/logging/DefaultLoggingClient.java | 20 +- .../v2/runner/remote/ApiClientProvider.java | 6 +- .../remote/DefaultProcessStatusCallback.java | 10 +- .../EventRecordingExecutionListener.java | 8 +- .../TaskCallEventRecordingListener.java | 8 +- .../v2/runner/sdk/ApiClientFactoryImpl.java | 65 +-- .../v2/runner/sdk/ApiConfigurationV1Impl.java | 59 +++ .../v2/runner/vm/CopyVariablesCommand.java | 2 +- .../concord/runtime/v2/runner/MainTest.java | 2 + .../runner/tasks/TaskCallInterceptorTest.java | 20 + server/impl/pom.xml | 1 - .../filters/ConcordAuthenticationHandler.java | 1 - .../server/org/secret/SecretResource.java | 7 +- .../org/secret/SecretResourceUtils.java | 1 - .../server/org/secret/SecretResourceV2.java | 5 +- .../store/concord/ConcordSecretStore.java | 2 - .../server/process/ProcessResource.java | 3 +- .../checkpoint/ProcessCheckpointResource.java | 6 +- .../ProcessCheckpointV2Resource.java | 2 - .../process/event/ProcessEventResource.java | 3 - .../server/process/form/FormResource.java | 3 +- .../server/process/form/FormResourceV1.java | 3 - .../server/process/form/FormResourceV2.java | 2 - .../server/process/locks/LockResult.java | 2 - .../server/process/locks/ProcessLocksDao.java | 1 - .../process/locks/ProcessLocksResource.java | 2 - .../server/process/logs/ProcessLogsDao.java | 1 - .../process/waits/ProcessWaitManager.java | 2 - .../waits/WaitProcessStatusListener.java | 2 - .../server/security/ldap/UserLdapGroup.java | 1 - .../concord/server/user/UserResourceV2.java | 1 - .../plugins/pfedsso/RedirectHelper.java | 1 - .../plugins/pfedsso/SsoConfiguration.java | 3 - .../concord/server/sdk/ProcessKey.java | 2 - targetplatform/pom.xml | 2 +- 273 files changed, 3619 insertions(+), 4149 deletions(-) create mode 100644 client/src/main/java/com/walmartlabs/concord/client/ApiClientFactoryImpl.java create mode 100644 client/src/main/java/com/walmartlabs/concord/client/ApiClientFactoryProvider.java create mode 100644 client/src/main/java/com/walmartlabs/concord/client/ApiClientProvider.java delete mode 100644 plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/RequestUtils.java delete mode 100644 runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/WorkingDirectory.java create mode 100644 runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/sdk/ApiConfigurationV1Impl.java 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> stats = fromJson(resp, List.class); + List> stats = fromJson(resp, List.class); - assertEquals(2, stats.size()); + assertEquals(2, stats.size()); - assertEquals("playbook/hello.yml", stats.get(0).get("playbook")); - Collection oks = (Collection)ConfigurationUtils.get(stats.get(0), "stats", "ok"); - assertNotNull(oks); - assertEquals(1, oks.size()); - assertEquals("127.0.0.1", oks.iterator().next()); + assertEquals("playbook/hello.yml", stats.get(0).get("playbook")); + Collection oks = (Collection)ConfigurationUtils.get(stats.get(0), "stats", "ok"); + assertNotNull(oks); + assertEquals(1, oks.size()); + assertEquals("127.0.0.1", oks.iterator().next()); + } } @Test @@ -203,25 +197,24 @@ public void testWithForm() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); + ProcessEntry pir = waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); // --- ProcessFormsApi formsApi = new ProcessFormsApi(getApiClient()); - List forms = formsApi.list(pir.getInstanceId()); + List forms = formsApi.listProcessForms(pir.getInstanceId()); assertEquals(1, forms.size()); - formsApi.submit(pir.getInstanceId(), forms.get(0).getName(), Collections.singletonMap("msg", "Hello!")); + formsApi.submitForm(pir.getInstanceId(), forms.get(0).getName(), Collections.singletonMap("msg", "Hello!")); // --- - pir = waitForCompletion(processApi, spr.getInstanceId()); + 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); } @@ -245,25 +238,24 @@ public void testWithFormSuspensionPostAnsible() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); + ProcessEntry pir = waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); // --- ProcessFormsApi formsApi = new ProcessFormsApi(getApiClient()); - List forms = formsApi.list(pir.getInstanceId()); + List forms = formsApi.listProcessForms(pir.getInstanceId()); assertEquals(1, forms.size()); - formsApi.submit(pir.getInstanceId(), forms.get(0).getName(), Collections.singletonMap("msg", "Hello!")); + formsApi.submitForm(pir.getInstanceId(), forms.get(0).getName(), Collections.singletonMap("msg", "Hello!")); // --- - pir = waitForCompletion(processApi, spr.getInstanceId()); + pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus()); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Hello!.*", ab); } @@ -284,10 +276,7 @@ public void testExtenalPlaybook() 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()); } @@ -304,15 +293,12 @@ public void testMergeDefaults() 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(".*_callbacks:myCallbackDir.*", ab); } @@ -320,7 +306,7 @@ public void testMergeDefaults() throws Exception { public void testGroupVars() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- @@ -342,13 +328,12 @@ public void testGroupVars() 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\":.*Hi there!.*", ab); } @@ -359,17 +344,16 @@ public void testOutVars() 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\":.*First hello from ansible.*", ab); assertLog(".*\"msg\":.*Second message.*", ab); } @@ -381,17 +365,16 @@ public void testStats() 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(".*OK:.*127.0.0.1.*", ab); } @@ -402,17 +385,16 @@ public void testBadStrings() 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(".*THIS TASK CONTAINS SENSITIVE INFORMATION.*", ab); } @@ -423,17 +405,16 @@ public void testRawStrings() 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(".*" + Pattern.quote("message '{{.lalala}}'") + ".*", ab); assertLog(".*" + Pattern.quote("message {{.unsafe}}") + ".*", ab); } @@ -446,22 +427,21 @@ public void testTemplateArgs() 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(".*message iddqd.*", ab); // --- ProcessEventsApi eventsApi = new ProcessEventsApi(getApiClient()); - List events = eventsApi.list(pir.getInstanceId(), "ANSIBLE", null, null, null, null, null, null); + List events = eventsApi.listProcessEvents(pir.getInstanceId(), "ANSIBLE", null, null, null, null, null, null); assertNotNull(events); // one pre and one post event assertEquals(2, events.size()); @@ -480,15 +460,14 @@ public void testExtraVarsFiles() 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 from a JSON file!.*", ab); assertLog(".*Hello from a YAML file!.*", ab); } @@ -500,15 +479,14 @@ public void testMultiInventories() 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 aaa.*", ab); assertLog(".*Hello bbb.*", ab); } @@ -520,15 +498,14 @@ public void testMultiInventoryFiles() 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 aaa.*", ab); assertLog(".*Hello bbb.*", ab); } @@ -540,15 +517,14 @@ public void testLimitWithMultipleHost() 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()); assertLogAtLeast(".*Hello aaa.*", 2, ab); assertLogAtLeast(".*Hello ccc.*", 2, ab); assertNoLog(".*Hello bbb.*", ab); @@ -565,13 +541,12 @@ public void testInventoryMixMatch() 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(".*Hello!.*", ab); } @@ -586,13 +561,12 @@ public void testInventoryNameInvalidChars() 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(".*Hello!.*", ab); } @@ -613,10 +587,9 @@ public void testLogFiltering() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Hello! my_password=.*", ab); // and then run with the filtering enabled @@ -629,9 +602,9 @@ public void testLogFiltering() throws Exception { // --- - pir = waitForCompletion(processApi, spr.getInstanceId()); + pir = waitForCompletion(getApiClient(), spr.getInstanceId()); - ab = getLog(pir.getLogFileName()); + ab = getLog(pir.getInstanceId()); assertNoLog(".*Hello! my_password=.*", ab); assertLog(".*SENSITIVE INFORMATION.*", ab); } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleLookupIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleLookupIT.java index f5731bd8b6..26b49e4314 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleLookupIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleLookupIT.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,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import java.net.URI; @@ -37,7 +37,7 @@ public class AnsibleLookupIT extends AbstractServerIT { public void testSecrets() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String secretName = "mySecret"; String secretValue = "value_" + randomString(); @@ -46,9 +46,9 @@ public void testSecrets() throws Exception { String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); // --- @@ -67,13 +67,12 @@ public void testSecrets() 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()); assertNoLog(".*Explicit org " + secretValue + ".*", ab); assertNoLog(".*Implicit org " + secretValue + ".*", ab); assertLogAtLeast(".*ENABLING NO_LOG.*", 2, ab); @@ -83,7 +82,7 @@ public void testSecrets() throws Exception { public void testSecretData() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String secretName = "mySecret"; String secretValue = "value_" + randomString(); @@ -92,9 +91,9 @@ public void testSecretData() throws Exception { String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); // --- @@ -113,13 +112,12 @@ public void testSecretData() 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()); assertNoLog(".*Explicit org " + secretValue + ".*", ab); assertNoLog(".*Implicit org " + secretValue + ".*", ab); assertLogAtLeast(".*ENABLING NO_LOG.*", 2, ab); @@ -129,7 +127,7 @@ public void testSecretData() throws Exception { public void testSecretDataNoPassword() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String secretName = "mySecret"; String secretValue = "value_" + randomString(); @@ -137,9 +135,9 @@ public void testSecretDataNoPassword() throws Exception { String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); // --- @@ -156,13 +154,12 @@ public void testSecretDataNoPassword() 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()); assertNoLog(".*Explicit org " + secretValue + ".*", ab); assertNoLog(".*Implicit org " + secretValue + ".*", ab); } @@ -171,16 +168,16 @@ public void testSecretDataNoPassword() throws Exception { public void testPublickey() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String secretName = "mySecret_" + randomString(); generateKeyPair(orgName, secretName, false, null); String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); // --- @@ -199,13 +196,12 @@ public void testPublickey() 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()); assertNoLog(".*Explicit org: ssh-rsa" + ".*", ab); assertNoLog(".*Implicit org: ssh-rsa" + ".*", ab); assertLogAtLeast(".*ENABLING NO_LOG.*", 2, ab); @@ -218,7 +214,7 @@ public void testPublickey() throws Exception { public void testSecretValue() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String secretName = "mySecret_" + randomString(); String secretValue = "hello_" + randomString(); @@ -237,12 +233,11 @@ public void testSecretValue() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pe = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pe = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(pe.getLogFileName()); + byte[] ab = getLog(pe.getInstanceId()); assertLog(".*Value: " + secretValue + ".*", ab); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsiblePolicyIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsiblePolicyIT.java index 5a79f417e9..4ec0378133 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsiblePolicyIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsiblePolicyIT.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,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import java.io.File; @@ -43,22 +43,22 @@ public void testTaskDeny() throws Exception { String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); // --- String policyName = "test_policy_" + randomString(); PolicyEntry policy = new PolicyEntry() - .setName(policyName) - .setRules(readPolicy("ansiblePolicyTaskDeny/test-policy.json")); + .name(policyName) + .rules(readPolicy("ansiblePolicyTaskDeny/test-policy.json")); PolicyApi policyApi = new PolicyApi(getApiClient()); - policyApi.createOrUpdate(policy); - policyApi.link(policyName, new PolicyLinkEntry() - .setOrgName(orgName) - .setProjectName(projectName)); + policyApi.createOrUpdatePolicy(policy); + policyApi.linkPolicy(policyName, new PolicyLinkEntry() + .orgName(orgName) + .projectName(projectName)); URI dir = AnsiblePolicyIT.class.getResource("ansiblePolicyTaskDeny").toURI(); byte[] payload = archive(dir, ITConstants.DEPENDENCIES_DIR); @@ -70,12 +70,12 @@ public void testTaskDeny() throws Exception { // --- - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FAILED, pir.getStatus()); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Task 'Copy a local file \\(copy\\)' is forbidden by the task policy.*", ab); } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsiblePolicyVerboseLimitIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsiblePolicyVerboseLimitIT.java index 870dba4a40..d630578c4d 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsiblePolicyVerboseLimitIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsiblePolicyVerboseLimitIT.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -46,13 +46,13 @@ public void setup() throws Exception { orgName = "org_" + randomString(); OrganizationsApi organizationsApi = new OrganizationsApi(getApiClient()); - organizationsApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + organizationsApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); Map ansibleVerboseLimits = new HashMap<>(); ansibleVerboseLimits.put("maxHosts", 1); @@ -60,16 +60,16 @@ public void setup() throws Exception { String policyName = "policy_" + randomString(); PolicyApi policyApi = new PolicyApi(getApiClient()); - policyApi.createOrUpdate(new PolicyEntry() - .setName(policyName) - .setRules(singletonMap("processCfg", + policyApi.createOrUpdatePolicy(new PolicyEntry() + .name(policyName) + .rules(singletonMap("processCfg", singletonMap("arguments", singletonMap("ansibleVerboseLimits", ansibleVerboseLimits))))); - policyApi.link(policyName, new PolicyLinkEntry() - .setOrgName(orgName) - .setProjectName(projectName)); + policyApi.linkPolicy(policyName, new PolicyLinkEntry() + .orgName(orgName) + .projectName(projectName)); } @Test @@ -92,13 +92,12 @@ public void testLargeInventoryLimitedToGroup() 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(), "Large inventory limited to small group must FINISH"); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*ansible completed successfully.*", ab); } @@ -121,14 +120,13 @@ public void testVerboseTooManyImportedTasks() 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(), "Imported tasks exceeding max work must FINISH"); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Disabling verbose output. Too much work.*", ab); } @@ -151,14 +149,13 @@ public void testVerboseTooManyHosts() 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(), "Large inventory with verbose logging must FINISH"); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Disabling verbose output. Too many hosts.*", ab); } @@ -181,14 +178,13 @@ public void testVerboseTooMuchWork() 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(), "Small inventory with many calls and verbose logging must FINISH"); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Disabling verbose output. Too much work.*", ab); } @@ -211,14 +207,13 @@ public void testNoVerboseLargeInventory() 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(), "Large inventory with standard logging must FINISH"); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*ansible completed successfully.*", ab); } @@ -242,13 +237,13 @@ public void testVerboseSmallInventory() 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(), "Small inventory with verbose logging must FINISH"); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); // only shows with verbose logging enabled // TODO may be flaky? no guarantee it'll *always* be in every ansible version assertLog(".*Using .* as config file.*", ab); diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleProjectIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleProjectIT.java index c303cb8589..555330278e 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleProjectIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleProjectIT.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.it.common.GitUtils; import com.walmartlabs.concord.it.common.MockGitSshServer; import com.walmartlabs.concord.sdk.Constants; @@ -28,7 +28,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import java.io.File; import java.io.InputStream; import java.nio.file.Path; import java.nio.file.Paths; @@ -102,17 +101,17 @@ public void testFailure() throws Exception { // --- RepositoryEntry repo = new RepositoryEntry() - .setName(repoName) - .setUrl(repoUrl) - .setBranch("master") - .setSecretName(repoSecretName); + .name(repoName) + .url(repoUrl) + .branch("master") + .secretName(repoSecretName); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); Map cfg = Collections.singletonMap(Constants.Request.TEMPLATE_KEY, templatePath); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRepositories(singletonMap(repoName, repo)) - .setCfg(cfg) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .repositories(singletonMap(repoName, repo)) + .cfg(cfg) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); // --- @@ -126,19 +125,19 @@ public void testFailure() throws Exception { // --- ProcessApi processApi = new ProcessApi(getApiClient()); - waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.FAILED); + waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.FAILED); // --- - File resp = processApi.downloadAttachment(spr.getInstanceId(), "ansible_stats.json"); - assertNotNull(resp); + try (InputStream resp = processApi.downloadAttachment(spr.getInstanceId(), "ansible_stats.json")) { + assertNotNull(resp); - Map stats = fromJson(resp); - - Collection failures = (Collection) stats.get("failures"); - assertNotNull(failures); - assertEquals(1, failures.size()); - assertEquals("128.0.0.1", failures.iterator().next()); + Map stats = fromJson(resp); + Collection failures = (Collection) stats.get("failures"); + assertNotNull(failures); + assertEquals(1, failures.size()); + assertEquals("128.0.0.1", failures.iterator().next()); + } } @SuppressWarnings("unchecked") @@ -161,16 +160,16 @@ public void test(Map input) throws Exception { // --- RepositoryEntry repo = new RepositoryEntry() - .setName(repoName) - .setUrl(repoUrl) - .setBranch("master") - .setSecretName(repoSecretName); + .name(repoName) + .url(repoUrl) + .branch("master") + .secretName(repoSecretName); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); Map cfg = Collections.singletonMap(Constants.Request.TEMPLATE_KEY, templatePath); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRepositories(singletonMap(repoName, repo)) - .setCfg(cfg)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .repositories(singletonMap(repoName, repo)) + .cfg(cfg)); // --- @@ -182,11 +181,11 @@ public void test(Map input) throws Exception { // --- ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry psr = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry psr = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(psr.getLogFileName()); + byte[] ab = getLog(psr.getInstanceId()); assertLog(".*\"msg\":.*Hello, world.*", ab); // check if `force_color` is working @@ -194,15 +193,15 @@ public void test(Map input) throws Exception { // --- - File resp = processApi.downloadAttachment(spr.getInstanceId(), "ansible_stats.json"); - assertNotNull(resp); - - Map stats = fromJson(resp); + try (InputStream resp = processApi.downloadAttachment(spr.getInstanceId(), "ansible_stats.json")) { + assertNotNull(resp); + Map stats = fromJson(resp); - Collection oks = (Collection) stats.get("ok"); - assertNotNull(oks); - assertEquals(1, oks.size()); - assertEquals("127.0.0.1", oks.iterator().next()); + Collection oks = (Collection) stats.get("ok"); + assertNotNull(oks); + assertEquals(1, oks.size()); + assertEquals("127.0.0.1", oks.iterator().next()); + } } private static InputStream resource(String path) { diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleRetryIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleRetryIT.java index 38c636d007..e158779fbd 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleRetryIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/AnsibleRetryIT.java @@ -20,12 +20,12 @@ * ===== */ -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.ProcessApi; +import com.walmartlabs.concord.client2.ProcessEntry; +import com.walmartlabs.concord.client2.StartProcessResponse; import org.junit.jupiter.api.Test; -import java.io.File; +import java.io.InputStream; import java.net.URI; import static com.walmartlabs.concord.it.common.ITUtils.archive; @@ -47,12 +47,13 @@ public void testSaveRetry() throws Exception { // wait for completion - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FAILED, pir.getStatus()); // retrieve the retry file - File r = processApi.downloadAttachment(pir.getInstanceId(), "hello.retry"); - assertNotNull(r); + try (InputStream is = processApi.downloadAttachment(pir.getInstanceId(), "hello.retry")) { + assertNotNull(is); + } } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ApiKeyIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ApiKeyIT.java index 51447b31e7..2a7a1c1d80 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ApiKeyIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ApiKeyIT.java @@ -20,8 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -35,32 +34,32 @@ public void testOwner() throws Exception { String userBName = "userB_" + randomString(); UsersApi usersApi = new UsersApi(getApiClient()); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userAName) - .setType(CreateUserRequest.TypeEnum.LOCAL)); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userBName) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userAName) + .type(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userBName) + .type(CreateUserRequest.TypeEnum.LOCAL)); // --- ApiKeysApi apiKeyResource = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse cakr = apiKeyResource.create(new CreateApiKeyRequest().setUsername(userAName)); - assertTrue(cakr.isOk()); + CreateApiKeyResponse cakr = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(userAName)); + assertTrue(cakr.getOk()); // --- setApiKey(cakr.getKey()); try { - apiKeyResource.create(new CreateApiKeyRequest().setUsername(userBName)); + apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(userBName)); fail("Should fail"); } catch (ApiException e) { } // --- - cakr = apiKeyResource.create(new CreateApiKeyRequest().setUsername(userAName)); - assertTrue(cakr.isOk()); + cakr = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(userAName)); + assertTrue(cakr.getOk()); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/AttachmentRbacIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/AttachmentRbacIT.java index dd0203a410..ce3a61f28e 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/AttachmentRbacIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/AttachmentRbacIT.java @@ -20,12 +20,12 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; +import java.io.InputStream; import java.util.*; import static com.walmartlabs.concord.it.common.ITUtils.archive; @@ -44,50 +44,50 @@ public void test() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // add the users A, B and C UsersApi usersApi = new UsersApi(getApiClient()); String userAName = "userA_" + randomString(); - usersApi.createOrUpdate(new CreateUserRequest(). - setUsername(userAName).setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest(). + username(userAName).type(CreateUserRequest.TypeEnum.LOCAL)); ApiKeysApi apiKeyResource = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse apiKeyA = apiKeyResource.create(new CreateApiKeyRequest().setUsername(userAName)); + CreateApiKeyResponse apiKeyA = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(userAName)); String userBName = "userB_" + randomString(); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userBName) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userBName) + .type(CreateUserRequest.TypeEnum.LOCAL)); - CreateApiKeyResponse apiKeyB = apiKeyResource.create(new CreateApiKeyRequest().setUsername(userBName)); + CreateApiKeyResponse apiKeyB = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(userBName)); String userCName = "userC_" + randomString(); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userCName) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userCName) + .type(CreateUserRequest.TypeEnum.LOCAL)); UUID userCUUID = usersApi.findByUsername(userCName).getId(); - CreateApiKeyResponse apiKeyC = apiKeyResource.create(new CreateApiKeyRequest().setUsername(userCName)); + CreateApiKeyResponse apiKeyC = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(userCName)); // create the user A's team String teamName = "team_" + randomString(); TeamsApi teamsApi = new TeamsApi(getApiClient()); - CreateTeamResponse ctr = teamsApi.createOrUpdate(orgName, new TeamEntry().setName(teamName)); + CreateTeamResponse ctr = teamsApi.createOrUpdateTeam(orgName, new TeamEntry().name(teamName)); - teamsApi.addUsers(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() - .setUsername(userAName) - .setRole(TeamUserEntry.RoleEnum.MEMBER))); + teamsApi.addUsersToTeam(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() + .username(userAName) + .role(TeamUserEntry.RoleEnum.MEMBER))); - teamsApi.addUsers(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() - .setUsername(userCName) - .setRole(TeamUserEntry.RoleEnum.OWNER))); + teamsApi.addUsersToTeam(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() + .username(userCName) + .role(TeamUserEntry.RoleEnum.OWNER))); - teamsApi.addUsers(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() - .setUsername(userBName) - .setRole(TeamUserEntry.RoleEnum.MEMBER))); + teamsApi.addUsersToTeam(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() + .username(userBName) + .role(TeamUserEntry.RoleEnum.MEMBER))); // switch to the user A and create a new private project @@ -96,17 +96,17 @@ public void test() throws Exception { String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setVisibility(ProjectEntry.VisibilityEnum.PUBLIC) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .visibility(ProjectEntry.VisibilityEnum.PUBLIC) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); // grant the team access to the project - projectsApi.updateAccessLevel(orgName, projectName, new ResourceAccessEntry() - .setTeamId(ctr.getId()) - .setOrgName(orgName) - .setTeamName(teamName) - .setLevel(ResourceAccessEntry.LevelEnum.READER)); + projectsApi.updateProjectAccessLevel(orgName, projectName, new ResourceAccessEntry() + .teamId(ctr.getId()) + .orgName(orgName) + .teamName(teamName) + .level(ResourceAccessEntry.LevelEnum.READER)); // start a new process using the project as the user A @@ -119,34 +119,35 @@ public void test() throws Exception { StartProcessResponse spr = start(input); ProcessApi processApi = new ProcessApi(getApiClient()); - waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.FINISHED); + waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.FINISHED); log.info("The initiator shall be able to list attachments"); List attachments = processApi.listAttachments(spr.getInstanceId()); assertNotNull(attachments, "Attachments shall not be null for initiator"); assertSame(2, attachments.size(), "Attachment size shall be 2 for initiator"); - File file = processApi.downloadAttachment(spr.getInstanceId(), attachments.get(0)); - assertNotNull(file, "File object shall not be null for initiator"); + try (InputStream is = processApi.downloadAttachment(spr.getInstanceId(), attachments.get(0))) { + assertNotNull(is, "File object shall not be null for initiator"); + } // switch to admin and add the user B setApiKey(apiKeyA.getKey()); - ProjectEntry projectEntry = projectsApi.get(orgName, projectName); + ProjectEntry projectEntry = projectsApi.getProject(orgName, projectName); // Update userC as owner EntityOwner projectOwner = projectEntry.getOwner(); - EntityOwner entityOwner = new EntityOwner(); - entityOwner.setId(userCUUID) - .setUsername(projectOwner.getUsername()) - .setUserDomain(projectOwner.getUserDomain()) - .setUserType(projectOwner.getUserType()) - .setDisplayName(projectOwner.getDisplayName()); + EntityOwner entityOwner = new EntityOwner() + .id(userCUUID) + .username(projectOwner.getUsername()) + .userDomain(projectOwner.getUserDomain()) + .userType(projectOwner.getUserType()) + .displayName(projectOwner.getDisplayName()); projectEntry.setOwner(entityOwner); - projectsApi.createOrUpdate(orgName, projectEntry); + projectsApi.createOrUpdateProject(orgName, projectEntry); log.info("The admin shall be able to list attachments"); // Admin shall be also able to list the attachments @@ -156,8 +157,9 @@ public void test() throws Exception { assertNotNull(attachments, "Attachments shall not be null for admin"); assertSame(2, attachments.size(), "Attachment size shall be 2 for admin"); - file = processApi.downloadAttachment(spr.getInstanceId(), attachments.get(0)); - assertNotNull(file, "File object shall not be null for admin"); + try (InputStream is = processApi.downloadAttachment(spr.getInstanceId(), attachments.get(0))) { + assertNotNull(is, "File object shall not be null for admin"); + } // switch to the user B (non admin) and try to list and download the attachments @@ -173,8 +175,7 @@ public void test() throws Exception { } // Non-admin who is only a member shall not able to download the attachments - try { - processApi.downloadAttachment(spr.getInstanceId(), attachments.get(0)); + try (InputStream is = processApi.downloadAttachment(spr.getInstanceId(), attachments.get(0))) { fail("Should fail when downloading attachments for non-admin"); } catch (Exception e) { assertNotNull(e, "Exception shall not be null"); @@ -190,7 +191,8 @@ public void test() throws Exception { assertSame(2, attachments.size(), "Attachment size shall be 2 for non-admin who is a owner"); - file = processApi.downloadAttachment(spr.getInstanceId(), attachments.get(0)); - assertNotNull(file, "File object shall not be null for non-admin who is a owner"); + try (InputStream is = processApi.downloadAttachment(spr.getInstanceId(), attachments.get(0))) { + assertNotNull(is, "File object shall not be null for non-admin who is a owner"); + } } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/CheckpointsIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/CheckpointsIT.java index 19de5c2c0f..cd9b7b7423 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/CheckpointsIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/CheckpointsIT.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. @@ -21,8 +21,7 @@ */ import com.google.common.collect.ImmutableMap; -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.sdk.Constants; import org.junit.jupiter.api.Test; @@ -45,17 +44,16 @@ public void testCheckpoint() throws Exception { // start the process - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); assertNotNull(spr.getInstanceId()); // wait for completion - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // check the logs - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*==Start.*", ab); assertLog(".*==Middle.*", ab); @@ -64,9 +62,9 @@ public void testCheckpoint() throws Exception { // restore from TWO checkpoint restoreFromCheckpoint(pir.getInstanceId(), "TWO"); - waitForCompletion(processApi, spr.getInstanceId()); + waitForCompletion(getApiClient(), spr.getInstanceId()); - ab = getLog(pir.getLogFileName()); + ab = getLog(pir.getInstanceId()); assertLog(".*==Start.*", ab); assertLog(".*==Middle.*", ab); @@ -75,8 +73,8 @@ public void testCheckpoint() throws Exception { // restore from ONE checkpoint restoreFromCheckpoint(pir.getInstanceId(), "ONE"); - waitForCompletion(processApi, spr.getInstanceId()); - ab = getLog(pir.getLogFileName()); + waitForCompletion(getApiClient(), spr.getInstanceId()); + ab = getLog(pir.getInstanceId()); assertLog(".*==Start.*", ab); assertLog(".*==Middle.*", 2, ab); @@ -87,17 +85,16 @@ public void testCheckpoint() throws Exception { public void testRestoreCheckpointWithGetByName() throws Exception { byte[] payload = archive(CheckpointsIT.class.getResource("oneCheckpoint").toURI()); - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); assertNotNull(spr.getInstanceId()); // --- - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*aaa before.*", ab); assertLog(".*bbb after.*", ab); @@ -109,9 +106,9 @@ public void testRestoreCheckpointWithGetByName() throws Exception { // --- - waitForCompletion(processApi, spr.getInstanceId()); + waitForCompletion(getApiClient(), spr.getInstanceId()); - ab = getLog(pir.getLogFileName()); + ab = getLog(pir.getInstanceId()); assertLog(".*aaa before.*", ab); assertLog(".*bbb after.*", 2, ab); } @@ -131,13 +128,12 @@ private void testRestoreCheckpointWithEventName(String resource) throws Exceptio byte[] payload = archive(CheckpointsIT.class.getResource(resource).toURI()); - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); assertNotNull(spr.getInstanceId()); // --- - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // restore from first checkpoint CheckpointV2Api checkpointV2Api = new CheckpointV2Api(getApiClient()); @@ -145,17 +141,17 @@ private void testRestoreCheckpointWithEventName(String resource) throws Exceptio // --- - waitForCompletion(processApi, spr.getInstanceId()); + waitForCompletion(getApiClient(), spr.getInstanceId()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Event Name: first*", ab); // restore from second checkpoint checkpointV2Api.processCheckpoint(pir.getInstanceId(), "second", "restore"); - waitForCompletion(processApi, spr.getInstanceId()); - ab = getLog(pir.getLogFileName()); + waitForCompletion(getApiClient(), spr.getInstanceId()); + ab = getLog(pir.getInstanceId()); assertLog(".*Event Name: second.*", ab); } @@ -167,18 +163,17 @@ public void testCheckpointWithError() throws Exception { // start the process - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); assertNotNull(spr.getInstanceId()); - waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); + waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); // --- Map data = Collections.singletonMap("shouldFail", true); submitForm(spr.getInstanceId(), data); // --- - ProcessEntry pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.FAILED); + ProcessEntry pir = waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.FAILED); // check error message assertProcessErrorMessage(pir, "As you wish"); @@ -186,7 +181,7 @@ public void testCheckpointWithError() throws Exception { // --- restoreFromCheckpoint(pir.getInstanceId(), "ONE"); - pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); + pir = waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); // no error message after process restored assertNoProcessErrorMessage(pir); @@ -195,9 +190,9 @@ public void testCheckpointWithError() throws Exception { data = Collections.singletonMap("shouldFail", false); submitForm(spr.getInstanceId(), data); - waitForCompletion(processApi, spr.getInstanceId()); + waitForCompletion(getApiClient(), spr.getInstanceId()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*==Start.*", ab); assertLog(".*==Middle.*", ab); assertLog(".*==End.*", ab); @@ -208,21 +203,21 @@ public void testCheckpointWithArgs() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); String value = "value_" + randomString(); EncryptValueResponse evr = projectsApi.encrypt(orgName, projectName, value); - assertTrue(evr.isOk()); + assertTrue(evr.getOk()); // prepare the payload @@ -230,7 +225,6 @@ public void testCheckpointWithArgs() throws Exception { // start the process - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(ImmutableMap.of( "org", orgName, "project", projectName, @@ -238,9 +232,9 @@ public void testCheckpointWithArgs() throws Exception { "arguments.encrypted", evr.getData())); assertNotNull(spr.getInstanceId()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*hello, World.*", 2, ab); assertLog(".*" + value + ".*", 4, ab); @@ -261,10 +255,9 @@ public void testExpressions() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*checkpoint test " + xValue + ".*", 1, ab); } @@ -277,15 +270,14 @@ public void testTags() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); assertNotNull(spr.getInstanceId()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*__logTag.*phase.*pre.*meta.*checkpointName.*ONE.*", ab); assertLog(".*__logTag.*phase.*post.*meta.*checkpointName.*ONE.*", ab); @@ -296,14 +288,14 @@ public void testTags() throws Exception { private void restoreFromCheckpoint(UUID instanceId, String name) throws ApiException { CheckpointApi checkpointApi = new CheckpointApi(getApiClient()); ProcessEventsApi eventsApi = new ProcessEventsApi(getApiClient()); - List processEvents = eventsApi.list(instanceId, null, null, null, null, null, true, null); + List processEvents = eventsApi.listProcessEvents(instanceId, null, null, null, null, null, true, null); assertNotNull(processEvents); // restore from ONE checkpoint String checkpointId = assertCheckpoint(name, processEvents); ResumeProcessResponse resp = checkpointApi.restore(instanceId, - new RestoreCheckpointRequest().setId(UUID.fromString(checkpointId))); + new RestoreCheckpointRequest().id(UUID.fromString(checkpointId))); assertNotNull(resp); } @@ -311,12 +303,12 @@ private void restoreFromCheckpoint(UUID instanceId, String name) throws ApiExcep private void submitForm(UUID instanceId, Map data) throws ApiException { ProcessFormsApi formsApi = new ProcessFormsApi(getApiClient()); - List forms = formsApi.list(instanceId); + List forms = formsApi.listProcessForms(instanceId); assertEquals(1, forms.size()); FormListEntry f = forms.get(0); - FormSubmitResponse fsr = formsApi.submit(instanceId, f.getName(), data); - assertTrue(fsr.isOk()); + FormSubmitResponse fsr = formsApi.submitForm(instanceId, f.getName(), data); + assertTrue(fsr.getOk()); } @SuppressWarnings("unchecked") diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ClasspathIsolationIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ClasspathIsolationIT.java index c636132361..59bb87ca78 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ClasspathIsolationIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ClasspathIsolationIT.java @@ -20,9 +20,8 @@ * ===== */ -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.ProcessEntry; +import com.walmartlabs.concord.client2.StartProcessResponse; import org.junit.jupiter.api.Test; import java.util.HashMap; @@ -47,9 +46,8 @@ public void testBrokenDeps() throws Exception { StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); - byte[] ab = getLog(pir.getLogFileName()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*hello!.*", ab); } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ClasspathRepoIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ClasspathRepoIT.java index 401ebeda9d..2c436146cf 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ClasspathRepoIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ClasspathRepoIT.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import java.util.Collections; @@ -39,28 +39,27 @@ public void test() throws Exception { String repoName = "repo_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate("Default", new ProjectEntry() - .setName(projectName) - .setAcceptsRawPayload(false) - .setRepositories(Collections.singletonMap(repoName, new RepositoryEntry() - .setName(repoName) - .setUrl(url) - .setBranch("master")))); + projectsApi.createOrUpdateProject("Default", new ProjectEntry() + .name(projectName) + .acceptsRawPayload(false) + .repositories(Collections.singletonMap(repoName, new RepositoryEntry() + .name(repoName) + .url(url) + .branch("master")))); // --- - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start("Default", projectName, repoName, null, null); - assertTrue(spr.isOk()); + assertTrue(spr.getOk()); // --- - ProcessEntry pe = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pe = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FINISHED, pe.getStatus()); // --- - byte[] ab = getLog(pe.getLogFileName()); + byte[] ab = getLog(pe.getInstanceId()); assertLog(".*OK.*", ab); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ConcordTaskForkFromGitRepoIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ConcordTaskForkFromGitRepoIT.java index de3718069b..2fc6099a63 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ConcordTaskForkFromGitRepoIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ConcordTaskForkFromGitRepoIT.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.it.common.GitUtils; import com.walmartlabs.concord.it.common.MockGitSshServer; import org.junit.jupiter.api.AfterEach; @@ -29,6 +29,7 @@ import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -45,7 +46,7 @@ public class ConcordTaskForkFromGitRepoIT extends AbstractServerIT { @BeforeEach public void setUp() throws Exception { - Path data = Paths.get(PortalIT.class.getResource("concordTaskFork").toURI()); + Path data = Paths.get(ConcordTaskForkFromGitRepoIT.class.getResource("concordTaskFork").toURI()); Path repo = GitUtils.createBareRepository(data); gitServer = new MockGitSshServer(0, repo); @@ -77,15 +78,15 @@ public void testFork() throws Exception { // --- RepositoryEntry repo = new RepositoryEntry() - .setName(repoName) - .setUrl(repoUrl) - .setBranch("master") - .setSecretId(response.getId()); + .name(repoName) + .url(repoUrl) + .branch("master") + .secretId(response.getId()); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRepositories(singletonMap(repoName, repo))); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .repositories(singletonMap(repoName, repo))); // --- @@ -97,20 +98,20 @@ public void testFork() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry parentProcessEntry = waitForCompletion(processApi, parentSpr.getInstanceId()); + ProcessV2Api processApi = new ProcessV2Api(getApiClient()); + ProcessEntry parentProcessEntry = waitForCompletion(getApiClient(), parentSpr.getInstanceId()); - byte[] ab = getLog(parentProcessEntry.getLogFileName()); + byte[] ab = getLog(parentProcessEntry.getInstanceId()); assertLog(".*repoCommitMessage: initial message.*", ab); - ProcessEntry processEntry = processApi.get(parentSpr.getInstanceId()); + ProcessEntry processEntry = processApi.getProcess(parentSpr.getInstanceId(), Collections.singleton("childrenIds")); assertEquals(1, processEntry.getChildrenIds().size()); - ProcessEntry child = processApi.get(processEntry.getChildrenIds().get(0)); + ProcessEntry child = processApi.getProcess(processEntry.getChildrenIds().iterator().next(), Collections.singleton("childrenIds")); assertNotNull(child); assertEquals(ProcessEntry.StatusEnum.FINISHED, child.getStatus()); - ab = getLog(child.getLogFileName()); + ab = getLog(child.getInstanceId()); assertLog(".*repoCommitMessage: initial message.*", ab); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ConcordTaskIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ConcordTaskIT.java index 6951ded6e8..93d369a92f 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ConcordTaskIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ConcordTaskIT.java @@ -21,13 +21,11 @@ */ import com.fasterxml.jackson.databind.ObjectMapper; -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.*; -import com.walmartlabs.concord.common.IOUtils; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import javax.xml.bind.DatatypeConverter; -import java.io.File; +import java.io.InputStream; import java.util.*; import static com.walmartlabs.concord.common.IOUtils.grep; @@ -44,28 +42,28 @@ public void testStartArchive() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // add the user A UsersApi usersApi = new UsersApi(getApiClient()); String userAName = "userA_" + randomString(); - usersApi.createOrUpdate(new CreateUserRequest().setUsername(userAName).setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest().username(userAName).type(CreateUserRequest.TypeEnum.LOCAL)); ApiKeysApi apiKeyResource = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse apiKeyA = apiKeyResource.create(new CreateApiKeyRequest().setUsername(userAName)); + CreateApiKeyResponse apiKeyA = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(userAName)); // create the user A's team String teamName = "team_" + randomString(); TeamsApi teamsApi = new TeamsApi(getApiClient()); - teamsApi.createOrUpdate(orgName, new TeamEntry().setName(teamName)); + teamsApi.createOrUpdateTeam(orgName, new TeamEntry().name(teamName)); - teamsApi.addUsers(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() - .setUsername(userAName) - .setRole(TeamUserEntry.RoleEnum.MEMBER))); + teamsApi.addUsersToTeam(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() + .username(userAName) + .role(TeamUserEntry.RoleEnum.MEMBER))); // switch to the user A and create a new private project @@ -74,17 +72,17 @@ public void testStartArchive() throws Exception { String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setVisibility(ProjectEntry.VisibilityEnum.PRIVATE) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .visibility(ProjectEntry.VisibilityEnum.PRIVATE) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); // grant the team access to the project - projectsApi.updateAccessLevel(orgName, projectName, new ResourceAccessEntry() - .setOrgName(orgName) - .setTeamName(teamName) - .setLevel(ResourceAccessEntry.LevelEnum.READER)); + projectsApi.updateProjectAccessLevel(orgName, projectName, new ResourceAccessEntry() + .orgName(orgName) + .teamName(teamName) + .level(ResourceAccessEntry.LevelEnum.READER)); // start a new process using the project as the user A @@ -96,12 +94,11 @@ public void testStartArchive() throws Exception { StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.FINISHED); + ProcessEntry pir = waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.FINISHED); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Done!.*", ab); } @@ -113,13 +110,12 @@ public void testStartDirectory() throws Exception { StartProcessResponse spr = start(input); - 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(".*Done! Hello! Good Bye.*", ab); } @@ -135,13 +131,12 @@ public void testCreateProject() throws Exception { StartProcessResponse spr = start(input); - 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(".*Done!.*", ab); } @@ -157,13 +152,12 @@ public void testStartAt() throws Exception { StartProcessResponse spr = start(input); - 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(".*Done! Hello!.*", ab); } @@ -175,13 +169,12 @@ public void testOutVarsNotFound() throws Exception { StartProcessResponse spr = start(input); - 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(".*Done!.*", ab); } @@ -193,13 +186,12 @@ public void testSubprocessFail() throws Exception { StartProcessResponse spr = start(input); - 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(".*Fail!.*", ab); assertNoLog(".*Done!.*", ab); } @@ -213,12 +205,12 @@ public void testSubprocessIgnoreFail() throws Exception { StartProcessResponse spr = start(input); 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(".*Done!.*", ab); } @@ -227,15 +219,15 @@ public void testStartChildFinishedWithError() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setVisibility(ProjectEntry.VisibilityEnum.PUBLIC) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .visibility(ProjectEntry.VisibilityEnum.PUBLIC) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); byte[] payload = archive(ConcordTaskIT.class.getResource("concordTaskFailChild").toURI()); Map input = new HashMap<>(); @@ -245,12 +237,11 @@ public void testStartChildFinishedWithError() throws Exception { StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.FAILED); + ProcessEntry pir = waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.FAILED); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Child process.*FAILED.*BOOOM.*", ab); } @@ -259,15 +250,15 @@ public void testForkWithItemsWithOutVariable() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setVisibility(ProjectEntry.VisibilityEnum.PUBLIC) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .visibility(ProjectEntry.VisibilityEnum.PUBLIC) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); byte[] payload = archive(ConcordTaskIT.class.getResource("concordTaskForkWithItemsWithOut").toURI()); Map input = new HashMap<>(); @@ -278,11 +269,11 @@ public void testForkWithItemsWithOutVariable() throws Exception { StartProcessResponse spr = start(input); ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.FAILED); + ProcessEntry pir = waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.FAILED); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*color=RED.*", ab); assertLog(".*color=WHITE.*", ab); assertLog(".*Done.*\\[\\[.*\\], \\[.*\\]\\] is completed.*", ab); @@ -293,15 +284,15 @@ public void testForkWithItems() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setVisibility(ProjectEntry.VisibilityEnum.PUBLIC) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .visibility(ProjectEntry.VisibilityEnum.PUBLIC) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); byte[] payload = archive(ConcordTaskIT.class.getResource("concordTaskForkWithItems").toURI()); Map input = new HashMap<>(); @@ -311,12 +302,11 @@ public void testForkWithItems() throws Exception { StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.FAILED); + ProcessEntry pir = waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.FAILED); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*color=RED.*", ab); assertLog(".*color=WHITE.*", ab); assertLog(".*Done.*\\[\\[.*\\], \\[.*\\]\\] is completed.*", ab); @@ -327,13 +317,13 @@ public void testExternalApiToken() throws Exception { String username = "user_" + randomString(); UsersApi usersApi = new UsersApi(getApiClient()); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(username) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(username) + .type(CreateUserRequest.TypeEnum.LOCAL)); ApiKeysApi apiKeysApi = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse cakr = apiKeysApi.create(new CreateApiKeyRequest() - .setUsername(username)); + CreateApiKeyResponse cakr = apiKeysApi.createUserApiKey(new CreateApiKeyRequest() + .username(username)); // --- @@ -344,12 +334,11 @@ public void testExternalApiToken() throws Exception { StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pe = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pe = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(pe.getLogFileName()); + byte[] ab = getLog(pe.getInstanceId()); assertLog(".*Hello, Concord!.*", ab); } @@ -358,13 +347,13 @@ public void testSuspendParentProcess() throws Exception { String username = "user_" + randomString(); UsersApi usersApi = new UsersApi(getApiClient()); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(username) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(username) + .type(CreateUserRequest.TypeEnum.LOCAL)); ApiKeysApi apiKeysApi = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse cakr = apiKeysApi.create(new CreateApiKeyRequest() - .setUsername(username)); + CreateApiKeyResponse cakr = apiKeysApi.createUserApiKey(new CreateApiKeyRequest() + .username(username)); // --- @@ -375,12 +364,11 @@ public void testSuspendParentProcess() throws Exception { StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pe = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pe = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(pe.getLogFileName()); + byte[] ab = getLog(pe.getInstanceId()); assertLog(".*Hello, Concord!.*", ab); } @@ -390,19 +378,19 @@ public void testSubWithNullArgValue() throws Exception { StartProcessResponse parentSpr = start(payload); - ProcessApi processApi = new ProcessApi(getApiClient()); - waitForCompletion(processApi, parentSpr.getInstanceId()); + ProcessV2Api processApi = new ProcessV2Api(getApiClient()); + waitForCompletion(getApiClient(), parentSpr.getInstanceId()); - ProcessEntry processEntry = processApi.get(parentSpr.getInstanceId()); + ProcessEntry processEntry = processApi.getProcess(parentSpr.getInstanceId(), Collections.singleton("childrenIds")); assertEquals(1, processEntry.getChildrenIds().size()); - ProcessEntry child = processApi.get(processEntry.getChildrenIds().get(0)); + ProcessEntry child = processApi.getProcess(processEntry.getChildrenIds().iterator().next(), Collections.singleton("childrenIds")); assertNotNull(child); assertEquals(ProcessEntry.StatusEnum.FINISHED, child.getStatus()); // --- - byte[] ab = getLog(child.getLogFileName()); + byte[] ab = getLog(child.getInstanceId()); assertLog(".*Child process, nullValue: ''.*", ab); assertLog(".*Child process, nullValue == null: 'true'.*", ab); assertLog(".*Child process, hasVariable\\('nullValue'\\): true.*", ab); @@ -413,15 +401,15 @@ public void testForkWithArguments() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setVisibility(ProjectEntry.VisibilityEnum.PUBLIC) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .visibility(ProjectEntry.VisibilityEnum.PUBLIC) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); byte[] payload = archive(ConcordTaskIT.class.getResource("concordTaskForkWithArguments").toURI()); Map input = new HashMap<>(); @@ -431,19 +419,19 @@ public void testForkWithArguments() throws Exception { StartProcessResponse parentSpr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - waitForCompletion(processApi, parentSpr.getInstanceId()); + ProcessV2Api processApi = new ProcessV2Api(getApiClient()); + waitForCompletion(getApiClient(), parentSpr.getInstanceId()); - ProcessEntry processEntry = processApi.get(parentSpr.getInstanceId()); + ProcessEntry processEntry = processApi.getProcess(parentSpr.getInstanceId(), Collections.singleton("childrenIds")); assertEquals(1, processEntry.getChildrenIds().size()); - ProcessEntry child = processApi.get(processEntry.getChildrenIds().get(0)); + ProcessEntry child = processApi.getProcess(processEntry.getChildrenIds().iterator().next(), Collections.singleton("childrenIds")); assertNotNull(child); assertEquals(ProcessEntry.StatusEnum.FINISHED, child.getStatus()); // --- - byte[] ab = getLog(child.getLogFileName()); + byte[] ab = getLog(child.getInstanceId()); assertLog(".*Hello from a subprocess.*", ab); assertLog(".*Concord Fork Process 123.*", ab); } @@ -453,15 +441,15 @@ public void testForkWithForm() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setVisibility(ProjectEntry.VisibilityEnum.PUBLIC) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .visibility(ProjectEntry.VisibilityEnum.PUBLIC) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); byte[] payload = archive(ConcordTaskIT.class.getResource("concordTaskForkWithForm").toURI()); Map input = new HashMap<>(); @@ -472,35 +460,36 @@ public void testForkWithForm() throws Exception { StartProcessResponse parentSpr = start(input); // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForStatus(processApi, parentSpr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); + ProcessEntry pir = waitForStatus(getApiClient(), parentSpr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); // --- ProcessFormsApi formsApi = new ProcessFormsApi(getApiClient()); - List forms = formsApi.list(parentSpr.getInstanceId()); + List forms = formsApi.listProcessForms(parentSpr.getInstanceId()); assertEquals(1, forms.size()); Map data = new HashMap<>(); data.put("firstName", "Boo"); - FormSubmitResponse fsr = formsApi.submit(pir.getInstanceId(), "myForm", data); - assertTrue(fsr.isOk()); + FormSubmitResponse fsr = formsApi.submitForm(pir.getInstanceId(), "myForm", data); + assertTrue(fsr.getOk()); - waitForCompletion(processApi, parentSpr.getInstanceId()); + waitForCompletion(getApiClient(), parentSpr.getInstanceId()); // --- - ProcessEntry processEntry = processApi.get(parentSpr.getInstanceId()); + ProcessV2Api processApi = new ProcessV2Api(getApiClient()); + + ProcessEntry processEntry = processApi.getProcess(parentSpr.getInstanceId(), Collections.singleton("childrenIds")); assertEquals(1, processEntry.getChildrenIds().size()); - ProcessEntry child = processApi.get(processEntry.getChildrenIds().get(0)); + ProcessEntry child = processApi.getProcess(processEntry.getChildrenIds().iterator().next(), Collections.singleton("childrenIds")); assertNotNull(child); assertEquals(ProcessEntry.StatusEnum.FINISHED, child.getStatus()); // --- - byte[] ab = getLog(child.getLogFileName()); + byte[] ab = getLog(child.getInstanceId()); assertLog(".*Hello from a subprocess.*", ab); assertLog(".*Concord Fork Process 234.*", ab); } @@ -512,15 +501,15 @@ public void testForkSuspend() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setVisibility(ProjectEntry.VisibilityEnum.PUBLIC) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .visibility(ProjectEntry.VisibilityEnum.PUBLIC) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); byte[] payload = archive(ConcordTaskIT.class.getResource("concordTaskForkSuspend").toURI()); Map input = new HashMap<>(); @@ -533,12 +522,11 @@ public void testForkSuspend() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pe = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pe = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(pe.getLogFileName()); + byte[] ab = getLog(pe.getInstanceId()); assertLog(".*\\{varFromFork=Hello, " + nameVar + "\\}.*", ab); assertLog(".*\\{varFromFork=Bye, " + nameVar + "\\}.*", ab); } @@ -552,15 +540,15 @@ public void testForkAsyncGrabOutVars() throws Exception { // --- ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pe = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pe = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(pe.getLogFileName()); + byte[] ab = getLog(pe.getInstanceId()); if (grep(".*\\{x=1, y=2, z=3\\}.*", ab).isEmpty() || grep(".*\\{a=4, b=5, c=6\\}.*", ab).isEmpty()) { for (UUID id : pe.getChildrenIds()) { - ProcessEntry pp = processApi.get(id); + ProcessEntry pp = new ProcessV2Api(getApiClient()).getProcess(id, Collections.singleton("childrenIds")); System.out.println("process: " + pp.getInstanceId() + ", status: " + pp.getStatus() + ", out: " + getOutVars(id, processApi)); System.out.println(">>>"); } @@ -571,18 +559,14 @@ public void testForkAsyncGrabOutVars() throws Exception { @SuppressWarnings("unchecked") private static Map getOutVars(UUID id, ProcessApi processApi) throws Exception { - File f = null; - try { - f = processApi.downloadAttachment(id, "out.json"); + try (InputStream is = processApi.downloadAttachment(id, "out.json")) { ObjectMapper om = new ObjectMapper(); - return om.readValue(f, Map.class); + return om.readValue(is, Map.class); } catch (ApiException e) { if (e.getCode() == 404) { return null; } throw e; - } finally { - IOUtils.delete(f); } } @@ -594,17 +578,20 @@ public void testParentInstanceId() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pe = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pe = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- ProcessV2Api processV2Api = new ProcessV2Api(getApiClient()); - List l = processV2Api.list(null, null, null, null, null, null, null, null, null, null, null, pe.getInstanceId(), null, null, null); + ProcessListFilter filter = ProcessListFilter.builder() + .parentInstanceId(pe.getInstanceId()) + .build(); + + List l = processV2Api.listProcesses(filter); assertEquals(2, l.size()); for (ProcessEntry e : l) { - byte[] ab = getLog(e.getLogFileName()); + byte[] ab = getLog(e.getInstanceId()); assertLog(".*parentInstanceId: " + pe.getInstanceId() + ".*", ab); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ConfigurableResourcesIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ConfigurableResourcesIT.java index 64080547e9..31b9157df6 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ConfigurableResourcesIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ConfigurableResourcesIT.java @@ -20,10 +20,8 @@ * ===== */ -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.*; +import com.walmartlabs.concord.client2.StartProcessResponse; import org.junit.jupiter.api.Test; import static com.walmartlabs.concord.it.common.ITUtils.archive; @@ -38,17 +36,16 @@ public class ConfigurableResourcesIT extends AbstractServerIT { public void testProfiles() throws Exception { // prepare the payload - byte[] payload = archive(ProcessIT.class.getResource("configurableProfilesDirectory").toURI()); + byte[] payload = archive(ConfigurableResourcesIT.class.getResource("configurableProfilesDirectory").toURI()); // start the process - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); assertNotNull(spr.getInstanceId()); // wait for completion - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // get the name of the agent's log file @@ -56,7 +53,7 @@ public void testProfiles() throws Exception { // check the logs - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Hello, world.*", ab); } @@ -65,17 +62,16 @@ public void testProfiles() throws Exception { public void testFlows() throws Exception { // prepare the payload - byte[] payload = archive(ProcessIT.class.getResource("configurableFlowsDirectory").toURI()); + byte[] payload = archive(ConfigurableResourcesIT.class.getResource("configurableFlowsDirectory").toURI()); // start the process - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); assertNotNull(spr.getInstanceId()); // wait for completion - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // get the name of the agent's log file @@ -83,7 +79,7 @@ public void testFlows() throws Exception { // check the logs - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*External flow!.*", ab); } @@ -92,17 +88,16 @@ public void testFlows() throws Exception { public void testDisabledProfiles() throws Exception { // prepare the payload - byte[] payload = archive(ProcessIT.class.getResource("disableProfilesDirectory").toURI()); + byte[] payload = archive(ConfigurableResourcesIT.class.getResource("disableProfilesDirectory").toURI()); // start the process - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); assertNotNull(spr.getInstanceId()); // wait for completion - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // get the name of the agent's log file @@ -110,14 +105,14 @@ public void testDisabledProfiles() throws Exception { // check the logs - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Hello, stranger.*", ab); } @Test public void testInvalidDir() throws Exception { - byte[] payload = archive(ProcessIT.class.getResource("invalidResourcesPath").toURI()); + byte[] payload = archive(ConfigurableResourcesIT.class.getResource("invalidResourcesPath").toURI()); // --- diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/CronIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/CronIT.java index 7b85c7c388..5aeaf338f7 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/CronIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/CronIT.java @@ -20,8 +20,9 @@ * ===== */ -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; +import com.walmartlabs.concord.client2.CreateSecretRequest; +import com.walmartlabs.concord.client2.ProcessListFilter; import com.walmartlabs.concord.common.IOUtils; import org.eclipse.jgit.api.Git; import org.junit.jupiter.api.Test; @@ -57,17 +58,17 @@ public void testProfiles() throws Exception { String repoName = "repo_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - if (orgApi.get(orgName) == null) { - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + if (orgApi.getOrg(orgName) == null) { + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); } ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setVisibility(ProjectEntry.VisibilityEnum.PUBLIC) - .setRepositories(Collections.singletonMap(repoName, new RepositoryEntry() - .setUrl(gitUrl) - .setBranch("master")))); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .visibility(ProjectEntry.VisibilityEnum.PUBLIC) + .repositories(Collections.singletonMap(repoName, new RepositoryEntry() + .url(gitUrl) + .branch("master")))); // --- @@ -112,7 +113,7 @@ public void testProfiles() throws Exception { // --- clean up - projectsApi.delete(orgName, projectName); + projectsApi.deleteProject(orgName, projectName); } @Test @@ -126,34 +127,34 @@ public void testRunAs() throws Exception { String repoName = "repo_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - if (orgApi.get(orgName) == null) { - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + if (orgApi.getOrg(orgName) == null) { + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); } ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setVisibility(ProjectEntry.VisibilityEnum.PUBLIC) - .setRepositories(Collections.singletonMap(repoName, new RepositoryEntry() - .setUrl(gitUrl) - .setBranch("master")))); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .visibility(ProjectEntry.VisibilityEnum.PUBLIC) + .repositories(Collections.singletonMap(repoName, new RepositoryEntry() + .url(gitUrl) + .branch("master")))); // --- String username = "user_" + randomString(); UsersApi usersApi = new UsersApi(getApiClient()); - CreateUserResponse cur = usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(username) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + CreateUserResponse cur = usersApi.createOrUpdateUser(new CreateUserRequest() + .username(username) + .type(CreateUserRequest.TypeEnum.LOCAL)); ApiKeysApi apiKeyResource = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse apiKeyResponse = apiKeyResource.create(new CreateApiKeyRequest().setUsername(username)); + CreateApiKeyResponse apiKeyResponse = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(username)); - SecretClient secretsApi = new SecretClient(getApiClient()); + com.walmartlabs.concord.client2.SecretClient secretsApi = new com.walmartlabs.concord.client2.SecretClient(getApiClient()); CreateSecretRequest secret = CreateSecretRequest.builder() .org(orgName) - .project(projectName) + .addProjectNames(projectName) .name("test-run-as") .data(apiKeyResponse.getKey().getBytes(StandardCharsets.UTF_8)) .build(); @@ -163,12 +164,16 @@ public void testRunAs() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); + ProcessV2Api processApi = new ProcessV2Api(getApiClient()); + ProcessListFilter filter = ProcessListFilter.builder() + .orgName(orgName) + .projectName(projectName) + .build(); while (true) { Thread.sleep(1000); - List processes = processApi.list(orgName, projectName, null, null, null, null, null, null, null, null, null); + List processes = processApi.listProcesses(filter); if (processes.size() != 1) { continue; } @@ -182,7 +187,7 @@ public void testRunAs() throws Exception { // --- - projectsApi.delete(orgName, projectName); + projectsApi.deleteProject(orgName, projectName); } private static String initRepo(String initResource) throws Exception { @@ -201,14 +206,21 @@ private static String initRepo(String initResource) throws Exception { private List listCronProcesses(String o, String p, String r, String tag) throws ApiException { ProcessV2Api processV2Api = new ProcessV2Api(getApiClient()); - return processV2Api.list(null, o, null, p, null, r, null, null, - Collections.singletonList(tag), null, "cron", null, null, null, null); + ProcessListFilter filter = ProcessListFilter.builder() + .orgName(o) + .projectName(p) + .repoName(r) + .initiator("cron") + .tags(Collections.singleton(tag)) + .build(); + + return processV2Api.listProcesses(filter); } private 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; } @@ -218,7 +230,7 @@ private List waitForTriggers(String orgName, String projectName, S } private boolean hasLogEntry(ProcessEntry e, String pattern) throws Exception { - byte[] ab = getLog(e.getLogFileName()); + byte[] ab = getLog(e.getInstanceId()); List l = grep(pattern, ab); return !l.isEmpty(); } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/CrudIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/CrudIT.java index 4847d10795..1452a90e6d 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/CrudIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/CrudIT.java @@ -20,8 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.parallel.Execution; import org.junit.jupiter.api.parallel.ExecutionMode; @@ -39,24 +38,24 @@ public void testOrgUpdate() throws Exception { Map meta = Collections.singletonMap("x", "123"); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry() - .setName(orgName) - .setMeta(meta) - .setVisibility(OrganizationEntry.VisibilityEnum.PUBLIC)); + orgApi.createOrUpdateOrg(new OrganizationEntry() + .name(orgName) + .meta(meta) + .visibility(OrganizationEntry.VisibilityEnum.PUBLIC)); // --- - OrganizationEntry e = orgApi.get(orgName); + OrganizationEntry e = orgApi.getOrg(orgName); assertNotNull(e.getMeta()); assertEquals("123", e.getMeta().get("x")); // --- - orgApi.createOrUpdate(e.setMeta(Collections.singletonMap("x", "234"))); + orgApi.createOrUpdateOrg(e.meta(Collections.singletonMap("x", "234"))); // --- - e = orgApi.get(orgName); + e = orgApi.getOrg(orgName); assertNotNull(e.getMeta()); assertEquals("234", e.getMeta().get("x")); } @@ -71,33 +70,33 @@ public void testProject() throws Exception { // --- create - ProjectOperationResponse createResp = projectsApi.createOrUpdate(orgName, new ProjectEntry().setName(projectName)); - assertTrue(createResp.isOk()); + ProjectOperationResponse createResp = projectsApi.createOrUpdateProject(orgName, new ProjectEntry().name(projectName)); + assertTrue(createResp.getOk()); assertNotNull(createResp.getId()); // --- update - ProjectOperationResponse updateResp = projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setId(createResp.getId()) - .setName(updateProjectName)); + ProjectOperationResponse updateResp = projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .id(createResp.getId()) + .name(updateProjectName)); assertEquals(ProjectOperationResponse.ResultEnum.UPDATED, updateResp.getResult()); assertEquals(createResp.getId(), updateResp.getId()); // --- get - ProjectEntry projectEntry = projectsApi.get(orgName, updateProjectName); + ProjectEntry projectEntry = projectsApi.getProject(orgName, updateProjectName); assertEquals(projectEntry.getId(), createResp.getId()); // --- create - createResp = projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRepositories(Collections.emptyMap())); - assertTrue(createResp.isOk()); + createResp = projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .repositories(Collections.emptyMap())); + assertTrue(createResp.getOk()); // --- list - List projectList = projectsApi.find(orgName, null, null, null); + List projectList = projectsApi.findProjects(orgName, null, null, null); projectEntry = findProject(projectList, projectName); assertNotNull(projectEntry); @@ -106,34 +105,32 @@ public void testProject() throws Exception { String newOrgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); CreateOrganizationResponse createOrganizationResponse = - orgApi.createOrUpdate(new OrganizationEntry().setName(newOrgName)); - assertTrue(createOrganizationResponse.isOk()); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(newOrgName)); + assertTrue(createOrganizationResponse.getOk()); assertNotNull(createOrganizationResponse.getId()); - ProjectOperationResponse moveResp = projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setId(createResp.getId()) - .setOrgId(createOrganizationResponse.getId()) + ProjectOperationResponse moveResp = projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .id(createResp.getId()) + .orgId(createOrganizationResponse.getId()) ); - assertTrue(moveResp.isOk()); + assertTrue(moveResp.getOk()); assertEquals(ProjectOperationResponse.ResultEnum.UPDATED, moveResp.getResult()); // --- error - empty name try { - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName("") - ); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry().name("")); fail("Project name should not be empty string"); } catch (ApiException e) { - assertTrue(e.getMessage().contains("must match")); + assertTrue(e.getMessage().contains("must match"), e::getMessage); } // --- error - null name and id try { - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(null) - .setId(null) + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(null) + .id(null) ); fail("Project name should not be empty string"); } catch (ApiException e) { @@ -142,17 +139,17 @@ public void testProject() throws Exception { // --- update project's organization name - moveResp = projectsApi.createOrUpdate(newOrgName, new ProjectEntry() - .setName(projectName) - .setOrgName(orgName) + moveResp = projectsApi.createOrUpdateProject(newOrgName, new ProjectEntry() + .name(projectName) + .orgName(orgName) ); - assertTrue(moveResp.isOk()); + assertTrue(moveResp.getOk()); assertEquals(ProjectOperationResponse.ResultEnum.UPDATED, moveResp.getResult()); // --- delete - GenericOperationResult deleteResp = projectsApi.delete(orgName, projectName); - assertTrue(deleteResp.isOk()); + GenericOperationResult deleteResp = projectsApi.deleteProject(orgName, projectName); + assertTrue(deleteResp.getOk()); } @Test @@ -165,19 +162,19 @@ public void testNonUniqueRepositoryNames() throws Exception { String repoName = "repo_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName1) - .setRepositories(Collections.singletonMap(repoName, new RepositoryEntry() - .setName(repoName) - .setUrl(createRepo("repositoryRefresh")) - .setBranch("master")))); - - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName2) - .setRepositories(Collections.singletonMap(repoName, new RepositoryEntry() - .setName(repoName) - .setUrl(createRepo("repositoryRefresh")) - .setBranch("master")))); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName1) + .repositories(Collections.singletonMap(repoName, new RepositoryEntry() + .name(repoName) + .url(createRepo("repositoryRefresh")) + .branch("master")))); + + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName2) + .repositories(Collections.singletonMap(repoName, new RepositoryEntry() + .name(repoName) + .url(createRepo("repositoryRefresh")) + .branch("master")))); } @Test @@ -190,32 +187,32 @@ public void testInventory() throws Exception { // --- create - CreateInventoryResponse cir = inventoriesApi.createOrUpdate(orgName, new InventoryEntry().setName(inventoryName)); - assertTrue(cir.isOk()); + CreateInventoryResponse cir = inventoriesApi.createOrUpdateInventory(orgName, new InventoryEntry().name(inventoryName)); + assertTrue(cir.getOk()); assertNotNull(cir.getId()); // --- update - CreateInventoryResponse updateInventoryResponse = inventoriesApi.createOrUpdate(orgName, + CreateInventoryResponse updateInventoryResponse = inventoriesApi.createOrUpdateInventory(orgName, new InventoryEntry() - .setId(cir.getId()) - .setName(updatedInventoryName)); + .id(cir.getId()) + .name(updatedInventoryName)); assertEquals(updateInventoryResponse.getResult(), CreateInventoryResponse.ResultEnum.UPDATED); assertEquals(updateInventoryResponse.getId(), cir.getId()); // --- get - InventoryEntry inventoryEntry = inventoriesApi.get(orgName, updatedInventoryName); + InventoryEntry inventoryEntry = inventoriesApi.getInventory(orgName, updatedInventoryName); assertNotNull(inventoryEntry); // -- list - List l = inventoriesApi.list(orgName); + List l = inventoriesApi.listInventories(orgName); assertTrue(l.stream().anyMatch(e -> updatedInventoryName.equals(e.getName()) && orgName.equals(e.getOrgName()))); // --- delete - GenericOperationResult deleteInventoryResponse = inventoriesApi.delete(orgName, updatedInventoryName); + GenericOperationResult deleteInventoryResponse = inventoriesApi.deleteInventory(orgName, updatedInventoryName); assertTrue(deleteInventoryResponse.getResult() == GenericOperationResult.ResultEnum.DELETED); } @@ -229,27 +226,27 @@ public void testInventoryData() throws Exception { Map data = Collections.singletonMap("k", "v"); InventoriesApi inventoriesApi = new InventoriesApi(getApiClient()); - inventoriesApi.createOrUpdate(orgName, new InventoryEntry().setName(inventoryName)); + inventoriesApi.createOrUpdateInventory(orgName, new InventoryEntry().name(inventoryName)); // --- create @SuppressWarnings("unchecked") - Map result = (Map) dataApi.data(orgName, inventoryName, itemPath, data); + Map result = (Map) dataApi.updateInventoryData(orgName, inventoryName, itemPath, data); assertNotNull(result); assertEquals(Collections.singletonMap("a", data), result); // --- get @SuppressWarnings("unchecked") - Map result2 = (Map) dataApi.get(orgName, inventoryName, itemPath, false); + Map result2 = (Map) dataApi.getInventoryData(orgName, inventoryName, itemPath, false); assertNotNull(result2); assertEquals(Collections.singletonMap("a", data), result); // --- delete - DeleteInventoryDataResponse didr = dataApi.delete(orgName, inventoryName, itemPath); + DeleteInventoryDataResponse didr = dataApi.deleteInventoryData(orgName, inventoryName, itemPath); assertNotNull(didr); - assertTrue(didr.isOk()); + assertTrue(didr.getOk()); } @Test @@ -263,47 +260,47 @@ public void testInventoryQuery() throws Exception { String text = "select * from test_" + randomString(); InventoriesApi inventoriesApi = new InventoriesApi(getApiClient()); - inventoriesApi.createOrUpdate(orgName, new InventoryEntry().setName(inventoryName)); + inventoriesApi.createOrUpdateInventory(orgName, new InventoryEntry().name(inventoryName)); // --- InventoryDataApi dataApi = new InventoryDataApi(getApiClient()); - dataApi.data(orgName, inventoryName, "/test", Collections.singletonMap("k", "v")); + dataApi.updateInventoryData(orgName, inventoryName, "/test", Collections.singletonMap("k", "v")); // --- create - CreateInventoryQueryResponse cqr = queriesApi.createOrUpdate(orgName, inventoryName, queryName, text); - assertTrue(cqr.isOk()); + CreateInventoryQueryResponse cqr = queriesApi.createOrUpdateInventoryQuery(orgName, inventoryName, queryName, text); + assertTrue(cqr.getOk()); assertNotNull(cqr.getId()); // --- update String updatedText = "select item_data::text from inventory_data"; - CreateInventoryQueryResponse uqr = queriesApi.createOrUpdate(orgName, inventoryName, queryName, updatedText); - assertTrue(uqr.isOk()); + CreateInventoryQueryResponse uqr = queriesApi.createOrUpdateInventoryQuery(orgName, inventoryName, queryName, updatedText); + assertTrue(uqr.getOk()); assertNotNull(uqr.getId()); // --- get - InventoryQueryEntry e1 = queriesApi.get(orgName, inventoryName, queryName); + InventoryQueryEntry e1 = queriesApi.getInventoryQuery(orgName, inventoryName, queryName); assertNotNull(e1); assertNotNull(e1.getId()); assertEquals(queryName, e1.getName()); assertEquals(updatedText, e1.getText()); // --- list - List list = queriesApi.list(orgName, inventoryName); + List list = queriesApi.listInventoryQueries(orgName, inventoryName); assertTrue(list.stream().anyMatch(e -> queryName.equals(e.getName()) && updatedText.equals(e.getText()))); // --- exec @SuppressWarnings("unchecked") - List result = queriesApi.exec(orgName, inventoryName, queryName, null); + List result = queriesApi.executeInventoryQuery(orgName, inventoryName, queryName, null); assertNotNull(result); Map m = (Map) result.get(0); assertEquals(Collections.singletonMap("k", "v"), m); // --- delete - DeleteInventoryQueryResponse dqr = queriesApi.delete(orgName, inventoryName, queryName); + DeleteInventoryQueryResponse dqr = queriesApi.deleteInventoryQuery(orgName, inventoryName, queryName); assertNotNull(dqr); - assertTrue(dqr.isOk()); + assertTrue(dqr.getOk()); } @Test @@ -315,12 +312,12 @@ public void testInvalidQueryName() throws Exception { String queryName = "queryName_" + randomString(); InventoriesApi inventoriesApi = new InventoriesApi(getApiClient()); - inventoriesApi.createOrUpdate(orgName, new InventoryEntry().setName(inventoryName)); + inventoriesApi.createOrUpdateInventory(orgName, new InventoryEntry().name(inventoryName)); // --- try { - queriesApi.exec(orgName, inventoryName, queryName, null); + queriesApi.executeInventoryQuery(orgName, inventoryName, queryName, null); fail("should fail"); } catch (ApiException e) { assertTrue(e.getMessage().contains("not found") && e.getMessage().contains(queryName)); @@ -332,27 +329,27 @@ public void testDashes() throws Exception { String orgName = randomString() + "-test~"; OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); - orgApi.get(orgName); + orgApi.getOrg(orgName); // --- String teamName = randomString() + "-test~"; TeamsApi teamsApi = new TeamsApi(getApiClient()); - teamsApi.createOrUpdate(orgName, new TeamEntry().setName(teamName)); + teamsApi.createOrUpdateTeam(orgName, new TeamEntry().name(teamName)); - teamsApi.get(orgName, teamName); + teamsApi.getTeam(orgName, teamName); // --- String projectName = randomString() + "-test~"; ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry().setName(projectName)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry().name(projectName)); - projectsApi.get(orgName, projectName); + projectsApi.getProject(orgName, projectName); // --- @@ -370,29 +367,29 @@ public void testTeam() throws Exception { TeamsApi teamsApi = new TeamsApi(getApiClient()); // Create - CreateTeamResponse teamResponse = teamsApi.createOrUpdate(orgName, new TeamEntry().setName(teamName)); - assertTrue(teamResponse.isOk()); + CreateTeamResponse teamResponse = teamsApi.createOrUpdateTeam(orgName, new TeamEntry().name(teamName)); + assertTrue(teamResponse.getOk()); assertNotNull(teamResponse.getId()); assertEquals(teamResponse.getResult(), CreateTeamResponse.ResultEnum.CREATED); // Update Team by Name - CreateTeamResponse updateTeamResponse = teamsApi.createOrUpdate(orgName, new TeamEntry() - .setName(teamName) - .setDescription("Update Description")); + CreateTeamResponse updateTeamResponse = teamsApi.createOrUpdateTeam(orgName, new TeamEntry() + .name(teamName) + .description("Update Description")); assertEquals(updateTeamResponse.getId(), teamResponse.getId()); assertEquals(updateTeamResponse.getResult(), CreateTeamResponse.ResultEnum.UPDATED); // Update Team by ID String updatedTeamName = "UpdatedName_" + randomString(); - CreateTeamResponse updateTeamById = teamsApi.createOrUpdate(orgName, new TeamEntry() - .setId(teamResponse.getId()) - .setName(updatedTeamName) - .setDescription("Name is updated")); + CreateTeamResponse updateTeamById = teamsApi.createOrUpdateTeam(orgName, new TeamEntry() + .id(teamResponse.getId()) + .name(updatedTeamName) + .description("Name is updated")); assertEquals(teamResponse.getId(), updateTeamById.getId()); assertEquals(updateTeamResponse.getResult(), CreateTeamResponse.ResultEnum.UPDATED); // Get - TeamEntry teamEntry = teamsApi.get(orgName, updatedTeamName); + TeamEntry teamEntry = teamsApi.getTeam(orgName, updatedTeamName); assertEquals(teamResponse.getId(), teamEntry.getId()); assertEquals(updatedTeamName, teamEntry.getName()); } @@ -402,42 +399,42 @@ public void testTeamManagementWithUserIds() throws Exception { OrganizationsApi organizationsApi = new OrganizationsApi(getApiClient()); String orgName = "org_" + randomString(); - organizationsApi.createOrUpdate(new OrganizationEntry() - .setName(orgName)); + organizationsApi.createOrUpdateOrg(new OrganizationEntry() + .name(orgName)); UsersApi usersApi = new UsersApi(getApiClient()); String userAName = "userA_" + randomString(); - CreateUserResponse curA = usersApi.createOrUpdate(new CreateUserRequest() - .setType(CreateUserRequest.TypeEnum.LOCAL) - .setUsername(userAName)); + CreateUserResponse curA = usersApi.createOrUpdateUser(new CreateUserRequest() + .type(CreateUserRequest.TypeEnum.LOCAL) + .username(userAName)); String userBName = "userB_" + randomString(); - CreateUserResponse curB = usersApi.createOrUpdate(new CreateUserRequest() - .setType(CreateUserRequest.TypeEnum.LOCAL) - .setUsername(userBName)); + CreateUserResponse curB = usersApi.createOrUpdateUser(new CreateUserRequest() + .type(CreateUserRequest.TypeEnum.LOCAL) + .username(userBName)); TeamsApi teamsApi = new TeamsApi(getApiClient()); String teamName = "team_" + randomString(); - teamsApi.createOrUpdate(orgName, new TeamEntry() - .setName(teamName)); + teamsApi.createOrUpdateTeam(orgName, new TeamEntry() + .name(teamName)); // --- - List l = teamsApi.listUsers(orgName, teamName); + List l = teamsApi.listUserTeams(orgName, teamName); assertEquals(1, l.size()); assertEquals("admin", l.get(0).getUsername()); // --- - teamsApi.addUsers(orgName, teamName, true, Arrays.asList( - new TeamUserEntry().setUserId(curA.getId()), - new TeamUserEntry().setUserId(curB.getId()))); + teamsApi.addUsersToTeam(orgName, teamName, true, Arrays.asList( + new TeamUserEntry().userId(curA.getId()), + new TeamUserEntry().userId(curB.getId()))); // --- - l = teamsApi.listUsers(orgName, teamName); + l = teamsApi.listUserTeams(orgName, teamName); assertEquals(2, l.size()); assertEquals(userAName.toLowerCase(), l.get(0).getUsername()); assertEquals(userBName.toLowerCase(), l.get(1).getUsername()); @@ -448,7 +445,7 @@ public void testSecrets() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - CreateOrganizationResponse orgResponse = orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + CreateOrganizationResponse orgResponse = orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- @@ -461,13 +458,13 @@ public void testSecrets() throws Exception { String repoName = "repo_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - ProjectOperationResponse projectResp = projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRepositories(Collections.singletonMap(repoName, new RepositoryEntry() - .setName(repoName) - .setUrl(createRepo("repositoryRefresh")) - .setBranch("master") - .setSecretName(secretName)))); + ProjectOperationResponse projectResp = projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .repositories(Collections.singletonMap(repoName, new RepositoryEntry() + .name(repoName) + .url(createRepo("repositoryRefresh")) + .branch("master") + .secretName(secretName)))); UUID projectId = projectResp.getId(); // --- @@ -478,20 +475,20 @@ public void testSecrets() throws Exception { // -- Update secret project name updateReq = new SecretUpdateRequest(); - updateReq.setProjectName(projectName).setOrgId(orgResponse.getId()); - secretsApi.update(orgName, secretName, updateReq); + updateReq.projectName(projectName).orgId(orgResponse.getId()); + secretsApi.updateSecretV1(orgName, secretName, updateReq); updateReq.setProjectName(""); - secretsApi.update(orgName, secretName, updateReq); + secretsApi.updateSecretV1(orgName, secretName, updateReq); updateReq.setProjectName(null); - secretsApi.update(orgName, secretName, updateReq); + secretsApi.updateSecretV1(orgName, secretName, updateReq); // -- Update secret project ID updateReq = new SecretUpdateRequest(); updateReq.setProjectId(projectId); - secretsApi.update(orgName, secretName, updateReq); + secretsApi.updateSecretV1(orgName, secretName, updateReq); updateReq.setProjectId(null); - secretsApi.update(orgName, secretName, updateReq); + secretsApi.updateSecretV1(orgName, secretName, updateReq); // -- Delete secret @@ -499,11 +496,13 @@ public void testSecrets() throws Exception { /// --- - ProjectEntry projectEntry = projectsApi.get(orgName, projectName); - Map repos = projectEntry.getRepositories(); + ProjectEntry projectEntry = projectsApi.getProject(orgName, projectName); + assertNull(projectEntry.getRepositories()); + + List repos = new RepositoriesApi(getApiClient()).listRepositories(orgName, projectName, null, null, null); assertEquals(1, repos.size()); - RepositoryEntry repo = repos.get(repoName); + RepositoryEntry repo = repos.get(0); assertNotNull(repo); assertNull(repo.getSecretName()); } @@ -521,27 +520,27 @@ public void testOrganization() throws Exception { // --- create - CreateOrganizationResponse createOrganizationResponse = orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); - assertTrue(createOrganizationResponse.isOk()); + CreateOrganizationResponse createOrganizationResponse = orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); + assertTrue(createOrganizationResponse.getOk()); assertNotNull(createOrganizationResponse.getId()); // --- update - CreateOrganizationResponse updateOrganizationResponse = orgApi.createOrUpdate(new OrganizationEntry() - .setId(createOrganizationResponse.getId()) - .setName(updatedOrgName)); + CreateOrganizationResponse updateOrganizationResponse = orgApi.createOrUpdateOrg(new OrganizationEntry() + .id(createOrganizationResponse.getId()) + .name(updatedOrgName)); assertEquals(updateOrganizationResponse.getResult(), CreateOrganizationResponse.ResultEnum.UPDATED); assertEquals(updateOrganizationResponse.getId(), createOrganizationResponse.getId()); // --- get - OrganizationEntry organizationEntry = orgApi.get(updatedOrgName); + OrganizationEntry organizationEntry = orgApi.getOrg(updatedOrgName); assertNotNull(organizationEntry); assertEquals(createOrganizationResponse.getId(), organizationEntry.getId()); // --- list - List organizationEntryList = orgApi.find(true, null, null, null); + List organizationEntryList = orgApi.listOrgs(true, null, null, null); assertNotNull(organizationEntryList); organizationEntry = findOrganization(organizationEntryList, updatedOrgName); assertNotNull(organizationEntry); @@ -555,15 +554,15 @@ public void testOrgVisibility() throws Exception { // create private org - CreateOrganizationResponse createOrganizationResponse = orgApi.createOrUpdate(new OrganizationEntry() - .setName(orgName) - .setVisibility(OrganizationEntry.VisibilityEnum.PRIVATE)); - assertTrue(createOrganizationResponse.isOk()); + CreateOrganizationResponse createOrganizationResponse = orgApi.createOrUpdateOrg(new OrganizationEntry() + .name(orgName) + .visibility(OrganizationEntry.VisibilityEnum.PRIVATE)); + assertTrue(createOrganizationResponse.getOk()); assertNotNull(createOrganizationResponse.getId()); // --- private org available for admin - List orgs = orgApi.find(false, null, null, null); + List orgs = orgApi.listOrgs(false, null, null, null); assertTrue(orgs.stream().anyMatch(e -> e.getId().equals(createOrganizationResponse.getId()))); // add the user A @@ -571,14 +570,14 @@ public void testOrgVisibility() throws Exception { UsersApi usersApi = new UsersApi(getApiClient()); String userAName = "userA_" + randomString(); - usersApi.createOrUpdate(new CreateUserRequest().setUsername(userAName).setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest().username(userAName).type(CreateUserRequest.TypeEnum.LOCAL)); ApiKeysApi apiKeyResource = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse apiKeyA = apiKeyResource.create(new CreateApiKeyRequest().setUsername(userAName)); + CreateApiKeyResponse apiKeyA = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(userAName)); setApiKey(apiKeyA.getKey()); - orgs = orgApi.find(true, null, null, null); + orgs = orgApi.listOrgs(true, null, null, null); assertTrue(orgs.stream().noneMatch(e -> e.getId().equals(createOrganizationResponse.getId()))); } @@ -589,13 +588,13 @@ public void testOrgMeta() throws Exception { String orgName = "org_" + randomString(); Map meta = Collections.singletonMap("x", true); - CreateOrganizationResponse cor = orgApi.createOrUpdate(new OrganizationEntry() - .setName(orgName) - .setMeta(meta)); + CreateOrganizationResponse cor = orgApi.createOrUpdateOrg(new OrganizationEntry() + .name(orgName) + .meta(meta)); // --- - OrganizationEntry e = orgApi.get(orgName); + OrganizationEntry e = orgApi.getOrg(orgName); assertNotNull(e); Map meta2 = e.getMeta(); @@ -605,11 +604,11 @@ public void testOrgMeta() throws Exception { // --- meta = Collections.singletonMap("y", 123.0); - orgApi.createOrUpdate(new OrganizationEntry() - .setId(cor.getId()) - .setMeta(meta)); + orgApi.createOrUpdateOrg(new OrganizationEntry() + .id(cor.getId()) + .meta(meta)); - e = orgApi.get(orgName); + e = orgApi.getOrg(orgName); assertNotNull(e); Map meta3 = e.getMeta(); @@ -623,23 +622,23 @@ public void testPolicies() throws Exception { OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); String orgName = "org_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- ProjectsApi projectsApi = new ProjectsApi(getApiClient()); String projectName = "project_" + randomString(); - projectsApi.createOrUpdate(orgName, new ProjectEntry().setName(projectName)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry().name(projectName)); // --- String userName = "user_" + randomString(); UsersApi usersApi = new UsersApi(getApiClient()); - CreateUserResponse createUserResponse = usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userName) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + CreateUserResponse createUserResponse = usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userName) + .type(CreateUserRequest.TypeEnum.LOCAL)); // --- @@ -648,113 +647,113 @@ public void testPolicies() throws Exception { String policyName = "policy_" + randomString(); Map policyRules = Collections.singletonMap("x", 123); - PolicyOperationResponse por = policyResource.createOrUpdate(new PolicyEntry() - .setName(policyName) - .setRules(policyRules)); + PolicyOperationResponse por = policyResource.createOrUpdatePolicy(new PolicyEntry() + .name(policyName) + .rules(policyRules)); String newPolicyName = "policy2_" + randomString(); - policyResource.createOrUpdate(new PolicyEntry() - .setId(por.getId()) - .setName(newPolicyName) - .setRules(policyRules)); + policyResource.createOrUpdatePolicy(new PolicyEntry() + .id(por.getId()) + .name(newPolicyName) + .rules(policyRules)); String policyForUser = "policy3_" + randomString(); - policyResource.createOrUpdate(new PolicyEntry() - .setName(policyForUser) - .setRules(policyRules)); + policyResource.createOrUpdatePolicy(new PolicyEntry() + .name(policyForUser) + .rules(policyRules)); - policyResource.createOrUpdate(new PolicyEntry() - .setId(por.getId()) - .setName(policyName) - .setRules(policyRules)); + policyResource.createOrUpdatePolicy(new PolicyEntry() + .id(por.getId()) + .name(policyName) + .rules(policyRules)); // --- - PolicyEntry pe = policyResource.get(policyName); + PolicyEntry pe = policyResource.getPolicy(policyName); assertNotNull(pe); // --- - policyResource.link(policyName, new PolicyLinkEntry() - .setOrgName(orgName) - .setProjectName(projectName)); + policyResource.linkPolicy(policyName, new PolicyLinkEntry() + .orgName(orgName) + .projectName(projectName)); - List l = policyResource.list(orgName, projectName, null, null, null); + List l = policyResource.listPolicies(orgName, projectName, null, null, null); assertEquals(1, l.size()); assertEquals(policyName, l.get(0).getName()); // --- - policyResource.link(policyName, new PolicyLinkEntry().setOrgName(orgName)); + policyResource.linkPolicy(policyName, new PolicyLinkEntry().orgName(orgName)); - l = policyResource.list(orgName, null, null, null, null); + l = policyResource.listPolicies(orgName, null, null, null, null); assertEquals(1, l.size()); assertEquals(policyName, l.get(0).getName()); // --- - policyResource.link(policyName, new PolicyLinkEntry().setUserName(userName)); + policyResource.linkPolicy(policyName, new PolicyLinkEntry().userName(userName)); - l = policyResource.list(null, null, userName, null, null); + l = policyResource.listPolicies(null, null, userName, null, null); assertEquals(1, l.size()); assertEquals(policyName, l.get(0).getName()); // --- - policyResource.link(policyForUser, new PolicyLinkEntry() - .setOrgName(orgName) - .setProjectName(projectName) - .setUserName(userName)); + policyResource.linkPolicy(policyForUser, new PolicyLinkEntry() + .orgName(orgName) + .projectName(projectName) + .userName(userName)); - l = policyResource.list(orgName, projectName, userName, null, null); + l = policyResource.listPolicies(orgName, projectName, userName, null, null); assertEquals(1, l.size()); assertEquals(policyForUser, l.get(0).getName()); // --- - policyResource.unlink(policyName, orgName, projectName, null, null, null); - l = policyResource.list(orgName, projectName, null, null, null); + policyResource.unlinkPolicy(policyName, orgName, projectName, null, null, null); + l = policyResource.listPolicies(orgName, projectName, null, null, null); assertEquals(1, l.size()); - l = policyResource.list(orgName, null, null, null, null); + l = policyResource.listPolicies(orgName, null, null, null, null); assertEquals(1, l.size()); // --- - policyResource.unlink(policyName, orgName, null, null, null, null); - l = policyResource.list(orgName, projectName, null, null, null); + policyResource.unlinkPolicy(policyName, orgName, null, null, null, null); + l = policyResource.listPolicies(orgName, projectName, null, null, null); assertEquals(0, l.size()); - l = policyResource.list(orgName, null, null, null, null); + l = policyResource.listPolicies(orgName, null, null, null, null); assertEquals(0, l.size()); // --- - policyResource.unlink(policyName, null, null, userName, null, null); - l = policyResource.list(null, null, userName, null, null); + policyResource.unlinkPolicy(policyName, null, null, userName, null, null); + l = policyResource.listPolicies(null, null, userName, null, null); assertEquals(0, l.size()); - l = policyResource.list(orgName, null, null, null, null); + l = policyResource.listPolicies(orgName, null, null, null, null); assertEquals(0, l.size()); // --- - policyResource.unlink(policyForUser, orgName, projectName, userName, null, null); - l = policyResource.list(orgName, projectName, userName, null, null); + policyResource.unlinkPolicy(policyForUser, orgName, projectName, userName, null, null); + l = policyResource.listPolicies(orgName, projectName, userName, null, null); assertEquals(0, l.size()); - l = policyResource.list(orgName, null, null, null, null); + l = policyResource.listPolicies(orgName, null, null, null, null); assertEquals(0, l.size()); // --- - policyResource.delete(policyName); - l = policyResource.list(null, null, null, null, null); + policyResource.deletePolicy(policyName); + l = policyResource.listPolicies(null, null, null, null, null); for (PolicyEntry e : l) { if (policyName.equals(e.getName())) { fail("Should've been removed: " + e.getName()); } } - usersApi.delete(createUserResponse.getId()); + usersApi.deleteUser(createUserResponse.getId()); - policyResource.delete(policyForUser); + policyResource.deletePolicy(policyForUser); } @Test @@ -765,31 +764,31 @@ public void testRoles() throws Exception { // --- create - RoleOperationResponse createRoleResponse = rolesApi.createOrUpdate(new RoleEntry().setName(roleName)); + RoleOperationResponse createRoleResponse = rolesApi.createOrUpdateRole(new RoleEntry().name(roleName)); assertEquals(RoleOperationResponse.ResultEnum.CREATED, createRoleResponse.getResult()); assertNotNull(createRoleResponse.getId()); // --- update - RoleOperationResponse updateRoleResponse = rolesApi.createOrUpdate(new RoleEntry() - .setId(createRoleResponse.getId()) - .setName(roleName) - .setPermissions(Collections.singletonList("getProcessQueueAllOrgs"))); + RoleOperationResponse updateRoleResponse = rolesApi.createOrUpdateRole(new RoleEntry() + .id(createRoleResponse.getId()) + .name(roleName) + .permissions(Collections.singleton("getProcessQueueAllOrgs"))); assertEquals(RoleOperationResponse.ResultEnum.UPDATED, updateRoleResponse.getResult()); // --- get - RoleEntry roleEntry = rolesApi.get(roleName); + RoleEntry roleEntry = rolesApi.getRole(roleName); assertNotNull(roleEntry); assertEquals(createRoleResponse.getId(), roleEntry.getId()); - assertEquals("getProcessQueueAllOrgs", roleEntry.getPermissions().get(0)); + assertEquals("getProcessQueueAllOrgs", roleEntry.getPermissions().iterator().next()); // --- list - List roleEntryList = rolesApi.list(); + List roleEntryList = rolesApi.listRoles(); assertNotNull(roleEntryList); - GenericOperationResult r = rolesApi.delete(roleName); + GenericOperationResult r = rolesApi.deleteRole(roleName); assertEquals(GenericOperationResult.ResultEnum.DELETED, r.getResult()); } @@ -801,13 +800,13 @@ public void testChangeOrganization() throws Exception { OrganizationsApi organizationsApi = new OrganizationsApi(getApiClient()); - UUID defaultOrgId = organizationsApi.get(orgName).getId(); + UUID defaultOrgId = organizationsApi.getOrg(orgName).getId(); // create a second organization - CreateOrganizationResponse createOrgResponse = organizationsApi.createOrUpdate(new OrganizationEntry() - .setName(secondOrgName) - .setVisibility(OrganizationEntry.VisibilityEnum.PUBLIC)); - assertTrue(createOrgResponse.isOk()); + CreateOrganizationResponse createOrgResponse = organizationsApi.createOrUpdateOrg(new OrganizationEntry() + .name(secondOrgName) + .visibility(OrganizationEntry.VisibilityEnum.PUBLIC)); + assertTrue(createOrgResponse.getOk()); assertNotNull(createOrgResponse.getId()); // -- test change org for project @@ -815,25 +814,25 @@ public void testChangeOrganization() throws Exception { String projectName = "project_" + randomString(); // create a project in Default org - ProjectOperationResponse createResp = projectsApi.createOrUpdate(orgName, new ProjectEntry().setName(projectName)); - assertTrue(createResp.isOk()); + ProjectOperationResponse createResp = projectsApi.createOrUpdateProject(orgName, new ProjectEntry().name(projectName)); + assertTrue(createResp.getOk()); assertNotNull(createResp.getId()); // -- move project to second organization by org Name - ProjectOperationResponse moveResponse = projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setOrgName(secondOrgName)); - assertTrue(moveResponse.isOk()); + ProjectOperationResponse moveResponse = projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .orgName(secondOrgName)); + assertTrue(moveResponse.getOk()); assertEquals("UPDATED", moveResponse.getResult().getValue()); - assertNotNull(projectsApi.get(secondOrgName, projectName)); + assertNotNull(projectsApi.getProject(secondOrgName, projectName)); // -- move project back to Default organization by org Id - moveResponse = projectsApi.createOrUpdate(secondOrgName, new ProjectEntry() - .setName(projectName) - .setOrgId(defaultOrgId)); - assertTrue(moveResponse.isOk()); + moveResponse = projectsApi.createOrUpdateProject(secondOrgName, new ProjectEntry() + .name(projectName) + .orgId(defaultOrgId)); + assertTrue(moveResponse.getOk()); assertEquals("UPDATED", moveResponse.getResult().getValue()); - assertNotNull(projectsApi.get(orgName, projectName)); + assertNotNull(projectsApi.getProject(orgName, projectName)); // -- test change org for secret SecretsApi secretsApi = new SecretsApi(getApiClient()); @@ -843,17 +842,17 @@ public void testChangeOrganization() throws Exception { addPlainSecret(orgName, secretName, false, null, "hey".getBytes()); // -- move secret to second organization by org Name - GenericOperationResult moveSecretResponse = secretsApi.update(orgName, secretName, - new SecretUpdateRequest().setOrgName(secondOrgName)); - assertTrue(moveSecretResponse.isOk()); + GenericOperationResult moveSecretResponse = secretsApi.updateSecretV1(orgName, secretName, + new SecretUpdateRequest().orgName(secondOrgName)); + assertTrue(moveSecretResponse.getOk()); assertEquals("UPDATED", moveSecretResponse.getResult().getValue()); - assertNotNull(secretsApi.get(secondOrgName, secretName)); + assertNotNull(new SecretsV2Api(getApiClient()).getSecret(secondOrgName, secretName)); // -- move secret back to Default organization by org Id - moveSecretResponse = secretsApi.update(secondOrgName, secretName, new SecretUpdateRequest().setOrgId(defaultOrgId)); - assertTrue(moveSecretResponse.isOk()); + moveSecretResponse = secretsApi.updateSecretV1(secondOrgName, secretName, new SecretUpdateRequest().orgId(defaultOrgId)); + assertTrue(moveSecretResponse.getOk()); assertEquals("UPDATED", moveSecretResponse.getResult().getValue()); - assertNotNull(secretsApi.get(orgName, secretName)); + assertNotNull(new SecretsV2Api(getApiClient()).getSecret(orgName, secretName)); } private static OrganizationEntry findOrganization(List l, String name) { diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/CryptoIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/CryptoIT.java index 7f76bc688a..f9ad6774d8 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/CryptoIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/CryptoIT.java @@ -21,7 +21,7 @@ */ import com.google.common.collect.ImmutableMap; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.intellij.lang.annotations.Language; import org.junit.jupiter.api.Test; @@ -96,7 +96,7 @@ public void testExportAsFileWithOrg() throws Exception { String orgName = "org@" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- @@ -108,7 +108,7 @@ public void testExportAsFileWithOrg() throws Exception { // --- - byte[] payload = archive(ProcessIT.class.getResource("cryptoFileWithOrg").toURI()); + byte[] payload = archive(CryptoIT.class.getResource("cryptoFileWithOrg").toURI()); StartProcessResponse spr = start(ImmutableMap.of( "archive", payload, @@ -118,10 +118,9 @@ public void testExportAsFileWithOrg() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*We got " + secretValue + ".*", ab); } @@ -130,7 +129,7 @@ public void testWithoutPassword() throws Exception { String orgName = "org@" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- @@ -141,7 +140,7 @@ public void testWithoutPassword() throws Exception { // --- - byte[] payload = archive(ProcessIT.class.getResource("cryptoWithoutPassword").toURI()); + byte[] payload = archive(CryptoIT.class.getResource("cryptoWithoutPassword").toURI()); StartProcessResponse spr = start(ImmutableMap.of( "archive", payload, @@ -150,10 +149,9 @@ public void testWithoutPassword() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*We got " + secretValue + ".*", ab); } @@ -162,27 +160,27 @@ public void testEncryptString() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); // --- String value = "value_" + randomString(); EncryptValueResponse evr = projectsApi.encrypt(orgName, projectName, value); - assertTrue(evr.isOk()); + assertTrue(evr.getOk()); // --- - byte[] payload = archive(ProcessIT.class.getResource("encryptString").toURI()); + byte[] payload = archive(CryptoIT.class.getResource("encryptString").toURI()); StartProcessResponse spr = start(ImmutableMap.of( "org", orgName, @@ -192,10 +190,9 @@ public void testEncryptString() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*We got " + Pattern.quote(evr.getData()) + ".*", ab); } @@ -204,27 +201,27 @@ public void testDecryptString() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); // --- String value = "value_" + randomString(); EncryptValueResponse evr = projectsApi.encrypt(orgName, projectName, value); - assertTrue(evr.isOk()); + assertTrue(evr.getOk()); // --- - byte[] payload = archive(ProcessIT.class.getResource("decryptString").toURI()); + byte[] payload = archive(CryptoIT.class.getResource("decryptString").toURI()); StartProcessResponse spr = start(ImmutableMap.of( "org", orgName, @@ -234,10 +231,9 @@ public void testDecryptString() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*We got " + value + ".*", ab); } @@ -246,27 +242,27 @@ public void testDecryptStringTooBig() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); // --- String value = "value_" + randomString(); EncryptValueResponse evr = projectsApi.encrypt(orgName, projectName, value); - assertTrue(evr.isOk()); + assertTrue(evr.getOk()); // --- - byte[] payload = archive(ProcessIT.class.getResource("decryptStringTooBig").toURI()); + byte[] payload = archive(CryptoIT.class.getResource("decryptStringTooBig").toURI()); StartProcessResponse spr = start(ImmutableMap.of( "org", orgName, @@ -275,10 +271,9 @@ public void testDecryptStringTooBig() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.FAILED); + ProcessEntry pir = waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.FAILED); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLogAtLeast(".*too big.*", 1, ab); } @@ -287,20 +282,20 @@ public void testDecryptInvalidString() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); // --- - byte[] payload = archive(ProcessIT.class.getResource("decryptString").toURI()); + byte[] payload = archive(CryptoIT.class.getResource("decryptString").toURI()); StartProcessResponse spr = start(ImmutableMap.of( "org", orgName, @@ -310,8 +305,7 @@ public void testDecryptInvalidString() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FAILED, pir.getStatus()); // --- @@ -324,8 +318,9 @@ public void testDecryptInvalidString() throws Exception { // --- - pir = waitForCompletion(processApi, spr.getInstanceId()); - assertEquals(ProcessEntry.StatusEnum.FAILED, pir.getStatus(), "Process logs: " + new String(getLog(pir.getLogFileName()))); + pir = waitForCompletion(getApiClient(), spr.getInstanceId()); + assertEquals(ProcessEntry.StatusEnum.FAILED, pir.getStatus(), + "Process logs: " + new String(getLog(pir.getInstanceId()))); } @Test @@ -337,9 +332,9 @@ public void testProjectSecret() throws Exception { String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); // --- @@ -355,13 +350,13 @@ public void testProjectSecret() throws Exception { String username = "user_" + randomString(); UsersApi usersApi = new UsersApi(getApiClient()); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(username) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(username) + .type(CreateUserRequest.TypeEnum.LOCAL)); ApiKeysApi apiKeysApi = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse cakr = apiKeysApi.create(new CreateApiKeyRequest() - .setUsername(username)); + CreateApiKeyResponse cakr = apiKeysApi.createUserApiKey(new CreateApiKeyRequest() + .username(username)); // --- @@ -383,14 +378,13 @@ public void testProjectSecret() throws Exception { public void testCurrentOrg() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi organizationsApi = new OrganizationsApi(getApiClient()); - organizationsApi.createOrUpdate(new OrganizationEntry() - .setName(orgName)); + organizationsApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.OWNERS)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.OWNERS)); String secretName = "secret_" + randomString(); @@ -402,7 +396,7 @@ public void testCurrentOrg() throws Exception { // --- - byte[] payload = archive(ProcessIT.class.getResource("currentOrgCrypto").toURI()); + byte[] payload = archive(CryptoIT.class.getResource("currentOrgCrypto").toURI()); Map input = new HashMap<>(); input.put("archive", payload); @@ -411,31 +405,30 @@ public void testCurrentOrg() throws Exception { input.put("project", projectName); StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pe = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); + ProcessEntry pe = waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); assertEquals(ProcessEntry.StatusEnum.SUSPENDED, pe.getStatus()); // --- ProcessFormsApi processFormsApi = new ProcessFormsApi(getApiClient()); - List forms = processFormsApi.list(pe.getInstanceId()); + List forms = processFormsApi.listProcessForms(pe.getInstanceId()); assertEquals(1, forms.size()); FormListEntry form = forms.get(0); - processFormsApi.submit(pe.getInstanceId(), form.getName(), Collections.singletonMap("x", "123")); + processFormsApi.submitForm(pe.getInstanceId(), form.getName(), Collections.singletonMap("x", "123")); - pe = waitForCompletion(processApi, spr.getInstanceId()); + pe = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FINISHED, pe.getStatus()); // --- - byte[] ab = getLog(pe.getLogFileName()); + byte[] ab = getLog(pe.getInstanceId()); assertLog(".*Before form: " + orgSecretValue + ".*", ab); assertLog(".*After form: " + orgSecretValue + ".*", ab); } private void test(String project, String secretName, String storePassword, @Language("RegExp") String log) throws Exception { - byte[] payload = archive(ProcessIT.class.getResource(project).toURI()); + byte[] payload = archive(CryptoIT.class.getResource(project).toURI()); StartProcessResponse spr = start(ImmutableMap.of( "archive", payload, @@ -444,10 +437,9 @@ private void test(String project, String secretName, String storePassword, @Lang // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLogAtLeast(log, 1, ab); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/DefaultProcessVariablesIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/DefaultProcessVariablesIT.java index 620c4c9662..84e8dcada6 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/DefaultProcessVariablesIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/DefaultProcessVariablesIT.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -50,17 +50,17 @@ public void precondition() throws Exception { policy.setRules(Collections.singletonMap("defaultProcessCfg", Collections.singletonMap("defaultTaskVariables", Collections.singletonMap("testDefaultVars", defVars)))); - policyApi.createOrUpdate(policy); + policyApi.createOrUpdatePolicy(policy); PolicyLinkEntry link = new PolicyLinkEntry(); - policyApi.link(POLICY_NAME, link); - policyApi.refresh(); + policyApi.linkPolicy(POLICY_NAME, link); + policyApi.refreshPolicy(); } @AfterEach public void cleanup() { PolicyApi policyApi = new PolicyApi(getApiClient()); try { - policyApi.delete(POLICY_NAME); + policyApi.deletePolicy(POLICY_NAME); } catch (Exception e) { // ignore } @@ -70,17 +70,16 @@ public void cleanup() { public void testDefaultVarsAccess() throws Exception { // prepare the payload - byte[] payload = archive(ProcessIT.class.getResource("defaultVars").toURI()); + byte[] payload = archive(DefaultProcessVariablesIT.class.getResource("defaultVars").toURI()); // start the process - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); assertNotNull(spr.getInstanceId()); // wait for completion - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // get the name of the agent's log file @@ -88,7 +87,7 @@ public void testDefaultVarsAccess() throws Exception { // check the logs - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Default vars: value1.*", ab); } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/DependenciesIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/DependenciesIT.java index 45c59dfa40..3c3743700f 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/DependenciesIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/DependenciesIT.java @@ -20,9 +20,9 @@ * ===== */ -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.ProcessApi; +import com.walmartlabs.concord.client2.ProcessEntry; +import com.walmartlabs.concord.client2.StartProcessResponse; import com.walmartlabs.concord.common.IOUtils; import com.walmartlabs.concord.sdk.Constants; import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; @@ -66,25 +66,24 @@ public void testUploadAndRun() throws Exception { StartProcessResponse spr = start(payload); assertNotNull(spr.getInstanceId()); - ProcessEntry psr = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry psr = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FINISHED, psr.getStatus()); // --- - byte[] ab = getLog(psr.getLogFileName()); + byte[] ab = getLog(psr.getInstanceId()); assertLog(".*Hello!.*", ab); } @Test public void testMaven() throws Exception { - byte[] payload = archive(ProcessIT.class.getResource("mvnDeps").toURI()); + byte[] payload = archive(DependenciesIT.class.getResource("mvnDeps").toURI()); - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); assertNotNull(spr.getInstanceId()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); - byte[] ab = getLog(pir.getLogFileName()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Hello, Concord.*", ab); } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/DependencyManagerIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/DependencyManagerIT.java index 6470fd59a4..2bd504db22 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/DependencyManagerIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/DependencyManagerIT.java @@ -22,9 +22,8 @@ import com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer; import com.github.tomakehurst.wiremock.junit5.WireMockExtension; -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.ProcessEntry; +import com.walmartlabs.concord.client2.StartProcessResponse; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -82,9 +81,8 @@ public void test() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); - byte[] ab = getLog(pir.getLogFileName()); + ProcessEntry pir = waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*downloading.*", ab); assertLog(".*using a cached copy.*", ab); diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/DispatcherIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/DispatcherIT.java index 38a8f2740e..00be10894f 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/DispatcherIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/DispatcherIT.java @@ -20,11 +20,13 @@ * ===== */ -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.ProcessApi; +import com.walmartlabs.concord.client2.ProcessEntry; +import com.walmartlabs.concord.client2.ProcessV2Api; +import com.walmartlabs.concord.client2.StartProcessResponse; import org.junit.jupiter.api.Test; +import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -40,7 +42,7 @@ public class DispatcherIT extends AbstractServerIT { */ @Test public void testUnknownFlavor() throws Exception { - byte[] payload = archive(ProcessIT.class.getResource("unknownFlavor").toURI()); + byte[] payload = archive(DispatcherIT.class.getResource("unknownFlavor").toURI()); Map input = new HashMap<>(); input.put("requirements.agent.type", randomString()); @@ -54,15 +56,15 @@ public void testUnknownFlavor() throws Exception { StartProcessResponse knownFlavor = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pe = waitForCompletion(processApi, knownFlavor.getInstanceId()); + ProcessEntry pe = waitForCompletion(getApiClient(), knownFlavor.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FINISHED, pe.getStatus()); // --- - pe = processApi.get(unknownFlavor.getInstanceId()); + ProcessV2Api processApi = new ProcessV2Api(getApiClient()); + pe = processApi.getProcess(unknownFlavor.getInstanceId(), Collections.emptySet()); assertEquals(ProcessEntry.StatusEnum.ENQUEUED, pe.getStatus()); - processApi.kill(pe.getInstanceId()); + new ProcessApi(getApiClient()).kill(pe.getInstanceId()); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/DockerAnsibleIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/DockerAnsibleIT.java index 5bf1535aa1..6ac8887fc7 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/DockerAnsibleIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/DockerAnsibleIT.java @@ -20,13 +20,13 @@ * ===== */ -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.ProcessApi; +import com.walmartlabs.concord.client2.ProcessEntry; +import com.walmartlabs.concord.client2.StartProcessResponse; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable; -import java.io.File; +import java.io.InputStream; import java.util.HashMap; import java.util.Map; @@ -41,7 +41,7 @@ public class DockerAnsibleIT extends AbstractServerIT { @Test public void test() throws Exception { - byte[] payload = archive(DockerIT.class.getResource("dockerAnsible").toURI(), + byte[] payload = archive(DockerAnsibleIT.class.getResource("dockerAnsible").toURI(), ITConstants.DEPENDENCIES_DIR); Map input = new HashMap<>(); @@ -51,17 +51,18 @@ public void test() throws Exception { // -- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertNotNull(pir.getLogFileName()); assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*\"msg\": \"Hello from Docker!\".*", ab); // -- - File resp = processApi.downloadAttachment(pir.getInstanceId(), "ansible_stats.json"); - assertNotNull(resp); + ProcessApi processApi = new ProcessApi(getApiClient()); + try (InputStream is = processApi.downloadAttachment(pir.getInstanceId(), "ansible_stats.json")) { + assertNotNull(is); + } } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/DockerIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/DockerIT.java index 89647ab99c..433cd3b07b 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/DockerIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/DockerIT.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,9 +20,8 @@ * ===== */ -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.ProcessEntry; +import com.walmartlabs.concord.client2.StartProcessResponse; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledIf; import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable; @@ -46,11 +45,10 @@ public void test() throws Exception { input.put("arguments.image", ITConstants.DOCKER_ANSIBLE_IMAGE); StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertNotNull(pir.getLogFileName()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*DOCKER: Hello, world.*", ab); } @@ -63,11 +61,10 @@ public void testOut() throws Exception { input.put("arguments.image", ITConstants.DOCKER_ANSIBLE_IMAGE); StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertNotNull(pir.getLogFileName()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*!! Hello, world !!.*", ab); assertLog(".*DOCKER: STDERR STILL WORKS.*", ab); } @@ -81,11 +78,10 @@ public void testTaskSyntaxOut() throws Exception { input.put("arguments.image", ITConstants.DOCKER_ANSIBLE_IMAGE); StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertNotNull(pir.getLogFileName()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*!! Hello, world.*", ab); assertLog(".*DOCKER: STDERR STILL WORKS.*", ab); } @@ -99,11 +95,10 @@ public void testNoLogWithStdOut() throws Exception { input.put("arguments.image", ITConstants.DOCKER_ANSIBLE_IMAGE); StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertNotNull(pir.getLogFileName()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertNoLog(".*!! Hello, world .*", ab); assertNoLog(".*STDERR WORKS !!.*", ab); } @@ -117,11 +112,10 @@ public void testLogWithoutStdOut() throws Exception { input.put("arguments.image", ITConstants.DOCKER_ANSIBLE_IMAGE); StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertNotNull(pir.getLogFileName()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*DOCKER: Hello, world.*", ab); assertLog(".*DOCKER: STDERR WORKS.*", ab); } @@ -135,11 +129,10 @@ public void testLogWithStdErr() throws Exception { input.put("arguments.image", ITConstants.DOCKER_ANSIBLE_IMAGE); StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertNotNull(pir.getLogFileName()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*STDERR: STDERR WORKS.*", ab); } @@ -149,10 +142,9 @@ public void testPullRetry() throws Exception { StartProcessResponse spr = start(payload); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLogAtLeast(".*Error pulling the image.*", 2, ab); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/DynamicFormIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/DynamicFormIT.java index dc1a71bbc7..9525c82ee5 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/DynamicFormIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/DynamicFormIT.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import java.util.HashMap; @@ -40,44 +40,43 @@ public void testWithGroovy() throws Exception { // --- - byte[] payload = archive(ProcessIT.class.getResource("dynamicFormWithGroovy").toURI()); + byte[] payload = archive(DynamicFormIT.class.getResource("dynamicFormWithGroovy").toURI()); - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); assertNotNull(spr.getInstanceId()); // --- - ProcessEntry pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); + ProcessEntry pir = waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); // --- ProcessFormsApi formsApi = new ProcessFormsApi(getApiClient()); - List forms = formsApi.list(spr.getInstanceId()); + List forms = formsApi.listProcessForms(spr.getInstanceId()); assertEquals(1, forms.size()); // --- FormListEntry f0 = forms.get(0); - assertFalse(f0.isCustom()); + assertFalse(f0.getCustom()); String formName = f0.getName(); Map data = new HashMap<>(); data.put("firstName", firstName); data.put("lastName", lastName); - FormSubmitResponse fsr = formsApi.submit(pir.getInstanceId(), formName, data); - assertTrue(fsr.isOk()); + FormSubmitResponse fsr = formsApi.submitForm(pir.getInstanceId(), formName, data); + assertTrue(fsr.getOk()); // --- - pir = waitForCompletion(processApi, spr.getInstanceId()); + pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus()); // -- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*firstName.*", ab); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/DynamicTaskIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/DynamicTaskIT.java index a056472f45..f2eaba8afb 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/DynamicTaskIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/DynamicTaskIT.java @@ -20,9 +20,9 @@ * ===== */ -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.ProcessApi; +import com.walmartlabs.concord.client2.ProcessEntry; +import com.walmartlabs.concord.client2.StartProcessResponse; import org.junit.jupiter.api.Test; import static com.walmartlabs.concord.it.common.ITUtils.archive; @@ -46,11 +46,11 @@ public void testDynamicTask() throws Exception { // --- - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Hey, world.*", ab); } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/EntityOwnerPolicyIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/EntityOwnerPolicyIT.java index fff2ce06c9..eecd304b93 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/EntityOwnerPolicyIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/EntityOwnerPolicyIT.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,8 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -56,25 +55,25 @@ public void init() throws Exception { @AfterEach public void cleanup() throws Exception { PolicyApi policyApi = new PolicyApi(getApiClient()); - policyApi.delete(policyName); + policyApi.deletePolicy(policyName); } @Test public void testOrgCreation() throws Exception { // --- user UsersApi usersApi = new UsersApi(getApiClient()); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userOwner) - .setEmail("owner@mail.com") - .setDisplayName("Test Owner") - .setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userOwner) + .email("owner@mail.com") + .displayName("Test Owner") + .type(CreateUserRequest.TypeEnum.LOCAL)); ApiKeysApi apiKeyResource = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse cakr = apiKeyResource.create(new CreateApiKeyRequest().setUsername(userOwner)); - assertTrue(cakr.isOk()); + CreateApiKeyResponse cakr = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(userOwner)); + assertTrue(cakr.getOk()); usersApi.updateUserRoles(userOwner, new UpdateUserRolesRequest() - .setRoles(Collections.singletonList("concordAdmin"))); + .roles(Collections.singleton("concordAdmin"))); // --- @@ -86,7 +85,7 @@ public void testOrgCreation() throws Exception { owner.setUsername(userOwner); try { - orgApi.createOrUpdate(new OrganizationEntry().setOwner(owner).setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().owner(owner).name(orgName)); fail("exception expected"); } catch (ApiException e) { assertTrue(e.getResponseBody().contains("Action forbidden: test-rule")); @@ -104,13 +103,13 @@ private Map createRule(String action, String entity, Map rules) throws ApiException { PolicyApi policyApi = new PolicyApi(getApiClient()); - policyApi.createOrUpdate(new PolicyEntry() - .setName(policyName) - .setRules(rules)); + policyApi.createOrUpdatePolicy(new PolicyEntry() + .name(policyName) + .rules(rules)); - policyApi.link(policyName, new PolicyLinkEntry() - .setOrgName(orgName) - .setProjectName(projectName)); + policyApi.linkPolicy(policyName, new PolicyLinkEntry() + .orgName(orgName) + .projectName(projectName)); return policyName; } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/EscapeGitCommitMessageIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/EscapeGitCommitMessageIT.java index 7204818d98..0656eddce4 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/EscapeGitCommitMessageIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/EscapeGitCommitMessageIT.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.it.common.GitUtils; import com.walmartlabs.concord.it.common.MockGitSshServer; import org.junit.jupiter.api.AfterEach; @@ -75,14 +75,14 @@ public void test() throws Exception { // --- RepositoryEntry repo = new RepositoryEntry() - .setName(repoName) - .setUrl(repoUrl) - .setBranch("master") - .setSecretId(response.getId()); + .name(repoName) + .url(repoUrl) + .branch("master") + .secretId(response.getId()); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRepositories(singletonMap(repoName, repo))); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .repositories(singletonMap(repoName, repo))); // --- Map input = new HashMap<>(); @@ -93,12 +93,11 @@ public void test() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry psr = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry psr = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(psr.getLogFileName()); + byte[] ab = getLog(psr.getInstanceId()); assertLog(".*Hello, Vasia.*", ab); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ExclusiveProcessIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ExclusiveProcessIT.java index 86d5fb21b1..5c99538a6c 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ExclusiveProcessIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ExclusiveProcessIT.java @@ -20,8 +20,8 @@ * ===== */ -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 org.junit.jupiter.api.Test; import java.util.HashMap; @@ -39,13 +39,13 @@ public class ExclusiveProcessIT extends AbstractServerIT { public void testExclusiveCancelOld() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); byte[] payload = archive(ExclusiveProcessIT.class.getResource("exclusiveCancelOld").toURI()); @@ -61,8 +61,8 @@ public void testExclusiveCancelOld() throws Exception { input.put("arguments.time", "1"); StartProcessResponse spr2 = start(input); - ProcessEntry p1 = waitForStatus(processApi, spr1.getInstanceId(), StatusEnum.CANCELLED); - ProcessEntry p2 = waitForStatus(processApi, spr2.getInstanceId(), StatusEnum.FINISHED); + ProcessEntry p1 = waitForStatus(getApiClient(), spr1.getInstanceId(), StatusEnum.CANCELLED); + ProcessEntry p2 = waitForStatus(getApiClient(), spr2.getInstanceId(), StatusEnum.FINISHED); System.out.println("p1: createdAt: " + p1.getCreatedAt() + ", status: " + p1.getStatus()); System.out.println("p2: createdAt: " + p2.getCreatedAt() + ", status: " + p2.getStatus()); @@ -72,8 +72,8 @@ public void testExclusiveCancelOld() throws Exception { System.out.println("p1 history: " + p1History); System.out.println("p2 history: " + p2History); - System.out.println("p1 log:" + new String(getLog(p1.getLogFileName()))); - System.out.println("p2 log:" + new String(getLog(p2.getLogFileName()))); + System.out.println("p1 log:" + new String(getLog(p1.getInstanceId()))); + System.out.println("p2 log:" + new String(getLog(p2.getInstanceId()))); } assertTrue(p1.getCreatedAt().isEqual(p2.getCreatedAt()) || p1.getCreatedAt().isBefore(p2.getCreatedAt())); diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ExpressionResolveOrderIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ExpressionResolveOrderIT.java index d741aa79b8..b7142533d8 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ExpressionResolveOrderIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ExpressionResolveOrderIT.java @@ -20,9 +20,8 @@ * ===== */ -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.ProcessEntry; +import com.walmartlabs.concord.client2.StartProcessResponse; import org.junit.jupiter.api.Test; import static com.walmartlabs.concord.it.common.ITUtils.archive; @@ -36,17 +35,16 @@ public class ExpressionResolveOrderIT extends AbstractServerIT { public void test() throws Exception { // prepare the payload - byte[] payload = archive(ProcessIT.class.getResource("resolveOrder").toURI()); + byte[] payload = archive(ExpressionResolveOrderIT.class.getResource("resolveOrder").toURI()); // start the process - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); assertNotNull(spr.getInstanceId()); // wait for completion - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // get the name of the agent's log file @@ -54,7 +52,7 @@ public void test() throws Exception { // check the logs - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*sleep time: 1 hour.*", ab); } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ExternalImportsIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ExternalImportsIT.java index ae97562569..37781c8537 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ExternalImportsIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ExternalImportsIT.java @@ -20,8 +20,8 @@ * ===== */ -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; +import com.walmartlabs.concord.client2.ProcessListFilter; import com.walmartlabs.concord.common.IOUtils; import org.eclipse.jgit.api.Git; import org.junit.jupiter.api.Test; @@ -59,16 +59,16 @@ public void testExternalImportWithForm() throws Exception { // wait for suspend - ProcessEntry pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); + ProcessEntry pir = waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); ProcessFormsApi formsApi = new ProcessFormsApi(getApiClient()); - List forms = formsApi.list(pir.getInstanceId()); + List forms = formsApi.listProcessForms(pir.getInstanceId()); assertEquals(1, forms.size()); - formsApi.submit(pir.getInstanceId(), forms.get(0).getName(), Collections.singletonMap("name", "boo")); + formsApi.submitForm(pir.getInstanceId(), forms.get(0).getName(), Collections.singletonMap("name", "boo")); // wait process finished - pir = waitForCompletion(processApi, spr.getInstanceId()); + pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // get the name of the agent's log file @@ -76,7 +76,7 @@ public void testExternalImportWithForm() throws Exception { // check the logs - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Hello, Concord!.*", ab); assertLog(".*Hello from Template, Concord!.*", ab); @@ -99,7 +99,7 @@ public void testExternalImportWithDefaults() throws Exception { // wait for completion - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // get the name of the agent's log file @@ -107,7 +107,7 @@ public void testExternalImportWithDefaults() throws Exception { // check the logs - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Hello, Concord!.*", ab); assertLog(".*Hello from Template, Concord!.*", ab); @@ -129,7 +129,7 @@ public void testExternalImportWithPath() throws Exception { // wait for completion - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // get the name of the agent's log file @@ -137,7 +137,7 @@ public void testExternalImportWithPath() throws Exception { // check the logs - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Hello, Concord!.*", ab); assertLog(".*Hello from Template DIR, Concord!.*", ab); @@ -159,7 +159,7 @@ public void testExternalImportWithConfigurationInImport() throws Exception { // wait for completion - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // get the name of the agent's log file @@ -167,7 +167,7 @@ public void testExternalImportWithConfigurationInImport() throws Exception { // check the logs - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Hello, Concord!.*", ab); assertLog(".*Hello from Template, Concord!.*", ab); @@ -191,7 +191,7 @@ public void testExternalImportWithConcordDirReplace() throws Exception { // wait for completion - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // get the name of the agent's log file @@ -199,7 +199,7 @@ public void testExternalImportWithConcordDirReplace() throws Exception { // check the logs - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Hello from Template, Concord!.*", ab); } @@ -220,13 +220,13 @@ public void testExternalImportWithOnFailure() throws Exception { // wait for completion - ProcessEntry pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.FAILED); + ProcessEntry pir = waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.FAILED); ProcessEntry child = waitForChild(processApi, spr.getInstanceId(), ProcessEntry.KindEnum.FAILURE_HANDLER, ProcessEntry.StatusEnum.FINISHED); // check the logs - byte[] ab = getLog(child.getLogFileName()); + byte[] ab = getLog(child.getInstanceId()); assertLog(".*oh, handled.*", ab); } @@ -247,13 +247,13 @@ public void testExternalImportWithForks() throws Exception { // wait for completion - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); ProcessEntry child = waitForChild(processApi, pir.getInstanceId(), ProcessEntry.KindEnum.DEFAULT, ProcessEntry.StatusEnum.FINISHED); // check the logs - byte[] ab = getLog(pir.getLogFileName()); - byte[] cd = getLog(child.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); + byte[] cd = getLog(child.getInstanceId()); assertLog(".*Hello, Concord!.*", ab); assertLog(".*Hello from Concord, imports!.*", cd); @@ -298,23 +298,23 @@ public void testExternalImportWithSymlink() throws Exception { private void assertExternalImportValidation(String userRepoUrl) throws Exception { String orgName = "org_" + randomString(); OrganizationsApi organizationsApi = new OrganizationsApi(getApiClient()); - organizationsApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + organizationsApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String projectName = "prj_" + randomString(); String repoName = "repo_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRepositories(Collections.singletonMap(repoName, new RepositoryEntry() - .setUrl(userRepoUrl) - .setBranch("master")))); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .repositories(Collections.singletonMap(repoName, new RepositoryEntry() + .url(userRepoUrl) + .branch("master")))); RepositoriesApi repositoriesApi = new RepositoriesApi(getApiClient()); GenericOperationResult refreshResp = repositoriesApi.refreshRepository(orgName, projectName, repoName, true); - assertTrue(refreshResp.isOk()); + assertTrue(refreshResp.getOk()); RepositoryValidationResponse resp = repositoriesApi.validateRepository(orgName, projectName, repoName); - assertTrue(resp.isOk()); + assertTrue(resp.getOk()); } @Test @@ -333,7 +333,7 @@ public void testExternalImportWithExcludeFullDir() throws Exception { // wait for completion - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // get the name of the agent's log file @@ -341,7 +341,7 @@ public void testExternalImportWithExcludeFullDir() throws Exception { // check the logs - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Hello, Concord!.*", ab); assertLog(".*Hello from Template, Concord!.*", ab); @@ -363,7 +363,7 @@ public void testExternalImportWithExcludeFileFromDir() throws Exception { // wait for completion - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // get the name of the agent's log file @@ -371,7 +371,7 @@ public void testExternalImportWithExcludeFileFromDir() throws Exception { // check the logs - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Hello, Concord!.*", ab); assertLog(".*Hello from Template, Concord!.*", ab); @@ -393,7 +393,7 @@ public void testExternalImportWithExcludeFile() throws Exception { // wait for completion - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // get the name of the agent's log file @@ -401,7 +401,7 @@ public void testExternalImportWithExcludeFile() throws Exception { // check the logs - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Hello, Concord!.*", ab); assertLog(".*Hello from Template DIR, Concord!.*", ab); @@ -414,23 +414,23 @@ public void testImportWithTriggers() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String projectName = "project_" + randomString(); String repoName = "repo_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRepositories(Collections.singletonMap(repoName, new RepositoryEntry() - .setUrl(clientRepoUrl) - .setBranch("master")))); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .repositories(Collections.singletonMap(repoName, new RepositoryEntry() + .url(clientRepoUrl) + .branch("master")))); // --- TriggersApi triggersApi = new TriggersApi(getApiClient()); while (true) { - List triggers = triggersApi.list(orgName, projectName, repoName); + List triggers = triggersApi.listTriggers(orgName, projectName, repoName); if (triggers != null && triggers.size() == 1 && triggers.get(0).getEventSource().equals("test")) { break; } @@ -441,15 +441,20 @@ public void testImportWithTriggers() throws Exception { // --- ExternalEventsApi externalEventsApi = new ExternalEventsApi(getApiClient()); - externalEventsApi.event("test", Collections.emptyMap()); + externalEventsApi.externalEvent("test", Collections.emptyMap()); // --- ProcessEntry pe; ProcessV2Api processApi = new ProcessV2Api(getApiClient()); + ProcessListFilter filter = ProcessListFilter.builder() + .orgName(orgName) + .projectName(projectName) + .build(); + while (true) { - List l = processApi.list(null, orgName, null, projectName, null, null, null, null, null, null, null, null, null, null, null); + List l = processApi.listProcesses(filter); Optional o = l.stream().filter(e -> e.getTriggeredBy().getTrigger().getEventSource().equals("test")).findFirst(); if (o.isPresent()) { @@ -462,9 +467,9 @@ public void testImportWithTriggers() throws Exception { // --- - waitForCompletion(new ProcessApi(getApiClient()), pe.getInstanceId()); + waitForCompletion(getApiClient(), pe.getInstanceId()); - byte[] ab = getLog(pe.getLogFileName()); + byte[] ab = getLog(pe.getInstanceId()); assertLog(".*Hello, Concord.*", ab); } @@ -479,12 +484,11 @@ public void testDependencyMerging() throws Exception { StartProcessResponse spr = start(payload); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Hello from Groovy!.*", ab); assertLog(".*Hello from Python!.*", ab); @@ -503,7 +507,7 @@ public void testExternalImportState() throws Exception { ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); assertNotNull(spr.getInstanceId()); - waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.ENQUEUED); + waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.ENQUEUED); try { processApi.downloadStateFile(spr.getInstanceId(), "import_data/concord.yml"); @@ -536,12 +540,11 @@ public void testGitImportWithCommitAsVersion() throws Exception { StartProcessResponse spr = start(payload); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Hello from Template, Concord!.*", ab); } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/FailureHandlingIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/FailureHandlingIT.java index 203422ce27..60c5aea828 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/FailureHandlingIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/FailureHandlingIT.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. @@ -21,8 +21,8 @@ */ -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 org.junit.jupiter.api.Test; import java.util.Collections; @@ -49,24 +49,24 @@ public void testFailure() throws Exception { StartProcessResponse spr = start(payload); - waitForStatus(processApi, spr.getInstanceId(), StatusEnum.SUSPENDED); + waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.SUSPENDED); // --- ProcessFormsApi formsApi = new ProcessFormsApi(getApiClient()); - List forms = formsApi.list(spr.getInstanceId()); + List forms = formsApi.listProcessForms(spr.getInstanceId()); assertEquals(1, forms.size()); Map data = Collections.singletonMap("firstName", "first-name"); - FormSubmitResponse fsr = formsApi.submit(spr.getInstanceId(), forms.get(0).getName(), data); - assertTrue(fsr.isOk()); + FormSubmitResponse fsr = formsApi.submitFormAsMultipart(spr.getInstanceId(), forms.get(0).getName(), data); + assertTrue(fsr.getOk()); - ProcessEntry pir = waitForStatus(processApi, spr.getInstanceId(), StatusEnum.FAILED); + ProcessEntry pir = waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.FAILED); // check the logs for the error message - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLogAtLeast(".*boom!.*", 1, ab); // find the child processes @@ -75,7 +75,7 @@ public void testFailure() throws Exception { // check the logs for the successful message - ab = getLog(child.getLogFileName()); + ab = getLog(child.getInstanceId()); assertLog(".*lastError:.*boom.*", ab); assertLog(".*projectInfo: \\{.*orgName=Default.*\\}.*", ab); assertLog(".*processInfo: \\{.*sessionKey=.*\\}.*", ab); @@ -88,7 +88,7 @@ public void testFailureHandlingError() throws Exception { byte[] payload = archive(ProcessIT.class.getResource("failureHandlingError").toURI()); StartProcessResponse spr = start(payload); - waitForStatus(processApi, spr.getInstanceId(), StatusEnum.FAILED); + waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.FAILED); // find the child processes @@ -109,11 +109,11 @@ public void testOnFailureDependencies() throws Exception { // --- ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pe = waitForStatus(processApi, spr.getInstanceId(), StatusEnum.FAILED); + ProcessEntry pe = waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.FAILED); // --- - byte[] ab = getLog(pe.getLogFileName()); + byte[] ab = getLog(pe.getInstanceId()); assertLogAtLeast(".*" + msg + ".*", 1, ab); // --- @@ -123,7 +123,7 @@ public void testOnFailureDependencies() throws Exception { // check the logs for the successful message - ab = getLog(child.getLogFileName()); + ab = getLog(child.getInstanceId()); assertLog(".*Hello!", ab); } @@ -133,12 +133,12 @@ public void testCancel() throws Exception { ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); - waitForStatus(processApi, spr.getInstanceId(), StatusEnum.RUNNING); + waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.RUNNING); // cancel the running process processApi.kill(spr.getInstanceId()); - waitForStatus(processApi, spr.getInstanceId(), StatusEnum.CANCELLED); + waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.CANCELLED); // find the child processes @@ -146,7 +146,7 @@ public void testCancel() throws Exception { // check the logs for the successful message - byte[] ab = getLog(child.getLogFileName()); + byte[] ab = getLog(child.getInstanceId()); assertLog(".*initiator is admin.*", ab); } @@ -163,17 +163,17 @@ public void testCancelSuspended() throws Exception { input.put("archive", payload); input.put("arguments.aValue", aValue); StartProcessResponse spr = start(input); - waitForStatus(processApi, spr.getInstanceId(), StatusEnum.SUSPENDED); + waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.SUSPENDED); // check if the form is there ProcessFormsApi processFormsApi = new ProcessFormsApi(getApiClient()); - List forms = processFormsApi.list(spr.getInstanceId()); + List forms = processFormsApi.listProcessForms(spr.getInstanceId()); assertEquals(1, forms.size()); // cancel the suspended process processApi.kill(spr.getInstanceId()); - waitForStatus(processApi, spr.getInstanceId(), StatusEnum.CANCELLED); + waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.CANCELLED); // find the child processes @@ -181,7 +181,7 @@ public void testCancelSuspended() throws Exception { // check the logs for the successful message - byte[] ab = getLog(child.getLogFileName()); + byte[] ab = getLog(child.getInstanceId()); assertLog(".*" + aValue + " still here.*", ab); } @@ -192,21 +192,21 @@ public void testCancelSuspendedAfterTwoForms() throws Exception { // start the process ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); - waitForStatus(processApi, spr.getInstanceId(), StatusEnum.SUSPENDED); + waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.SUSPENDED); // check if the first form is there ProcessFormsApi formsApi = new ProcessFormsApi(getApiClient()); - List forms = formsApi.list(spr.getInstanceId()); + List forms = formsApi.listProcessForms(spr.getInstanceId()); assertEquals(1, forms.size()); // submit the first form - formsApi.submit(spr.getInstanceId(), "myForm1", Collections.singletonMap("x", "123")); + formsApi.submitForm(spr.getInstanceId(), "myForm1", Collections.singletonMap("x", "123")); // wait for the process to suspend - waitForStatus(processApi, spr.getInstanceId(), StatusEnum.SUSPENDED); + waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.SUSPENDED); // check if the second form's ready - forms = formsApi.list(spr.getInstanceId()); + forms = formsApi.listProcessForms(spr.getInstanceId()); assertEquals(1, forms.size()); // cancel the process @@ -218,7 +218,7 @@ public void testCancelSuspendedAfterTwoForms() throws Exception { assertEquals(StatusEnum.FINISHED, child.getStatus()); // check the logs for the successful message - byte[] ab = getLog(child.getLogFileName()); + byte[] ab = getLog(child.getInstanceId()); assertLog(".*Hello!.*", ab); } @@ -233,7 +233,7 @@ public void testOnFailureForForks() throws Exception { // --- ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pe = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pe = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- @@ -249,7 +249,7 @@ public void testOnFailureForForks() throws Exception { // --- ProcessEntry onFailureProc = waitForChild(processApi, childWithOnFailure.getInstanceId(), ProcessEntry.KindEnum.FAILURE_HANDLER, StatusEnum.FINISHED); - byte[] ab = getLog(onFailureProc.getLogFileName()); + byte[] ab = getLog(onFailureProc.getInstanceId()); assertLog(".*Got.*aFork!.*", ab); // --- diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/FilePermissionsIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/FilePermissionsIT.java index bb511bdb8f..74cfd96ceb 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/FilePermissionsIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/FilePermissionsIT.java @@ -20,9 +20,8 @@ * ===== */ -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.ProcessEntry; +import com.walmartlabs.concord.client2.StartProcessResponse; import com.walmartlabs.concord.common.IOUtils; import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; import org.junit.jupiter.api.Test; @@ -60,12 +59,11 @@ public void test() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload.toByteArray()); assertNotNull(spr.getInstanceId()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); - byte[] ab = getLog(pir.getLogFileName()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Hello!.*", ab); } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ForceSuspendIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ForceSuspendIT.java index d38732bd04..ea1bc2615e 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ForceSuspendIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ForceSuspendIT.java @@ -20,9 +20,9 @@ * ===== */ -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.ProcessApi; +import com.walmartlabs.concord.client2.ProcessEntry; +import com.walmartlabs.concord.client2.StartProcessResponse; import org.junit.jupiter.api.Test; import java.util.HashMap; @@ -49,19 +49,19 @@ public void testTask() throws Exception { StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); - byte[] ab = getLog(pir.getLogFileName()); + ProcessEntry pir = waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Requesting suspend.*", ab); assertLog(".*Whoa!.*", 0, ab); // --- + ProcessApi processApi = new ProcessApi(getApiClient()); processApi.resume(pir.getInstanceId(), eventName, null, null); - pir = waitForCompletion(processApi, spr.getInstanceId()); + pir = waitForCompletion(getApiClient(), spr.getInstanceId()); - ab = getLog(pir.getLogFileName()); + ab = getLog(pir.getInstanceId()); assertLog(".*Whoa!.*", ab); } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/FormIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/FormIT.java index 8d2fecad68..19b944838f 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/FormIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/FormIT.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. @@ -21,8 +21,8 @@ */ -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 org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; @@ -43,38 +43,37 @@ public void test() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); - ProcessEntry pe = waitForStatus(processApi, spr.getInstanceId(), StatusEnum.SUSPENDED); + ProcessEntry pe = waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.SUSPENDED); assertEquals(StatusEnum.SUSPENDED, pe.getStatus()); // --- ProcessFormsApi formsApi = new ProcessFormsApi(getApiClient()); - List forms = formsApi.list(spr.getInstanceId()); + List forms = formsApi.listProcessForms(spr.getInstanceId()); assertEquals(1, forms.size()); // --- FormListEntry f0 = forms.get(0); - assertFalse(f0.isCustom()); + assertFalse(f0.getCustom()); String formName = f0.getName(); Map data = Collections.singletonMap("firstName", firstName); - FormSubmitResponse fsr = formsApi.submit(spr.getInstanceId(), formName, data); - assertTrue(fsr.isOk()); + FormSubmitResponse fsr = formsApi.submitForm(spr.getInstanceId(), formName, data); + assertTrue(fsr.getOk()); - ProcessEntry psr = waitForStatus(processApi, spr.getInstanceId(), StatusEnum.SUSPENDED); + ProcessEntry psr = waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.SUSPENDED); - byte[] ab = getLog(psr.getLogFileName()); + byte[] ab = getLog(psr.getInstanceId()); assertLog(".*100223.*", ab); // --- - forms = formsApi.list(spr.getInstanceId()); + forms = formsApi.listProcessForms(spr.getInstanceId()); assertEquals(1, forms.size()); // --- @@ -86,16 +85,16 @@ public void test() throws Exception { data.put("rememberMe", true); data.put("file", "file-content"); - fsr = formsApi.submit(spr.getInstanceId(), formName, data); - assertTrue(fsr.isOk()); + fsr = formsApi.submitForm(spr.getInstanceId(), formName, data); + assertTrue(fsr.getOk()); assertTrue(fsr.getErrors() == null || fsr.getErrors().isEmpty()); - psr = waitForCompletion(processApi, spr.getInstanceId()); + psr = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(StatusEnum.FINISHED, psr.getStatus()); // --- - ab = getLog(psr.getLogFileName()); + ab = getLog(psr.getInstanceId()); assertLog(".*" + firstName + " " + lastName + ".*", ab); assertLog(".*100323.*", ab); assertLog(".*r3d.*", ab); @@ -112,37 +111,36 @@ public void testSubmitMultipart() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); - waitForStatus(processApi, spr.getInstanceId(), StatusEnum.SUSPENDED); + waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.SUSPENDED); // --- ProcessFormsApi formsApi = new ProcessFormsApi(getApiClient()); - List forms = formsApi.list(spr.getInstanceId()); + List forms = formsApi.listProcessForms(spr.getInstanceId()); assertEquals(1, forms.size()); // --- FormListEntry f0 = forms.get(0); - assertFalse(f0.isCustom()); + assertFalse(f0.getCustom()); String formName = f0.getName(); Map data = Collections.singletonMap("firstName", firstName); - FormSubmitResponse fsr = request("/api/v1/process/" + spr.getInstanceId() + "/form/" + formName + "/multipart", data, FormSubmitResponse.class); - assertTrue(fsr.isOk()); + FormSubmitResponse fsr = formsApi.submitFormAsMultipart(spr.getInstanceId(), formName, data); + assertTrue(fsr.getOk()); - ProcessEntry psr = waitForStatus(processApi, spr.getInstanceId(), StatusEnum.SUSPENDED); + ProcessEntry psr = waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.SUSPENDED); - byte[] ab = getLog(psr.getLogFileName()); + byte[] ab = getLog(psr.getInstanceId()); assertLog(".*100223.*", ab); // --- - forms = formsApi.list(spr.getInstanceId()); + forms = formsApi.listProcessForms(spr.getInstanceId()); assertEquals(1, forms.size()); // --- @@ -154,16 +152,16 @@ public void testSubmitMultipart() throws Exception { data.put("rememberMe", true); data.put("file", "file-content".getBytes()); - fsr = request("/api/v1/process/" + spr.getInstanceId() + "/form/" + formName + "/multipart", data, FormSubmitResponse.class); - assertTrue(fsr.isOk()); + fsr = formsApi.submitFormAsMultipart(spr.getInstanceId(), formName, data); + assertTrue(fsr.getOk()); assertTrue(fsr.getErrors() == null || fsr.getErrors().isEmpty()); - psr = waitForCompletion(processApi, spr.getInstanceId()); + psr = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(StatusEnum.FINISHED, psr.getStatus()); // --- - ab = getLog(psr.getLogFileName()); + ab = getLog(psr.getInstanceId()); assertLog(".*" + firstName + " " + lastName + ".*", ab); assertLog(".*100323.*", ab); assertLog(".*r3d.*", ab); @@ -180,27 +178,27 @@ public void testValues() throws Exception { ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); - waitForStatus(processApi, spr.getInstanceId(), StatusEnum.SUSPENDED); + waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.SUSPENDED); // --- ProcessFormsApi formResource = new ProcessFormsApi(getApiClient()); - List forms = formResource.list(spr.getInstanceId()); + List forms = formResource.listProcessForms(spr.getInstanceId()); FormListEntry f0 = forms.get(0); String formName = f0.getName(); Map data = Collections.singletonMap("name", "Concord"); - FormSubmitResponse fsr = formResource.submit(spr.getInstanceId(), formName, data); - assertTrue(fsr.isOk()); + FormSubmitResponse fsr = formResource.submitForm(spr.getInstanceId(), formName, data); + assertTrue(fsr.getOk()); // --- - ProcessEntry psr = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry psr = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(StatusEnum.FINISHED, psr.getStatus()); - byte[] ab = getLog(psr.getLogFileName()); + byte[] ab = getLog(psr.getInstanceId()); assertLog(".*Hello, Concord.*", ab); } @@ -212,25 +210,25 @@ public void testAdditionalValuesSubmit() throws Exception { ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); - waitForStatus(processApi, spr.getInstanceId(), StatusEnum.SUSPENDED); + waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.SUSPENDED); // --- ProcessFormsApi formsApi = new ProcessFormsApi(getApiClient()); - List forms = formsApi.list(spr.getInstanceId()); + List forms = formsApi.listProcessForms(spr.getInstanceId()); FormListEntry f0 = forms.get(0); String formName = f0.getName(); - FormSubmitResponse fsr = formsApi.submit(spr.getInstanceId(), formName, Collections.emptyMap()); - assertTrue(fsr.isOk()); + FormSubmitResponse fsr = formsApi.submitForm(spr.getInstanceId(), formName, Collections.emptyMap()); + assertTrue(fsr.getOk()); // --- - ProcessEntry psr = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry psr = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(StatusEnum.FINISHED, psr.getStatus()); - byte[] ab = getLog(psr.getLogFileName()); + byte[] ab = getLog(psr.getInstanceId()); assertLog(".*we got 123 hello 234.*", ab); } @@ -248,29 +246,29 @@ public void testExternalFormFile() throws Exception { // --- ProcessApi processApi = new ProcessApi(getApiClient()); - waitForStatus(processApi, spr.getInstanceId(), StatusEnum.SUSPENDED); + waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.SUSPENDED); // --- ProcessFormsApi formsApi = new ProcessFormsApi(getApiClient()); - List forms = formsApi.list(spr.getInstanceId()); + List forms = formsApi.listProcessForms(spr.getInstanceId()); assertEquals(1, forms.size()); // --- FormListEntry f0 = forms.get(0); - assertFalse(f0.isCustom()); + assertFalse(f0.getCustom()); String formName = f0.getName(); Map data = Collections.singletonMap("myField", fieldValue); - FormSubmitResponse fsr = formsApi.submit(spr.getInstanceId(), formName, data); - assertTrue(fsr.isOk()); + FormSubmitResponse fsr = formsApi.submitForm(spr.getInstanceId(), formName, data); + assertTrue(fsr.getOk()); - ProcessEntry psr = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry psr = waitForCompletion(getApiClient(), spr.getInstanceId()); - byte[] ab = getLog(psr.getLogFileName()); + byte[] ab = getLog(psr.getInstanceId()); assertLog(".*We got " + fieldValue + ".*", ab); } @@ -283,13 +281,13 @@ public void testMultiValueInput() throws Exception { ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); - waitForStatus(processApi, spr.getInstanceId(), StatusEnum.SUSPENDED); + waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.SUSPENDED); // --- ProcessFormsApi formResource = new ProcessFormsApi(getApiClient()); - List forms = formResource.list(spr.getInstanceId()); + List forms = formResource.listProcessForms(spr.getInstanceId()); FormListEntry f0 = forms.get(0); String formName = f0.getName(); @@ -298,15 +296,15 @@ public void testMultiValueInput() throws Exception { skills.add("angular"); skills.add("react"); Map data = Collections.singletonMap("skills", skills); - FormSubmitResponse fsr = formResource.submit(spr.getInstanceId(), formName, data); - assertTrue(fsr.isOk()); + FormSubmitResponse fsr = formResource.submitForm(spr.getInstanceId(), formName, data); + assertTrue(fsr.getOk()); // --- - ProcessEntry psr = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry psr = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(StatusEnum.FINISHED, psr.getStatus()); - byte[] ab = getLog(psr.getLogFileName()); + byte[] ab = getLog(psr.getInstanceId()); assertLog(".*(Skills ->) \\[(angular|react), (react|angular)\\].*", ab); } @@ -320,13 +318,13 @@ public void testDynamicFields() throws Exception { ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); - waitForStatus(processApi, spr.getInstanceId(), StatusEnum.SUSPENDED); + waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.SUSPENDED); // --- ProcessFormsApi formsApi = new ProcessFormsApi(getApiClient()); - List forms = formsApi.list(spr.getInstanceId()); + List forms = formsApi.listProcessForms(spr.getInstanceId()); assertEquals(1, forms.size()); // --- @@ -336,15 +334,15 @@ public void testDynamicFields() throws Exception { String fieldValue = "test_" + randomString(); Map data = Collections.singletonMap("x", fieldValue); - FormSubmitResponse fsr = formsApi.submit(spr.getInstanceId(), formName, data); - assertTrue(fsr.isOk()); + FormSubmitResponse fsr = formsApi.submitForm(spr.getInstanceId(), formName, data); + assertTrue(fsr.getOk()); - ProcessEntry psr = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry psr = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(StatusEnum.FINISHED, psr.getStatus()); // --- - byte[] ab = getLog(psr.getLogFileName()); + byte[] ab = getLog(psr.getInstanceId()); assertLog(".*We got: " + fieldValue + ".*", ab); } @@ -357,13 +355,13 @@ public void testReadonlyField() throws Exception { ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); - waitForStatus(processApi, spr.getInstanceId(), StatusEnum.SUSPENDED); + waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.SUSPENDED); // --- ProcessFormsApi formsApi = new ProcessFormsApi(getApiClient()); - List forms = formsApi.list(spr.getInstanceId()); + List forms = formsApi.listProcessForms(spr.getInstanceId()); assertEquals(1, forms.size()); // --- @@ -373,15 +371,15 @@ public void testReadonlyField() throws Exception { String fieldValue = "test_" + randomString(); Map data = Collections.singletonMap("myValue", fieldValue); - FormSubmitResponse fsr = formsApi.submit(spr.getInstanceId(), formName, data); - assertTrue(fsr.isOk()); + FormSubmitResponse fsr = formsApi.submitForm(spr.getInstanceId(), formName, data); + assertTrue(fsr.getOk()); - ProcessEntry psr = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry psr = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(StatusEnum.FINISHED, psr.getStatus()); // --- - byte[] ab = getLog(psr.getLogFileName()); + byte[] ab = getLog(psr.getInstanceId()); assertLog(".*default value.*", ab); } @@ -394,13 +392,13 @@ public void testOptionalFileTypeField() throws Exception { ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); - waitForStatus(processApi, spr.getInstanceId(), StatusEnum.SUSPENDED); + waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.SUSPENDED); // --- ProcessFormsApi formsApi = new ProcessFormsApi(getApiClient()); - List forms = formsApi.list(spr.getInstanceId()); + List forms = formsApi.listProcessForms(spr.getInstanceId()); assertEquals(1, forms.size()); // --- @@ -409,10 +407,10 @@ public void testOptionalFileTypeField() throws Exception { String formName = form.getName(); Map data = Collections.emptyMap(); - FormSubmitResponse fsr = formsApi.submit(spr.getInstanceId(), formName, data); - assertTrue(fsr.isOk()); + FormSubmitResponse fsr = formsApi.submitForm(spr.getInstanceId(), formName, data); + assertTrue(fsr.getOk()); - ProcessEntry psr = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry psr = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(StatusEnum.FINISHED, psr.getStatus()); } @@ -429,27 +427,27 @@ public void testFormCallWithExpression() throws Exception { StartProcessResponse spr = start(input); ProcessApi processApi = new ProcessApi(getApiClient()); - waitForStatus(processApi, spr.getInstanceId(), StatusEnum.SUSPENDED); + waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.SUSPENDED); // --- ProcessFormsApi formsApi = new ProcessFormsApi(getApiClient()); - List forms = formsApi.list(spr.getInstanceId()); + List forms = formsApi.listProcessForms(spr.getInstanceId()); FormListEntry f0 = forms.get(0); String formName = f0.getName(); Map data = Collections.singletonMap("name", "Concord"); - FormSubmitResponse fsr = formsApi.submit(spr.getInstanceId(), formName, data); - assertTrue(fsr.isOk()); + FormSubmitResponse fsr = formsApi.submitForm(spr.getInstanceId(), formName, data); + assertTrue(fsr.getOk()); // --- - ProcessEntry psr = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry psr = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(StatusEnum.FINISHED, psr.getStatus()); - byte[] ab = getLog(psr.getLogFileName()); + byte[] ab = getLog(psr.getInstanceId()); assertLog(".*Hello, Concord.*", ab); } @@ -467,16 +465,15 @@ public void testFormLabelInterpolation() throws Exception { StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - waitForStatus(processApi, spr.getInstanceId(), StatusEnum.SUSPENDED); + waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.SUSPENDED); // --- ProcessFormsApi formsApi = new ProcessFormsApi(getApiClient()); - List l = formsApi.list(spr.getInstanceId()); + List l = formsApi.listProcessForms(spr.getInstanceId()); assertEquals(1, l.size()); - FormInstanceEntry f = formsApi.get(spr.getInstanceId(), l.get(0).getName()); + FormInstanceEntry f = formsApi.getProcessForm(spr.getInstanceId(), l.get(0).getName()); assertNotNull(f); assertEquals(1, f.getFields().size()); @@ -496,27 +493,27 @@ public void testSingleExpressionAllowedValue() throws Exception { StartProcessResponse spr = start(input); ProcessApi processApi = new ProcessApi(getApiClient()); - waitForStatus(processApi, spr.getInstanceId(), StatusEnum.SUSPENDED); + waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.SUSPENDED); // --- ProcessFormsApi formsApi = new ProcessFormsApi(getApiClient()); - List forms = formsApi.list(spr.getInstanceId()); + List forms = formsApi.listProcessForms(spr.getInstanceId()); FormListEntry f0 = forms.get(0); String formName = f0.getName(); Map data = Collections.emptyMap(); - FormSubmitResponse fsr = formsApi.submit(spr.getInstanceId(), formName, data); - assertTrue(fsr.isOk()); + FormSubmitResponse fsr = formsApi.submitForm(spr.getInstanceId(), formName, data); + assertTrue(fsr.getOk()); // --- - ProcessEntry psr = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry psr = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(StatusEnum.FINISHED, psr.getStatus()); - byte[] ab = getLog(psr.getLogFileName()); + byte[] ab = getLog(psr.getInstanceId()); assertLog(".*field1: one.*", ab); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/GeneralTriggerIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/GeneralTriggerIT.java index b81c0818aa..40743d579e 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/GeneralTriggerIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/GeneralTriggerIT.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.common.IOUtils; import org.eclipse.jgit.api.Git; import org.junit.jupiter.api.Test; @@ -54,15 +54,15 @@ public void testExclusive() throws Exception { String repoName = "repo_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setVisibility(ProjectEntry.VisibilityEnum.PUBLIC) - .setRepositories(Collections.singletonMap(repoName, new RepositoryEntry() - .setUrl(gitUrl) - .setBranch("master")))); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .visibility(ProjectEntry.VisibilityEnum.PUBLIC) + .repositories(Collections.singletonMap(repoName, new RepositoryEntry() + .url(gitUrl) + .branch("master")))); // --- @@ -75,17 +75,17 @@ public void testExclusive() throws Exception { eventParam.put("key1", "value1"); // first process - eea.event("testTrigger", eventParam); + eea.externalEvent("testTrigger", eventParam); // second process - eea.event("testTrigger", eventParam); + eea.externalEvent("testTrigger", eventParam); Map ps = waitProcesses(orgName, projectName, ProcessEntry.StatusEnum.FINISHED, ProcessEntry.StatusEnum.CANCELLED); assertProcessLog(ps.get(ProcessEntry.StatusEnum.FINISHED), ".*Hello from exclusive trigger.*"); assertProcessLog(ps.get(ProcessEntry.StatusEnum.CANCELLED), ".*Process\\(es\\) with exclusive group 'RED' is already in the queue. Current process has been cancelled.*"); // --- - orgApi.delete(orgName, "yes"); + orgApi.deleteOrg(orgName, "yes"); } @Test @@ -109,15 +109,15 @@ public void testExclusiveFromConfiguration() throws Exception { String repoName = "repo_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setVisibility(ProjectEntry.VisibilityEnum.PUBLIC) - .setRepositories(Collections.singletonMap(repoName, new RepositoryEntry() - .setUrl(gitUrl) - .setBranch("master")))); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .visibility(ProjectEntry.VisibilityEnum.PUBLIC) + .repositories(Collections.singletonMap(repoName, new RepositoryEntry() + .url(gitUrl) + .branch("master")))); // --- @@ -130,18 +130,18 @@ public void testExclusiveFromConfiguration() throws Exception { eventParam.put("key1", "value1"); // first process - eea.event("testTrigger", eventParam); + eea.externalEvent("testTrigger", eventParam); // second process // we assume that the first process is in the RUNNING status when the second process is created - eea.event("testTrigger", eventParam); + eea.externalEvent("testTrigger", eventParam); Map ps = waitProcesses(orgName, projectName, ProcessEntry.StatusEnum.FINISHED, ProcessEntry.StatusEnum.CANCELLED); assertProcessLog(ps.get(ProcessEntry.StatusEnum.FINISHED), ".*Hello from exclusive trigger.*"); assertProcessLog(ps.get(ProcessEntry.StatusEnum.CANCELLED), ".*Process\\(es\\) with exclusive group 'RED' is already in the queue. Current process has been cancelled.*"); // --- - orgApi.delete(orgName, "yes"); + orgApi.deleteOrg(orgName, "yes"); } @Test @@ -165,15 +165,15 @@ public void testExclusiveWithTriggerOverride() throws Exception { String repoName = "repo_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setVisibility(ProjectEntry.VisibilityEnum.PUBLIC) - .setRepositories(Collections.singletonMap(repoName, new RepositoryEntry() - .setUrl(gitUrl) - .setBranch("master")))); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .visibility(ProjectEntry.VisibilityEnum.PUBLIC) + .repositories(Collections.singletonMap(repoName, new RepositoryEntry() + .url(gitUrl) + .branch("master")))); // --- @@ -186,16 +186,16 @@ public void testExclusiveWithTriggerOverride() throws Exception { eventParam.put("key1", "value1"); // first process - eea.event("testTrigger", eventParam); + eea.externalEvent("testTrigger", eventParam); // second process - eea.event("testTrigger", eventParam); + eea.externalEvent("testTrigger", eventParam); Map ps = waitProcesses(orgName, projectName, ProcessEntry.StatusEnum.FINISHED, ProcessEntry.StatusEnum.CANCELLED); assertProcessLog(ps.get(ProcessEntry.StatusEnum.FINISHED), ".*Hello from exclusive trigger.*"); assertProcessLog(ps.get(ProcessEntry.StatusEnum.CANCELLED), ".*Process\\(es\\) with exclusive group 'TRIGGER' is already in the queue. Current process has been cancelled.*"); // --- - orgApi.delete(orgName, "yes"); + orgApi.deleteOrg(orgName, "yes"); } } \ No newline at end of file diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/GeneralTriggerV2IT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/GeneralTriggerV2IT.java index 8f4a1af34f..71e827abb0 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/GeneralTriggerV2IT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/GeneralTriggerV2IT.java @@ -20,8 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.common.IOUtils; import org.eclipse.jgit.api.Git; import org.junit.jupiter.api.Test; @@ -59,19 +58,19 @@ private void setup(String yamlPath) throws Exception { repoName = "repo_" + randomString(); orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setVisibility(ProjectEntry.VisibilityEnum.PUBLIC) - .setRepositories(Collections.singletonMap(repoName, new RepositoryEntry() - .setUrl(gitUrl) - .setBranch("master")))); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .visibility(ProjectEntry.VisibilityEnum.PUBLIC) + .repositories(Collections.singletonMap(repoName, new RepositoryEntry() + .url(gitUrl) + .branch("master")))); } private void cleanup() throws ApiException { - orgApi.delete(orgName, "yes"); + orgApi.deleteOrg(orgName, "yes"); } @Test @@ -85,10 +84,10 @@ public void testExclusiveV2() throws Exception { eventParam.put("key1", "value2"); // first process - eea.event("testTriggerv2", eventParam); + eea.externalEvent("testTriggerv2", eventParam); // second process - eea.event("testTriggerv2", eventParam); + eea.externalEvent("testTriggerv2", eventParam); Map ps = waitProcesses(orgName, projectName, ProcessEntry.StatusEnum.FINISHED, ProcessEntry.StatusEnum.CANCELLED); assertProcessLog(ps.get(ProcessEntry.StatusEnum.FINISHED), ".*Hello from exclusive trigger v2.*"); @@ -110,10 +109,10 @@ public void testExclusiveFromConfigurationV2() throws Exception { eventParam.put("key1", "value2"); // first process - eea.event("testTriggerv2", eventParam); + eea.externalEvent("testTriggerv2", eventParam); // second process - eea.event("testTriggerv2", eventParam); + eea.externalEvent("testTriggerv2", eventParam); Map ps = waitProcesses(orgName, projectName, ProcessEntry.StatusEnum.FINISHED, ProcessEntry.StatusEnum.CANCELLED); assertProcessLog(ps.get(ProcessEntry.StatusEnum.FINISHED), ".*Hello from exclusive trigger v2.*"); @@ -137,10 +136,10 @@ public void testExclusiveWithTriggerOverrideV2() throws Exception { eventParam.put("key1", "value2"); // first process - eea.event("testTriggerv2", eventParam); + eea.externalEvent("testTriggerv2", eventParam); // second process - eea.event("testTriggerv2", eventParam); + eea.externalEvent("testTriggerv2", eventParam); Map ps = waitProcesses(orgName, projectName, ProcessEntry.StatusEnum.FINISHED, ProcessEntry.StatusEnum.CANCELLED); assertProcessLog(ps.get(ProcessEntry.StatusEnum.FINISHED), ".*Hello from exclusive trigger v2.*"); diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/GitBranchesIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/GitBranchesIT.java index 16f2c9fa61..b2bcf72385 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/GitBranchesIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/GitBranchesIT.java @@ -20,11 +20,10 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.common.IOUtils; import com.walmartlabs.concord.it.common.MockGitSshServer; import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.lib.ConfigConstants; import org.eclipse.jgit.transport.RefSpec; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -57,7 +56,7 @@ public void setUp() throws Exception { .setURI("file://" + bareRepo) .call()) { - Path initialData = Paths.get(PortalIT.class.getResource("gitBranches/qa").toURI()); + Path initialData = Paths.get(GitBranchesIT.class.getResource("gitBranches/qa").toURI()); IOUtils.copy(initialData, workdir); git.add().addFilepattern(".").call(); @@ -68,7 +67,7 @@ public void setUp() throws Exception { git.checkout().setCreateBranch(true).setName("dev").call(); - Path devData = Paths.get(PortalIT.class.getResource("gitBranches/dev").toURI()); + Path devData = Paths.get(GitBranchesIT.class.getResource("gitBranches/dev").toURI()); IOUtils.copy(devData, workdir, StandardCopyOption.REPLACE_EXISTING); git.add().addFilepattern(".").call(); @@ -97,12 +96,12 @@ public void test() throws Exception { assertEquals(SecretOperationResponse.ResultEnum.CREATED, sor.getResult()); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRepositories(Collections.singletonMap(repoName, new RepositoryEntry() - .setUrl(repoUrl) - .setSecretId(sor.getId()) - .setBranch("qa")))); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .repositories(Collections.singletonMap(repoName, new RepositoryEntry() + .url(repoUrl) + .secretId(sor.getId()) + .branch("qa")))); // --- @@ -115,20 +114,20 @@ public void test() throws Exception { // --- ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pe = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pe = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FINISHED, pe.getStatus()); - byte[] ab = getLog(pe.getLogFileName()); + byte[] ab = getLog(pe.getInstanceId()); assertLog(".*running qa.*", ab); // --- RepositoriesApi repositoriesApi = new RepositoriesApi(getApiClient()); - repositoriesApi.createOrUpdate(orgName, projectName, new RepositoryEntry() - .setName(repoName) - .setUrl(repoUrl) - .setSecretId(sor.getId()) - .setBranch("dev")); + repositoriesApi.createOrUpdateRepository(orgName, projectName, new RepositoryEntry() + .name(repoName) + .url(repoUrl) + .secretId(sor.getId()) + .branch("dev")); // --- @@ -140,10 +139,10 @@ public void test() throws Exception { // --- - pe = waitForCompletion(processApi, spr.getInstanceId()); + pe = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FINISHED, pe.getStatus()); - ab = getLog(pe.getLogFileName()); + ab = getLog(pe.getInstanceId()); assertLog(".*running dev.*", ab); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/GitHubNonOrgEventIt.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/GitHubNonOrgEventIt.java index 99f220d5ce..b83e48804a 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/GitHubNonOrgEventIt.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/GitHubNonOrgEventIt.java @@ -20,8 +20,8 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; +import com.walmartlabs.concord.client2.ProcessListFilter; import com.walmartlabs.concord.common.IOUtils; import com.walmartlabs.concord.it.common.GitHubUtils; import org.eclipse.jgit.api.Git; @@ -33,6 +33,7 @@ import java.nio.file.Paths; import java.util.Collections; import java.util.List; +import java.util.Map; import static com.walmartlabs.concord.it.common.ServerClient.assertLog; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -60,21 +61,21 @@ public void test() throws Exception { String repoName = "repo_" + randomString(); OrganizationsApi organizationsApi = new OrganizationsApi(getApiClient()); - organizationsApi.createOrUpdate(new OrganizationEntry() - .setName(orgName)); + organizationsApi.createOrUpdateOrg(new OrganizationEntry() + .name(orgName)); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRepositories(Collections.singletonMap(repoName, new RepositoryEntry() - .setUrl(gitUrl)))); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .repositories(Collections.singletonMap(repoName, new RepositoryEntry() + .url(gitUrl)))); // --- TriggersApi triggersApi = new TriggersApi(getApiClient()); while (!Thread.currentThread().isInterrupted()) { - List triggers = triggersApi.list(orgName, projectName, repoName); + List triggers = triggersApi.listTriggers(orgName, projectName, repoName); if (!triggers.isEmpty()) { break; } @@ -89,9 +90,15 @@ public void test() throws Exception { List processes; ProcessV2Api processV2Api = new ProcessV2Api(getApiClient()); + ProcessListFilter filter = ProcessListFilter.builder() + .orgName(orgName) + .projectName(projectName) + .status(ProcessEntry.StatusEnum.FINISHED) + .build(); + while (true) { - processes = processV2Api.list(null, orgName, null, projectName, null, null, null, null, null, ProcessEntry.StatusEnum.FINISHED.getValue(), null, null, null, null, null); - if (processes.size() > 0) { + processes = processV2Api.listProcesses(filter); + if (!processes.isEmpty()) { break; } @@ -104,22 +111,26 @@ public void test() throws Exception { ProcessEntry pe = processes.get(0); - byte[] ab = getLog(pe.getLogFileName()); + byte[] ab = getLog(pe.getInstanceId()); assertLog(".*EVENT:.*added_to_repository.*", ab); } + @SuppressWarnings("unchecked") private void githubEvent(String eventFile, String repoName, String eventName) throws Exception { - String event = new String(Files.readAllBytes(Paths.get(GitHubNonOrgEventIt.class.getResource(eventFile).toURI()))); + String eventStr = new String(Files.readAllBytes(Paths.get(GitHubNonOrgEventIt.class.getResource(eventFile).toURI()))); if (repoName != null) { - event = event.replace("org-repo", repoName); + eventStr = eventStr.replace("org-repo", repoName); } + Map event = getApiClient().getObjectMapper().readValue(eventStr, Map.class); + eventStr = getApiClient().getObjectMapper().writeValueAsString(event); + ApiClient client = getApiClient(); - client.addDefaultHeader("X-Hub-Signature", "sha1=" + GitHubUtils.sign(event)); + client.addDefaultHeader("X-Hub-Signature", "sha1=" + GitHubUtils.sign(eventStr)); GitHubEventsApi gitHubEvents = new GitHubEventsApi(client); - String result = gitHubEvents.onEvent(event, "abc", eventName); + String result = gitHubEvents.onEvent(null, "abc", eventName, event); assertEquals("ok", result); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/GitHubTriggersV2IT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/GitHubTriggersV2IT.java index d2188338c9..79d60035d8 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/GitHubTriggersV2IT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/GitHubTriggersV2IT.java @@ -20,7 +20,8 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; +import com.walmartlabs.concord.client2.ProcessListFilter; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; @@ -65,7 +66,7 @@ public void testFilterBySender() throws Exception { OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); String orgXName = "orgX_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgXName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgXName)); Path repo = initRepo("githubTests/repos/v2/defaultTrigger"); String branch = "branch_" + randomString(); @@ -94,7 +95,7 @@ public void testFilterBySender() throws Exception { "_USER_LDAP_DN", ""); // A's triggers should be activated - ProcessEntry procA = waitForAProcess(orgXName, projectAName, "github", null); + ProcessEntry procA = waitForAProcess(orgXName, projectAName, "github"); expectNoProceses(orgXName, projectGName, null); // --- @@ -113,7 +114,7 @@ public void testFilterBySender() throws Exception { "_USER_LDAP_DN", ""); // G's triggers should be activated - waitForAProcess(orgXName, projectGName, "github", null); + waitForAProcess(orgXName, projectGName, "github"); // no A's are expected expectNoProceses(orgXName, projectAName, now); @@ -138,7 +139,7 @@ public void testDefaultBranch() throws Exception { OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); String orgXName = "orgX_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgXName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgXName)); // Project A // master branch + a default trigger @@ -155,7 +156,7 @@ public void testDefaultBranch() throws Exception { "_REF", "refs/heads/master"); // A's trigger should be activated - waitForAProcess(orgXName, projectAName, "github", null); + waitForAProcess(orgXName, projectAName, "github"); // --- @@ -167,7 +168,7 @@ public void testOnPushWithFullTriggerParams() throws Exception { OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); String orgXName = "orgX_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgXName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgXName)); // Project A // master branch + a default trigger @@ -185,7 +186,7 @@ public void testOnPushWithFullTriggerParams() throws Exception { "_USER_LDAP_DN", ""); // A's trigger should be activated - waitForAProcess(orgXName, projectAName, "github", null); + waitForAProcess(orgXName, projectAName, "github"); // --- @@ -197,7 +198,7 @@ public void testOnPushWithFiles() throws Exception { OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); String orgXName = "orgX_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgXName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgXName)); // Project A // master branch + a default trigger @@ -214,7 +215,7 @@ public void testOnPushWithFiles() throws Exception { "_USER_LDAP_DN", ""); // A's trigger should be activated - waitForAProcess(orgXName, projectAName, "github", null); + waitForAProcess(orgXName, projectAName, "github"); // --- @@ -230,7 +231,7 @@ public void testRequestInfo() throws Exception { OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); String orgXName = "orgX_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgXName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgXName)); // Project A // master branch + a default trigger @@ -247,7 +248,7 @@ public void testRequestInfo() throws Exception { "_USER_LDAP_DN", ""); // A's trigger should be activated - ProcessEntry pe = waitForAProcess(orgXName, projectAName, "github", null); + ProcessEntry pe = waitForAProcess(orgXName, projectAName, "github"); assertLog(pe, ".*Hello, !.*"); @@ -261,7 +262,7 @@ public void testQueryParamsCondition() throws Exception { OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); String orgXName = "orgX_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgXName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgXName)); // Project A // master branch + a default trigger @@ -279,7 +280,7 @@ public void testQueryParamsCondition() throws Exception { "_USER_LDAP_DN", ""); // A's trigger should be activated - ProcessEntry pe = waitForAProcess(orgXName, projectAName, "github", null); + ProcessEntry pe = waitForAProcess(orgXName, projectAName, "github"); assertLog(pe, ".*Hello, value1!.*"); @@ -293,7 +294,7 @@ public void testIgnoreEmptyPush() throws Exception { OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); String orgName = "org_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String projectName = "project_" + randomString(); String repoName = "repo_" + randomString(); @@ -307,11 +308,16 @@ public void testIgnoreEmptyPush() throws Exception { "_REF", "refs/heads/master", "_USER_LDAP_DN", ""); - ProcessEntry pe = waitForAProcess(orgName, projectName, "github", null); + ProcessEntry pe = waitForAProcess(orgName, projectName, "github"); assertLog(pe, ".*onEmpty: .*"); - ProcessApi processApi = new ProcessApi(getApiClient()); - List list = processApi.list(orgName, projectName, null, null, null, null, null, null, null, null, null); + ProcessV2Api processApi = new ProcessV2Api(getApiClient()); + ProcessListFilter filter = ProcessListFilter.builder() + .orgName(orgName) + .projectName(projectName) + .build(); + + List list = processApi.listProcesses(filter); assertEquals(1, list.size()); // --- @@ -322,7 +328,7 @@ public void testIgnoreEmptyPush() throws Exception { "_USER_LDAP_DN", ""); while (true) { - list = processApi.list(orgName, projectName, null, null, null, null, null, null, null, null, null); + list = processApi.listProcesses(filter); if (list.size() == 3) { break; } @@ -338,7 +344,7 @@ public void testRefreshOnGitHubEvent() throws Exception { OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); String orgName = "org_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // -- create two projects to hold two similarly named repos @@ -367,11 +373,16 @@ public void testRefreshOnGitHubEvent() throws Exception { // -- locate and wait for repository refresh process ProcessV2Api processApi = new ProcessV2Api(getApiClient()); + ProcessListFilter filter = ProcessListFilter.builder() + .orgName("ConcordSystem") + .projectName("concordTriggers") + .limit(1) + .offset(0) + .build(); ProcessEntry refreshProc; + while (true) { - refreshProc = processApi.list(null, "ConcordSystem", null, - "concordTriggers", null, null, null, null, null, null, null, - null, null, 1, 0).stream() + refreshProc = processApi.listProcesses(filter).stream() .filter(e -> e.getInitiator().equals("github")) .findFirst() .orElse(null); @@ -389,10 +400,13 @@ public void testRefreshOnGitHubEvent() throws Exception { // -- process log should indicate only one repo was refreshed ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - ProjectEntry p = projectsApi.get(orgName, projectName1); - RepositoryEntry repo = p.getRepositories().entrySet().stream() - .filter(e -> e.getKey().equals(repoNameShort)) - .map(Map.Entry::getValue) + ProjectEntry p = projectsApi.getProject(orgName, projectName1); + + RepositoriesApi repositoriesApi = new RepositoriesApi(getApiClient()); + List repos = repositoriesApi.listRepositories(orgName, projectName1, null, null, null); + + RepositoryEntry repo = repos.stream() + .filter(e -> e.getName().equals(repoNameShort)) .findFirst() .orElseThrow(() -> new Exception("Unable to locate repository")); @@ -406,7 +420,7 @@ public void testUseInitiatorFromSender() throws Exception { OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); String orgName = "org_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String projectName = "project_" + randomString(); String repoName = "repo_" + randomString(); @@ -421,7 +435,7 @@ public void testUseInitiatorFromSender() throws Exception { "_FULL_REPO_NAME", toRepoName(projectRepo), "_REF", "refs/heads/master"); - ProcessEntry pe = waitForAProcess(orgName, projectName, username, null); + ProcessEntry pe = waitForAProcess(orgName, projectName, username); assertEquals(username, pe.getInitiator()); } @@ -432,7 +446,7 @@ public void testUseInitiatorFromSenderLdapDn() throws Exception { OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); String orgName = "org_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String projectName = "project_" + randomString(); String repoName = "repo_" + randomString(); @@ -446,7 +460,7 @@ public void testUseInitiatorFromSenderLdapDn() throws Exception { "_FULL_REPO_NAME", toRepoName(projectRepo), "_REF", "refs/heads/master"); - ProcessEntry pe = waitForAProcess(orgName, projectName, username, null); + ProcessEntry pe = waitForAProcess(orgName, projectName, username); assertEquals(username, pe.getInitiator()); } @@ -455,7 +469,7 @@ public void testExclusiveGroupByBranch() throws Exception { OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); String orgXName = "orgX_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgXName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgXName)); // Project A // master branch + a default trigger @@ -472,7 +486,7 @@ public void testExclusiveGroupByBranch() throws Exception { "_REF", "refs/heads/master"); // A's trigger should be activated - ProcessEntry pe = waitForAProcess(orgXName, projectAName, "github", null); + ProcessEntry pe = waitForAProcess(orgXName, projectAName, "github"); assertLog(pe, ".*Process' exclusive group: master.*"); @@ -486,7 +500,7 @@ public void testExclusiveGroupByEventAttr() throws Exception { OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); String orgXName = "orgX_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgXName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgXName)); // Project A // master branch + a default trigger @@ -503,7 +517,7 @@ public void testExclusiveGroupByEventAttr() throws Exception { "_REF", "refs/heads/master"); // A's trigger should be activated - ProcessEntry pe = waitForAProcess(orgXName, projectAName, "github", null); + ProcessEntry pe = waitForAProcess(orgXName, projectAName, "github"); assertLog(pe, ".*Process' exclusive group: pr-test-3.*"); @@ -521,9 +535,9 @@ private String createUser() throws Exception { createLdapUser(ldapCtx, username); UsersApi usersApi = new UsersApi(getApiClient()); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(username) - .setType(CreateUserRequest.TypeEnum.LDAP)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(username) + .type(CreateUserRequest.TypeEnum.LDAP)); return username; } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/GitRepositoryIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/GitRepositoryIT.java index e45e2f7cbc..b26a15c9e2 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/GitRepositoryIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/GitRepositoryIT.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.common.IOUtils; import com.walmartlabs.concord.it.common.MockGitSshServer; import org.eclipse.jgit.api.Git; @@ -86,12 +86,12 @@ public void testGitUrlWithDifferentUser() throws Exception { assertEquals(SecretOperationResponse.ResultEnum.CREATED, sor.getResult()); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRepositories(Collections.singletonMap(repoName, new RepositoryEntry() - .setUrl(repoUrl) - .setBranch("master") - .setSecretId(sor.getId()) + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .repositories(Collections.singletonMap(repoName, new RepositoryEntry() + .url(repoUrl) + .branch("master") + .secretId(sor.getId()) ))); // --- @@ -104,11 +104,10 @@ public void testGitUrlWithDifferentUser() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pe = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pe = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FINISHED, pe.getStatus()); - byte[] ab = getLog(pe.getLogFileName()); + byte[] ab = getLog(pe.getInstanceId()); assertLog(".*Hello Concord!.*", ab); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/GroovyIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/GroovyIT.java index 53575a06b4..523aaa8f67 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/GroovyIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/GroovyIT.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import static com.walmartlabs.concord.it.common.ITUtils.archive; @@ -35,30 +35,29 @@ public void test() throws Exception { String username = "user_" + randomString(); UsersApi usersApi = new UsersApi(getApiClient()); - CreateUserResponse cur = usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(username) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(username) + .type(CreateUserRequest.TypeEnum.LOCAL)); ApiKeysApi apiKeyResource = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse cakr = apiKeyResource.create(new CreateApiKeyRequest().setUsername(username)); + CreateApiKeyResponse cakr = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(username)); setApiKey(cakr.getKey()); // --- - byte[] payload = archive(ProcessIT.class.getResource("groovy").toURI()); + byte[] payload = archive(GroovyIT.class.getResource("groovy").toURI()); - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); assertNotNull(spr.getInstanceId()); // --- - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Hello, " + username + ".*", ab); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/HttpTaskIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/HttpTaskIT.java index b2a768a42a..2d8c14167c 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/HttpTaskIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/HttpTaskIT.java @@ -29,9 +29,9 @@ import com.github.tomakehurst.wiremock.http.Request; import com.github.tomakehurst.wiremock.http.ResponseDefinition; import com.github.tomakehurst.wiremock.junit5.WireMockExtension; -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.ProcessApi; +import com.walmartlabs.concord.client2.ProcessEntry; +import com.walmartlabs.concord.client2.StartProcessResponse; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -114,10 +114,10 @@ public void testGetAsString() throws Exception { StartProcessResponse spr = start(input); - 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(".*Success response.*", ab); } @@ -126,18 +126,16 @@ public void testGet() throws Exception { URI dir = HttpTaskIT.class.getResource("httpGet").toURI(); byte[] payload = archive(dir); - ProcessApi processApi = new ProcessApi(getApiClient()); - Map input = new HashMap<>(); input.put("archive", payload); input.put("arguments.url", SERVER_URL + mockHttpPathPing); StartProcessResponse spr = start(input); - 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(".*Success response.*", ab); assertLog(".*Out Response: true*", ab); } @@ -147,18 +145,16 @@ public void testGetAsDefaultMethod() throws Exception { URI dir = HttpTaskIT.class.getResource("httpGetAsDefaultMethod").toURI(); byte[] payload = archive(dir); - ProcessApi processApi = new ProcessApi(getApiClient()); - Map input = new HashMap<>(); input.put("archive", payload); input.put("arguments.url", SERVER_URL + mockHttpPathPing); StartProcessResponse spr = start(input); - 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(".*Request method: GET*", ab); assertLog(".*Success response.*", ab); assertLog(".*Out Response: true*", ab); @@ -169,18 +165,16 @@ public void testGetWithQueryParams() throws Exception { URI dir = HttpTaskIT.class.getResource("httpGetWithQueryParams").toURI(); byte[] payload = archive(dir); - ProcessApi processApi = new ProcessApi(getApiClient()); - Map input = new HashMap<>(); input.put("archive", payload); input.put("arguments.url", mockHttpBaseUrl + rule.getPort() + mockHttpPathQueryParams); StartProcessResponse spr = start(input); - 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(".*Success response.*", ab); assertLog(".*message: hello concord!*", ab); assertLog(".*multi-value-1: value1*", ab); @@ -200,12 +194,10 @@ public void testGetWithAuthUsingPassword() throws Exception { input.put("arguments.url", mockHttpBaseUrl + rule.getPort() + mockHttpPathPassword); StartProcessResponse spr = start(input); - 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(".*Success response.*", ab); assertLog(".*Out Response: true*", ab); } @@ -221,12 +213,10 @@ public void testGetWithAuthUsingToken() throws Exception { input.put("arguments.url", mockHttpBaseUrl + rule.getPort() + mockHttpPathToken); StartProcessResponse spr = start(input); - 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(".*Success response.*", ab); assertLog(".*Out Response: true*", ab); } @@ -243,12 +233,10 @@ public void testPost() throws Exception { input.put("arguments.url", mockHttpBaseUrl + rule.getPort() + mockHttpPathPassword); StartProcessResponse spr = start(input); - 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(".*Success response.*", ab); assertLog(".*Out Response: true*", ab); } @@ -265,12 +253,10 @@ public void testPostWithArrayBody() throws Exception { input.put("arguments.url", mockHttpBaseUrl + rule.getPort() + mockHttpPathPassword); StartProcessResponse spr = start(input); - 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(".*Success response.*", ab); assertLog(".*Out Response: true*", ab); } @@ -287,12 +273,10 @@ public void testPostWithDebug() throws Exception { input.put("arguments.url", mockHttpBaseUrl + rule.getPort() + mockHttpPathPassword); StartProcessResponse spr = start(input); - 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(".*requestInfo.*", ab); assertLog(".*responseInfo.*", ab); } @@ -307,12 +291,10 @@ public void testPostWithFormUrlEncoded() throws Exception { input.put("arguments.url", mockHttpBaseUrl + rule.getPort() + mockHttpPathFormUrlEncoded); StartProcessResponse spr = start(input); - 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(".*Success response.*", ab); assertLog(".*Out Response: true*", ab); } @@ -329,12 +311,10 @@ public void testPatch() throws Exception { input.put("arguments.url", mockHttpBaseUrl + rule.getPort() + mockHttpPathPassword); StartProcessResponse spr = start(input); - 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(".*Success response.*", ab); assertLog(".*Out Response: true*", ab); } @@ -350,12 +330,10 @@ public void testPostWithAuthUsingToken() throws Exception { input.put("arguments.url", mockHttpBaseUrl + rule.getPort() + mockHttpPathToken); StartProcessResponse spr = start(input); - 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(".*Success response.*", ab); assertLog(".*Out Response: true*", ab); } @@ -365,13 +343,12 @@ public void testGetWithInvalidUrl() throws Exception { URI dir = HttpTaskIT.class.getResource("httpGetWithInvalidUrl").toURI(); byte[] payload = archive(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.FAILED, pir.getStatus()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*server not exists.*", ab); } @@ -386,12 +363,10 @@ public void testGetWithHeaders() throws Exception { input.put("arguments.url", mockHttpBaseUrl + rule.getPort() + mockHttpPathHeaders); StartProcessResponse spr = start(input); - 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(".*Success response.*", ab); assertLog(".*Out Response: true*", ab); assertLog(".*Response content: request headers:.*h1=v1.*", ab); @@ -410,12 +385,10 @@ public void testGetWithIgnoreErrors() throws Exception { input.put("arguments.url", mockHttpBaseUrl + rule.getPort() + mockHttpPathUnauthorized); StartProcessResponse spr = start(input); - 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(".*statusCode: 401*", ab); assertLog(".*Success response: false*", ab); } @@ -425,18 +398,16 @@ public void testGetEmptyResponse() throws Exception { URI dir = HttpTaskIT.class.getResource("httpGetEmpty").toURI(); byte[] payload = archive(dir); - ProcessApi processApi = new ProcessApi(getApiClient()); - Map input = new HashMap<>(); input.put("archive", payload); input.put("arguments.url", mockHttpBaseUrl + rule.getPort() + mockHttpPathEmpty); StartProcessResponse spr = start(input); - 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(".*Success response: true.*", ab); assertLog(".*Content is NULL: true.*", ab); } @@ -452,12 +423,10 @@ public void testFollowRedirects() throws Exception { input.put("arguments.url", mockHttpBaseUrl + rule.getPort() + mockHttpPathFollowRedirects); StartProcessResponse spr = start(input); - 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(".*Response status code: 302.*", ab); } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/InitiatorIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/InitiatorIT.java index 134b4e54ca..158410255c 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/InitiatorIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/InitiatorIT.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import static com.walmartlabs.concord.it.common.ITUtils.archive; @@ -35,30 +35,29 @@ public void test() throws Exception { String username = "user_" + randomString(); UsersApi usersApi = new UsersApi(getApiClient()); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(username) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(username) + .type(CreateUserRequest.TypeEnum.LOCAL)); ApiKeysApi apiKeyResource = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse cakr = apiKeyResource.create(new CreateApiKeyRequest().setUsername(username)); + CreateApiKeyResponse cakr = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(username)); setApiKey(cakr.getKey()); // --- - byte[] payload = archive(ProcessIT.class.getResource("initiator").toURI()); + byte[] payload = archive(InitiatorIT.class.getResource("initiator").toURI()); - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); assertNotNull(spr.getInstanceId()); // --- - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Hello, " + username + ".*", ab); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/InventoryIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/InventoryIT.java index ee919b6003..7a2441bc52 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/InventoryIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/InventoryIT.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import java.util.HashMap; @@ -36,26 +36,26 @@ public class InventoryIT extends AbstractServerIT { public void testQuery() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); String inventoryName = "inventory_" + randomString(); InventoriesApi inventoriesApi = new InventoriesApi(getApiClient()); - inventoriesApi.createOrUpdate(orgName, new InventoryEntry().setName(inventoryName) - .setOrgName(orgName) - .setVisibility(InventoryEntry.VisibilityEnum.PUBLIC)); + inventoriesApi.createOrUpdateInventory(orgName, new InventoryEntry().name(inventoryName) + .orgName(orgName) + .visibility(InventoryEntry.VisibilityEnum.PUBLIC)); String queryName = "query_" + randomString(); InventoryQueriesApi queriesApi = new InventoryQueriesApi(getApiClient()); - queriesApi.createOrUpdate(orgName, inventoryName, queryName, "select cast(to_json(item_data) as varchar) from inventory_data where item_path like '%/testPath'"); + queriesApi.createOrUpdateInventoryQuery(orgName, inventoryName, queryName, "select cast(to_json(item_data) as varchar) from inventory_data where item_path like '%/testPath'"); InventoryDataApi dataApi = new InventoryDataApi(getApiClient()); - dataApi.data(orgName, inventoryName, "/testPath", "{\"data\": \"testData\"}"); + dataApi.updateInventoryData(orgName, inventoryName, "/testPath", "{\"data\": \"testData\"}"); // --- @@ -70,12 +70,11 @@ public void testQuery() throws Exception { StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Inventory Item_data: testData.*", ab); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/InventoryQueryIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/InventoryQueryIT.java index bb395dbce6..eabb0cacf3 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/InventoryQueryIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/InventoryQueryIT.java @@ -20,13 +20,15 @@ * ===== */ -import com.squareup.okhttp.Call; -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.ApiResponse; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; -import java.util.*; +import java.io.InputStream; +import java.net.URI; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.HashMap; +import java.util.List; import static org.junit.jupiter.api.Assertions.*; @@ -47,13 +49,13 @@ public void testQueryWithEmptyParams() throws Exception { "WHERE item_data @> ?::jsonb"; InventoriesApi inventoryResource = new InventoriesApi(getApiClient()); - inventoryResource.createOrUpdate(orgName, new InventoryEntry().setName(inventoryName)); + inventoryResource.createOrUpdateInventory(orgName, new InventoryEntry().name(inventoryName)); - CreateInventoryQueryResponse cqr = resource.createOrUpdate(orgName, inventoryName, queryName, text); - assertTrue(cqr.isOk()); + CreateInventoryQueryResponse cqr = resource.createOrUpdateInventoryQuery(orgName, inventoryName, queryName, text); + assertTrue(cqr.getOk()); assertNotNull(cqr.getId()); - List resp = resource.exec(orgName, inventoryName, queryName, new HashMap<>()); + List resp = resource.executeInventoryQuery(orgName, inventoryName, queryName, new HashMap<>()); assertNotNull(resp); } @@ -64,14 +66,14 @@ public void testDifferentContentTypes() throws Exception { OrganizationsApi organizationsApi = new OrganizationsApi(getApiClient()); String orgName = "org_" + randomString(); - organizationsApi.createOrUpdate(new OrganizationEntry() - .setName(orgName)); + organizationsApi.createOrUpdateOrg(new OrganizationEntry() + .name(orgName)); InventoriesApi inventoriesApi = new InventoriesApi(getApiClient()); String inventoryName = "inventory_" + randomString(); - inventoriesApi.createOrUpdate(orgName, new InventoryEntry() - .setName(inventoryName)); + inventoriesApi.createOrUpdateInventory(orgName, new InventoryEntry() + .name(inventoryName)); // --- @@ -80,17 +82,29 @@ public void testDifferentContentTypes() throws Exception { } private static void assertQuery(ApiClient client, String orgName, String inventoryName, String queryName, String contentType) throws Exception { - Set auths = client.getAuthentications().keySet(); - String[] authNames = auths.toArray(new String[0]); - String data = "select * from inventory_data"; - Map headerParams = new HashMap<>(Collections.singletonMap("Content-Type", contentType)); - Call call = client.buildCall("/api/v1/org/" + orgName + "/inventory/" + inventoryName + "/query/" + queryName, - "POST", new ArrayList<>(), new ArrayList<>(), - data, headerParams, new HashMap<>(), authNames, null); + HttpRequest.Builder requestBuilder = client.requestBuilder(); + + String localVarPath = "/api/v1/org/{orgName}/inventory/{inventoryName}/query/{queryName}" + .replace("{orgName}", ApiClient.urlEncode(orgName)) + .replace("{inventoryName}", ApiClient.urlEncode(inventoryName)) + .replace("{queryName}", ApiClient.urlEncode(queryName)); + + requestBuilder.uri(URI.create(client.getBaseUri() + localVarPath)); + + requestBuilder.header("Content-Type", contentType); + String acceptHeaderValue = "application/json"; + acceptHeaderValue += ",application/vnd.siesta-validation-errors-v1+json"; + requestBuilder.header("Accept", acceptHeaderValue); + requestBuilder.method("POST", HttpRequest.BodyPublishers.ofString(data)); + + HttpResponse response = client.getHttpClient().send( + requestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + + assertEquals(200, response.statusCode()); - ApiResponse response = client.execute(call, CreateInventoryQueryResponse.class); - assertEquals(200, response.getStatusCode()); + new InventoryQueriesApi(client).createOrUpdateInventoryQuery(orgName, inventoryName, queryName, data); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/JsonStoreIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/JsonStoreIT.java index 4ccc0e633f..8f5bfb7909 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/JsonStoreIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/JsonStoreIT.java @@ -20,8 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import java.util.ArrayList; @@ -36,11 +35,11 @@ public class JsonStoreIT extends AbstractServerIT { public void testValidationJsonStoreRequest() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi organizationsApi = new OrganizationsApi(getApiClient()); - organizationsApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + organizationsApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); JsonStoreApi api = new JsonStoreApi(getApiClient()); try { - api.createOrUpdate(orgName, new JsonStoreRequest().setName("")); + api.createOrUpdateJsonStore(orgName, new JsonStoreRequest().name("")); fail("exception expected"); } catch (ApiException e) { assertEquals(400, e.getCode()); @@ -53,53 +52,53 @@ public void testBulkAccessUpdate() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- String storeName = "store_" + randomString(); JsonStoreApi jsonStoreApi = new JsonStoreApi(getApiClient()); - jsonStoreApi.createOrUpdate(orgName, new JsonStoreRequest() - .setName(storeName)); + jsonStoreApi.createOrUpdateJsonStore(orgName, new JsonStoreRequest() + .name(storeName)); // --- String teamName = "team_" + randomString(); TeamsApi teamsApi = new TeamsApi(getApiClient()); - CreateTeamResponse teamResp = teamsApi.createOrUpdate(orgName, new TeamEntry() - .setName(teamName)); + CreateTeamResponse teamResp = teamsApi.createOrUpdateTeam(orgName, new TeamEntry() + .name(teamName)); // --- Typical one-or-more teams bulk access update List teams = new ArrayList<>(1); teams.add(new ResourceAccessEntry() - .setOrgName(orgName) - .setTeamId(teamResp.getId()) - .setTeamName(teamName) - .setLevel(ResourceAccessEntry.LevelEnum.OWNER)); - GenericOperationResult addTeamsResult = jsonStoreApi.updateAccessLevel_0(orgName, storeName, teams); + .orgName(orgName) + .teamId(teamResp.getId()) + .teamName(teamName) + .level(ResourceAccessEntry.LevelEnum.OWNER)); + GenericOperationResult addTeamsResult = jsonStoreApi.bulkUpdateJsonStoreAccessLevel(orgName, storeName, teams); assertNotNull(addTeamsResult); - assertTrue(addTeamsResult.isOk()); + assertTrue(addTeamsResult.getOk()); - List currentTeams = jsonStoreApi.getAccessLevel(orgName, storeName); + List currentTeams = jsonStoreApi.getJsonStoreAccessLevel(orgName, storeName); assertNotNull(currentTeams); assertEquals(1, currentTeams.size()); // --- Empty teams list clears all - GenericOperationResult clearTeamsResult = jsonStoreApi.updateAccessLevel_0(orgName, storeName, Collections.emptyList()); + GenericOperationResult clearTeamsResult = jsonStoreApi.bulkUpdateJsonStoreAccessLevel(orgName, storeName, Collections.emptyList()); assertNotNull(clearTeamsResult); - assertTrue(clearTeamsResult.isOk()); + assertTrue(clearTeamsResult.getOk()); - currentTeams = jsonStoreApi.getAccessLevel(orgName, storeName); + currentTeams = jsonStoreApi.getJsonStoreAccessLevel(orgName, storeName); assertNotNull(currentTeams); assertEquals(0, currentTeams.size()); // --- Null list not allowed, throws error try { - jsonStoreApi.updateAccessLevel_0(orgName, storeName, null); + jsonStoreApi.bulkUpdateJsonStoreAccessLevel(orgName, storeName, null); } catch (ApiException expected) { assertEquals(400, expected.getCode()); assertTrue(expected.getResponseBody().contains("List of teams is null")); @@ -109,8 +108,8 @@ public void testBulkAccessUpdate() throws Exception { // --- - teamsApi.delete(orgName, teamName); - jsonStoreApi.delete(orgName, storeName); - orgApi.delete(orgName, "yes"); + teamsApi.deleteTeam(orgName, teamName); + jsonStoreApi.deleteJsonStore(orgName, storeName); + orgApi.deleteOrg(orgName, "yes"); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/JsonStoreTaskIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/JsonStoreTaskIT.java index b46cb5eb21..4de663702e 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/JsonStoreTaskIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/JsonStoreTaskIT.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import java.util.HashMap; @@ -47,12 +47,11 @@ public void testStoreOperations() throws Exception { StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*the store doesn't exist.*", ab); assertLog(".*the item doesn't exist.*", ab); assertLog(".*the store exists now.*", ab); @@ -78,12 +77,11 @@ public void testPutGetData() throws Exception { StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*empty: $", ab); assertLog(".*get: \\{x=1}*", ab); }); @@ -96,10 +94,10 @@ private void withOrg(Consumer consumer) throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); try { - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); consumer.accept(orgName); } finally { - orgApi.delete(orgName, "yes"); + orgApi.deleteOrg(orgName, "yes"); } } @@ -107,12 +105,12 @@ private void withProject(String orgName, Consumer consumer) throws Excep String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); try { - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); consumer.accept(projectName); } finally { - projectsApi.delete(orgName, projectName); + projectsApi.deleteProject(orgName, projectName); } } @@ -120,12 +118,12 @@ private void withStore(String orgName, Consumer consumer) throws Excepti String storageName = "storage_" + randomString(); JsonStoreApi storageApi = new JsonStoreApi(getApiClient()); try { - storageApi.createOrUpdate(orgName, new JsonStoreRequest() - .setName(storageName) - .setVisibility(JsonStoreRequest.VisibilityEnum.PUBLIC)); + storageApi.createOrUpdateJsonStore(orgName, new JsonStoreRequest() + .name(storageName) + .visibility(JsonStoreRequest.VisibilityEnum.PUBLIC)); consumer.accept(storageName); } finally { - storageApi.delete(orgName, storageName); + storageApi.deleteJsonStore(orgName, storageName); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/KvPolicyIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/KvPolicyIT.java index 138cec5b41..e37a08f6c0 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/KvPolicyIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/KvPolicyIT.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import java.io.File; @@ -40,51 +40,50 @@ public void test() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); // --- String policyName = "policy_" + randomString(); PolicyApi policyResource = new PolicyApi(getApiClient()); - policyResource.createOrUpdate(new PolicyEntry().setName(policyName).setRules(readPolicy("kvPolicy/test-policy.json"))); - policyResource.link(policyName, new PolicyLinkEntry().setOrgName(orgName)); + policyResource.createOrUpdatePolicy(new PolicyEntry().name(policyName).rules(readPolicy("kvPolicy/test-policy.json"))); + policyResource.linkPolicy(policyName, new PolicyLinkEntry().orgName(orgName)); // --- - byte[] payload = archive(ProcessIT.class.getResource("kvPolicy").toURI()); + byte[] payload = archive(KvPolicyIT.class.getResource("kvPolicy").toURI()); Map input = new HashMap<>(); input.put("org", orgName); input.put("project", projectName); input.put("archive", payload); - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(input); - 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(".*kv\\.putLong\\('two', 444\\).*Found KV policy violations: Maximum KV entries exceeded: current 1, limit 1.*", ab); // --- - policyResource.createOrUpdate(new PolicyEntry().setName(policyName).setRules(readPolicy("kvPolicy/test-policy-relaxed.json"))); + policyResource.createOrUpdatePolicy(new PolicyEntry().name(policyName).rules(readPolicy("kvPolicy/test-policy-relaxed.json"))); // --- spr = start(input); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); - ab = getLog(pir.getLogFileName()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); + ab = getLog(pir.getInstanceId()); assertLog(".*Hello!.*", ab); } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/KvServiceIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/KvServiceIT.java index 237f650709..1319c2b1c4 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/KvServiceIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/KvServiceIT.java @@ -21,7 +21,7 @@ */ import com.google.common.collect.ImmutableMap; -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; @@ -89,14 +89,14 @@ public void testKvWithSpecialString() throws Exception { public void testInvalidKeys() throws Exception { OrganizationsApi organizationsApi = new OrganizationsApi(getApiClient()); String orgName = "org_" + randomString(); - organizationsApi.createOrUpdate(new OrganizationEntry() - .setName(orgName)); + organizationsApi.createOrUpdateOrg(new OrganizationEntry() + .name(orgName)); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); String projectName = "project_" + randomString(); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.OWNERS)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.OWNERS)); // --- @@ -111,12 +111,12 @@ public void testInvalidKeys() throws Exception { // --- 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()); assertLogAtLeast(".*Keys cannot be empty or null.*", 1, ab); } @@ -124,14 +124,14 @@ public void testInvalidKeys() throws Exception { public void testCallFromScript() throws Exception { OrganizationsApi organizationsApi = new OrganizationsApi(getApiClient()); String orgName = "org_" + randomString(); - organizationsApi.createOrUpdate(new OrganizationEntry() - .setName(orgName)); + organizationsApi.createOrUpdateOrg(new OrganizationEntry() + .name(orgName)); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); String projectName = "project_" + randomString(); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.OWNERS)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.OWNERS)); // --- @@ -145,12 +145,11 @@ public void testCallFromScript() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pe = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pe = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(pe.getLogFileName()); + byte[] ab = getLog(pe.getInstanceId()); assertLog(".*got myKey: myValue*", ab); } @@ -158,13 +157,12 @@ private byte[] test(String process, String entryPoint, String testKey) throws Ex Map args = ImmutableMap.of("testKey", testKey); byte[] payload = createPayload(process, entryPoint, args); - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); assertNotNull(spr.getInstanceId()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); - return getLog(pir.getLogFileName()); + return getLog(pir.getInstanceId()); } private byte[] createPayload(String process, String entryPoint, Map args) throws Exception { @@ -178,7 +176,7 @@ private byte[] createPayload(String process, String entryPoint, Map artifactHostsA = artifactsApi.list(hostAId, null, artifactUrl, 1000, 0); // TODO might require paging + List artifactHostsA = artifactsApi.listHostArtifacts(hostAId, null, artifactUrl, 1000, 0); // TODO might require paging if (artifactHostsA != null && artifactHostsA.size() == 1) { break; } @@ -100,7 +98,7 @@ public void testE2e() throws Exception { List hostAProcesses = listHostProcesses(hostAId); assertEquals("admin", hostAProcesses.get(0).getInitiator()); - List hostBProcesses = listHostProcesses(hostBId); + List hostBProcesses = listHostProcesses(hostBId); assertEquals("admin", hostBProcesses.get(0).getInitiator()); // check the host facts @@ -117,10 +115,10 @@ public void testE2e() throws Exception { input.put("arguments.artifactUrl", artifactUrl); spr = start(input); - pir = waitForCompletion(processApi, spr.getInstanceId()); + pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus()); - ab = getLog(pir.getLogFileName()); + ab = getLog(pir.getInstanceId()); assertLog(".*ok=true.*", ab); assertLog(".*name: " + hostA.toLowerCase() + ".*", ab); assertLog(".*name: " + hostB.toLowerCase() + ".*", ab); @@ -137,11 +135,10 @@ public void testMultipleFactsPerHost() throws Exception { input.put("arguments.host", host); StartProcessResponse spr = start(input); - 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(".*" + host + ".*failed=0.*", ab); // --- @@ -154,7 +151,7 @@ public void testMultipleFactsPerHost() throws Exception { private static UUID findHost(String host, NodeRosterHostsApi hostsApi) throws InterruptedException, ApiException { while (true) { - List l = hostsApi.list(host, null, null, null, 10, 0); + List l = hostsApi.listKnownHosts(host, null, null, null, 10, 0); HostEntry e = l.stream().filter(h -> h.getName().equalsIgnoreCase(host)).findFirst().orElse(null); if (e != null) { @@ -165,10 +162,10 @@ private static UUID findHost(String host, NodeRosterHostsApi hostsApi) throws In } } - private List listHostProcesses(UUID hostAId) throws Exception { + private List listHostProcesses(UUID hostAId) throws Exception { NodeRosterProcessesApi nrProcessApi = new NodeRosterProcessesApi(getApiClient()); while (true) { - List result = nrProcessApi.list(hostAId, null, 1000, 0); + List result = nrProcessApi.listHosts(hostAId, null, 1000, 0); if (!result.isEmpty()) { return result; } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/OneOpsTriggerIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/OneOpsTriggerIT.java index 42fce86ecf..d62a97971e 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/OneOpsTriggerIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/OneOpsTriggerIT.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,10 +20,9 @@ * ===== */ -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.OrganizationEntry; -import com.walmartlabs.concord.client.OrganizationsApi; -import com.walmartlabs.concord.client.ProcessEntry; +import com.walmartlabs.concord.client2.*; +import com.walmartlabs.concord.client2.OrganizationsApi; +import com.walmartlabs.concord.client2.ProcessEntry; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -33,8 +32,6 @@ public class OneOpsTriggerIT extends AbstractOneOpsTriggerIT { - protected static final long DEFAULT_TEST_TIMEOUT = 120000; - private OrganizationsApi orgApi; private String orgName; private String projectName; @@ -44,7 +41,7 @@ public class OneOpsTriggerIT extends AbstractOneOpsTriggerIT { public void setup() throws Exception { orgApi = new OrganizationsApi(getApiClient()); orgName = "org_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); Path repo = initRepo("oneopsTests/trigger"); projectName = "project_" + randomString(); @@ -55,7 +52,7 @@ public void setup() throws Exception { @AfterEach public void tearDown() throws ApiException { - orgApi.delete(orgName, "yes"); + orgApi.deleteOrg(orgName, "yes"); } @Test @@ -66,6 +63,5 @@ public void testOneOpsTriggerv1() throws Exception { Map ps = waitProcesses(orgName, projectName, ProcessEntry.StatusEnum.FINISHED); assertProcessLog(ps.get(ProcessEntry.StatusEnum.FINISHED), ".*Oneops has completed a deployment trigger version 1*"); - } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/OneOpsTriggerITV2.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/OneOpsTriggerITV2.java index 898551ca95..5beb0b7126 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/OneOpsTriggerITV2.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/OneOpsTriggerITV2.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,10 +20,9 @@ * ===== */ -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.OrganizationEntry; -import com.walmartlabs.concord.client.OrganizationsApi; -import com.walmartlabs.concord.client.ProcessEntry; +import com.walmartlabs.concord.client2.*; +import com.walmartlabs.concord.client2.OrganizationsApi; +import com.walmartlabs.concord.client2.ProcessEntry; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -33,8 +32,6 @@ public class OneOpsTriggerITV2 extends AbstractOneOpsTriggerIT { - protected static final long DEFAULT_TEST_TIMEOUT = 120000; - private OrganizationsApi orgApi; private String orgName; private String projectName; @@ -44,7 +41,7 @@ public class OneOpsTriggerITV2 extends AbstractOneOpsTriggerIT { public void setup() throws Exception { orgApi = new OrganizationsApi(getApiClient()); orgName = "org_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); Path repo = initRepo("oneopsTests/trigger"); projectName = "project_" + randomString(); @@ -56,7 +53,7 @@ public void setup() throws Exception { @AfterEach public void tearDown() throws ApiException { - orgApi.delete(orgName, "yes"); + orgApi.deleteOrg(orgName, "yes"); } @Test diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/OutVariablesIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/OutVariablesIT.java index 93edae9604..cec74e5648 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/OutVariablesIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/OutVariablesIT.java @@ -20,12 +20,11 @@ * ===== */ -import com.fasterxml.jackson.databind.ObjectMapper; -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.ProcessApi; +import com.walmartlabs.concord.client2.StartProcessResponse; import org.junit.jupiter.api.Test; -import java.io.File; +import java.io.InputStream; import java.util.*; import static com.walmartlabs.concord.it.common.ITUtils.archive; @@ -36,7 +35,7 @@ public class OutVariablesIT extends AbstractServerIT { @Test public void testRequestParamAndPredefined() throws Exception { - byte[] payload = archive(ProcessIT.class.getResource("out").toURI()); + byte[] payload = archive(OutVariablesIT.class.getResource("out").toURI()); String[] out = {"x", "y.some.boolean", "z"}; Map input = new HashMap<>(); @@ -54,7 +53,7 @@ public void testRequestParamAndPredefined() throws Exception { @Test public void testPredefined() throws Exception { - byte[] payload = archive(ProcessIT.class.getResource("out").toURI()); + byte[] payload = archive(OutVariablesIT.class.getResource("out").toURI()); Map input = new HashMap<>(); input.put("archive", payload); @@ -70,13 +69,13 @@ public void testPredefined() throws Exception { @SuppressWarnings("unchecked") private Map getOutVars(UUID instanceId) throws Exception { - ProcessApi processApi = new ProcessApi(getApiClient()); - waitForCompletion(processApi, instanceId); + waitForCompletion(getApiClient(), instanceId); // --- - File outJson = processApi.downloadAttachment(instanceId, "out.json"); - - return new ObjectMapper().readValue(outJson, Map.class); + ProcessApi processApi = new ProcessApi(getApiClient()); + try (InputStream outJson = processApi.downloadAttachment(instanceId, "out.json")) { + return getApiClient().getObjectMapper().readValue(outJson, Map.class); + } } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/OutVariablesProjectIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/OutVariablesProjectIT.java index c1e83323c5..3fd428140c 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/OutVariablesProjectIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/OutVariablesProjectIT.java @@ -20,8 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import java.util.Collections; @@ -41,14 +40,14 @@ public void testOutVars() throws Exception { String orgName = "Default"; String projectName = "project_" + System.currentTimeMillis(); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setAcceptsRawPayload(true) - .setOutVariablesMode(ProjectEntry.OutVariablesModeEnum.EVERYONE) - .setName(projectName)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .acceptsRawPayload(true) + .outVariablesMode(ProjectEntry.OutVariablesModeEnum.EVERYONE) + .name(projectName)); // --- - byte[] payload = archive(ProcessIT.class.getResource("example").toURI()); + byte[] payload = archive(OutVariablesProjectIT.class.getResource("example").toURI()); Map input = new HashMap<>(); input.put("org", orgName); @@ -60,7 +59,7 @@ public void testOutVars() throws Exception { input.put("request", cfg); StartProcessResponse spr = start(input); - ProcessEntry pe = waitForCompletion(new ProcessApi(getApiClient()), spr.getInstanceId()); + ProcessEntry pe = waitForCompletion(getApiClient(), spr.getInstanceId()); Map out = (Map) pe.getMeta().get("out"); assertEquals("world", out.get("myName")); assertEquals(true, out.get("myBool")); @@ -72,13 +71,13 @@ public void testReject() throws Exception { String orgName = "Default"; String projectName = "project_" + System.currentTimeMillis(); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setAcceptsRawPayload(true) - .setName(projectName)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .acceptsRawPayload(true) + .name(projectName)); // --- - byte[] payload = archive(ProcessIT.class.getResource("example").toURI()); + byte[] payload = archive(OutVariablesProjectIT.class.getResource("example").toURI()); try { Map input = new HashMap<>(); @@ -99,12 +98,12 @@ public void testRejectFromRequest() throws Exception { String orgName = "Default"; String projectName = "project_" + System.currentTimeMillis(); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setAcceptsRawPayload(true) - .setName(projectName)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .acceptsRawPayload(true) + .name(projectName)); // --- - byte[] payload = archive(ProcessIT.class.getResource("example").toURI()); + byte[] payload = archive(OutVariablesProjectIT.class.getResource("example").toURI()); try { Map input = new HashMap<>(); input.put("org", orgName); @@ -116,10 +115,10 @@ public void testRejectFromRequest() throws Exception { start(input); StartProcessResponse spr = start(input); - ProcessEntry pe = waitForCompletion(new ProcessApi(getApiClient()), 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(".*The project is not accepting custom out variables.*", ab); } catch (ApiException e) { diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/PermissionIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/PermissionIT.java index a748756e8f..1fddc25b17 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/PermissionIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/PermissionIT.java @@ -20,12 +20,10 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import java.util.*; import static org.junit.jupiter.api.Assertions.*; @@ -43,27 +41,27 @@ public void testCreateOrgPermission() throws Exception { // -- Create role with permission to create orgs - List permissions = new ArrayList<>(); + Set permissions = new HashSet<>(); permissions.add("createOrg"); - RoleOperationResponse rop = rolesApi.createOrUpdate(new RoleEntry() - .setName(roleName) - .setPermissions(permissions)); + RoleOperationResponse rop = rolesApi.createOrUpdateRole(new RoleEntry() + .name(roleName) + .permissions(permissions)); // -- Create user with the role - List roles = new ArrayList<>(); + Set roles = new HashSet<>(); roles.add(roleName); - CreateUserResponse cur = usersApi.createOrUpdate(new CreateUserRequest() - .setType(CreateUserRequest.TypeEnum.LOCAL) - .setUsername(userName) + CreateUserResponse cur = usersApi.createOrUpdateUser(new CreateUserRequest() + .type(CreateUserRequest.TypeEnum.LOCAL) + .username(userName) .roles(roles)); // -- Switch to new user's api key ApiKeysApi apiKeysApi = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse apiKeyA = apiKeysApi.create(new CreateApiKeyRequest().setUsername(userName)); + CreateApiKeyResponse apiKeyA = apiKeysApi.createUserApiKey(new CreateApiKeyRequest().username(userName)); setApiKey(apiKeyA.getKey()); @@ -71,18 +69,18 @@ public void testCreateOrgPermission() throws Exception { // -- Create the org OrganizationsApi organizationsApi = new OrganizationsApi(getApiClient()); - CreateOrganizationResponse cor1 = organizationsApi.createOrUpdate(new OrganizationEntry().setName(orgNameA)); + CreateOrganizationResponse cor1 = organizationsApi.createOrUpdateOrg(new OrganizationEntry().name(orgNameA)); - assertTrue(cor1.isOk()); + assertTrue(cor1.getOk()); // -- Remove role (and permission) from user resetApiKey(); - usersApi.createOrUpdate(new CreateUserRequest() - .setType(CreateUserRequest.TypeEnum.LOCAL) - .setUsername(userName) - .setRoles(Collections.emptyList()) + usersApi.createOrUpdateUser(new CreateUserRequest() + .type(CreateUserRequest.TypeEnum.LOCAL) + .username(userName) + .roles(Collections.emptySet()) ); @@ -90,7 +88,7 @@ public void testCreateOrgPermission() throws Exception { setApiKey(apiKeyA.getKey()); try { - organizationsApi.createOrUpdate(new OrganizationEntry().setName(orgNameB)); + organizationsApi.createOrUpdateOrg(new OrganizationEntry().name(orgNameB)); fail("users without creatOrg permissions must not be allowed to create orgs."); } catch (Exception e) { assertTrue(e.getMessage().contains("'createOrg' permission")); @@ -108,68 +106,68 @@ public void testUpdateOrgPermission() throws Exception { // -- Create role with permission to update orgs RolesApi rolesApi = new RolesApi(getApiClient()); - RoleOperationResponse role = rolesApi.createOrUpdate(new RoleEntry() - .setName(roleName) - .setPermissions(Collections.singletonList("updateOrg"))); + RoleOperationResponse role = rolesApi.createOrUpdateRole(new RoleEntry() + .name(roleName) + .permissions(Collections.singleton("updateOrg"))); // -- Create user with the role UsersApi usersApi = new UsersApi(getApiClient()); - CreateUserResponse userA = usersApi.createOrUpdate(new CreateUserRequest() - .setType(CreateUserRequest.TypeEnum.LOCAL) - .setUsername(userNameA) - .roles(Collections.singletonList(roleName))); + CreateUserResponse userA = usersApi.createOrUpdateUser(new CreateUserRequest() + .type(CreateUserRequest.TypeEnum.LOCAL) + .username(userNameA) + .roles(Collections.singleton(roleName))); // -- Create the org OrganizationsApi organizationsApi = new OrganizationsApi(getApiClient()); - CreateOrganizationResponse cor1 = organizationsApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + CreateOrganizationResponse cor1 = organizationsApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); - assertTrue(cor1.isOk()); - assertEquals("admin", organizationsApi.get(orgName).getOwner().getUsername()); + assertTrue(cor1.getOk()); + assertEquals("admin", organizationsApi.getOrg(orgName).getOwner().getUsername()); // -- Switch to new user's api key ApiKeysApi apiKeysApi = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse userAKey = apiKeysApi.create(new CreateApiKeyRequest().setUsername(userNameA)); + CreateApiKeyResponse userAKey = apiKeysApi.createUserApiKey(new CreateApiKeyRequest().username(userNameA)); setApiKey(userAKey.getKey()); // update org owner - organizationsApi.createOrUpdate(new OrganizationEntry() - .setName(orgName) - .owner(new EntityOwner().setId(userA.getId()))); + organizationsApi.createOrUpdateOrg(new OrganizationEntry() + .name(orgName) + .owner(new EntityOwner().id(userA.getId()))); - assertEquals(userA.getId(), organizationsApi.get(orgName).getOwner().getId()); + assertEquals(userA.getId(), organizationsApi.getOrg(orgName).getOwner().getId()); // -- Remove role (and permission) from user resetApiKey(); - usersApi.createOrUpdate(new CreateUserRequest() - .setType(CreateUserRequest.TypeEnum.LOCAL) - .setUsername(userNameA) - .setRoles(Collections.emptyList()) + usersApi.createOrUpdateUser(new CreateUserRequest() + .type(CreateUserRequest.TypeEnum.LOCAL) + .username(userNameA) + .roles(Collections.emptySet()) ); // new user - userB - CreateUserResponse userB = usersApi.createOrUpdate(new CreateUserRequest() - .setType(CreateUserRequest.TypeEnum.LOCAL) - .setUsername(userNameB)); + CreateUserResponse userB = usersApi.createOrUpdateUser(new CreateUserRequest() + .type(CreateUserRequest.TypeEnum.LOCAL) + .username(userNameB)); // change owner: userA -> userB setApiKey(userAKey.getKey()); - organizationsApi.createOrUpdate(new OrganizationEntry() - .setName(orgName) - .owner(new EntityOwner().setId(userB.getId()))); + organizationsApi.createOrUpdateOrg(new OrganizationEntry() + .name(orgName) + .owner(new EntityOwner().id(userB.getId()))); - assertEquals(userB.getId(), organizationsApi.get(orgName).getOwner().getId()); + assertEquals(userB.getId(), organizationsApi.getOrg(orgName).getOwner().getId()); // -- Org update must be denied try { - organizationsApi.createOrUpdate(new OrganizationEntry().setName(orgName).setVisibility(OrganizationEntry.VisibilityEnum.PRIVATE)); + organizationsApi.createOrUpdateOrg(new OrganizationEntry().name(orgName).visibility(OrganizationEntry.VisibilityEnum.PRIVATE)); fail("users without updateOrg permissions must not be allowed to create orgs."); } catch (Exception e) { assertTrue(e.getMessage().contains("'updateOrg' permission")); @@ -177,9 +175,9 @@ public void testUpdateOrgPermission() throws Exception { // cleanup resetApiKey(); - organizationsApi.delete(orgName, "yes"); - usersApi.delete(userA.getId()); - usersApi.delete(userB.getId()); - rolesApi.delete(roleName); + organizationsApi.deleteOrg(orgName, "yes"); + usersApi.deleteUser(userA.getId()); + usersApi.deleteUser(userB.getId()); + rolesApi.deleteRole(roleName); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/PolicyIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/PolicyIT.java index 0887c02c3e..54116e926a 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/PolicyIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/PolicyIT.java @@ -20,9 +20,8 @@ * ===== */ -import com.walmartlabs.concord.ApiException; -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 org.junit.jupiter.api.Test; import java.util.HashMap; @@ -39,26 +38,26 @@ public class PolicyIT extends AbstractServerIT { public void testCfg() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi organizationsApi = new OrganizationsApi(getApiClient()); - organizationsApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + organizationsApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); String policyName = "policy_" + randomString(); PolicyApi policyApi = new PolicyApi(getApiClient()); - policyApi.createOrUpdate(new PolicyEntry() - .setName(policyName) - .setRules(singletonMap("processCfg", + policyApi.createOrUpdatePolicy(new PolicyEntry() + .name(policyName) + .rules(singletonMap("processCfg", singletonMap("arguments", singletonMap("x", singletonMap("name", "Concord")))))); - policyApi.link(policyName, new PolicyLinkEntry() - .setOrgName(orgName) - .setProjectName(projectName)); + policyApi.linkPolicy(policyName, new PolicyLinkEntry() + .orgName(orgName) + .projectName(projectName)); // --- @@ -66,23 +65,22 @@ public void testCfg() throws Exception { StartProcessResponse spr = start(payload); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Hello, Stranger.*", ab); // --- spr = start(orgName, projectName, null, null, payload); - pir = waitForCompletion(processApi, spr.getInstanceId()); + pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - ab = getLog(pir.getLogFileName()); + ab = getLog(pir.getInstanceId()); assertLog(".*Hello, Concord.*", ab); } @@ -103,23 +101,22 @@ public void testMaxForkDepth() throws Exception { StartProcessResponse spr = start(orgName, projectName, null, null, payload); - ProcessApi processApi = new ProcessApi(getApiClient()); - waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.RUNNING); + waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.RUNNING); - waitForCompletion(processApi, spr.getInstanceId()); + waitForCompletion(getApiClient(), spr.getInstanceId()); } @Test public void testConcurrentProcess() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi organizationsApi = new OrganizationsApi(getApiClient()); - organizationsApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + organizationsApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); String policyName = "policy_" + randomString(); PolicyApi policyApi = new PolicyApi(getApiClient()); @@ -127,13 +124,13 @@ public void testConcurrentProcess() throws Exception { queueRules.put("concurrent", singletonMap("max", 1)); Map rules = singletonMap("queue", queueRules); - policyApi.createOrUpdate(new PolicyEntry() - .setName(policyName) - .setRules(rules)); + policyApi.createOrUpdatePolicy(new PolicyEntry() + .name(policyName) + .rules(rules)); - policyApi.link(policyName, new PolicyLinkEntry() - .setOrgName(orgName) - .setProjectName(projectName)); + policyApi.linkPolicy(policyName, new PolicyLinkEntry() + .orgName(orgName) + .projectName(projectName)); // --- @@ -147,8 +144,7 @@ public void testConcurrentProcess() throws Exception { StartProcessResponse spr1 = start(input1); - ProcessApi processApi = new ProcessApi(getApiClient()); - waitForStatus(processApi, spr1.getInstanceId(), StatusEnum.RUNNING); + waitForStatus(getApiClient(), spr1.getInstanceId(), StatusEnum.RUNNING); // --- start second process @@ -159,24 +155,24 @@ public void testConcurrentProcess() throws Exception { // --- - waitForCompletion(processApi, spr1.getInstanceId()); + waitForCompletion(getApiClient(), spr1.getInstanceId()); // --- - waitForCompletion(processApi, spr2.getInstanceId()); + waitForCompletion(getApiClient(), spr2.getInstanceId()); } @Test public void testConcurrentWithSuspendedProcess() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi organizationsApi = new OrganizationsApi(getApiClient()); - organizationsApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + organizationsApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); String policyName = "policy_" + randomString(); PolicyApi policyApi = new PolicyApi(getApiClient()); @@ -184,13 +180,13 @@ public void testConcurrentWithSuspendedProcess() throws Exception { queueRules.put("concurrent", singletonMap("max", 1)); Map rules = singletonMap("queue", queueRules); - policyApi.createOrUpdate(new PolicyEntry() - .setName(policyName) - .setRules(rules)); + policyApi.createOrUpdatePolicy(new PolicyEntry() + .name(policyName) + .rules(rules)); - policyApi.link(policyName, new PolicyLinkEntry() - .setOrgName(orgName) - .setProjectName(projectName)); + policyApi.linkPolicy(policyName, new PolicyLinkEntry() + .orgName(orgName) + .projectName(projectName)); // --- @@ -204,8 +200,7 @@ public void testConcurrentWithSuspendedProcess() throws Exception { StartProcessResponse spr1 = start(input1); - ProcessApi processApi = new ProcessApi(getApiClient()); - waitForStatus(processApi, spr1.getInstanceId(), StatusEnum.RUNNING); + waitForStatus(getApiClient(), spr1.getInstanceId(), StatusEnum.RUNNING); // --- start the second process @@ -220,7 +215,7 @@ public void testConcurrentWithSuspendedProcess() throws Exception { // --- - waitForCompletion(processApi, spr2.getInstanceId()); + waitForCompletion(getApiClient(), spr2.getInstanceId()); } @Test @@ -245,12 +240,11 @@ public void testMaxProcessTimeout() throws Exception { input.put("request", singletonMap("processTimeout", "PT10M")); StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pe = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pe = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(StatusEnum.FAILED, pe.getStatus()); - byte[] ab = getLog(pe.getLogFileName()); + byte[] ab = getLog(pe.getInstanceId()); assertLog(".*Maximum processTimeout value exceeded.*", ab); } @@ -258,7 +252,7 @@ private String createOrg() throws ApiException { String orgName = "org_" + randomString(); OrganizationsApi organizationsApi = new OrganizationsApi(getApiClient()); - organizationsApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + organizationsApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); return orgName; } @@ -267,9 +261,9 @@ private String createProject(String orgName) throws ApiException { String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); return projectName; } @@ -278,13 +272,13 @@ private String createPolicy(String orgName, String projectName, Map l = processApi.list(null, null, por.getId(), null, null, null, null, null, null, 10, 0); + ProcessV2Api processApi = new ProcessV2Api(getApiClient()); + List l = processApi.listProcesses(ProcessListFilter.builder() + .projectId(por.getId()) + .limit(10) + .build()); assertEquals(1, l.size()); // --- ProcessEntry pe = l.get(0); - pe = waitForCompletion(processApi, pe.getInstanceId()); + pe = waitForCompletion(getApiClient(), pe.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FINISHED, pe.getStatus()); } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/PrincipalPermissionIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/PrincipalPermissionIT.java index 908d682020..d669312121 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/PrincipalPermissionIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/PrincipalPermissionIT.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,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import java.util.HashMap; @@ -48,10 +48,10 @@ public void testPrincipalPermission() throws Exception { String text = "select item_path from inventory_data where item_path like '%/testPath'"; InventoriesApi inventoryResource = new InventoriesApi(getApiClient()); - inventoryResource.createOrUpdate(orgName, new InventoryEntry().setName(inventoryName)); + inventoryResource.createOrUpdateInventory(orgName, new InventoryEntry().name(inventoryName)); - CreateInventoryQueryResponse cqr = resource.createOrUpdate(orgName, inventoryName, queryName, text); - assertTrue(cqr.isOk()); + CreateInventoryQueryResponse cqr = resource.createOrUpdateInventoryQuery(orgName, inventoryName, queryName, text); + assertTrue(cqr.getOk()); assertNotNull(cqr.getId()); Map input = new HashMap<>(); @@ -62,7 +62,7 @@ public void testPrincipalPermission() throws Exception { StartProcessResponse spr = start(input); ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus()); List processEntryList = processApi.listSubprocesses(spr.getInstanceId(), null); @@ -70,7 +70,7 @@ public void testPrincipalPermission() throws Exception { assertEquals(ProcessEntry.StatusEnum.FINISHED, pe.getStatus()); } - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Done!.*", ab); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessContainerIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessContainerIT.java index be040620b3..f622d4f169 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessContainerIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessContainerIT.java @@ -20,9 +20,8 @@ * ===== */ -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.ProcessEntry; +import com.walmartlabs.concord.client2.StartProcessResponse; import com.walmartlabs.concord.common.IOUtils; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -42,7 +41,7 @@ public class ProcessContainerIT extends AbstractServerIT { @Test public void test() throws Exception { - Path src = Paths.get(DockerIT.class.getResource("processContainer").toURI()); + Path src = Paths.get(ProcessContainerIT.class.getResource("processContainer").toURI()); Path dst = IOUtils.createTempDir("test"); IOUtils.copy(src, dst); @@ -59,12 +58,11 @@ public void test() throws Exception { // -- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertNotNull(pir.getLogFileName()); assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Hello from Docker!.*", ab); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessCountIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessCountIT.java index 070b89b714..c619d75300 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessCountIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessCountIT.java @@ -20,8 +20,8 @@ * ===== */ -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; +import com.walmartlabs.concord.client2.ProcessListFilter; import com.walmartlabs.concord.common.IOUtils; import org.eclipse.jgit.api.Git; import org.junit.jupiter.api.Test; @@ -58,7 +58,7 @@ public void test() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String projectName = "project_" + randomString(); String repoName = "repo_" + randomString(); @@ -66,11 +66,11 @@ public void test() throws Exception { System.out.println(">>>" + orgName + "/" + projectName); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRepositories(Collections.singletonMap(repoName, new RepositoryEntry() - .setBranch("master") - .setUrl(gitUrl)))); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .repositories(Collections.singletonMap(repoName, new RepositoryEntry() + .branch("master") + .url(gitUrl)))); // --- @@ -82,35 +82,46 @@ public void test() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pe = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pe = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FINISHED, pe.getStatus()); - byte[] ab = getLog(pe.getLogFileName()); + byte[] ab = getLog(pe.getInstanceId()); assertLog(".*Hello!.*", ab); // --- ProcessV2Api processV2Api = new ProcessV2Api(getApiClient()); - List l = processV2Api.list(null, orgName, null, projectName, null, repoName, null, null, null, null, null, null, null, null, null); + ProcessListFilter filter = ProcessListFilter.builder() + .orgName(orgName) + .projectName(projectName) + .repoName(repoName) + .build(); + + List l = processV2Api.listProcesses(filter); assertEquals(1, l.size()); assertEquals(pe.getInstanceId(), l.get(0).getInstanceId()); + filter = ProcessListFilter.builder() + .orgName(orgName) + .projectName(projectName) + .repoName(repoName + randomString()) + .build(); + // specifying an invalid repository name should return a 404 response try { - processV2Api.list(null, orgName, null, projectName, null, repoName + randomString(), null, null, null, null, null, null, null, null, null); + processV2Api.listProcesses(filter); } catch (ApiException e) { assertEquals(404, e.getCode()); } // --- - int i = processV2Api.count(null, orgName, null, projectName, null, repoName, null, null, null, null, null, null); + int i = processV2Api.countProcesses(null, orgName, null, projectName, null, repoName, null, null, null, null, null, null); assertEquals(1, i); // specifying an invalid repository name should return a 404 response try { - processV2Api.count(null, orgName, null, projectName, null, repoName + randomString(), null, null, null, null, null, null); + processV2Api.countProcesses(null, orgName, null, projectName, null, repoName + randomString(), null, null, null, null, null, null); } catch (ApiException e) { assertEquals(404, e.getCode()); } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessEventsIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessEventsIT.java index 07d80b74ca..e339c7bcb3 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessEventsIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessEventsIT.java @@ -20,8 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import java.util.Collections; @@ -41,17 +40,17 @@ public void testIncludeAllPermissions() throws Exception { OrganizationsApi organizationsApi = new OrganizationsApi(getApiClient()); String orgName = "org_" + randomString(); - organizationsApi.createOrUpdate(new OrganizationEntry() - .setName(orgName)); + organizationsApi.createOrUpdateOrg(new OrganizationEntry() + .name(orgName)); // --- ProjectsApi projectsApi = new ProjectsApi(getApiClient()); String projectName = "project_" + randomString(); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.OWNERS)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.OWNERS)); // --- @@ -65,20 +64,19 @@ public void testIncludeAllPermissions() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pe = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pe = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FINISHED, pe.getStatus()); // --- - byte[] ab = getLog(pe.getLogFileName()); + byte[] ab = getLog(pe.getInstanceId()); assertLog(".*Hello!.*", ab); // --- ProcessEventsApi eventsApi = new ProcessEventsApi(getApiClient()); - List events = eventsApi.list(pe.getInstanceId(), "ELEMENT", null, null, null, "pre", true, 10); + List events = eventsApi.listProcessEvents(pe.getInstanceId(), "ELEMENT", null, null, null, "pre", true, 10); assertEquals(1, events.size()); ProcessEventEntry ev = events.get(0); @@ -89,13 +87,13 @@ public void testIncludeAllPermissions() throws Exception { UsersApi usersApi = new UsersApi(getApiClient()); String userName = "user_" + randomString(); - CreateUserResponse cur = usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userName) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + CreateUserResponse cur = usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userName) + .type(CreateUserRequest.TypeEnum.LOCAL)); ApiKeysApi apiKeysApi = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse car = apiKeysApi.create(new CreateApiKeyRequest() - .setUserId(cur.getId())); + CreateApiKeyResponse car = apiKeysApi.createUserApiKey(new CreateApiKeyRequest() + .userId(cur.getId())); // --- @@ -104,7 +102,7 @@ public void testIncludeAllPermissions() throws Exception { // --- try { - eventsApi.list(pe.getInstanceId(), "ELEMENT", null, null, null, "pre", true, 10); + eventsApi.listProcessEvents(pe.getInstanceId(), "ELEMENT", null, null, null, "pre", true, 10); fail("should fail"); } catch (ApiException e) { assertEquals(403, e.getCode()); @@ -119,22 +117,22 @@ public void testIncludeAllPermissions() throws Exception { TeamsApi teamsApi = new TeamsApi(getApiClient()); String teamName = "team_" + randomString(); - CreateTeamResponse ctr = teamsApi.createOrUpdate(orgName, new TeamEntry() - .setName(teamName)); + CreateTeamResponse ctr = teamsApi.createOrUpdateTeam(orgName, new TeamEntry() + .name(teamName)); - teamsApi.addUsers(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() - .setUserId(cur.getId()) - .setRole(TeamUserEntry.RoleEnum.MEMBER))); + teamsApi.addUsersToTeam(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() + .userId(cur.getId()) + .role(TeamUserEntry.RoleEnum.MEMBER))); - projectsApi.updateAccessLevel(orgName, projectName, new ResourceAccessEntry() - .setTeamId(ctr.getId()) - .setLevel(ResourceAccessEntry.LevelEnum.WRITER)); + projectsApi.updateProjectAccessLevel(orgName, projectName, new ResourceAccessEntry() + .teamId(ctr.getId()) + .level(ResourceAccessEntry.LevelEnum.WRITER)); // --- setApiKey(car.getKey()); - events = eventsApi.list(pe.getInstanceId(), "ELEMENT", null, null, null, "pre", true, 10); + events = eventsApi.listProcessEvents(pe.getInstanceId(), "ELEMENT", null, null, null, "pre", true, 10); assertEquals(1, events.size()); ev = events.get(0); diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessIT.java index 671b022b21..20c37e8dcd 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessIT.java @@ -22,15 +22,15 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import com.walmartlabs.concord.ApiException; -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.client2.ProcessListFilter; import com.walmartlabs.concord.common.ConfigurationUtils; import com.walmartlabs.concord.common.IOUtils; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import java.io.File; +import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -68,7 +68,7 @@ public void testTimeout() throws Exception { fail("should fail"); } catch (ApiException e) { String s = e.getResponseBody(); - ProcessEntry pir = getApiClient().getJSON().deserialize(s, ProcessEntry.class); + ProcessEntry pir = getApiClient().getObjectMapper().readValue(s, ProcessEntry.class); assertTrue(StatusEnum.RUNNING.equals(pir.getStatus()) || StatusEnum.ENQUEUED.equals(pir.getStatus()) || StatusEnum.PREPARING.equals(pir.getStatus()) @@ -78,23 +78,22 @@ public void testTimeout() throws Exception { processApi.kill(spr.getInstanceId()); - waitForStatus(processApi, spr.getInstanceId(), StatusEnum.CANCELLED, StatusEnum.FAILED, StatusEnum.FINISHED); + waitForStatus(getApiClient(), spr.getInstanceId(), StatusEnum.CANCELLED, StatusEnum.FAILED, StatusEnum.FINISHED); } @Test public void testTaskOut() throws Exception { byte[] payload = archive(ProcessIT.class.getResource("taskOut").toURI(), ITConstants.DEPENDENCIES_DIR); - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); // --- - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*I said: Hello!.*", ab); } @@ -102,16 +101,15 @@ public void testTaskOut() throws Exception { public void testDelegateOut() throws Exception { byte[] payload = archive(ProcessIT.class.getResource("delegateOut").toURI(), ITConstants.DEPENDENCIES_DIR); - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); // --- - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*I said: Hello!.*", ab); } @@ -121,40 +119,54 @@ public void testProjectId() throws Exception { String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - ProjectOperationResponse por1 = projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + ProjectOperationResponse por1 = projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); // --- byte[] payload = archive(ProcessIT.class.getResource("example").toURI()); - ProcessApi processApi = new ProcessApi(getApiClient()); Map input = new HashMap<>(); input.put("org", orgName); input.put("project", projectName); input.put("archive", payload); StartProcessResponse sprA = start(input); - waitForCompletion(processApi, sprA.getInstanceId()); + waitForCompletion(getApiClient(), sprA.getInstanceId()); // --- StartProcessResponse sprB = start(payload); - waitForCompletion(processApi, sprB.getInstanceId()); + waitForCompletion(getApiClient(), sprB.getInstanceId()); // --- String anotherProjectName = "another_" + randomString(); - ProjectOperationResponse por2 = projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(anotherProjectName)); + ProjectOperationResponse por2 = projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(anotherProjectName)); - List l = processApi.list(null, null, por2.getId(), null, null, null, null, null, null, 30, 0); + ProcessV2Api processV2Api = new ProcessV2Api(getApiClient()); + ProcessListFilter filter = ProcessListFilter.builder() + .projectId(por2.getId()) + .limit(30) + .build(); + + List l = processV2Api.listProcesses(filter); assertTrue(l.isEmpty()); - l = processApi.list(null, null, por1.getId(), null, null, null, null, null, null, 30, 0); + filter = ProcessListFilter.builder() + .projectId(por1.getId()) + .limit(30) + .build(); + + l = processV2Api.listProcesses(filter); assertEquals(1, l.size()); - l = processApi.list(null, null, null, null, null, null, null, null, null, 30, 0); + filter = ProcessListFilter.builder() + .limit(30) + .build(); + + l = processV2Api.listProcesses(filter); ProcessEntry p = null; for (ProcessEntry e : l) { if (e.getInstanceId().equals(sprB.getInstanceId())) { @@ -172,28 +184,28 @@ public void testGetAllProcessesForChildIds() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // add the user A UsersApi usersApi = new UsersApi(getApiClient()); String userAName = "userA_" + randomString(); - usersApi.createOrUpdate(new CreateUserRequest().setUsername(userAName).setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest().username(userAName).type(CreateUserRequest.TypeEnum.LOCAL)); ApiKeysApi apiKeyResource = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse apiKeyA = apiKeyResource.create(new CreateApiKeyRequest().setUsername(userAName)); + CreateApiKeyResponse apiKeyA = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(userAName)); // create the user A's team String teamName = "team_" + randomString(); TeamsApi teamsApi = new TeamsApi(getApiClient()); - CreateTeamResponse ctr = teamsApi.createOrUpdate(orgName, new TeamEntry().setName(teamName)); + CreateTeamResponse ctr = teamsApi.createOrUpdateTeam(orgName, new TeamEntry().name(teamName)); - teamsApi.addUsers(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() - .setUsername(userAName) - .setRole(TeamUserEntry.RoleEnum.MEMBER))); + teamsApi.addUsersToTeam(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() + .username(userAName) + .role(TeamUserEntry.RoleEnum.MEMBER))); // switch to the user A and create a new private project @@ -202,18 +214,18 @@ public void testGetAllProcessesForChildIds() throws Exception { String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - ProjectOperationResponse por = projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setVisibility(ProjectEntry.VisibilityEnum.PRIVATE) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + ProjectOperationResponse por = projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .visibility(ProjectEntry.VisibilityEnum.PRIVATE) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); // grant the team access to the project - projectsApi.updateAccessLevel(orgName, projectName, new ResourceAccessEntry() - .setTeamId(ctr.getId()) - .setOrgName(orgName) - .setTeamName(teamName) - .setLevel(ResourceAccessEntry.LevelEnum.READER)); + projectsApi.updateProjectAccessLevel(orgName, projectName, new ResourceAccessEntry() + .teamId(ctr.getId()) + .orgName(orgName) + .teamName(teamName) + .level(ResourceAccessEntry.LevelEnum.READER)); //Start a process with zero child @@ -224,8 +236,7 @@ public void testGetAllProcessesForChildIds() throws Exception { input.put("project", projectName); StartProcessResponse singleNodeProcess = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - waitForCompletion(processApi, singleNodeProcess.getInstanceId()); + waitForCompletion(getApiClient(), singleNodeProcess.getInstanceId()); // Start a process with children @@ -236,11 +247,15 @@ public void testGetAllProcessesForChildIds() throws Exception { input.put("project", projectName); StartProcessResponse parentSpr = start(input); - waitForCompletion(processApi, parentSpr.getInstanceId()); + waitForCompletion(getApiClient(), parentSpr.getInstanceId()); // --- - - List processEntry = processApi.list(null, null, por.getId(), null, null, null, null, null, null, 10, 0); + ProcessListFilter filter = ProcessListFilter.builder() + .projectId(por.getId()) + .limit(10) + .addInclude(ProcessDataInclude.CHILDREN_IDS) + .build(); + List processEntry = new ProcessV2Api(getApiClient()).listProcesses(filter); for (ProcessEntry pe : processEntry) { if (pe.getInstanceId().equals(singleNodeProcess.getInstanceId())) { assertTrue(pe.getChildrenIds() == null || pe.getChildrenIds().isEmpty()); @@ -256,10 +271,10 @@ public void testForkInitiatorFromApiKey() throws Exception { UsersApi usersApi = new UsersApi(getApiClient()); String userAName = "userA_" + randomString(); - usersApi.createOrUpdate(new CreateUserRequest().setUsername(userAName).setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest().username(userAName).type(CreateUserRequest.TypeEnum.LOCAL)); ApiKeysApi apiKeyResource = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse apiKeyA = apiKeyResource.create(new CreateApiKeyRequest().setUsername(userAName)); + CreateApiKeyResponse apiKeyA = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(userAName)); String yaml = new String(Files.readAllBytes(Paths.get(ProcessIT.class.getResource("forkInitiator").toURI()).resolve("concord.yml"))); yaml = yaml.replace("{{apiKey}}", apiKeyA.getKey()); @@ -275,21 +290,25 @@ public void testForkInitiatorFromApiKey() throws Exception { StartProcessResponse parentSpr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - - ProcessEntry processEntry = waitForCompletion(processApi, parentSpr.getInstanceId()); - assertEquals(ProcessEntry.StatusEnum.FINISHED, processEntry.getStatus()); + ProcessEntry processEntry = waitForCompletion(getApiClient(), parentSpr.getInstanceId()); + assertEquals(StatusEnum.FINISHED, processEntry.getStatus(), () -> { + try { + return new String(getLog(processEntry.getInstanceId())); + } catch (ApiException e) { + throw new RuntimeException(e); + } + }); assertEquals(1, processEntry.getChildrenIds().size()); - ProcessEntry child = waitForCompletion(processApi, processEntry.getChildrenIds().get(0)); - assertEquals(ProcessEntry.StatusEnum.FINISHED, child.getStatus()); + ProcessEntry child = waitForCompletion(getApiClient(), processEntry.getChildrenIds().iterator().next()); + assertEquals(StatusEnum.FINISHED, child.getStatus()); { - byte[] ab = getLog(processEntry.getLogFileName()); + byte[] ab = getLog(processEntry.getInstanceId()); assertLog(".*initiator: .*admin.*", ab); } { - byte[] ab = getLog(child.getLogFileName()); + byte[] ab = getLog(child.getInstanceId()); assertLog(".*initiator: .*" + userAName.toLowerCase() + ".*", ab); } } @@ -304,14 +323,15 @@ public void testEffectiveYaml() throws Exception { // --- - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); - assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); + assertEquals(StatusEnum.FINISHED, pir.getStatus()); - File effectiveYaml = processApi.downloadStateFile(pir.getInstanceId(), ".concord/effective.concord.yml"); - assertNotNull(effectiveYaml); + try (InputStream effectiveYaml = processApi.downloadStateFile(pir.getInstanceId(), ".concord/effective.concord.yml")) { + assertNotNull(effectiveYaml); - Map m = new ObjectMapper(new YAMLFactory()).readValue(effectiveYaml, Map.class); - String entryPoint = (String) ConfigurationUtils.get(m, "configuration", "entryPoint"); - assertEquals("test", entryPoint); + Map m = new ObjectMapper(new YAMLFactory()).readValue(effectiveYaml, Map.class); + String entryPoint = (String) ConfigurationUtils.get(m, "configuration", "entryPoint"); + assertEquals("test", entryPoint); + } } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessLocksIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessLocksIT.java index af908c8ed7..84b3ecab14 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessLocksIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessLocksIT.java @@ -20,8 +20,8 @@ * ===== */ -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 org.junit.jupiter.api.Test; import java.util.HashMap; @@ -39,27 +39,26 @@ public void testOrgScope() throws Exception { String projectName = "project_" + randomString(); OrganizationsApi organizationsApi = new OrganizationsApi(getApiClient()); - organizationsApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + organizationsApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry().setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry().name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); // --- - byte[] payload = archive(ProcessIT.class.getResource("processLocks").toURI()); + byte[] payload = archive(ProcessLocksIT.class.getResource("processLocks").toURI()); Map input = new HashMap<>(); input.put("org", orgName); input.put("project", projectName); input.put("archive", payload); - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse sprA = start(input); - ProcessEntry pirA = waitForStatus(processApi, sprA.getInstanceId(), StatusEnum.FAILED, StatusEnum.RUNNING); + ProcessEntry pirA = waitForStatus(getApiClient(), sprA.getInstanceId(), StatusEnum.FAILED, StatusEnum.RUNNING); assertEquals(StatusEnum.RUNNING, pirA.getStatus()); - waitForLog(pirA.getLogFileName(), ".*locked!.*"); + waitForLog(pirA.getInstanceId(), ".*locked!.*"); // --- @@ -70,15 +69,15 @@ public void testOrgScope() throws Exception { StartProcessResponse sprB = start(input); - ProcessEntry pirB = waitForStatus(processApi, sprB.getInstanceId(), StatusEnum.FAILED, StatusEnum.SUSPENDED); + ProcessEntry pirB = waitForStatus(getApiClient(), sprB.getInstanceId(), StatusEnum.FAILED, StatusEnum.SUSPENDED); assertEquals(StatusEnum.SUSPENDED, pirB.getStatus()); // --- - pirA = waitForStatus(processApi, sprA.getInstanceId(), StatusEnum.FAILED, StatusEnum.FINISHED); + pirA = waitForStatus(getApiClient(), sprA.getInstanceId(), StatusEnum.FAILED, StatusEnum.FINISHED); assertEquals(StatusEnum.FINISHED, pirA.getStatus()); - pirB = waitForStatus(processApi, sprB.getInstanceId(), StatusEnum.FAILED, StatusEnum.FINISHED); + pirB = waitForStatus(getApiClient(), sprB.getInstanceId(), StatusEnum.FAILED, StatusEnum.FINISHED); assertEquals(StatusEnum.FINISHED, pirB.getStatus()); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessMetadataIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessMetadataIT.java index eab774cd8c..f37db66fe5 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessMetadataIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessMetadataIT.java @@ -1,4 +1,4 @@ -package com.walmartlabs.concord.it.server; +package com.walmartlabs.concord.it.server;//package com.walmartlabs.concord.it.server; /*- * ***** @@ -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,16 +20,8 @@ * ===== */ -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.squareup.okhttp.HttpUrl; -import com.squareup.okhttp.OkHttpClient; -import com.squareup.okhttp.Request; -import com.squareup.okhttp.Response; -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.client.*; -import com.walmartlabs.concord.it.common.ServerClient; -import com.walmartlabs.concord.it.common.ServerCompatModule; +import com.walmartlabs.concord.client2.*; +import com.walmartlabs.concord.client2.ProcessListFilter; import org.junit.jupiter.api.Test; import java.util.HashMap; @@ -42,18 +34,15 @@ public class ProcessMetadataIT extends AbstractServerIT { - private static final TypeReference> LIST_OF_PROCESS_ENTRIES = new TypeReference>() { - }; - @Test public void test() throws Exception { String orgName = "Default"; String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); // --- String randomStringA = "randomA_" + randomString(); @@ -64,9 +53,8 @@ public void test() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - waitForCompletion(processApi, sprA.getInstanceId()); - waitForCompletion(processApi, sprB.getInstanceId()); + waitForCompletion(getApiClient(), sprA.getInstanceId()); + waitForCompletion(getApiClient(), sprB.getInstanceId()); // --- @@ -113,36 +101,18 @@ private StartProcessResponse start(String orgName, String projectName, String va } private List list(String orgName, String projectName, String... kv) throws Exception { - ApiClient apiClient = getApiClient(); - HttpUrl.Builder b = HttpUrl.parse(apiClient.getBasePath() + "/api/v2/process") - .newBuilder() - .addQueryParameter("orgName", orgName) - .addQueryParameter("projectName", projectName); + Map meta = new HashMap<>(); for (int i = 0; i < kv.length - 1; i += 2) { - b.addQueryParameter(kv[i], kv[i + 1]); + meta.put(kv[i], kv[i + 1]); } - Request req = new Request.Builder() - .url(b.build()) - .header("Authorization", ServerClient.DEFAULT_API_KEY) + ProcessListFilter filter = ProcessListFilter.builder() + .orgName(orgName) + .projectName(projectName) + .meta(meta) .build(); - OkHttpClient httpClient = apiClient.getHttpClient(); - Response resp = null; - try { - resp = httpClient.newCall(req).execute(); - if (!resp.isSuccessful()) { - throw new RuntimeException("Request failed: " + resp); - } - - ObjectMapper om = new ObjectMapper(); - om.registerModule(new ServerCompatModule()); // to parse timestamps - return om.readValue(resp.body().byteStream(), LIST_OF_PROCESS_ENTRIES); - } finally { - if (resp != null && resp.body() != null) { - resp.body().close(); - } - } + return new ProcessV2Api(getApiClient()).listProcesses(filter); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessRbacIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessRbacIT.java index 00d9a22791..80ae110b12 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessRbacIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessRbacIT.java @@ -20,8 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import java.util.Collections; @@ -41,28 +40,28 @@ public void test() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // add the user A UsersApi usersApi = new UsersApi(getApiClient()); String userAName = "userA_" + randomString(); - usersApi.createOrUpdate(new CreateUserRequest().setUsername(userAName).setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest().username(userAName).type(CreateUserRequest.TypeEnum.LOCAL)); ApiKeysApi apiKeyResource = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse apiKeyA = apiKeyResource.create(new CreateApiKeyRequest().setUsername(userAName)); + CreateApiKeyResponse apiKeyA = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(userAName)); // create the user A's team String teamName = "team_" + randomString(); TeamsApi teamsApi = new TeamsApi(getApiClient()); - CreateTeamResponse ctr = teamsApi.createOrUpdate(orgName, new TeamEntry().setName(teamName)); + CreateTeamResponse ctr = teamsApi.createOrUpdateTeam(orgName, new TeamEntry().name(teamName)); - teamsApi.addUsers(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() - .setUsername(userAName) - .setRole(TeamUserEntry.RoleEnum.MEMBER))); + teamsApi.addUsersToTeam(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() + .username(userAName) + .role(TeamUserEntry.RoleEnum.MEMBER))); // switch to the user A and create a new private project @@ -71,18 +70,18 @@ public void test() throws Exception { String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setVisibility(ProjectEntry.VisibilityEnum.PRIVATE) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .visibility(ProjectEntry.VisibilityEnum.PRIVATE) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); // grant the team access to the project - projectsApi.updateAccessLevel(orgName, projectName, new ResourceAccessEntry() - .setTeamId(ctr.getId()) - .setOrgName(orgName) - .setTeamName(teamName) - .setLevel(ResourceAccessEntry.LevelEnum.READER)); + projectsApi.updateProjectAccessLevel(orgName, projectName, new ResourceAccessEntry() + .teamId(ctr.getId()) + .orgName(orgName) + .teamName(teamName) + .level(ResourceAccessEntry.LevelEnum.READER)); // start a new process using the project as the user A @@ -94,19 +93,18 @@ public void test() throws Exception { StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.FINISHED); + waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.FINISHED); // switch to admin and add the user B resetApiKey(); String userBName = "userB_" + randomString(); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userBName) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userBName) + .type(CreateUserRequest.TypeEnum.LOCAL)); - CreateApiKeyResponse apiKeyB = apiKeyResource.create(new CreateApiKeyRequest().setUsername(userBName)); + CreateApiKeyResponse apiKeyB = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(userBName)); // switch to the user B and try starting a process using the project @@ -122,15 +120,15 @@ public void test() throws Exception { resetApiKey(); - teamsApi.addUsers(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() - .setUsername(userBName) - .setRole(TeamUserEntry.RoleEnum.MEMBER))); + teamsApi.addUsersToTeam(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() + .username(userBName) + .role(TeamUserEntry.RoleEnum.MEMBER))); // switch to the user B and start a process using the project setApiKey(apiKeyB.getKey()); spr = start(input); - waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.FINISHED); + waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.FINISHED); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessStateIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessStateIT.java index bd10840760..56f97fb46b 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessStateIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProcessStateIT.java @@ -20,12 +20,12 @@ * ===== */ -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.ProcessApi; +import com.walmartlabs.concord.client2.ProcessEntry; +import com.walmartlabs.concord.client2.StartProcessResponse; import org.junit.jupiter.api.Test; -import java.io.File; +import java.io.InputStream; import java.util.HashMap; import java.util.Map; @@ -38,7 +38,7 @@ public class ProcessStateIT extends AbstractServerIT { @Test public void testSingleFile() throws Exception { - byte[] payload = archive(ProcessIT.class.getResource("stateSingleFile").toURI()); + byte[] payload = archive(ProcessStateIT.class.getResource("stateSingleFile").toURI()); // --- @@ -49,12 +49,13 @@ public void testSingleFile() throws Exception { // --- ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pe = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pe = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FINISHED, pe.getStatus()); // --- - File resp = processApi.downloadStateFile(spr.getInstanceId(), "concord.yml"); - assertNotNull(resp); + try (InputStream resp = processApi.downloadStateFile(spr.getInstanceId(), "concord.yml")) { + assertNotNull(resp); + } } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProjectDeleteIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProjectDeleteIT.java index b03be006d2..27b0858b47 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProjectDeleteIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProjectDeleteIT.java @@ -20,10 +20,10 @@ * ===== */ -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; +import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -39,16 +39,15 @@ public void test() throws Exception { String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - ProjectOperationResponse cpr = projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); - assertTrue(cpr.isOk()); + ProjectOperationResponse cpr = projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + assertTrue(cpr.getOk()); // --- byte[] payload = archive(ProjectDeleteIT.class.getResource("simple").toURI()); - ProcessApi processApi = new ProcessApi(getApiClient()); Map input = new HashMap<>(); input.put("archive", payload); input.put("org", orgName); @@ -57,24 +56,25 @@ public void test() throws Exception { // --- - ProcessEntry pe = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pe = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FINISHED, pe.getStatus()); assertEquals(cpr.getId(), pe.getProjectId()); // --- - GenericOperationResult dpr = projectsApi.delete(orgName, projectName); - assertTrue(dpr.isOk()); + GenericOperationResult dpr = projectsApi.deleteProject(orgName, projectName); + assertTrue(dpr.getOk()); try { - projectsApi.get(orgName, projectName); + projectsApi.getProject(orgName, projectName); fail("Should fail"); } catch (ApiException e) { } // --- - pe = processApi.get(spr.getInstanceId()); + ProcessV2Api processApi = new ProcessV2Api(getApiClient()); + pe = processApi.getProcess(spr.getInstanceId(), Collections.emptySet()); assertNull(pe.getProjectId()); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProjectFileIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProjectFileIT.java index 3a6d5ae340..e63c4c4917 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProjectFileIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProjectFileIT.java @@ -20,7 +20,7 @@ * ===== */ -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; @@ -120,16 +120,15 @@ public void testDependencies() throws Exception { // send the request - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); assertNotNull(spr.getInstanceId()); - ProcessEntry psr = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry psr = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FINISHED, psr.getStatus()); // --- - byte[] ab = getLog(psr.getLogFileName()); + byte[] ab = getLog(psr.getInstanceId()); assertLog(".*Hello!.*", ab); } @@ -146,22 +145,21 @@ public void testArchiveOverride() throws Exception { generateKeyPair(orgName, secretName, false, null); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE) - .setRepositories(Collections.singletonMap(repoName, new RepositoryEntry() - .setName(repoName) - .setUrl(createRepo("repositoryRefresh")) - .setBranch("master") - .setSecretName(secretName)))); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE) + .repositories(Collections.singletonMap(repoName, new RepositoryEntry() + .name(repoName) + .url(createRepo("repositoryRefresh")) + .branch("master") + .secretName(secretName)))); // --- - byte[] payload = archive(ProcessIT.class.getResource("projectfile/singleprofile").toURI()); + byte[] payload = archive(ProjectFileIT.class.getResource("projectfile/singleprofile").toURI()); // --- - ProcessApi processApi = new ProcessApi(getApiClient()); Map input = new HashMap<>(); input.put("archive", payload); input.put("org", orgName); @@ -169,11 +167,11 @@ public void testArchiveOverride() throws Exception { StartProcessResponse spr = start(input); assertNotNull(spr.getInstanceId()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*54321.*", ab); } @@ -184,15 +182,14 @@ public void testExpressionScriptName() throws Exception { } private void simpleTest(String resource, String... logPatterns) throws Exception { - byte[] payload = archive(ProcessIT.class.getResource(resource).toURI()); + byte[] payload = archive(ProjectFileIT.class.getResource(resource).toURI()); // --- - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); assertNotNull(spr.getInstanceId()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- @@ -200,7 +197,7 @@ private void simpleTest(String resource, String... logPatterns) throws Exception return; } - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); for (String p : logPatterns) { assertLog(p, ab); diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProjectIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProjectIT.java index 62682e22a9..9222df99b5 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProjectIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProjectIT.java @@ -20,8 +20,7 @@ * ===== */ -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.eclipse.jgit.api.Git; @@ -69,7 +68,7 @@ public void test() throws Exception { ProcessEntry psr = doTest(projectName, username, permissions, repoName, repoUrl, entryPoint, args, false); - byte[] ab = getLog(psr.getLogFileName()); + byte[] ab = getLog(psr.getInstanceId()); assertLog(".*" + greeting + ".*", ab); } @@ -103,7 +102,7 @@ public void testEntryPointFromYml() throws Exception { ProcessEntry psr = doTest(projectName, username, permissions, repoName, repoUrl, null, Collections.emptyMap(), false); - byte[] ab = getLog(psr.getLogFileName()); + byte[] ab = getLog(psr.getInstanceId()); assertLog(".*Hello, Concord.*", ab); } @@ -155,7 +154,7 @@ public void testWithCommitId() throws Exception { // --- ProcessEntry psr = doTest(projectName, username, permissions, repoName, repoUrl, entryPoint, args, commitId, null, false); - byte[] ab = getLog(psr.getLogFileName()); + byte[] ab = getLog(psr.getInstanceId()); assertLog(".*test-commit-1.*" + greeting + ".*", ab); } } @@ -206,7 +205,7 @@ public void testWithTag() throws Exception { // --- ProcessEntry psr = doTest(projectName, username, permissions, repoName, repoUrl, entryPoint, args, null, tag, false); - byte[] ab = getLog(psr.getLogFileName()); + byte[] ab = getLog(psr.getInstanceId()); assertLog(".*test-commit-1.*" + greeting + ".*", ab); } @@ -236,7 +235,7 @@ public void testInitImport() throws Exception { TriggersApi triggersApi = new TriggersApi(getApiClient()); while (true) { - List triggers = triggersApi.list("Default", projectName, repoName); + List triggers = triggersApi.listTriggers("Default", projectName, repoName); if (hasCondition("github", "branch", "foo", triggers) && hasCondition("github", "branch", "foo2", triggers) && hasCondition("oneops", "org", "myOrg", triggers)) { @@ -277,7 +276,7 @@ public void testRepositoryValidation() throws Exception { RepositoriesApi repositoriesApi = new RepositoriesApi(getApiClient()); RepositoryValidationResponse result = repositoriesApi.validateRepository("Default", projectName, repoName); - assertTrue(result.isOk()); + assertTrue(result.getOk()); } @Test @@ -311,7 +310,7 @@ public void testRepositoryValidationForEmptyFlow() throws Exception { RepositoriesApi repositoriesApi = new RepositoriesApi(getApiClient()); RepositoryValidationResponse resp = repositoriesApi.validateRepository("Default", projectName, repoName); - assertTrue(resp.isOk()); + assertTrue(resp.getOk()); }); } @@ -346,7 +345,7 @@ public void testRepositoryValidationForEmptyForm() throws Exception { RepositoriesApi repositoriesApi = new RepositoriesApi(getApiClient()); RepositoryValidationResponse resp = repositoriesApi.validateRepository("Default", projectName, repoName); - assertTrue(resp.isOk()); + assertTrue(resp.getOk()); }); } @@ -372,11 +371,11 @@ public void testDisabledRepository() throws Exception { String repoUrl = gitUrl; ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRepositories(Collections.singletonMap(repoName, new RepositoryEntry() - .setName(repoName).setUrl(repoUrl) - .setDisabled(true)))); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .repositories(Collections.singletonMap(repoName, new RepositoryEntry() + .name(repoName).url(repoUrl) + .disabled(true)))); // --- Map input = new HashMap<>(); @@ -393,53 +392,53 @@ public void testBulkAccessUpdate() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName)); // --- String teamName = "team_" + randomString(); TeamsApi teamsApi = new TeamsApi(getApiClient()); - CreateTeamResponse teamResp = teamsApi.createOrUpdate(orgName, new TeamEntry() - .setName(teamName)); + CreateTeamResponse teamResp = teamsApi.createOrUpdateTeam(orgName, new TeamEntry() + .name(teamName)); // --- Typical one-or-more teams bulk access update List teams = new ArrayList<>(1); teams.add(new ResourceAccessEntry() - .setOrgName(orgName) - .setTeamId(teamResp.getId()) - .setTeamName(teamName) - .setLevel(ResourceAccessEntry.LevelEnum.OWNER)); - GenericOperationResult addTeamsResult = projectsApi.updateAccessLevel_0(orgName, projectName, teams); + .orgName(orgName) + .teamId(teamResp.getId()) + .teamName(teamName) + .level(ResourceAccessEntry.LevelEnum.OWNER)); + GenericOperationResult addTeamsResult = projectsApi.updateProjectAccessLevelBulk(orgName, projectName, teams); assertNotNull(addTeamsResult); - assertTrue(addTeamsResult.isOk()); + assertTrue(addTeamsResult.getOk()); - List currentTeams = projectsApi.getAccessLevel(orgName, projectName); + List currentTeams = projectsApi.getProjectAccessLevel(orgName, projectName); assertNotNull(currentTeams); assertEquals(1, currentTeams.size()); // --- Empty teams list clears all - GenericOperationResult clearTeamsResult = projectsApi.updateAccessLevel_0(orgName, projectName, Collections.emptyList()); + GenericOperationResult clearTeamsResult = projectsApi.updateProjectAccessLevelBulk(orgName, projectName, Collections.emptyList()); assertNotNull(clearTeamsResult); - assertTrue(clearTeamsResult.isOk()); + assertTrue(clearTeamsResult.getOk()); - currentTeams = projectsApi.getAccessLevel(orgName, projectName); + currentTeams = projectsApi.getProjectAccessLevel(orgName, projectName); assertNotNull(currentTeams); assertEquals(0, currentTeams.size()); // --- Null list not allowed, throws error try { - projectsApi.updateAccessLevel_0(orgName, projectName, null); + projectsApi.updateProjectAccessLevelBulk(orgName, projectName, null); } catch (ApiException expected) { assertEquals(400, expected.getCode()); assertTrue(expected.getResponseBody().contains("List of teams is null")); @@ -449,12 +448,11 @@ public void testBulkAccessUpdate() throws Exception { // --- - teamsApi.delete(orgName, teamName); - projectsApi.delete(orgName, projectName); - orgApi.delete(orgName, "yes"); + teamsApi.deleteTeam(orgName, teamName); + projectsApi.deleteProject(orgName, projectName); + orgApi.deleteOrg(orgName, "yes"); } - private static boolean hasCondition(String src, String k, Object v, Collection entries) { for (TriggerEntry e : entries) { Map c = e.getConditions(); @@ -482,18 +480,18 @@ protected void createProjectAndRepo(String projectName, String tag) throws Exception { UsersApi usersApi = new UsersApi(getApiClient()); - CreateUserResponse cur = usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(username) - .setType(CreateUserRequest.TypeEnum.LOCAL)); - assertTrue(cur.isOk()); + CreateUserResponse cur = usersApi.createOrUpdateUser(new CreateUserRequest() + .username(username) + .type(CreateUserRequest.TypeEnum.LOCAL)); + assertTrue(cur.getOk()); UUID userId = cur.getId(); ApiKeysApi apiKeyResource = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse cakr = apiKeyResource.create(new CreateApiKeyRequest() - .setUserId(userId) - .setUserType(CreateApiKeyRequest.UserTypeEnum.LOCAL)); - assertTrue(cakr.isOk()); + CreateApiKeyResponse cakr = apiKeyResource.createUserApiKey(new CreateApiKeyRequest() + .userId(userId) + .userType(CreateApiKeyRequest.UserTypeEnum.LOCAL)); + assertTrue(cakr.getOk()); String apiKey = cakr.getKey(); @@ -502,15 +500,15 @@ protected void createProjectAndRepo(String projectName, setApiKey(apiKey); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - ProjectOperationResponse cpr = projectsApi.createOrUpdate("Default", new ProjectEntry() - .setName(projectName) - .setRepositories(Collections.singletonMap(repoName, + ProjectOperationResponse cpr = projectsApi.createOrUpdateProject("Default", new ProjectEntry() + .name(projectName) + .repositories(Collections.singletonMap(repoName, new RepositoryEntry() - .setName(repoName) - .setUrl(repoUrl) - .setBranch(tag != null ? tag : "master") - .setCommitId(commitId)))); - assertTrue(cpr.isOk()); + .name(repoName) + .url(repoUrl) + .branch(tag != null ? tag : "master") + .commitId(commitId)))); + assertTrue(cpr.getOk()); } protected ProcessEntry doTest(String projectName, @@ -550,13 +548,13 @@ protected ProcessEntry doTest(String projectName, input.put("request", args); input.put("sync", sync); StartProcessResponse spr = start(input); - assertTrue(spr.isOk()); + assertTrue(spr.getOk()); UUID instanceId = spr.getInstanceId(); // --- - ProcessEntry psr = waitForCompletion(processApi, instanceId); + ProcessEntry psr = waitForCompletion(getApiClient(), instanceId); assertEquals(ProcessEntry.StatusEnum.FINISHED, psr.getStatus()); // --- diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProjectInfoIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProjectInfoIT.java index 9e4d648150..e9590d986e 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProjectInfoIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProjectInfoIT.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import java.util.UUID; @@ -40,9 +40,9 @@ public void test() throws Exception { String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - ProjectOperationResponse cpr = projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + ProjectOperationResponse cpr = projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); // --- @@ -50,15 +50,14 @@ public void test() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(orgName, projectName, null, null, payload); assertNotNull(spr.getInstanceId()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Org ID:.*" + orgId + ".*", ab); assertLog(".*Project ID:.*" + cpr.getId() + ".*", ab); } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProjectTaskIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProjectTaskIT.java index c43c8f6ad0..71d5836409 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ProjectTaskIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ProjectTaskIT.java @@ -20,9 +20,8 @@ * ===== */ -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.ProcessEntry; +import com.walmartlabs.concord.client2.StartProcessResponse; import com.walmartlabs.concord.common.IOUtils; import com.walmartlabs.concord.it.common.MockGitSshServer; import org.eclipse.jgit.api.Git; @@ -88,7 +87,7 @@ public void testCreate() throws Exception { // --- - byte[] payload = archive(ProcessIT.class.getResource("projectTask").toURI()); + byte[] payload = archive(ProjectTaskIT.class.getResource("projectTask").toURI()); Map input = new HashMap<>(); input.put("archive", payload); @@ -105,12 +104,11 @@ public void testCreate() throws Exception { StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*CREATED.*", ab); assertLog(".*Done!.*", ab); diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/PublicFlowsIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/PublicFlowsIT.java index 8f56d55eb0..a09c3bf7cf 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/PublicFlowsIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/PublicFlowsIT.java @@ -20,9 +20,8 @@ * ===== */ -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.ProcessEntry; +import com.walmartlabs.concord.client2.StartProcessResponse; import org.junit.jupiter.api.Test; import java.util.HashMap; @@ -40,16 +39,15 @@ public class PublicFlowsIT extends AbstractServerIT { */ @Test public void testProfiles() throws Exception { - byte[] payload = archive(ProcessIT.class.getResource("publicFlowsInProfiles").toURI()); + byte[] payload = archive(PublicFlowsIT.class.getResource("publicFlowsInProfiles").toURI()); Map input = new HashMap<>(); input.put("archive", payload); StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pe = waitForCompletion(processApi, spr.getInstanceId()); - byte[] ab = getLog(pe.getLogFileName()); + ProcessEntry pe = waitForCompletion(getApiClient(), spr.getInstanceId()); + byte[] ab = getLog(pe.getInstanceId()); assertLog(".*Hello A.*", ab); assertLog(".*Hello B.*", ab); @@ -64,8 +62,8 @@ public void testProfiles() throws Exception { spr = start(input); - pe = waitForCompletion(processApi, spr.getInstanceId()); - ab = getLog(pe.getLogFileName()); + pe = waitForCompletion(getApiClient(), spr.getInstanceId()); + ab = getLog(pe.getInstanceId()); assertLog(".*Hello A.*", ab); assertNoLog(".*Hello B.*", ab); @@ -79,10 +77,10 @@ public void testProfiles() throws Exception { spr = start(input); - pe = waitForCompletion(processApi, spr.getInstanceId()); + pe = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FAILED, pe.getStatus()); - ab = getLog(pe.getLogFileName()); + ab = getLog(pe.getInstanceId()); assertLogAtLeast(".*not a public flow.*", 1, ab); } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/RawPayloadProjectIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/RawPayloadProjectIT.java index e0da616f5e..00f18865f5 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/RawPayloadProjectIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/RawPayloadProjectIT.java @@ -20,10 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.ProjectEntry; -import com.walmartlabs.concord.client.ProjectsApi; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import java.util.HashMap; @@ -40,12 +37,12 @@ public void testReject() throws Exception { String orgName = "Default"; String projectName = "project_" + System.currentTimeMillis(); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName)); // --- - byte[] payload = archive(ProcessIT.class.getResource("example").toURI()); + byte[] payload = archive(RawPayloadProjectIT.class.getResource("example").toURI()); try { Map input = new HashMap<>(); diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/RepositoryRefreshIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/RepositoryRefreshIT.java index d131a79128..c440f0fa5d 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/RepositoryRefreshIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/RepositoryRefreshIT.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -64,14 +64,13 @@ public void test() 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()); // --- TriggersApi triggerResource = new TriggersApi(getApiClient()); - List list = triggerResource.list(orgName, projectName, repoName); + List list = triggerResource.listTriggers(orgName, projectName, repoName); assertFalse(list.isEmpty()); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/RequirementsIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/RequirementsIT.java index f4b8832c9d..d49c64d610 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/RequirementsIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/RequirementsIT.java @@ -20,10 +20,11 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -46,15 +47,15 @@ public void testForkWithRequirements() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setVisibility(ProjectEntry.VisibilityEnum.PUBLIC) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .visibility(ProjectEntry.VisibilityEnum.PUBLIC) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); byte[] payload = archive(ProcessRbacIT.class.getResource("concordTaskForkWithRequirements").toURI()); Map input = new HashMap<>(); @@ -64,21 +65,21 @@ public void testForkWithRequirements() throws Exception { StartProcessResponse parentSpr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pe = waitForCompletion(processApi, parentSpr.getInstanceId()); + ProcessEntry pe = waitForCompletion(getApiClient(), parentSpr.getInstanceId()); assertNotNull(pe.getRequirements()); assertFalse(pe.getRequirements().isEmpty()); - ProcessEntry processEntry = processApi.get(parentSpr.getInstanceId()); + ProcessV2Api processApi = new ProcessV2Api(getApiClient()); + ProcessEntry processEntry = processApi.getProcess(parentSpr.getInstanceId(), Collections.singleton("childrenIds")); assertEquals(1, processEntry.getChildrenIds().size()); - ProcessEntry child = processApi.get(processEntry.getChildrenIds().get(0)); + ProcessEntry child = processApi.getProcess(processEntry.getChildrenIds().iterator().next(), Collections.emptySet()); assertNotNull(child); assertEquals(ProcessEntry.StatusEnum.FINISHED, child.getStatus()); // --- - byte[] ab = getLog(child.getLogFileName()); + byte[] ab = getLog(child.getInstanceId()); assertLog(".*Hello from a subprocess.*", ab); // --- diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ResourceIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ResourceIT.java index 2b8dd700f4..df157328d6 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ResourceIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ResourceIT.java @@ -20,9 +20,8 @@ * ===== */ -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.ProcessEntry; +import com.walmartlabs.concord.client2.StartProcessResponse; import org.intellij.lang.annotations.Language; import org.junit.jupiter.api.Test; @@ -89,17 +88,16 @@ private ProcessEntry test(String resource) throws Exception { URI dir = ResourceIT.class.getResource(resource).toURI(); byte[] payload = archive(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()); return pir; } private void basicAssert(ProcessEntry pir, @Language("RegExp") String pattern) throws Exception { - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(pattern, ab); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/RunAsIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/RunAsIT.java index 56b9db2f7d..22939f48b8 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/RunAsIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/RunAsIT.java @@ -20,8 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import java.util.*; @@ -60,11 +59,11 @@ public void testSwitchCurrentUser() throws Exception { // grant the team access to the project ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.updateAccessLevel(orgName, projectName, new ResourceAccessEntry() - .setTeamId(teamId) - .setOrgName(orgName) - .setTeamName(teamName) - .setLevel(ResourceAccessEntry.LevelEnum.READER)); + projectsApi.updateProjectAccessLevel(orgName, projectName, new ResourceAccessEntry() + .teamId(teamId) + .orgName(orgName) + .teamName(teamName) + .level(ResourceAccessEntry.LevelEnum.READER)); // Start a process @@ -76,9 +75,9 @@ public void testSwitchCurrentUser() throws Exception { StartProcessResponse p = start(input); ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pe = waitForStatus(processApi, p.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); + ProcessEntry pe = waitForStatus(getApiClient(), p.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); - byte[] ab = getLog(pe.getLogFileName()); + byte[] ab = getLog(pe.getInstanceId()); // assume Concord forces all user/domain names to lower case assertLog(".*username=" + userAName.toLowerCase() + ".*==.*username=" + userAName.toLowerCase() + ".*", ab); @@ -91,7 +90,7 @@ public void testSwitchCurrentUser() throws Exception { // try submit as a wrong user try { - formsApi.submit(p.getInstanceId(), formName, data); + formsApi.submitForm(p.getInstanceId(), formName, data); fail("exception expected"); } catch (ApiException e) { // ignore @@ -101,13 +100,13 @@ public void testSwitchCurrentUser() throws Exception { resetApiKey(); - FormSubmitResponse fsr = formsApi.submit(p.getInstanceId(), formName, data); - assertTrue(fsr.isOk()); + FormSubmitResponse fsr = formsApi.submitForm(p.getInstanceId(), formName, data); + assertTrue(fsr.getOk()); - pe = waitForCompletion(processApi, p.getInstanceId()); + pe = waitForCompletion(getApiClient(), p.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FINISHED, pe.getStatus()); - ab = getLog(pe.getLogFileName()); + ab = getLog(pe.getInstanceId()); assertLog(".*Now we are running as admin. Initiator: " + userAName.toLowerCase() + ".*", ab); } @@ -143,11 +142,11 @@ public void testWithMultipleUsers() throws Exception { // grant the team access to the project ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.updateAccessLevel(orgName, projectName, new ResourceAccessEntry() - .setTeamId(teamId) - .setOrgName(orgName) - .setTeamName(teamName) - .setLevel(ResourceAccessEntry.LevelEnum.READER)); + projectsApi.updateProjectAccessLevel(orgName, projectName, new ResourceAccessEntry() + .teamId(teamId) + .orgName(orgName) + .teamName(teamName) + .level(ResourceAccessEntry.LevelEnum.READER)); // Start a process @@ -160,9 +159,9 @@ public void testWithMultipleUsers() throws Exception { StartProcessResponse p = start(input); ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pe = waitForStatus(processApi, p.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); + ProcessEntry pe = waitForStatus(getApiClient(), p.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); - byte[] ab = getLog(pe.getLogFileName()); + byte[] ab = getLog(pe.getInstanceId()); // assume Concord forces all user/domain names to lower case assertLog(".*username=" + userAName.toLowerCase() + ".*==.*username=" + userAName.toLowerCase() + ".*", ab); @@ -175,7 +174,7 @@ public void testWithMultipleUsers() throws Exception { // try submit as a wrong user try { - formsApi.submit(p.getInstanceId(), formName, data); + formsApi.submitForm(p.getInstanceId(), formName, data); fail("exception expected"); } catch (ApiException e) { // ignore @@ -184,16 +183,16 @@ public void testWithMultipleUsers() throws Exception { // switch to the user B and submit the form setApiKey(apiKeyB.getKey()); - FormSubmitResponse fsr = formsApi.submit(p.getInstanceId(), formName, data); - assertTrue(fsr.isOk()); + FormSubmitResponse fsr = formsApi.submitForm(p.getInstanceId(), formName, data); + assertTrue(fsr.getOk()); - pe = waitForCompletion(processApi, p.getInstanceId()); + pe = waitForCompletion(getApiClient(), p.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FINISHED, pe.getStatus()); // starting from 1.39.0 the log endpoint performs additional RBAC checks // in this case user B doesn't have permissions to access the log try { - getLog(pe.getLogFileName()); + getLog(pe.getInstanceId()); fail("should fail"); } catch (ApiException e) { assertEquals(403, e.getCode()); @@ -202,7 +201,7 @@ public void testWithMultipleUsers() throws Exception { // switch to the user A and fetch the log again setApiKey(apiKeyA.getKey()); - ab = getLog(pe.getLogFileName()); + ab = getLog(pe.getInstanceId()); assertLog(".*Now we are running as " + userBName.toLowerCase() + ".*", ab); } @@ -232,10 +231,9 @@ public void testPayload() throws Exception { input.put("arguments.sudoUser", userBName.toLowerCase()); StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pe = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); + ProcessEntry pe = waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); - byte[] ab = getLog(pe.getLogFileName()); + byte[] ab = getLog(pe.getInstanceId()); // assume Concord forces all user/domain names to lower case assertLog(".*AAA: " + userAName.toLowerCase() + ".*", ab); @@ -247,17 +245,17 @@ public void testPayload() throws Exception { ProcessFormsApi formsApi = new ProcessFormsApi(getApiClient()); Map data = Collections.singletonMap("msg", "Hello!"); - formsApi.submit(pe.getInstanceId(), formName, data); + formsApi.submitForm(pe.getInstanceId(), formName, data); // wait for the process to finish - pe = waitForCompletion(processApi, spr.getInstanceId()); + pe = waitForCompletion(getApiClient(), spr.getInstanceId()); // check the logs resetApiKey(); - ab = getLog(pe.getLogFileName()); + ab = getLog(pe.getInstanceId()); assertLog(".*BBB: Hello!.*", ab); // assume Concord forces all user/domain names to lower case assertLog(".*CCC: " + userAName.toLowerCase() + ".*", ab); @@ -265,18 +263,18 @@ public void testPayload() throws Exception { private void createOrg(String orgName) throws Exception { OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - CreateOrganizationResponse r = orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); - assertTrue(r.isOk()); + CreateOrganizationResponse r = orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); + assertTrue(r.getOk()); } private UUID createTeam(String orgName, String teamName, String... username) throws Exception { TeamsApi teamsApi = new TeamsApi(getApiClient()); - CreateTeamResponse ctr = teamsApi.createOrUpdate(orgName, new TeamEntry().setName(teamName)); + CreateTeamResponse ctr = teamsApi.createOrUpdateTeam(orgName, new TeamEntry().name(teamName)); - teamsApi.addUsers(orgName, teamName, false, Arrays.stream(username) + teamsApi.addUsersToTeam(orgName, teamName, false, Arrays.stream(username) .map(u -> new TeamUserEntry() - .setUsername(u) - .setRole(TeamUserEntry.RoleEnum.MEMBER)) + .username(u) + .role(TeamUserEntry.RoleEnum.MEMBER)) .collect(Collectors.toList())); return ctr.getId(); @@ -285,31 +283,32 @@ private UUID createTeam(String orgName, String teamName, String... username) thr private CreateApiKeyResponse addUser(String userAName) throws ApiException { UsersApi usersApi = new UsersApi(getApiClient()); - usersApi.createOrUpdate(new CreateUserRequest().setUsername(userAName).setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest().username(userAName) + .type(CreateUserRequest.TypeEnum.LOCAL)); ApiKeysApi apiKeyResource = new ApiKeysApi(getApiClient()); - return apiKeyResource.create(new CreateApiKeyRequest().setUsername(userAName)); + return apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(userAName)); } private void createProject(String orgName, String projectName) throws ApiException { ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - ProjectOperationResponse por = projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setVisibility(ProjectEntry.VisibilityEnum.PRIVATE) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); - assertTrue(por.isOk()); + ProjectOperationResponse por = projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .visibility(ProjectEntry.VisibilityEnum.PRIVATE) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + assertTrue(por.getOk()); } private String findForm(UUID instanceId) throws Exception { ProcessFormsApi formsApi = new ProcessFormsApi(getApiClient()); - List forms = formsApi.list(instanceId); + List forms = formsApi.listProcessForms(instanceId); assertEquals(1, forms.size()); // --- FormListEntry f0 = forms.get(0); - assertFalse(f0.isCustom()); + assertFalse(f0.getCustom()); return f0.getName(); } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/SecretIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/SecretIT.java index 70620c5a14..e9794745e3 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/SecretIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/SecretIT.java @@ -20,8 +20,8 @@ * ===== */ -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; +import com.walmartlabs.concord.client2.CreateSecretRequest; import com.walmartlabs.concord.common.secret.KeyPair; import com.walmartlabs.concord.common.secret.UsernamePassword; import org.junit.jupiter.api.Assertions; @@ -40,15 +40,14 @@ public void testOwnerChange() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry().name(projectName)); // --- @@ -60,14 +59,14 @@ public void testOwnerChange() throws Exception { String userName = "myUser_" + randomString(); UsersApi usersApi = new UsersApi(getApiClient()); - CreateUserResponse cur = usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userName) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + CreateUserResponse cur = usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userName) + .type(CreateUserRequest.TypeEnum.LOCAL)); SecretsApi secretsApi = new SecretsApi(getApiClient()); SecretUpdateRequest req = new SecretUpdateRequest(); - req.setOwner(new EntityOwner().setId(cur.getId())); - secretsApi.update(orgName, secretName, req); + req.setOwner(new EntityOwner().id(cur.getId())); + secretsApi.updateSecretV1(orgName, secretName, req); PublicKeyResponse pkr = secretsApi.getPublicKey(orgName, secretName); @@ -77,8 +76,8 @@ public void testOwnerChange() throws Exception { // --- secretsApi.delete(orgName, secretName); - projectsApi.delete(orgName, projectName); - orgApi.delete(orgName, "yes"); + projectsApi.deleteProject(orgName, projectName); + orgApi.deleteOrg(orgName, "yes"); } @Test @@ -86,15 +85,15 @@ public void testBulkAccessUpdate() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName)); // --- @@ -108,35 +107,35 @@ public void testBulkAccessUpdate() throws Exception { // --- String teamName = "team_" + randomString(); - CreateTeamResponse teamResp = teamsApi.createOrUpdate(orgName, new TeamEntry() - .setName(teamName)); + CreateTeamResponse teamResp = teamsApi.createOrUpdateTeam(orgName, new TeamEntry() + .name(teamName)); // --- Typical one-or-more teams bulk access update List teams = new ArrayList<>(1); teams.add(new ResourceAccessEntry() - .setOrgName(orgName) - .setTeamId(teamResp.getId()) - .setTeamName(teamName) - .setLevel(ResourceAccessEntry.LevelEnum.OWNER)); - GenericOperationResult addTeamsResult = secretsApi.updateAccessLevel_0(orgName, secretName, teams); + .orgName(orgName) + .teamId(teamResp.getId()) + .teamName(teamName) + .level(ResourceAccessEntry.LevelEnum.OWNER)); + GenericOperationResult addTeamsResult = secretsApi.updateSecretAccessLevelBulk(orgName, secretName, teams); assertNotNull(addTeamsResult); - assertTrue(addTeamsResult.isOk()); + assertTrue(addTeamsResult.getOk()); - List currentTeams = secretsApi.getAccessLevel(orgName, secretName); + List currentTeams = secretsApi.getSecretAccessLevel(orgName, secretName); assertNotNull(currentTeams); assertEquals(1, currentTeams.size()); // --- Empty teams list clears all - GenericOperationResult clearTeamsResult = secretsApi.updateAccessLevel_0(orgName, secretName, Collections.emptyList()); + GenericOperationResult clearTeamsResult = secretsApi.updateSecretAccessLevelBulk(orgName, secretName, Collections.emptyList()); assertNotNull(clearTeamsResult); - assertTrue(clearTeamsResult.isOk()); + assertTrue(clearTeamsResult.getOk()); // --- Null list not allowed, throws error try { - secretsApi.updateAccessLevel_0(orgName, secretName, null); + secretsApi.updateSecretAccessLevelBulk(orgName, secretName, null); } catch (ApiException expected) { assertEquals(400, expected.getCode()); assertTrue(expected.getResponseBody().contains("List of teams is null")); @@ -146,10 +145,10 @@ public void testBulkAccessUpdate() throws Exception { // --- - teamsApi.delete(orgName, teamName); + teamsApi.deleteTeam(orgName, teamName); secretsApi.delete(orgName, secretName); - projectsApi.delete(orgName, projectName); - orgApi.delete(orgName, "yes"); + projectsApi.deleteProject(orgName, projectName); + orgApi.deleteOrg(orgName, "yes"); } @Test @@ -157,15 +156,15 @@ public void testSecretUpdate() throws Exception { String orgNameInit = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgNameInit)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgNameInit)); // --- String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgNameInit, new ProjectEntry() - .setName(projectName)); + projectsApi.createOrUpdateProject(orgNameInit, new ProjectEntry() + .name(projectName)); // --- @@ -177,24 +176,24 @@ public void testSecretUpdate() throws Exception { String userName = "myUser_" + randomString(); UsersApi usersApi = new UsersApi(getApiClient()); - CreateUserResponse cur = usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userName) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + CreateUserResponse cur = usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userName) + .type(CreateUserRequest.TypeEnum.LOCAL)); // --- String newOrgName = "org_" + randomString(); - UUID newOrgId = orgApi.createOrUpdate(new OrganizationEntry().setName(newOrgName)).getId(); + UUID newOrgId = orgApi.createOrUpdateOrg(new OrganizationEntry().name(newOrgName)).getId(); String newSecretName = "name_" + randomString(); - UpdateSecretRequest request = UpdateSecretRequest.builder() + com.walmartlabs.concord.client2.UpdateSecretRequest request = com.walmartlabs.concord.client2.UpdateSecretRequest.builder() .newOrgId(newOrgId) .newOwnerId(cur.getId()) - .newVisibility(SecretEntry.VisibilityEnum.PRIVATE) + .newVisibility(SecretEntryV2.VisibilityEnum.PRIVATE) .newName(newSecretName) .build(); - SecretClient secretClient = new SecretClient(getApiClient()); + com.walmartlabs.concord.client2.SecretClient secretClient = new com.walmartlabs.concord.client2.SecretClient(getApiClient()); secretClient.updateSecret(orgNameInit, secretName, request); SecretsApi secretsApi = new SecretsApi(getApiClient()); @@ -204,17 +203,17 @@ public void testSecretUpdate() throws Exception { assertNotNull(pkr); assertNotNull(pkr.getPublicKey()); - SecretEntry secret = secretsApi.get(newOrgName, newSecretName); + SecretEntryV2 secret = new SecretsV2Api(getApiClient()).getSecret(newOrgName, newSecretName); assertNotNull(secret); assertEquals(cur.getId(), secret.getOwner().getId()); assertNull(secret.getProjectName()); - assertEquals(SecretEntry.VisibilityEnum.PRIVATE, secret.getVisibility()); + assertEquals(SecretEntryV2.VisibilityEnum.PRIVATE, secret.getVisibility()); // --- - orgApi.delete(orgNameInit, "yes"); - orgApi.delete(newOrgName, "yes"); + orgApi.deleteOrg(orgNameInit, "yes"); + orgApi.deleteOrg(newOrgName, "yes"); } @Test @@ -222,7 +221,7 @@ public void testSecretPasswordUpdate() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- @@ -234,17 +233,17 @@ public void testSecretPasswordUpdate() throws Exception { // --- String newPassword = "q2q2Q2Q2"; - UpdateSecretRequest request = UpdateSecretRequest.builder() + com.walmartlabs.concord.client2.UpdateSecretRequest request = com.walmartlabs.concord.client2.UpdateSecretRequest.builder() .currentPassword(initPassword) .newPassword(newPassword) .build(); // --- - SecretClient secretsApi = new SecretClient(getApiClient()); + com.walmartlabs.concord.client2.SecretClient secretsApi = new com.walmartlabs.concord.client2.SecretClient(getApiClient()); secretsApi.updateSecret(orgName, secretName, request); - KeyPair kp = secretsApi.getData(orgName, secretName, newPassword, SecretEntry.TypeEnum.KEY_PAIR); + KeyPair kp = secretsApi.getData(orgName, secretName, newPassword, SecretEntryV2.TypeEnum.KEY_PAIR); assertNotNull(kp); } @@ -254,7 +253,7 @@ public void testSecretDataUpdate() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- @@ -263,14 +262,14 @@ public void testSecretDataUpdate() throws Exception { // --- - UpdateSecretRequest request = UpdateSecretRequest.builder() + com.walmartlabs.concord.client2.UpdateSecretRequest request = com.walmartlabs.concord.client2.UpdateSecretRequest.builder() .usernamePassword(CreateSecretRequest.UsernamePassword.of("test", "q1")) .build(); - SecretClient secretClient = new SecretClient(getApiClient()); + com.walmartlabs.concord.client2.SecretClient secretClient = new com.walmartlabs.concord.client2.SecretClient(getApiClient()); secretClient.updateSecret(orgName, secretName, request); - UsernamePassword up = secretClient.getData(orgName, secretName, null, SecretEntry.TypeEnum.USERNAME_PASSWORD); + UsernamePassword up = secretClient.getData(orgName, secretName, null, SecretEntryV2.TypeEnum.USERNAME_PASSWORD); assertNotNull(up); assertEquals("test", up.getUsername()); @@ -283,8 +282,8 @@ public void testUpdateNonUniqueName() throws Exception { String orgName2 = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName1)); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName2)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName1)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName2)); // --- @@ -292,11 +291,11 @@ public void testUpdateNonUniqueName() throws Exception { addUsernamePassword(orgName1, secretName, false, null, "test", "q1"); addUsernamePassword(orgName2, secretName, false, null, "test", "q1"); - UpdateSecretRequest request = UpdateSecretRequest.builder() + com.walmartlabs.concord.client2.UpdateSecretRequest request = com.walmartlabs.concord.client2.UpdateSecretRequest.builder() .newOrgName(orgName2) .build(); - SecretClient secretClient = new SecretClient(getApiClient()); + com.walmartlabs.concord.client2.SecretClient secretClient = new com.walmartlabs.concord.client2.SecretClient(getApiClient()); ApiException exception = Assertions.assertThrows(ApiException.class, () -> secretClient.updateSecret(orgName1, secretName, request)); assertThat(exception.getMessage(), containsString("Secret already exists")); @@ -307,15 +306,15 @@ public void testCreateSecretWithMultipleProjectIds() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String projectName1 = "project_" + randomString(); String projectName2 = "proejct_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - ProjectOperationResponse response1 = projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName1)); - ProjectOperationResponse response2 = projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName2)); + ProjectOperationResponse response1 = projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName1)); + ProjectOperationResponse response2 = projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName2)); // --- @@ -324,15 +323,15 @@ public void testCreateSecretWithMultipleProjectIds() throws Exception { assertEquals(secretResponse.getResult().toString(), "CREATED"); SecretsApi secretsApi = new SecretsApi(getApiClient()); SecretsV2Api secretsV2Api = new SecretsV2Api(getApiClient()); - SecretEntryV2 secretEntry = secretsV2Api.get(orgName, secretName); + SecretEntryV2 secretEntry = secretsV2Api.getSecret(orgName, secretName); assertTrue(secretEntry.getProjects().stream().map(ProjectEntry::getName).anyMatch(projectName -> projectName.equals(projectName1))); assertTrue(secretEntry.getProjects().stream().map(ProjectEntry::getName).anyMatch(projectName -> projectName.equals(projectName2))); - projectsApi.delete(orgName, projectName1); - projectsApi.delete(orgName, projectName2); + projectsApi.deleteProject(orgName, projectName1); + projectsApi.deleteProject(orgName, projectName2); secretsApi.delete(orgName, secretName); - orgApi.delete(orgName, "yes"); + orgApi.deleteOrg(orgName, "yes"); } @Test @@ -340,15 +339,15 @@ public void testCreateSecretWithMultipleProjectNames() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String projectName1 = "project_" + randomString(); String projectName2 = "proejct_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - ProjectOperationResponse response1 = projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName1)); - ProjectOperationResponse response2 = projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName2)); + ProjectOperationResponse response1 = projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName1)); + ProjectOperationResponse response2 = projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName2)); // --- @@ -358,14 +357,14 @@ public void testCreateSecretWithMultipleProjectNames() throws Exception { SecretsApi secretsApi = new SecretsApi(getApiClient()); SecretsV2Api secretsV2Api = new SecretsV2Api(getApiClient()); - SecretEntryV2 secretEntry = secretsV2Api.get(orgName, secretName); + SecretEntryV2 secretEntry = secretsV2Api.getSecret(orgName, secretName); assertTrue(secretEntry.getProjects().stream().map(ProjectEntry::getName).anyMatch(projectName -> projectName.equals(projectName1))); assertTrue(secretEntry.getProjects().stream().map(ProjectEntry::getName).anyMatch(projectName -> projectName.equals(projectName2))); - projectsApi.delete(orgName, projectName1); - projectsApi.delete(orgName, projectName2); + projectsApi.deleteProject(orgName, projectName1); + projectsApi.deleteProject(orgName, projectName2); secretsApi.delete(orgName, secretName); - orgApi.delete(orgName, "yes"); + orgApi.deleteOrg(orgName, "yes"); } @@ -374,7 +373,7 @@ public void testUpdateSecretWithMultipleProjectNames() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- @@ -385,25 +384,27 @@ public void testUpdateSecretWithMultipleProjectNames() throws Exception { String projectName1 = "project_" + randomString(); String projectName2 = "proejct_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - ProjectOperationResponse response1 = projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName1)); - ProjectOperationResponse response2 = projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName2)); - - SecretClient secretClient = new SecretClient(getApiClient()); - UpdateSecretRequestV2 request = UpdateSecretRequestV2.builder().newProjectIds(new HashSet(Arrays.asList(response1.getId(), response2.getId()))).build(); + ProjectOperationResponse response1 = projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName1)); + ProjectOperationResponse response2 = projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName2)); + + com.walmartlabs.concord.client2.SecretClient secretClient = new com.walmartlabs.concord.client2.SecretClient(getApiClient()); + com.walmartlabs.concord.client2.UpdateSecretRequest request = UpdateSecretRequest.builder() + .newProjectIds(new HashSet<>(Arrays.asList(response1.getId(), response2.getId()))) + .build(); secretClient.updateSecret(orgName, secretName, request); SecretsApi secretsApi = new SecretsApi(getApiClient()); SecretsV2Api secretsV2Api = new SecretsV2Api(getApiClient()); - SecretEntryV2 secretEntry = secretsV2Api.get(orgName, secretName); + SecretEntryV2 secretEntry = secretsV2Api.getSecret(orgName, secretName); assertTrue(secretEntry.getProjects().stream().map(ProjectEntry::getName).anyMatch(projectName -> projectName.equals(projectName1))); assertTrue(secretEntry.getProjects().stream().map(ProjectEntry::getName).anyMatch(projectName -> projectName.equals(projectName2))); - projectsApi.delete(orgName, projectName1); - projectsApi.delete(orgName, projectName2); + projectsApi.deleteProject(orgName, projectName1); + projectsApi.deleteProject(orgName, projectName2); secretsApi.delete(orgName, secretName); - orgApi.delete(orgName, "yes"); + orgApi.deleteOrg(orgName, "yes"); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/SecretProjectsIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/SecretProjectsIT.java index 8eaf4689ef..e5352e451d 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/SecretProjectsIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/SecretProjectsIT.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import java.util.*; @@ -36,18 +36,18 @@ public void test() throws Exception { OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); String orgName = "org_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); String projectName1 = "project_" + randomString(); String projectName2 = "project_" + randomString(); String projectName3 = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName1).setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName2).setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName3).setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName1).rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName2).rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName3).rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); String secretName = "secret_" + randomString(); String storePassword = "St0rePassword1"; @@ -63,18 +63,18 @@ public void test() throws Exception { ApiKeysApi apiKeyResource = new ApiKeysApi(getApiClient()); String userName = "userA_" + randomString(); - CreateUserResponse userResponse = usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userName) - .setType(CreateUserRequest.TypeEnum.LOCAL)); - CreateApiKeyResponse apiKeyResponse = apiKeyResource.create(new CreateApiKeyRequest() - .setUsername(userName) - .setUserType(CreateApiKeyRequest.UserTypeEnum.LOCAL)); + CreateUserResponse userResponse = usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userName) + .type(CreateUserRequest.TypeEnum.LOCAL)); + CreateApiKeyResponse apiKeyResponse = apiKeyResource.createUserApiKey(new CreateApiKeyRequest() + .username(userName) + .userType(CreateApiKeyRequest.UserTypeEnum.LOCAL)); String teamName = "team_" + randomString(); - teamsApi.createOrUpdate(orgName, new TeamEntry().setName(teamName)); - teamsApi.addUsers(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() - .setUsername(userName) - .setRole(TeamUserEntry.RoleEnum.MEMBER))); + teamsApi.createOrUpdateTeam(orgName, new TeamEntry().name(teamName)); + teamsApi.addUsersToTeam(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() + .username(userName) + .role(TeamUserEntry.RoleEnum.MEMBER))); resetApiKey(); setApiKey(apiKeyResponse.getKey()); @@ -89,45 +89,42 @@ public void test() throws Exception { StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertNotNull(pir.getLogFileName()); - byte[] bytes = getLog(pir.getLogFileName()); + byte[] bytes = getLog(pir.getInstanceId()); assertLog(".*Project-scoped secrets can only be accessed within the project they belong to.*", 2, bytes); input.put("project", projectName2); spr = start(input); - processApi = new ProcessApi(getApiClient()); - pir = waitForCompletion(processApi, spr.getInstanceId()); + pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertNotNull(pir.getLogFileName()); - bytes = getLog(pir.getLogFileName()); + bytes = getLog(pir.getInstanceId()); assertLog(".*C0nC0rD.*", bytes); input.put("project", projectName1); spr = start(input); - processApi = new ProcessApi(getApiClient()); - pir = waitForCompletion(processApi, spr.getInstanceId()); + pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertNotNull(pir.getLogFileName()); - bytes = getLog(pir.getLogFileName()); + bytes = getLog(pir.getInstanceId()); assertLog(".*C0nC0rD.*", bytes); resetApiKey(); setApiKey(DEFAULT_API_KEY); - projectsApi.delete(orgName, projectName1); - projectsApi.delete(orgName, projectName2); - projectsApi.delete(orgName, projectName3); + projectsApi.deleteProject(orgName, projectName1); + projectsApi.deleteProject(orgName, projectName2); + projectsApi.deleteProject(orgName, projectName3); SecretsApi secretsApi = new SecretsApi(getApiClient()); secretsApi.delete(orgName, secretName); - usersApi.delete(userResponse.getId()); - teamsApi.delete(orgName, teamName); - orgApi.delete(orgName, "yes"); + usersApi.deleteUser(userResponse.getId()); + teamsApi.deleteTeam(orgName, teamName); + orgApi.deleteOrg(orgName, "yes"); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/SecretsTaskIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/SecretsTaskIT.java index 1c22d53006..b400c92f23 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/SecretsTaskIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/SecretsTaskIT.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import java.util.HashMap; @@ -42,10 +42,10 @@ public void test() throws Exception { String projectName1 = "project_"+ randomString(); String projectName2 = "project_" + randomString(); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName2).setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName1).setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName2).rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName1).rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); String secretName = "secret_" + randomString(); @@ -62,11 +62,10 @@ public void test() throws Exception { StartProcessResponse spr = start(input); - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertNotNull(pir.getLogFileName()); - byte[] bytes = getLog(pir.getLogFileName()); + byte[] bytes = getLog(pir.getInstanceId()); // System.out.println(new String(bytes)); assertLog(".* Delete secret2.*", bytes); } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/SerializationIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/SerializationIT.java index 409cb4bd40..0313ac7f8b 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/SerializationIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/SerializationIT.java @@ -21,7 +21,7 @@ */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import java.util.Collections; @@ -43,36 +43,35 @@ public void test() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); assertNotNull(spr.getInstanceId()); // --- - ProcessEntry pe = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); + ProcessEntry pe = waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); assertEquals(ProcessEntry.StatusEnum.SUSPENDED, pe.getStatus()); // --- ProcessFormsApi formsApi = new ProcessFormsApi(getApiClient()); - List forms = formsApi.list(spr.getInstanceId()); + List forms = formsApi.listProcessForms(spr.getInstanceId()); assertEquals(1, forms.size()); FormListEntry f = forms.get(0); - formsApi.submit(spr.getInstanceId(), f.getName(), + formsApi.submitForm(spr.getInstanceId(), f.getName(), Collections.singletonMap("y", "hello")); // --- - pe = waitForCompletion(processApi, spr.getInstanceId()); - byte[] ab = getLog(pe.getLogFileName()); + pe = waitForCompletion(getApiClient(), spr.getInstanceId()); + byte[] ab = getLog(pe.getInstanceId()); assertLog(".*hello.*", ab); } @Test public void testNonSerializable() throws Exception { - byte[] payload = archive(DependencyManagerIT.class.getResource("nonSerializableTest").toURI()); + byte[] payload = archive(SerializationIT.class.getResource("nonSerializableTest").toURI()); Map input = new HashMap<>(); input.put("archive", payload); @@ -83,9 +82,8 @@ public void testNonSerializable() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.FAILED); - byte[] ab = getLog(pir.getLogFileName()); + ProcessEntry pir = waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.FAILED); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Not serializable value: test.*", ab); } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/SmtpIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/SmtpIT.java index e7224479a1..d26be19164 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/SmtpIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/SmtpIT.java @@ -22,7 +22,7 @@ import com.icegreen.greenmail.junit5.GreenMailExtension; import com.icegreen.greenmail.util.ServerSetup; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.sdk.Constants; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -63,14 +63,13 @@ public void testSimple() throws Exception { cfg.put(Constants.Request.ARGUMENTS_KEY, args); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - 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)); // -- - ProcessApi processApi = new ProcessApi(getApiClient()); Map input = new HashMap<>(); input.put("org", orgName); input.put("project", projectName); @@ -79,7 +78,7 @@ public void testSimple() throws Exception { // --- - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus()); // --- diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/SuspendIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/SuspendIT.java index 287a92c324..1fbc82491a 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/SuspendIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/SuspendIT.java @@ -20,17 +20,14 @@ * ===== */ -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.ProcessApi; +import com.walmartlabs.concord.client2.ProcessEntry; +import com.walmartlabs.concord.client2.StartProcessResponse; import com.walmartlabs.concord.sdk.Constants; import org.junit.jupiter.api.Test; import java.net.URI; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; import java.util.regex.Pattern; import static com.walmartlabs.concord.it.common.ITUtils.archive; @@ -51,9 +48,9 @@ public void test() throws Exception { // --- - ProcessEntry pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); + ProcessEntry pir = waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*aaaa.*", ab); // --- @@ -64,11 +61,11 @@ public void test() throws Exception { processApi.resume(spr.getInstanceId(), "ev1", null, req); - pir = waitForCompletion(processApi, spr.getInstanceId()); + pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus()); - waitForLog(pir.getLogFileName(), ".*bbbb.*"); - waitForLog(pir.getLogFileName(), ".*" + Pattern.quote(testValue) + ".*"); + waitForLog(pir.getInstanceId(), ".*bbbb.*"); + waitForLog(pir.getInstanceId(), ".*" + Pattern.quote(testValue) + ".*"); } @Test @@ -77,21 +74,20 @@ public void testSuspendForCompletion() throws Exception { // --- byte[] payload = archive(SuspendIT.class.getResource("suspendForCompletion").toURI()); - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse parentSpr = start(payload); // --- - ProcessEntry p = waitForStatus(processApi, parentSpr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); - List childrenIds = p.getChildrenIds(); + ProcessEntry p = waitForStatus(getApiClient(), parentSpr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); + Set childrenIds = p.getChildrenIds(); assertEquals(2, childrenIds.size()); for(UUID childId : childrenIds) { - waitForCompletion(processApi, childId); + waitForCompletion(getApiClient(), childId); } - ProcessEntry pir = waitForCompletion(processApi, parentSpr.getInstanceId()); - byte[] ab = getLog(pir.getLogFileName()); + ProcessEntry pir = waitForCompletion(getApiClient(), parentSpr.getInstanceId()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*process is resumed.*", ab); } @@ -102,21 +98,20 @@ public void testSuspendForForkedProcess() throws Exception { // --- byte[] payload = archive(SuspendIT.class.getResource("suspendForForkedProcesses").toURI()); - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse parentSpr = start(payload); // --- - ProcessEntry p = waitForStatus(processApi, parentSpr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); - List childrenIds = p.getChildrenIds(); + ProcessEntry p = waitForStatus(getApiClient(), parentSpr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); + Set childrenIds = p.getChildrenIds(); assertEquals(3, childrenIds.size()); for(UUID childId : childrenIds) { - waitForCompletion(processApi, childId); + waitForCompletion(getApiClient(), childId); } - ProcessEntry pir = waitForCompletion(processApi, parentSpr.getInstanceId()); - byte[] ab = getLog(pir.getLogFileName()); + ProcessEntry pir = waitForCompletion(getApiClient(), parentSpr.getInstanceId()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*task completed.*", ab); } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/TaskRetryIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/TaskRetryIT.java index 526f4e9972..6c43bd9665 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/TaskRetryIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/TaskRetryIT.java @@ -20,9 +20,9 @@ * ===== */ -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.ProcessApi; +import com.walmartlabs.concord.client2.ProcessEntry; +import com.walmartlabs.concord.client2.StartProcessResponse; import org.junit.jupiter.api.Test; import java.net.URI; @@ -38,32 +38,30 @@ public class TaskRetryIT extends AbstractServerIT { @Test public void testAnsibleRetry() throws Exception { - URI uri = ProcessIT.class.getResource("taskRetry").toURI(); + URI uri = TaskRetryIT.class.getResource("taskRetry").toURI(); byte[] payload = archive(uri, ITConstants.DEPENDENCIES_DIR); // start the process - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); // wait for completion - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus()); // check logs - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*msg\": \"Hi retry!\".*", ab); } @Test public void testAnsibleRetryWithExpression() throws Exception { - URI uri = ProcessIT.class.getResource("taskRetryWithExpression").toURI(); + URI uri = TaskRetryIT.class.getResource("taskRetryWithExpression").toURI(); byte[] payload = archive(uri, ITConstants.DEPENDENCIES_DIR); // start the process - ProcessApi processApi = new ProcessApi(getApiClient()); Map input = new HashMap<>(); input.put("archive", payload); input.put("arguments.retryCount", "1"); @@ -72,11 +70,11 @@ public void testAnsibleRetryWithExpression() throws Exception { // wait for completion - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus()); // check logs - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*msg\": \"Hi retry!\".*", ab); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/TeamRbacIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/TeamRbacIT.java index 3075d44d38..4faaddf982 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/TeamRbacIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/TeamRbacIT.java @@ -20,8 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import java.util.Collections; @@ -36,20 +35,20 @@ public void testOrgs() throws Exception { OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); String orgAName = "orgA_" + randomString(); - CreateOrganizationResponse orgA = orgApi.createOrUpdate(new OrganizationEntry().setName(orgAName)); + CreateOrganizationResponse orgA = orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgAName)); String orgBName = "orgB_" + randomString(); - CreateOrganizationResponse orgB = orgApi.createOrUpdate(new OrganizationEntry().setName(orgBName)); + CreateOrganizationResponse orgB = orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgBName)); // --- TeamsApi teamsApi = new TeamsApi(getApiClient()); String teamAName = "teamA_" + randomString(); - teamsApi.createOrUpdate(orgAName, new TeamEntry().setName(teamAName)); + teamsApi.createOrUpdateTeam(orgAName, new TeamEntry().name(teamAName)); String teamBName = "teamB_" + randomString(); - teamsApi.createOrUpdate(orgBName, new TeamEntry().setName(teamBName)); + teamsApi.createOrUpdateTeam(orgBName, new TeamEntry().name(teamBName)); // --- @@ -57,49 +56,50 @@ public void testOrgs() throws Exception { ApiKeysApi apiKeyResource = new ApiKeysApi(getApiClient()); String userAName = "userA_" + randomString(); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userAName) - .setType(CreateUserRequest.TypeEnum.LOCAL)); - CreateApiKeyResponse apiKeyA = apiKeyResource.create(new CreateApiKeyRequest() - .setUsername(userAName) - .setUserType(CreateApiKeyRequest.UserTypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userAName) + .type(CreateUserRequest.TypeEnum.LOCAL)); + CreateApiKeyResponse apiKeyA = apiKeyResource.createUserApiKey(new CreateApiKeyRequest() + .username(userAName) + .userType(CreateApiKeyRequest.UserTypeEnum.LOCAL)); - teamsApi.addUsers(orgAName, teamAName, false, Collections.singletonList(new TeamUserEntry() - .setUsername(userAName) - .setRole(TeamUserEntry.RoleEnum.MEMBER))); + teamsApi.addUsersToTeam(orgAName, teamAName, false, Collections.singletonList(new TeamUserEntry() + .username(userAName) + .role(TeamUserEntry.RoleEnum.MEMBER))); String userBName = "userB_" + randomString(); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userBName) - .setType(CreateUserRequest.TypeEnum.LOCAL)); - CreateApiKeyResponse apiKeyB = apiKeyResource.create(new CreateApiKeyRequest() - .setUsername(userBName) - .setUserType(CreateApiKeyRequest.UserTypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userBName) + .type(CreateUserRequest.TypeEnum.LOCAL)); + CreateApiKeyResponse apiKeyB = apiKeyResource.createUserApiKey(new CreateApiKeyRequest() + .username(userBName) + .userType(CreateApiKeyRequest.UserTypeEnum.LOCAL)); - teamsApi.addUsers(orgBName, teamBName, false, Collections.singletonList(new TeamUserEntry() - .setUsername(userBName) - .setRole(TeamUserEntry.RoleEnum.MEMBER))); + teamsApi.addUsersToTeam(orgBName, teamBName, false, Collections.singletonList(new TeamUserEntry() + .username(userBName) + .role(TeamUserEntry.RoleEnum.MEMBER))); // --- - ProjectsApi projectsApi = new ProjectsApi(getApiClient()); setApiKey(apiKeyA.getKey()); String projectAName = "projectA_" + randomString(); - projectsApi.createOrUpdate(orgAName, new ProjectEntry().setName(projectAName)); + ProjectsApi projectsApi = new ProjectsApi(getApiClient()); + projectsApi.createOrUpdateProject(orgAName, new ProjectEntry().name(projectAName)); try { String projectBName = "projectB_" + randomString(); - projectsApi.createOrUpdate(orgBName, new ProjectEntry().setName(projectBName)); + projectsApi.createOrUpdateProject(orgBName, new ProjectEntry().name(projectBName)); fail("should fail"); } catch (ApiException e) { } setApiKey(apiKeyB.getKey()); + projectsApi = new ProjectsApi(getApiClient()); String projectBName = "projectB_" + randomString(); - projectsApi.createOrUpdate(orgBName, new ProjectEntry().setName(projectBName)); + projectsApi.createOrUpdateProject(orgBName, new ProjectEntry().name(projectBName)); } @Test @@ -107,14 +107,14 @@ public void testTeamCreators() throws Exception { OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); String orgName = "orgA_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- TeamsApi teamsApi = new TeamsApi(getApiClient()); String teamAName = "teamA_" + randomString(); - teamsApi.createOrUpdate(orgName, new TeamEntry().setName(teamAName)); + teamsApi.createOrUpdateTeam(orgName, new TeamEntry().name(teamAName)); // --- @@ -122,19 +122,19 @@ public void testTeamCreators() throws Exception { ApiKeysApi apiKeyResource = new ApiKeysApi(getApiClient()); String userAName = "userA_" + randomString(); - usersApi.createOrUpdate(new CreateUserRequest().setUsername(userAName).setType(CreateUserRequest.TypeEnum.LOCAL)); - CreateApiKeyResponse apiKeyA = apiKeyResource.create(new CreateApiKeyRequest() - .setUsername(userAName) - .setUserType(CreateApiKeyRequest.UserTypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest().username(userAName).type(CreateUserRequest.TypeEnum.LOCAL)); + CreateApiKeyResponse apiKeyA = apiKeyResource.createUserApiKey(new CreateApiKeyRequest() + .username(userAName) + .userType(CreateApiKeyRequest.UserTypeEnum.LOCAL)); // --- setApiKey(apiKeyA.getKey()); try { - teamsApi.createOrUpdate(orgName, new TeamEntry() - .setName(teamAName) - .setDescription("test")); + teamsApi.createOrUpdateTeam(orgName, new TeamEntry() + .name(teamAName) + .description("test")); fail("Should fail"); } catch (ApiException e) { } @@ -143,24 +143,24 @@ public void testTeamCreators() throws Exception { resetApiKey(); - teamsApi.addUsers(orgName, teamAName, false, Collections.singletonList(new TeamUserEntry() - .setUsername(userAName) - .setRole(TeamUserEntry.RoleEnum.MAINTAINER))); + teamsApi.addUsersToTeam(orgName, teamAName, false, Collections.singletonList(new TeamUserEntry() + .username(userAName) + .role(TeamUserEntry.RoleEnum.MAINTAINER))); // --- setApiKey(apiKeyA.getKey()); - teamsApi.createOrUpdate(orgName, new TeamEntry() - .setName(teamAName) - .setDescription("test")); + teamsApi.createOrUpdateTeam(orgName, new TeamEntry() + .name(teamAName) + .description("test")); // --- String teamBName = "teamB_" + randomString(); try { - teamsApi.createOrUpdate(orgName, new TeamEntry().setName(teamBName)); + teamsApi.createOrUpdateTeam(orgName, new TeamEntry().name(teamBName)); fail("Should fail"); } catch (ApiException e) { } @@ -169,13 +169,13 @@ public void testTeamCreators() throws Exception { resetApiKey(); - teamsApi.addUsers(orgName, teamAName, false, Collections.singletonList(new TeamUserEntry() - .setUsername(userAName) - .setRole(TeamUserEntry.RoleEnum.OWNER))); + teamsApi.addUsersToTeam(orgName, teamAName, false, Collections.singletonList(new TeamUserEntry() + .username(userAName) + .role(TeamUserEntry.RoleEnum.OWNER))); // --- - teamsApi.createOrUpdate(orgName, new TeamEntry().setName(teamBName)); + teamsApi.createOrUpdateTeam(orgName, new TeamEntry().name(teamBName)); } @Test @@ -183,14 +183,14 @@ public void testTeamMaintainers() throws Exception { OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); String orgName = "orgA_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- TeamsApi teamsApi = new TeamsApi(getApiClient()); String teamName = "teamA_" + randomString(); - teamsApi.createOrUpdate(orgName, new TeamEntry().setName(teamName)); + teamsApi.createOrUpdateTeam(orgName, new TeamEntry().name(teamName)); // --- @@ -198,27 +198,27 @@ public void testTeamMaintainers() throws Exception { ApiKeysApi apiKeyResource = new ApiKeysApi(getApiClient()); String userAName = "userA_" + randomString(); - usersApi.createOrUpdate(new CreateUserRequest().setUsername(userAName).setType(CreateUserRequest.TypeEnum.LOCAL)); - CreateApiKeyResponse apiKeyA = apiKeyResource.create(new CreateApiKeyRequest().setUsername(userAName)); + usersApi.createOrUpdateUser(new CreateUserRequest().username(userAName).type(CreateUserRequest.TypeEnum.LOCAL)); + CreateApiKeyResponse apiKeyA = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(userAName)); - teamsApi.addUsers(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() - .setUsername(userAName) - .setRole(TeamUserEntry.RoleEnum.MAINTAINER))); + teamsApi.addUsersToTeam(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() + .username(userAName) + .role(TeamUserEntry.RoleEnum.MAINTAINER))); String userBName = "userB_" + randomString(); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userBName) - .setType(CreateUserRequest.TypeEnum.LOCAL)); - CreateApiKeyResponse apiKeyB = apiKeyResource.create(new CreateApiKeyRequest().setUsername(userBName)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userBName) + .type(CreateUserRequest.TypeEnum.LOCAL)); + CreateApiKeyResponse apiKeyB = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(userBName)); // --- setApiKey(apiKeyB.getKey()); try { - teamsApi.addUsers(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() - .setUsername(userBName) - .setRole(TeamUserEntry.RoleEnum.MEMBER))); + teamsApi.addUsersToTeam(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() + .username(userBName) + .role(TeamUserEntry.RoleEnum.MEMBER))); fail("should fail"); } catch (ApiException e) { } @@ -226,9 +226,9 @@ public void testTeamMaintainers() throws Exception { // --- setApiKey(apiKeyA.getKey()); - teamsApi.addUsers(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() - .setUsername(userBName) - .setRole(TeamUserEntry.RoleEnum.MEMBER))); + teamsApi.addUsersToTeam(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() + .username(userBName) + .role(TeamUserEntry.RoleEnum.MEMBER))); } @Test @@ -238,30 +238,30 @@ public void testNewTeamOwner() throws Exception { UsersApi usersApi = new UsersApi(getApiClient()); ApiKeysApi apiKeyResource = new ApiKeysApi(getApiClient()); - usersApi.createOrUpdate(new CreateUserRequest().setUsername(userA).setType(CreateUserRequest.TypeEnum.LOCAL)); - CreateApiKeyResponse userAKey = apiKeyResource.create(new CreateApiKeyRequest().setUsername(userA)); + usersApi.createOrUpdateUser(new CreateUserRequest().username(userA).type(CreateUserRequest.TypeEnum.LOCAL)); + CreateApiKeyResponse userAKey = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(userA)); String userB = "userA_" + randomString(); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userB) - .setType(CreateUserRequest.TypeEnum.LOCAL)); - CreateApiKeyResponse userBKey = apiKeyResource.create(new CreateApiKeyRequest() - .setUsername(userB)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userB) + .type(CreateUserRequest.TypeEnum.LOCAL)); + CreateApiKeyResponse userBKey = apiKeyResource.createUserApiKey(new CreateApiKeyRequest() + .username(userB)); // --- OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); String orgName = "orgA_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- TeamsApi teamsApi = new TeamsApi(getApiClient()); - teamsApi.addUsers(orgName, "default", false, Collections.singletonList(new TeamUserEntry() - .setUsername(userA) - .setRole(TeamUserEntry.RoleEnum.OWNER))); + teamsApi.addUsersToTeam(orgName, "default", false, Collections.singletonList(new TeamUserEntry() + .username(userA) + .role(TeamUserEntry.RoleEnum.OWNER))); // --- @@ -271,7 +271,7 @@ public void testNewTeamOwner() throws Exception { String teamName = "teamA_" + randomString(); try { - teamsApi.createOrUpdate(orgName, new TeamEntry().setName(teamName)); + teamsApi.createOrUpdateTeam(orgName, new TeamEntry().name(teamName)); fail("Should fail"); } catch (ApiException e) { } @@ -282,10 +282,10 @@ public void testNewTeamOwner() throws Exception { // --- - teamsApi.createOrUpdate(orgName, new TeamEntry().setName(teamName)); - teamsApi.addUsers(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() - .setUsername(userB) - .setRole(TeamUserEntry.RoleEnum.MEMBER))); + teamsApi.createOrUpdateTeam(orgName, new TeamEntry().name(teamName)); + teamsApi.addUsersToTeam(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() + .username(userB) + .role(TeamUserEntry.RoleEnum.MEMBER))); } @Test @@ -293,33 +293,33 @@ public void testTeamDelete() throws Exception { OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); String orgName = "orgA_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- TeamsApi teamsApi = new TeamsApi(getApiClient()); String teamName = "teamA_" + randomString(); - teamsApi.createOrUpdate(orgName, new TeamEntry().setName(teamName)); + teamsApi.createOrUpdateTeam(orgName, new TeamEntry().name(teamName)); // --- - teamsApi.addUsers(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() - .setUsername("admin") - .setRole(TeamUserEntry.RoleEnum.OWNER))); + teamsApi.addUsersToTeam(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() + .username("admin") + .role(TeamUserEntry.RoleEnum.OWNER))); // --- - List l = teamsApi.list(orgName); + List l = teamsApi.listTeams(orgName); assertEquals(2, l.size()); // --- - teamsApi.delete(orgName, teamName); + teamsApi.deleteTeam(orgName, teamName); // --- - l = teamsApi.list(orgName); + l = teamsApi.listTeams(orgName); assertEquals(1, l.size()); } @@ -328,14 +328,14 @@ public void testOrgProjects() throws Exception { OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); String orgName = "orgA_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- TeamsApi teamsApi = new TeamsApi(getApiClient()); String teamName = "teamA_" + randomString(); - CreateTeamResponse ctr = teamsApi.createOrUpdate(orgName, new TeamEntry().setName(teamName)); + CreateTeamResponse ctr = teamsApi.createOrUpdateTeam(orgName, new TeamEntry().name(teamName)); // --- @@ -343,14 +343,14 @@ public void testOrgProjects() throws Exception { ApiKeysApi apiKeyResource = new ApiKeysApi(getApiClient()); String userAName = "userA_" + randomString(); - usersApi.createOrUpdate(new CreateUserRequest().setUsername(userAName).setType(CreateUserRequest.TypeEnum.LOCAL)); - CreateApiKeyResponse apiKeyA = apiKeyResource.create(new CreateApiKeyRequest().setUsername(userAName)); + usersApi.createOrUpdateUser(new CreateUserRequest().username(userAName).type(CreateUserRequest.TypeEnum.LOCAL)); + CreateApiKeyResponse apiKeyA = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(userAName)); String userBName = "userB_" + randomString(); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userBName) - .setType(CreateUserRequest.TypeEnum.LOCAL)); - CreateApiKeyResponse apiKeyB = apiKeyResource.create(new CreateApiKeyRequest().setUsername(userBName)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userBName) + .type(CreateUserRequest.TypeEnum.LOCAL)); + CreateApiKeyResponse apiKeyB = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(userBName)); // --- @@ -360,7 +360,7 @@ public void testOrgProjects() throws Exception { String projectName = "projectA_" + randomString(); try { - projectsApi.createOrUpdate(orgName, new ProjectEntry().setName(projectName)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry().name(projectName)); fail("should fail"); } catch (ApiException e) { } @@ -368,24 +368,24 @@ public void testOrgProjects() throws Exception { // --- resetApiKey(); - teamsApi.addUsers(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() - .setUsername(userAName) - .setRole(TeamUserEntry.RoleEnum.MEMBER))); + teamsApi.addUsersToTeam(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() + .username(userAName) + .role(TeamUserEntry.RoleEnum.MEMBER))); // --- setApiKey(apiKeyA.getKey()); - projectsApi.createOrUpdate(orgName, new ProjectEntry().setName(projectName)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry().name(projectName)); // --- setApiKey(apiKeyB.getKey()); try { - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setDescription("new description") - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .description("new description") + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); fail("should fail"); } catch (ApiException e) { } @@ -393,29 +393,29 @@ public void testOrgProjects() throws Exception { // --- setApiKey(apiKeyA.getKey()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setDescription("new description") - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .description("new description") + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); // --- setApiKey(apiKeyA.getKey()); - projectsApi.updateAccessLevel(orgName, projectName, new ResourceAccessEntry() - .setTeamId(ctr.getId()) - .setOrgName(orgName) - .setTeamName(teamName) - .setLevel(ResourceAccessEntry.LevelEnum.WRITER)); + projectsApi.updateProjectAccessLevel(orgName, projectName, new ResourceAccessEntry() + .teamId(ctr.getId()) + .orgName(orgName) + .teamName(teamName) + .level(ResourceAccessEntry.LevelEnum.WRITER)); // --- setApiKey(apiKeyB.getKey()); try { - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setDescription("another description") - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .description("another description") + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); fail("should fail"); } catch (ApiException e) { } @@ -423,17 +423,17 @@ public void testOrgProjects() throws Exception { // --- resetApiKey(); - teamsApi.addUsers(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() - .setUsername(userBName) - .setRole(TeamUserEntry.RoleEnum.MEMBER))); + teamsApi.addUsersToTeam(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() + .username(userBName) + .role(TeamUserEntry.RoleEnum.MEMBER))); // --- setApiKey(apiKeyB.getKey()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setDescription("another description") - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .description("another description") + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); } @Test @@ -441,14 +441,14 @@ public void testOrgPublicSecrets() throws Exception { OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); String orgAName = "orgA_" + randomString(); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgAName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgAName)); // --- TeamsApi teamsApi = new TeamsApi(getApiClient()); String teamAName = "teamA_" + randomString(); - teamsApi.createOrUpdate(orgAName, new TeamEntry().setName(teamAName)); + teamsApi.createOrUpdateTeam(orgAName, new TeamEntry().name(teamAName)); // --- @@ -456,14 +456,14 @@ public void testOrgPublicSecrets() throws Exception { ApiKeysApi apiKeyResource = new ApiKeysApi(getApiClient()); String userAName = "userA_" + randomString(); - usersApi.createOrUpdate(new CreateUserRequest().setUsername(userAName).setType(CreateUserRequest.TypeEnum.LOCAL)); - CreateApiKeyResponse apiKeyA = apiKeyResource.create(new CreateApiKeyRequest().setUsername(userAName)); + usersApi.createOrUpdateUser(new CreateUserRequest().username(userAName).type(CreateUserRequest.TypeEnum.LOCAL)); + CreateApiKeyResponse apiKeyA = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(userAName)); String userBName = "userB_" + randomString(); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userBName) - .setType(CreateUserRequest.TypeEnum.LOCAL)); - CreateApiKeyResponse apiKeyB = apiKeyResource.create(new CreateApiKeyRequest().setUsername(userBName)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userBName) + .type(CreateUserRequest.TypeEnum.LOCAL)); + CreateApiKeyResponse apiKeyB = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(userBName)); // --- @@ -479,9 +479,9 @@ public void testOrgPublicSecrets() throws Exception { // --- resetApiKey(); - teamsApi.addUsers(orgAName, teamAName, false, Collections.singletonList(new TeamUserEntry() - .setUsername(userAName) - .setRole(TeamUserEntry.RoleEnum.MEMBER))); + teamsApi.addUsersToTeam(orgAName, teamAName, false, Collections.singletonList(new TeamUserEntry() + .username(userAName) + .role(TeamUserEntry.RoleEnum.MEMBER))); // --- @@ -516,30 +516,30 @@ public void testInventory() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- String teamName = "teamA_" + randomString(); TeamsApi teamsApi = new TeamsApi(getApiClient()); - teamsApi.createOrUpdate(orgName, new TeamEntry().setName(teamName)); + teamsApi.createOrUpdateTeam(orgName, new TeamEntry().name(teamName)); // --- String inventoryName = "inv_" + randomString(); InventoriesApi inventoryResource = new InventoriesApi(getApiClient()); - inventoryResource.createOrUpdate(orgName, new InventoryEntry() - .setName(inventoryName) - .setVisibility(InventoryEntry.VisibilityEnum.PRIVATE)); + inventoryResource.createOrUpdateInventory(orgName, new InventoryEntry() + .name(inventoryName) + .visibility(InventoryEntry.VisibilityEnum.PRIVATE)); // --- - inventoryResource.updateAccessLevel(orgName, inventoryName, new ResourceAccessEntry() - .setOrgName(orgName) - .setTeamName(teamName) - .setLevel(ResourceAccessEntry.LevelEnum.READER)); + inventoryResource.updateInventoryAccessLevel(orgName, inventoryName, new ResourceAccessEntry() + .orgName(orgName) + .teamName(teamName) + .level(ResourceAccessEntry.LevelEnum.READER)); // --- @@ -547,35 +547,35 @@ public void testInventory() throws Exception { String userBName = "userB_" + randomString(); UsersApi usersApi = new UsersApi(getApiClient()); - usersApi.createOrUpdate(new CreateUserRequest().setUsername(userAName).setType(CreateUserRequest.TypeEnum.LOCAL)); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userBName) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest().username(userAName).type(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userBName) + .type(CreateUserRequest.TypeEnum.LOCAL)); // --- ApiKeysApi apiKeyResource = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse cakrA = apiKeyResource.create(new CreateApiKeyRequest().setUsername(userAName)); - CreateApiKeyResponse cakrB = apiKeyResource.create(new CreateApiKeyRequest().setUsername(userBName)); + CreateApiKeyResponse cakrA = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(userAName)); + CreateApiKeyResponse cakrB = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(userBName)); // --- - teamsApi.addUsers(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() - .setUsername(userAName) - .setRole(TeamUserEntry.RoleEnum.MEMBER))); + teamsApi.addUsersToTeam(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() + .username(userAName) + .role(TeamUserEntry.RoleEnum.MEMBER))); // --- setApiKey(cakrA.getKey()); - inventoryResource.get(orgName, inventoryName); + inventoryResource.getInventory(orgName, inventoryName); // --- setApiKey(cakrB.getKey()); try { - inventoryResource.get(orgName, inventoryName); + inventoryResource.getInventory(orgName, inventoryName); fail("Should fail"); } catch (ApiException e) { } @@ -584,15 +584,15 @@ public void testInventory() throws Exception { resetApiKey(); - teamsApi.addUsers(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() - .setUsername(userBName) - .setRole(TeamUserEntry.RoleEnum.MEMBER))); + teamsApi.addUsersToTeam(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() + .username(userBName) + .role(TeamUserEntry.RoleEnum.MEMBER))); // --- setApiKey(cakrB.getKey()); - inventoryResource.get(orgName, inventoryName); + inventoryResource.getInventory(orgName, inventoryName); } @Test @@ -600,32 +600,32 @@ public void testTeamUsersUpsert() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- String teamName = "team_" + randomString(); TeamsApi teamsApi = new TeamsApi(getApiClient()); - teamsApi.createOrUpdate(orgName, new TeamEntry().setName(teamName)); + teamsApi.createOrUpdateTeam(orgName, new TeamEntry().name(teamName)); // --- String username = "user_" + randomString(); UsersApi usersApi = new UsersApi(getApiClient()); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(username) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(username) + .type(CreateUserRequest.TypeEnum.LOCAL)); // --- - teamsApi.addUsers(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() - .setUsername(username) - .setRole(TeamUserEntry.RoleEnum.MEMBER))); - teamsApi.addUsers(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() - .setUsername(username) - .setRole(TeamUserEntry.RoleEnum.MAINTAINER))); + teamsApi.addUsersToTeam(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() + .username(username) + .role(TeamUserEntry.RoleEnum.MEMBER))); + teamsApi.addUsersToTeam(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() + .username(username) + .role(TeamUserEntry.RoleEnum.MAINTAINER))); } @Test @@ -635,34 +635,34 @@ public void testSecretAccessLevels() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- String secretName = "secret_" + randomString(); SecretOperationResponse sor = addPlainSecret(orgName, secretName, false, null, new byte[]{0, 1, 2}); - secretResource.update(orgName, secretName, new SecretUpdateRequest() - .setId(sor.getId()) - .setVisibility(SecretUpdateRequest.VisibilityEnum.PRIVATE)); + secretResource.updateSecretV1(orgName, secretName, new SecretUpdateRequest() + .id(sor.getId()) + .visibility(SecretUpdateRequest.VisibilityEnum.PRIVATE)); // --- String username = "user_" + randomString(); UsersApi usersApi = new UsersApi(getApiClient()); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(username) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(username) + .type(CreateUserRequest.TypeEnum.LOCAL)); ApiKeysApi apiKeyResource = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse cakr = apiKeyResource.create(new CreateApiKeyRequest().setUsername(username)); + CreateApiKeyResponse cakr = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(username)); // --- setApiKey(cakr.getKey()); try { - secretResource.get(orgName, secretName); + new SecretsV2Api(getApiClient()).getSecret(orgName, secretName); fail("Should fail"); } catch (ApiException e) { } @@ -676,18 +676,18 @@ public void testSecretAccessLevels() throws Exception { String teamName = "team_" + randomString(); TeamsApi teamsApi = new TeamsApi(getApiClient()); - teamsApi.createOrUpdate(orgName, new TeamEntry().setName(teamName)); + teamsApi.createOrUpdateTeam(orgName, new TeamEntry().name(teamName)); - teamsApi.addUsers(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() - .setUsername(username) - .setRole(TeamUserEntry.RoleEnum.MEMBER))); + teamsApi.addUsersToTeam(orgName, teamName, false, Collections.singletonList(new TeamUserEntry() + .username(username) + .role(TeamUserEntry.RoleEnum.MEMBER))); // --- setApiKey(cakr.getKey()); try { - secretResource.get(orgName, secretName); + new SecretsV2Api(getApiClient()).getSecret(orgName, secretName); fail("Should fail"); } catch (ApiException e) { } @@ -696,15 +696,15 @@ public void testSecretAccessLevels() throws Exception { resetApiKey(); - secretResource.updateAccessLevel(orgName, secretName, new ResourceAccessEntry() - .setTeamName(teamName) - .setLevel(ResourceAccessEntry.LevelEnum.READER)); + secretResource.updateSecretAccessLevel(orgName, secretName, new ResourceAccessEntry() + .teamName(teamName) + .level(ResourceAccessEntry.LevelEnum.READER)); // --- setApiKey(cakr.getKey()); - SecretEntry s = secretResource.get(orgName, secretName); + SecretEntryV2 s = new SecretsV2Api(getApiClient()).getSecret(orgName, secretName); assertEquals(secretName, s.getName()); try { @@ -717,9 +717,9 @@ public void testSecretAccessLevels() throws Exception { resetApiKey(); - secretResource.updateAccessLevel(orgName, secretName, new ResourceAccessEntry() - .setTeamName(teamName) - .setLevel(ResourceAccessEntry.LevelEnum.OWNER)); + secretResource.updateSecretAccessLevel(orgName, secretName, new ResourceAccessEntry() + .teamName(teamName) + .level(ResourceAccessEntry.LevelEnum.OWNER)); // --- @@ -737,44 +737,44 @@ public void testSecretAccessLevels() throws Exception { public void testPublicOrgVisibility() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi organizationsApi = new OrganizationsApi(getApiClient()); - organizationsApi.createOrUpdate(new OrganizationEntry() - .setName(orgName) - .setVisibility(OrganizationEntry.VisibilityEnum.PUBLIC)); + organizationsApi.createOrUpdateOrg(new OrganizationEntry() + .name(orgName) + .visibility(OrganizationEntry.VisibilityEnum.PUBLIC)); - assertTrue(organizationsApi.find(true, null, null, null).stream().anyMatch(o -> o.getName().equals(orgName))); + assertTrue(organizationsApi.listOrgs(true, null, null, null).stream().anyMatch(o -> o.getName().equals(orgName))); // --- String userName = "user_" + randomString(); UsersApi usersApi = new UsersApi(getApiClient()); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userName) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userName) + .type(CreateUserRequest.TypeEnum.LOCAL)); ApiKeysApi apiKeysApi = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse cakr = apiKeysApi.create(new CreateApiKeyRequest() - .setUsername(userName) - .setUserType(CreateApiKeyRequest.UserTypeEnum.LOCAL)); + CreateApiKeyResponse cakr = apiKeysApi.createUserApiKey(new CreateApiKeyRequest() + .username(userName) + .userType(CreateApiKeyRequest.UserTypeEnum.LOCAL)); setApiKey(cakr.getKey()); - assertTrue(organizationsApi.find(false, null, null, null).stream().anyMatch(o -> o.getName().equals(orgName))); + assertTrue(organizationsApi.listOrgs(false, null, null, null).stream().anyMatch(o -> o.getName().equals(orgName))); // --- resetApiKey(); + organizationsApi = new OrganizationsApi(getApiClient()); + organizationsApi.createOrUpdateOrg(new OrganizationEntry() + .name(orgName) + .visibility(OrganizationEntry.VisibilityEnum.PRIVATE)); - organizationsApi.createOrUpdate(new OrganizationEntry() - .setName(orgName) - .setVisibility(OrganizationEntry.VisibilityEnum.PRIVATE)); - - assertTrue(organizationsApi.find(true, null, null, null).stream().anyMatch(o -> o.getName().equals(orgName))); + assertTrue(organizationsApi.listOrgs(true, null, null, null).stream().anyMatch(o -> o.getName().equals(orgName))); // --- setApiKey(cakr.getKey()); - - assertFalse(organizationsApi.find(true, null, null, null).stream().anyMatch(o -> o.getName().equals(orgName))); + organizationsApi = new OrganizationsApi(getApiClient()); + assertFalse(organizationsApi.listOrgs(true, null, null, null).stream().anyMatch(o -> o.getName().equals(orgName))); } /** @@ -785,42 +785,42 @@ public void testPublicOrgVisibility() throws Exception { public void testOwnersVisibility() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi organizationsApi = new OrganizationsApi(getApiClient()); - organizationsApi.createOrUpdate(new OrganizationEntry() - .setName(orgName) - .setVisibility(OrganizationEntry.VisibilityEnum.PRIVATE)); + organizationsApi.createOrUpdateOrg(new OrganizationEntry() + .name(orgName) + .visibility(OrganizationEntry.VisibilityEnum.PRIVATE)); // --- String userName = "user_" + randomString(); UsersApi usersApi = new UsersApi(getApiClient()); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userName) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userName) + .type(CreateUserRequest.TypeEnum.LOCAL)); ApiKeysApi apiKeysApi = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse cakr = apiKeysApi.create(new CreateApiKeyRequest() - .setUsername(userName) - .setUserType(CreateApiKeyRequest.UserTypeEnum.LOCAL)); + CreateApiKeyResponse cakr = apiKeysApi.createUserApiKey(new CreateApiKeyRequest() + .username(userName) + .userType(CreateApiKeyRequest.UserTypeEnum.LOCAL)); setApiKey(cakr.getKey()); - assertFalse(organizationsApi.find(true, null, null, null).stream().anyMatch(o -> o.getName().equals(orgName))); + assertFalse(organizationsApi.listOrgs(true, null, null, null).stream().anyMatch(o -> o.getName().equals(orgName))); // --- resetApiKey(); - organizationsApi.createOrUpdate(new OrganizationEntry() - .setName(orgName) + organizationsApi.createOrUpdateOrg(new OrganizationEntry() + .name(orgName) .owner(new EntityOwner() - .setUsername(userName) - .setUserType(EntityOwner.UserTypeEnum.LOCAL))); + .username(userName) + .userType(EntityOwner.UserTypeEnum.LOCAL))); // --- setApiKey(cakr.getKey()); - assertTrue(organizationsApi.find(true, null, null, null).stream().anyMatch(o -> o.getName().equals(orgName))); + assertTrue(organizationsApi.listOrgs(true, null, null, null).stream().anyMatch(o -> o.getName().equals(orgName))); // --- @@ -828,28 +828,27 @@ public void testOwnersVisibility() throws Exception { String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setVisibility(ProjectEntry.VisibilityEnum.PRIVATE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .visibility(ProjectEntry.VisibilityEnum.PRIVATE)); String secretName = "secret_" + randomString(); addPlainSecret(orgName, secretName, false, null, "hello!".getBytes()); String jsonStoreName = "store_" + randomString(); JsonStoreApi jsonStoreApi = new JsonStoreApi(getApiClient()); - jsonStoreApi.createOrUpdate(orgName, new JsonStoreRequest() - .setName(jsonStoreName) - .setVisibility(JsonStoreRequest.VisibilityEnum.PRIVATE)); + jsonStoreApi.createOrUpdateJsonStore(orgName, new JsonStoreRequest() + .name(jsonStoreName) + .visibility(JsonStoreRequest.VisibilityEnum.PRIVATE)); // --- setApiKey(cakr.getKey()); - assertTrue(projectsApi.find(orgName, null, null, null).stream().anyMatch(p -> p.getName().equals(projectName))); + assertTrue(projectsApi.findProjects(orgName, null, null, null).stream().anyMatch(p -> p.getName().equals(projectName))); - SecretsApi secretsApi = new SecretsApi(getApiClient()); - assertTrue(secretsApi.list(orgName, null, null, null).stream().anyMatch(s -> s.getName().equals(secretName))); + assertTrue(new SecretsV2Api(getApiClient()).listSecrets(orgName, null, null, null).stream().anyMatch(s -> s.getName().equals(secretName))); - assertTrue(jsonStoreApi.list(orgName, null, null, null).stream().anyMatch(p -> p.getName().equals(jsonStoreName))); + assertTrue(jsonStoreApi.listJsonStores(orgName, null, null, null).stream().anyMatch(p -> p.getName().equals(jsonStoreName))); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/TemplateIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/TemplateIT.java index cad485ec07..b9bc00ee8e 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/TemplateIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/TemplateIT.java @@ -20,7 +20,7 @@ * ===== */ -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; @@ -51,9 +51,9 @@ public void test() throws Exception { Path templatePath = createTemplate(processYml, MAIN_JS); TemplateAliasApi templateAliasResource = new TemplateAliasApi(getApiClient()); - templateAliasResource.createOrUpdate(new TemplateAliasEntry() - .setAlias(templateAlias) - .setUrl(templatePath.toUri().toString())); + templateAliasResource.createOrUpdateTemplate(new TemplateAliasEntry() + .alias(templateAlias) + .url(templatePath.toUri().toString())); // --- @@ -66,14 +66,13 @@ public void test() throws Exception { ProjectsApi projectsApi = new ProjectsApi(getApiClient()); 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)); // --- - ProcessApi processApi = new ProcessApi(getApiClient()); Map input = new HashMap<>(); input.put("org", orgName); input.put("project", projectName); @@ -82,12 +81,12 @@ public void test() throws Exception { // --- - 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, " + myName + ".*", ab); } @@ -99,9 +98,9 @@ public void testInputVariablesStillPresent() throws Exception { Path templatePath = createTemplate(processYml, MAIN_JS); TemplateAliasApi templateAliasResource = new TemplateAliasApi(getApiClient()); - templateAliasResource.createOrUpdate(new TemplateAliasEntry() - .setAlias(templateAlias) - .setUrl(templatePath.toUri().toString())); + templateAliasResource.createOrUpdateTemplate(new TemplateAliasEntry() + .alias(templateAlias) + .url(templatePath.toUri().toString())); // --- @@ -114,16 +113,15 @@ public void testInputVariablesStillPresent() throws Exception { ProjectsApi projectsApi = new ProjectsApi(getApiClient()); 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)); // --- Map args = Collections.singletonMap(Constants.Request.ARGUMENTS_KEY, Collections.singletonMap("xxx", "BOO")); - ProcessApi processApi = new ProcessApi(getApiClient()); Map input = new HashMap<>(); input.put("org", orgName); input.put("project", projectName); @@ -133,12 +131,12 @@ public void testInputVariablesStillPresent() throws Exception { // --- - 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(".*BOO.*", ab); } @@ -149,7 +147,7 @@ public void testEntryPointReference() throws Exception { Path tmpDir = createTempDir(); - File src = new File(ProjectIT.class.getResource("repositoryValidationTemplateRef").toURI()); + File src = new File(TemplateIT.class.getResource("repositoryValidationTemplateRef").toURI()); IOUtils.copy(src.toPath(), tmpDir); Path concordYml = tmpDir.resolve("concord.yml"); @@ -173,20 +171,20 @@ public void testEntryPointReference() throws Exception { // --- OrganizationsApi organizationsApi = new OrganizationsApi(getApiClient()); - organizationsApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + organizationsApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - 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")))); // --- RepositoriesApi repositoriesApi = new RepositoriesApi(getApiClient()); RepositoryValidationResponse resp = repositoriesApi.validateRepository(orgName, projectName, repoName); - assertTrue(resp.isOk()); + assertTrue(resp.getOk()); assertFalse(resp.getWarnings().isEmpty()); } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/TemplateMergeIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/TemplateMergeIT.java index b72f8bbc22..4a05e0f5ab 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/TemplateMergeIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/TemplateMergeIT.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.sdk.Constants; import org.junit.jupiter.api.Test; @@ -48,10 +48,10 @@ public void test() throws Exception { String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setCfg(Collections.singletonMap(Constants.Request.TEMPLATE_KEY, template.toUri().toString())) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .cfg(Collections.singletonMap(Constants.Request.TEMPLATE_KEY, template.toUri().toString())) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); // --- @@ -63,13 +63,12 @@ public void test() 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(".*Hello, Concord.*", ab); } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ThrowExceptionTaskIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ThrowExceptionTaskIT.java index ee9a46468f..954707a90e 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ThrowExceptionTaskIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ThrowExceptionTaskIT.java @@ -20,9 +20,8 @@ * ===== */ -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.ProcessEntry; +import com.walmartlabs.concord.client2.StartProcessResponse; import org.junit.jupiter.api.Test; import java.net.URI; @@ -41,16 +40,15 @@ public void testThrowException() throws Exception { // start the process - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); // wait for completion - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FAILED, pir.getStatus()); // check logs - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Catch that!.*", 3, ab); } @@ -61,16 +59,15 @@ public void testThrowExceptionMessage() throws Exception { // start the process - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); // wait for completion - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); assertEquals(ProcessEntry.StatusEnum.FAILED, pir.getStatus()); // check logs - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Kaboom!! Error occurred.*", 2, ab); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/TimeoutHandlingIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/TimeoutHandlingIT.java index af6c58c37f..4e66cdcb3e 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/TimeoutHandlingIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/TimeoutHandlingIT.java @@ -20,9 +20,9 @@ * ===== */ -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.ProcessApi; +import com.walmartlabs.concord.client2.ProcessEntry; +import com.walmartlabs.concord.client2.StartProcessResponse; import org.junit.jupiter.api.Test; import static com.walmartlabs.concord.it.common.ITUtils.archive; @@ -36,13 +36,13 @@ public void testTimeout() throws Exception { // prepare the payload - byte[] payload = archive(ProcessIT.class.getResource("timeoutHandling").toURI()); + byte[] payload = archive(TimeoutHandlingIT.class.getResource("timeoutHandling").toURI()); // start the process and wait for it to fail StartProcessResponse spr = start(payload); - waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.TIMED_OUT); + waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.TIMED_OUT); // find the child processes @@ -50,7 +50,7 @@ public void testTimeout() throws Exception { // check the handler's logs for expected messages - byte[] ab = getLog(child.getLogFileName()); + byte[] ab = getLog(child.getInstanceId()); assertLog(".*projectInfo: \\{.*orgName=Default.*\\}.*", ab); assertLog(".*processInfo: \\{.*sessionKey=.*\\}.*", ab); assertLog(".*initiator: \\{.*username=.*\\}.*", ab); diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/TriggerIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/TriggerIT.java index 6d4507e302..9d94974ee0 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/TriggerIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/TriggerIT.java @@ -20,8 +20,9 @@ * ===== */ -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.client2.ProcessListFilter; import com.walmartlabs.concord.common.IOUtils; import org.eclipse.jgit.api.Git; import org.junit.jupiter.api.Test; @@ -52,16 +53,16 @@ public void testTriggerProcessStartupFailure() throws Exception { String policyName = "policy_" + randomString(); PolicyApi policyApi = new PolicyApi(getApiClient()); - policyApi.createOrUpdate(new PolicyEntry() - .setName(policyName) - .setRules(readPolicy("invalidTriggersBrokenProcess/policy.json"))); + policyApi.createOrUpdatePolicy(new PolicyEntry() + .name(policyName) + .rules(readPolicy("invalidTriggersBrokenProcess/policy.json"))); - policyApi.link(policyName, new PolicyLinkEntry().setOrgName(orgName)); + policyApi.linkPolicy(policyName, new PolicyLinkEntry().orgName(orgName)); // --- ExternalEventsApi eventResource = new ExternalEventsApi(getApiClient()); - eventResource.event("testTrigger2", Collections.singletonMap("x", "abc")); + eventResource.externalEvent("testTrigger2", Collections.singletonMap("x", "abc")); // --- @@ -78,21 +79,21 @@ public void testTriggerProfiles() throws Exception { // --- ExternalEventsApi eventResource = new ExternalEventsApi(getApiClient()); - eventResource.event("testTrigger", Collections.emptyMap()); + eventResource.externalEvent("testTrigger", Collections.emptyMap()); // --- List l = waitForProcs(por.getId(), 1, StatusEnum.FINISHED); ProcessEntry pe = l.get(0); - byte[] ab = getLog(pe.getLogFileName()); + byte[] ab = getLog(pe.getInstanceId()); assertLog(".*Hello, Concord.*", ab); } private ProjectOperationResponse register(String orgName, String projectName, String repoResource, int expectedTriggerCount) throws Exception { OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - if (orgApi.get(orgName) == null) { - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + if (orgApi.getOrg(orgName) == null) { + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); } // --- @@ -109,7 +110,7 @@ private ProjectOperationResponse register(String orgName, String projectName, St TriggersApi triggerResource = new TriggersApi(getApiClient()); while (true) { - List triggers = triggerResource.list(orgName, projectName, repoName); + List triggers = triggerResource.listTriggers(orgName, projectName, repoName); if (triggers != null && triggers.size() == expectedTriggerCount) { break; } @@ -136,23 +137,29 @@ private ProjectOperationResponse createProject(String orgName, String projectNam // --- ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - return projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRepositories(Collections.singletonMap(repoName, new RepositoryEntry() - .setUrl(gitUrl) - .setBranch("master")))); + return projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .repositories(Collections.singletonMap(repoName, new RepositoryEntry() + .url(gitUrl) + .branch("master")))); } private Map readPolicy(String file) throws Exception { - URL url = AnsiblePolicyIT.class.getResource(file); + URL url = TriggerIT.class.getResource(file); return fromJson(new File(url.toURI())); } - private List waitForProcs(UUID id, int expectedCount, StatusEnum expectedStatus) throws Exception { - ProcessApi processApi = new ProcessApi(getApiClient()); + private List waitForProcs(UUID projectId, int expectedCount, StatusEnum expectedStatus) throws Exception { + ProcessV2Api processApi = new ProcessV2Api(getApiClient()); + + ProcessListFilter filter = ProcessListFilter.builder() + .projectId(projectId) + .limit(10) + .offset(0) + .build(); while (true) { - List l = processApi.list(null, null, id, null, null, null, null, null, null, 10, 0); + List l = processApi.listProcesses(filter); if (l != null && l.size() == expectedCount && allHasStatus(l, expectedStatus)) { return l; } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/TriggersRefreshIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/TriggersRefreshIT.java index 046493dc87..6f3e18fcbf 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/TriggersRefreshIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/TriggersRefreshIT.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.common.IOUtils; import com.walmartlabs.concord.sdk.Constants; import org.eclipse.jgit.api.Git; @@ -63,34 +63,34 @@ public void testTriggerRepoRefresh() throws Exception { // --- UsersApi usersApi = new UsersApi(getApiClient()); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(username) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(username) + .type(CreateUserRequest.TypeEnum.LOCAL)); ApiKeysApi apiKeysApi = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse cakr = apiKeysApi.create(new CreateApiKeyRequest() - .setUsername(username)); + CreateApiKeyResponse cakr = apiKeysApi.createUserApiKey(new CreateApiKeyRequest() + .username(username)); // --- OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - if (orgApi.get(orgName) == null) { - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + if (orgApi.getOrg(orgName) == null) { + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); } TeamsApi teamsApi = new TeamsApi(getApiClient()); - teamsApi.addUsers(orgName, "default", false, Collections.singletonList(new TeamUserEntry() - .setUsername(username) - .setRole(TeamUserEntry.RoleEnum.MEMBER) - .setUserType(TeamUserEntry.UserTypeEnum.LOCAL))); + teamsApi.addUsersToTeam(orgName, "default", false, Collections.singletonList(new TeamUserEntry() + .username(username) + .role(TeamUserEntry.RoleEnum.MEMBER) + .userType(TeamUserEntry.UserTypeEnum.LOCAL))); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setVisibility(ProjectEntry.VisibilityEnum.PUBLIC) - .setRepositories(Collections.singletonMap(repoName, new RepositoryEntry() - .setUrl(gitUrl) - .setBranch("master")))); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .visibility(ProjectEntry.VisibilityEnum.PUBLIC) + .repositories(Collections.singletonMap(repoName, new RepositoryEntry() + .url(gitUrl) + .branch("master")))); // --- @@ -127,7 +127,7 @@ public void testTriggerRepoRefresh() throws Exception { private 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/UserManagementIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/UserManagementIT.java index 7d10cd9131..c1b3e4cf46 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/UserManagementIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/UserManagementIT.java @@ -20,8 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import java.util.Collections; @@ -36,20 +35,20 @@ public void test() throws Exception { String username = "user_" + randomString(); - CreateUserResponse cur = usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(username) - .setType(CreateUserRequest.TypeEnum.LOCAL)); - assertTrue(cur.isOk()); + CreateUserResponse cur = usersApi.createOrUpdateUser(new CreateUserRequest() + .username(username) + .type(CreateUserRequest.TypeEnum.LOCAL)); + assertTrue(cur.getOk()); // --- ApiKeysApi apiKeyResource = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse cakr = apiKeyResource.create(new CreateApiKeyRequest().setUsername(username)); - assertTrue(cakr.isOk()); + CreateApiKeyResponse cakr = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(username)); + assertTrue(cakr.getOk()); // --- - usersApi.delete(cur.getId()); + usersApi.deleteUser(cur.getId()); } @Test @@ -57,14 +56,14 @@ public void testAdmins() throws Exception { UsersApi usersApi = new UsersApi(getApiClient()); String userAName = "userA_" + randomString(); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userAName) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userAName) + .type(CreateUserRequest.TypeEnum.LOCAL)); // --- ApiKeysApi apiKeyResource = new ApiKeysApi(getApiClient()); - CreateApiKeyResponse apiKey = apiKeyResource.create(new CreateApiKeyRequest().setUsername(userAName)); + CreateApiKeyResponse apiKey = apiKeyResource.createUserApiKey(new CreateApiKeyRequest().username(userAName)); // --- @@ -72,9 +71,9 @@ public void testAdmins() throws Exception { String userBName = "userB_" + randomString(); try { - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userBName) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userBName) + .type(CreateUserRequest.TypeEnum.LOCAL)); fail("should fail"); } catch (ApiException e) { } @@ -82,19 +81,19 @@ public void testAdmins() throws Exception { // --- resetApiKey(); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userAName) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userAName) + .type(CreateUserRequest.TypeEnum.LOCAL)); usersApi.updateUserRoles(userAName, new UpdateUserRolesRequest() - .setRoles(Collections.singletonList("concordAdmin"))); + .roles(Collections.singleton("concordAdmin"))); // --- setApiKey(apiKey.getKey()); - usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userBName) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userBName) + .type(CreateUserRequest.TypeEnum.LOCAL)); } @Test @@ -105,25 +104,25 @@ public void testWithRoles() throws Exception { String username = "user_" + randomString(); RolesApi rolesApi = new RolesApi(getApiClient()); - RoleOperationResponse ror = rolesApi.createOrUpdate(new RoleEntry().setName(roleName)); + RoleOperationResponse ror = rolesApi.createOrUpdateRole(new RoleEntry().name(roleName)); assertEquals(RoleOperationResponse.ResultEnum.CREATED, ror.getResult()); - CreateUserResponse cur = usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(username) - .setType(CreateUserRequest.TypeEnum.LOCAL) - .setRoles(Collections.singletonList(roleName))); - assertTrue(cur.isOk()); + CreateUserResponse cur = usersApi.createOrUpdateUser(new CreateUserRequest() + .username(username) + .type(CreateUserRequest.TypeEnum.LOCAL) + .roles(Collections.singleton(roleName))); + assertTrue(cur.getOk()); UserEntry userEntry = usersApi.findByUsername(username); assertNotNull(userEntry); - assertEquals(roleName, userEntry.getRoles().get(0).getName()); + assertEquals(roleName, userEntry.getRoles().iterator().next().getName()); // --- - DeleteUserResponse dur = usersApi.delete(cur.getId()); - assertTrue(dur.isOk()); + DeleteUserResponse dur = usersApi.deleteUser(cur.getId()); + assertTrue(dur.getOk()); - GenericOperationResult delete = rolesApi.delete(roleName); + GenericOperationResult delete = rolesApi.deleteRole(roleName); assertEquals(GenericOperationResult.ResultEnum.DELETED, delete.getResult()); } @@ -132,9 +131,9 @@ public void testSpecialCharactersInUsernames() throws Exception { String userName = "usEr_" + randomString() + "@domain.local"; UsersApi usersApi = new UsersApi(getApiClient()); - CreateUserResponse cur = usersApi.createOrUpdate(new CreateUserRequest() - .setUsername(userName) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + CreateUserResponse cur = usersApi.createOrUpdateUser(new CreateUserRequest() + .username(userName) + .type(CreateUserRequest.TypeEnum.LOCAL)); assertNotNull(cur.getId()); UserEntry e = usersApi.findByUsername(userName); diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/ValidationIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/ValidationIT.java index c5283dd13d..fbb2b13300 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/ValidationIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/ValidationIT.java @@ -20,11 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.CreateUserRequest; -import com.walmartlabs.concord.client.ProjectEntry; -import com.walmartlabs.concord.client.ProjectsApi; -import com.walmartlabs.concord.client.UsersApi; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -37,15 +33,15 @@ public void testProjectCreation() throws Exception { ProjectsApi projectsApi = new ProjectsApi(getApiClient()); try { - ProjectEntry req = new ProjectEntry().setName("@123_123"); - projectsApi.createOrUpdate("Default", req); + ProjectEntry req = new ProjectEntry().name("@123_123"); + projectsApi.createOrUpdateProject("Default", req); fail("Should fail with a validation error"); } catch (ApiException e) { assertInvalidRequest(e); } - ProjectEntry req = new ProjectEntry().setName("aProperName@" + System.currentTimeMillis()); - projectsApi.createOrUpdate("Default", req); + ProjectEntry req = new ProjectEntry().name("aProperName@" + System.currentTimeMillis()); + projectsApi.createOrUpdateProject("Default", req); } @Test @@ -84,8 +80,8 @@ public void testInvalidUsername() { } try { - usersApi.createOrUpdate(new CreateUserRequest().setUsername(longUsername) - .setType(CreateUserRequest.TypeEnum.LOCAL)); + usersApi.createOrUpdateUser(new CreateUserRequest().username(longUsername) + .type(CreateUserRequest.TypeEnum.LOCAL)); fail("Should fail with a validation error"); } catch (ApiException e) { assertInvalidRequest(e); diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/VariablesIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/VariablesIT.java index c45e481f13..337bf01e00 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/VariablesIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/VariablesIT.java @@ -21,7 +21,7 @@ */ import com.google.common.collect.ImmutableMap; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import java.util.HashMap; @@ -39,29 +39,28 @@ public void test() throws Exception { String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setCfg(ImmutableMap.of("arguments", + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .cfg(ImmutableMap.of("arguments", ImmutableMap.of("nested", ImmutableMap.of( "y", "cba", "z", true)))) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); // --- byte[] payload = archive(VariablesIT.class.getResource("variables").toURI()); - ProcessApi processApi = new ProcessApi(getApiClient()); Map input = new HashMap<>(); input.put("org", orgName); input.put("project", projectName); input.put("archive", payload); StartProcessResponse spr = start(payload); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*x=123.*", ab); assertLog(".*y=abc.*", ab); @@ -78,14 +77,14 @@ public void testCrypto() throws Exception { String secretValue = "secret_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); EncryptValueResponse evr = projectsApi.encrypt(orgName, projectName, secretValue); String encryptedValue = evr.getData(); - projectsApi.updateConfiguration(orgName, projectName, + projectsApi.updateProjectConfiguration(orgName, projectName, ImmutableMap.of("arguments", ImmutableMap.of("mySecret", encryptedValue))); @@ -93,16 +92,15 @@ public void testCrypto() throws Exception { byte[] payload = archive(VariablesIT.class.getResource("crypto").toURI()); - ProcessApi processApi = new ProcessApi(getApiClient()); Map input = new HashMap<>(); input.put("org", orgName); input.put("project", projectName); input.put("archive", payload); StartProcessResponse spr = start(input); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*" + secretValue + ".*", ab); } @@ -128,10 +126,9 @@ public void testArrayInterpolation() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*" + varA + ".*" + varB + ".*", ab); } @@ -146,10 +143,9 @@ public void testSetVar() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*shouldBeNull: $", ab); assertLog(".*nested\\.var: nested\\.var.*", ab); } @@ -165,10 +161,9 @@ public void testGetNestedVar() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*param1: 1$", ab); assertLog(".*defaultValue: 101$", ab); assertLog(".*defaultValueFromUnknown: 102$", ab); @@ -186,10 +181,9 @@ public void testSetDependentVars() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*obj.x: 123$", ab); assertLog(".*obj.name: Concord$", ab); assertLog(".*obj.msg: Hello, Concord$", ab); @@ -206,10 +200,9 @@ public void testSetDependentVars2() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*event: \\{branch=master\\}$", ab); assertLog(".*commitEvent.event: push$", ab); assertLog(".*commitEvent.branch: master$", ab); diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/VariablesInjectionIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/VariablesInjectionIT.java index 4eda795112..4b4eb871fc 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/VariablesInjectionIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/VariablesInjectionIT.java @@ -20,9 +20,8 @@ * ===== */ -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; -import com.walmartlabs.concord.client.StartProcessResponse; +import com.walmartlabs.concord.client2.ProcessEntry; +import com.walmartlabs.concord.client2.StartProcessResponse; import org.junit.jupiter.api.Test; import static com.walmartlabs.concord.it.common.ITUtils.archive; @@ -37,13 +36,12 @@ public void test() throws Exception { byte[] payload = archive(VariablesInjectionIT.class.getResource("inject").toURI(), ITConstants.DEPENDENCIES_DIR); - ProcessApi processApi = new ProcessApi(getApiClient()); StartProcessResponse spr = start(payload); assertNotNull(spr.getInstanceId()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Hello, Concord!.*", ab); assertLog(".*Hello, world!!!.*", ab); diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/WithItemsIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/WithItemsIT.java index 5c441b36b1..e8f688e391 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/WithItemsIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/WithItemsIT.java @@ -21,7 +21,7 @@ */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import java.net.URI; @@ -35,7 +35,7 @@ public class WithItemsIT extends AbstractServerIT { @Test public void testAnsible() throws Exception { - URI uri = ProcessIT.class.getResource("ansibleWithItems").toURI(); + URI uri = WithItemsIT.class.getResource("ansibleWithItems").toURI(); byte[] payload = archive(uri, ITConstants.DEPENDENCIES_DIR); // --- @@ -46,13 +46,12 @@ public void testAnsible() 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(".*Hello!.*", ab); assertLog(".*Hi there!.*", ab); assertLog(".*Howdy!.*", ab); @@ -60,7 +59,7 @@ public void testAnsible() throws Exception { @Test public void testForms() throws Exception { - URI uri = ProcessIT.class.getResource("formsWithItems").toURI(); + URI uri = WithItemsIT.class.getResource("formsWithItems").toURI(); byte[] payload = archive(uri); // --- @@ -71,36 +70,35 @@ public void testForms() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); + waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); // --- ProcessFormsApi formResource = new ProcessFormsApi(getApiClient()); - List forms = formResource.list(spr.getInstanceId()); + List forms = formResource.listProcessForms(spr.getInstanceId()); assertEquals(1, forms.size()); - formResource.submit(spr.getInstanceId(), forms.get(0).getName(), Collections.emptyMap()); + formResource.submitForm(spr.getInstanceId(), forms.get(0).getName(), Collections.emptyMap()); - ProcessEntry pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); - byte[] ab = getLog(pir.getLogFileName()); + ProcessEntry pir = waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Hello!.*", ab); // --- - forms = formResource.list(spr.getInstanceId()); + forms = formResource.listProcessForms(spr.getInstanceId()); assertEquals(1, forms.size()); - formResource.submit(spr.getInstanceId(), forms.get(0).getName(), Collections.emptyMap()); + formResource.submitForm(spr.getInstanceId(), forms.get(0).getName(), Collections.emptyMap()); - pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.FINISHED); - ab = getLog(pir.getLogFileName()); + pir = waitForStatus(getApiClient(), spr.getInstanceId(), ProcessEntry.StatusEnum.FINISHED); + ab = getLog(pir.getInstanceId()); assertLog(".*Hi there!.*", ab); } @Test public void testExternalItems() throws Exception { - URI uri = ProcessIT.class.getResource("externalWithItems").toURI(); + URI uri = WithItemsIT.class.getResource("externalWithItems").toURI(); byte[] payload = archive(uri); // --- @@ -114,12 +112,11 @@ public void testExternalItems() throws Exception { // --- - ProcessApi processApi = new ProcessApi(getApiClient()); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); // --- - byte[] ab = getLog(pir.getLogFileName()); + byte[] ab = getLog(pir.getInstanceId()); assertLog(".*Hello!.*", ab); assertLog(".*Hi there!.*", ab); assertLog(".*Howdy!.*", ab); @@ -127,7 +124,7 @@ public void testExternalItems() throws Exception { @Test public void testLotsOfItems() throws Exception { - URI uri = ProcessIT.class.getResource("externalWithItems").toURI(); + URI uri = WithItemsIT.class.getResource("externalWithItems").toURI(); byte[] payload = archive(uri); // --- @@ -145,14 +142,13 @@ public void testLotsOfItems() 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()); } @Test public void testSubsequentCalls() throws Exception { - URI uri = ProcessIT.class.getResource("multipleWithItems").toURI(); + URI uri = WithItemsIT.class.getResource("multipleWithItems").toURI(); byte[] payload = archive(uri); // --- @@ -163,8 +159,7 @@ public void testSubsequentCalls() 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()); } } diff --git a/it/server/src/test/java/com/walmartlabs/concord/it/server/WorkspacePolicyIT.java b/it/server/src/test/java/com/walmartlabs/concord/it/server/WorkspacePolicyIT.java index 043ce23585..74a77bb93a 100644 --- a/it/server/src/test/java/com/walmartlabs/concord/it/server/WorkspacePolicyIT.java +++ b/it/server/src/test/java/com/walmartlabs/concord/it/server/WorkspacePolicyIT.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import org.junit.jupiter.api.Test; import java.io.File; @@ -40,51 +40,49 @@ public void test() throws Exception { String orgName = "org_" + randomString(); OrganizationsApi orgApi = new OrganizationsApi(getApiClient()); - orgApi.createOrUpdate(new OrganizationEntry().setName(orgName)); + orgApi.createOrUpdateOrg(new OrganizationEntry().name(orgName)); // --- String projectName = "project_" + randomString(); ProjectsApi projectsApi = new ProjectsApi(getApiClient()); - projectsApi.createOrUpdate(orgName, new ProjectEntry() - .setName(projectName) - .setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); + projectsApi.createOrUpdateProject(orgName, new ProjectEntry() + .name(projectName) + .rawPayloadMode(ProjectEntry.RawPayloadModeEnum.EVERYONE)); // --- String policyName = "policy_" + randomString(); PolicyApi policyResource = new PolicyApi(getApiClient()); - policyResource.createOrUpdate(new PolicyEntry().setName(policyName).setRules(readPolicy("workspacePolicy/test-policy.json"))); - policyResource.link(policyName, new PolicyLinkEntry().setOrgName(orgName)); + policyResource.createOrUpdatePolicy(new PolicyEntry().name(policyName).rules(readPolicy("workspacePolicy/test-policy.json"))); + policyResource.linkPolicy(policyName, new PolicyLinkEntry().orgName(orgName)); // --- - byte[] payload = archive(ProcessIT.class.getResource("workspacePolicy").toURI()); + byte[] payload = archive(WorkspacePolicyIT.class.getResource("workspacePolicy").toURI()); Map input = new HashMap<>(); input.put("org", orgName); input.put("project", projectName); input.put("archive", payload); - ProcessApi processApi = new ProcessApi(getApiClient()); - StartProcessResponse spr = start(input); - 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(".*Workspace policy violation.*", ab); // --- - policyResource.createOrUpdate(new PolicyEntry().setName(policyName).setRules(readPolicy("workspacePolicy/test-policy-relaxed.json"))); + policyResource.createOrUpdatePolicy(new PolicyEntry().name(policyName).rules(readPolicy("workspacePolicy/test-policy-relaxed.json"))); // --- spr = start(input); - ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId()); - ab = getLog(pir.getLogFileName()); + ProcessEntry pir = waitForCompletion(getApiClient(), spr.getInstanceId()); + ab = getLog(pir.getInstanceId()); assertLog(".*Hello!.*", ab); } diff --git a/it/tasks/client1-test/src/main/java/com/walmartlabs/concord/it/tasks/suspendtest/Client1TestTask.java b/it/tasks/client1-test/src/main/java/com/walmartlabs/concord/it/tasks/suspendtest/Client1TestTask.java index 95fc7d15d1..7ae5f0027f 100644 --- a/it/tasks/client1-test/src/main/java/com/walmartlabs/concord/it/tasks/suspendtest/Client1TestTask.java +++ b/it/tasks/client1-test/src/main/java/com/walmartlabs/concord/it/tasks/suspendtest/Client1TestTask.java @@ -20,7 +20,6 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; import com.walmartlabs.concord.client.ApiClientConfiguration; import com.walmartlabs.concord.client.ApiClientFactory; import com.walmartlabs.concord.client.ProcessApi; diff --git a/plugins/tasks/ansible/pom.xml b/plugins/tasks/ansible/pom.xml index f44699cdf4..8aa3fc196a 100644 --- a/plugins/tasks/ansible/pom.xml +++ b/plugins/tasks/ansible/pom.xml @@ -25,7 +25,7 @@ com.walmartlabs.concord - concord-client + concord-client2 provided diff --git a/plugins/tasks/ansible/src/main/java/com/walmartlabs/concord/plugins/ansible/AnsibleCallbacks.java b/plugins/tasks/ansible/src/main/java/com/walmartlabs/concord/plugins/ansible/AnsibleCallbacks.java index 7863b857bf..64a1df65c7 100644 --- a/plugins/tasks/ansible/src/main/java/com/walmartlabs/concord/plugins/ansible/AnsibleCallbacks.java +++ b/plugins/tasks/ansible/src/main/java/com/walmartlabs/concord/plugins/ansible/AnsibleCallbacks.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.ProcessEventsApi; +import com.walmartlabs.concord.client2.ProcessEventsApi; import com.walmartlabs.concord.sdk.MapUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/plugins/tasks/ansible/src/main/java/com/walmartlabs/concord/plugins/ansible/AnsibleTask.java b/plugins/tasks/ansible/src/main/java/com/walmartlabs/concord/plugins/ansible/AnsibleTask.java index f648c48352..923a6f4f26 100644 --- a/plugins/tasks/ansible/src/main/java/com/walmartlabs/concord/plugins/ansible/AnsibleTask.java +++ b/plugins/tasks/ansible/src/main/java/com/walmartlabs/concord/plugins/ansible/AnsibleTask.java @@ -22,8 +22,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.client.ProcessEventsApi; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.plugins.ansible.secrets.AnsibleSecretService; import com.walmartlabs.concord.runtime.v2.sdk.TaskResult; import com.walmartlabs.concord.sdk.Constants; diff --git a/plugins/tasks/ansible/src/main/java/com/walmartlabs/concord/plugins/ansible/EventSender.java b/plugins/tasks/ansible/src/main/java/com/walmartlabs/concord/plugins/ansible/EventSender.java index 01f0420884..0ac27ed854 100644 --- a/plugins/tasks/ansible/src/main/java/com/walmartlabs/concord/plugins/ansible/EventSender.java +++ b/plugins/tasks/ansible/src/main/java/com/walmartlabs/concord/plugins/ansible/EventSender.java @@ -22,9 +22,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.ProcessEventRequest; -import com.walmartlabs.concord.client.ProcessEventsApi; +import com.walmartlabs.concord.client2.ApiException; +import com.walmartlabs.concord.client2.ProcessEventRequest; +import com.walmartlabs.concord.client2.ProcessEventsApi; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/plugins/tasks/ansible/src/main/java/com/walmartlabs/concord/plugins/ansible/v1/AnsibleTaskV1.java b/plugins/tasks/ansible/src/main/java/com/walmartlabs/concord/plugins/ansible/v1/AnsibleTaskV1.java index d4485e73dd..6bdde222c0 100644 --- a/plugins/tasks/ansible/src/main/java/com/walmartlabs/concord/plugins/ansible/v1/AnsibleTaskV1.java +++ b/plugins/tasks/ansible/src/main/java/com/walmartlabs/concord/plugins/ansible/v1/AnsibleTaskV1.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.ApiClientFactory; +import com.walmartlabs.concord.client2.ApiClientFactory; import com.walmartlabs.concord.sdk.ApiConfiguration; import com.walmartlabs.concord.sdk.DockerService; import com.walmartlabs.concord.sdk.SecretService; diff --git a/plugins/tasks/ansible/src/main/java/com/walmartlabs/concord/plugins/ansible/v1/RunPlaybookTask2.java b/plugins/tasks/ansible/src/main/java/com/walmartlabs/concord/plugins/ansible/v1/RunPlaybookTask2.java index 3a91a460d2..9e6410ee53 100644 --- a/plugins/tasks/ansible/src/main/java/com/walmartlabs/concord/plugins/ansible/v1/RunPlaybookTask2.java +++ b/plugins/tasks/ansible/src/main/java/com/walmartlabs/concord/plugins/ansible/v1/RunPlaybookTask2.java @@ -20,9 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.client.ApiClientConfiguration; -import com.walmartlabs.concord.client.ApiClientFactory; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.plugins.ansible.*; import com.walmartlabs.concord.runtime.v2.sdk.TaskResult; import com.walmartlabs.concord.sdk.*; @@ -96,7 +94,7 @@ public void execute(Context ctx) throws Exception { private void run(Context ctx, Path workDir, Map args) throws Exception { ApiClient apiClient = apiClientFactory.create(ApiClientConfiguration.builder() - .context(context) + .sessionToken(ContextUtils.getSessionToken(context)) .build()); AnsibleSecretServiceV1 ansibleSecretService = new AnsibleSecretServiceV1(context, secretService); @@ -109,7 +107,7 @@ private void run(Context ctx, Path workDir, Map args) throws Exc String orgName = projectInfo != null ? (String) projectInfo.get("orgName") : null; AnsibleContext context = AnsibleContext.builder() - .apiBaseUrl(apiClient.getBasePath()) + .apiBaseUrl(apiClient.getBaseUrl()) .instanceId(UUID.fromString(txId)) .workDir(workDir) .tmpDir(createTmpDir(workDir)) diff --git a/plugins/tasks/ansible/src/main/java/com/walmartlabs/concord/plugins/ansible/v2/AnsibleTaskV2.java b/plugins/tasks/ansible/src/main/java/com/walmartlabs/concord/plugins/ansible/v2/AnsibleTaskV2.java index 6455f8a483..cfae6e0b0c 100644 --- a/plugins/tasks/ansible/src/main/java/com/walmartlabs/concord/plugins/ansible/v2/AnsibleTaskV2.java +++ b/plugins/tasks/ansible/src/main/java/com/walmartlabs/concord/plugins/ansible/v2/AnsibleTaskV2.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; +import com.walmartlabs.concord.client2.ApiClient; import com.walmartlabs.concord.common.ConfigurationUtils; import com.walmartlabs.concord.plugins.ansible.*; import com.walmartlabs.concord.plugins.ansible.secrets.AnsibleSecretService; @@ -69,7 +69,7 @@ public TaskResult execute(Variables input) throws Exception { boolean debug = getBoolean(ConfigurationUtils.deepMerge(defaults, in), TaskParams.DEBUG_KEY.getKey(), false) || context.processConfiguration().debug(); AnsibleContext ctx = AnsibleContext.builder() - .apiBaseUrl(apiClient.getBasePath()) + .apiBaseUrl(apiClient.getBaseUrl()) .instanceId(instanceId) .workDir(workDir) .tmpDir(tmpDir) diff --git a/plugins/tasks/concord/pom.xml b/plugins/tasks/concord/pom.xml index 550db22cbf..99806d7ef0 100644 --- a/plugins/tasks/concord/pom.xml +++ b/plugins/tasks/concord/pom.xml @@ -36,7 +36,7 @@ com.walmartlabs.concord - concord-client + concord-client2 provided @@ -66,11 +66,6 @@ org.apache.commons commons-compress - - com.squareup.okhttp - okhttp - 2.7.5 - org.junit.jupiter diff --git a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/AbstractConcordTask.java b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/AbstractConcordTask.java index 3cbee36db5..4ad054c1a1 100644 --- a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/AbstractConcordTask.java +++ b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/AbstractConcordTask.java @@ -20,17 +20,13 @@ * ===== */ -import com.fasterxml.jackson.databind.ObjectMapper; -import com.squareup.okhttp.*; -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.client.ImmutableApiClientConfiguration.Builder; +import com.walmartlabs.concord.client2.*; 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 com.walmartlabs.concord.sdk.Task; import javax.inject.Inject; -import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -39,8 +35,6 @@ public abstract class AbstractConcordTask implements Task { - private final ObjectMapper objectMapper = new ObjectMapper(); - protected static final String API_KEY = "apiKey"; @Inject @@ -54,9 +48,9 @@ protected T withClient(Context ctx, CheckedFunction f) throws } protected T withClient(Context ctx, boolean withApiKey, CheckedFunction f) throws Exception { - Builder builder = ApiClientConfiguration.builder() + ImmutableApiClientConfiguration.Builder builder = ApiClientConfiguration.builder() .baseUrl(getBaseUrl(ctx)) - .context(ctx); + .sessionToken(ContextUtils.getSessionToken(ctx)); if (withApiKey) { builder.apiKey(getApiKey(ctx)); @@ -67,56 +61,6 @@ protected T withClient(Context ctx, boolean withApiKey, CheckedFunction T request(Context ctx, String uri, String method, Map input, Class entityType) throws Exception { - return withClient(ctx, client -> { - RequestBody request = input != null ? ClientUtils.createMultipartBody(input).build() : null; - - Request.Builder b = new Request.Builder() - .url(client.getBasePath() + uri) - .header("Accept", "*/*") - .method(method, request); - - // we're going to use the "raw" OkHttpClient, so we need to set up the auth manually - String apiKey = getApiKey(ctx); - if (apiKey != null) { - b.header("Authorization", apiKey); - } else { - b.header(Constants.Headers.SESSION_TOKEN, apiCfg.getSessionToken(ctx)); - } - - OkHttpClient ok = client.getHttpClient(); - Response resp = ok.newCall(b.build()).execute(); - assertResponse(resp); - - if (resp.code() == 204) { // HTTP "No Content" - return null; - } - - try (ResponseBody body = resp.body()) { - return objectMapper.readValue(body.byteStream(), entityType); - } - }); - } - - protected void assertResponse(Response resp) throws IOException { - int code = resp.code(); - if (code < 200 || code >= 400) { - try (ResponseBody body = resp.body()) { - if (isJson(resp)) { - Object details = objectMapper.readValue(body.byteStream(), Object.class); - String msg = extractMessage(details); - throw new IOException(msg); - } else { - if (code == 401) { - throw new IOException("Request error: " + code + ", please verify the credentials used"); - } else { - throw new IOException("Request error: " + code); - } - } - } - } - } - private String getApiKey(Context ctx) { return (String) ctx.getVariable(API_KEY); } @@ -163,16 +107,6 @@ protected Map createCfg(Context ctx, String... keys) { return m; } - private static boolean isJson(Response resp) { - String contentType = resp.header("Content-Type"); - if (contentType == null) { - return false; - } - - contentType = contentType.toLowerCase(); - return contentType.contains("json"); - } - protected static String getBaseUrl(Context ctx) { Object v = ctx.getVariable(Keys.BASE_URL_KEY); if (v == null) { @@ -190,4 +124,4 @@ protected static String getBaseUrl(Context ctx) { protected interface CheckedFunction { R apply(T t) throws Exception; } -} +} \ No newline at end of file diff --git a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/ConcordTask.java b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/ConcordTask.java index 4fc7617fa2..331016caae 100644 --- a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/ConcordTask.java +++ b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/ConcordTask.java @@ -21,7 +21,7 @@ */ import com.fasterxml.jackson.databind.ObjectMapper; -import com.walmartlabs.concord.ApiException; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.common.IOUtils; import com.walmartlabs.concord.sdk.*; import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; @@ -30,8 +30,8 @@ import javax.inject.Named; import javax.xml.bind.DatatypeConverter; -import java.io.File; import java.io.IOException; +import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -164,8 +164,7 @@ public List listSubprocesses(@InjectVariable("context") Context ctx, Map return withClient(ctx, client -> { ProcessApi api = new ProcessApi(client); - List tl = tags != null ? new ArrayList<>(tags) : null; - List result = api.listSubprocesses(instanceId, tl); + List result = api.listSubprocesses(instanceId, tags); return result.stream() .map(ProcessEntry::getInstanceId) @@ -196,8 +195,8 @@ public Map waitForCompletion(@InjectVariable("context") Context c while (true) { try { ProcessEntry e = ClientUtils.withRetry(3, 1000, () -> withClient(ctx, client -> { - ProcessApi api = new ProcessApi(client); - return api.get(id); + ProcessV2Api api = new ProcessV2Api(client); + return api.getProcess(id, Collections.singleton("childrenIds")); })); ProcessEntry.StatusEnum s = e.getStatus(); @@ -357,7 +356,7 @@ private void start(Context ctx, Map cfg, UUID parentInstanceId) } } - StartProcessResponse resp = request(ctx, "/api/v1/process", "POST", input, StartProcessResponse.class); + StartProcessResponse resp = withClient(ctx, apiClient -> new ProcessApi(apiClient).startProcess(input)); UUID processId = resp.getInstanceId(); @@ -430,8 +429,8 @@ private void continueAfterSuspend(Context ctx) throws Exception { private Result continueAfterSuspend(Context ctx, Map cfg, UUID processId) throws Exception { ProcessEntry e = ClientUtils.withRetry(3, 1000, () -> withClient(ctx, client -> { - ProcessApi api = new ProcessApi(client); - return api.get(processId); + ProcessV2Api api = new ProcessV2Api(client); + return api.getProcess(processId, Collections.singleton("childrenIds")); })); ProcessEntry.StatusEnum s = e.getStatus(); @@ -531,19 +530,15 @@ private Map getOutVars(Context ctx, UUID processId) throws Excep return withClient(ctx, client -> { ProcessApi api = new ProcessApi(client); - File f = null; - try { - f = api.downloadAttachment(processId, "out.json"); + try (InputStream is = api.downloadAttachment(processId, "out.json")){ ObjectMapper om = new ObjectMapper(); - return om.readValue(f, Map.class); + return om.readValue(is, Map.class); } catch (ApiException e) { if (e.getCode() == 404) { return null; } log.error("Error while reading the out variables", e); throw e; - } finally { - IOUtils.delete(f); } }); } @@ -620,7 +615,7 @@ private Future forkOne(Context ctx, Map cfg) { return executor.submit(() -> withClient(ctx, client -> { ProcessApi api = new ProcessApi(client); - StartProcessResponse resp = api.fork(instanceId, req, false, null); + StartProcessResponse resp = api.fork(instanceId, false, null, req); log.info("Forked a child process: {} url: {}", resp.getInstanceId(), getProcessUrl(ctx, resp.getInstanceId())); return resp.getInstanceId(); })); @@ -945,4 +940,4 @@ private enum Action { FORK, KILL } -} +} \ No newline at end of file diff --git a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/ConcordTaskCommon.java b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/ConcordTaskCommon.java index 0d17b49adb..cab7964d6a 100644 --- a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/ConcordTaskCommon.java +++ b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/ConcordTaskCommon.java @@ -21,8 +21,7 @@ */ import com.fasterxml.jackson.databind.ObjectMapper; -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.ApiException; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.common.IOUtils; import com.walmartlabs.concord.runtime.v2.sdk.TaskResult; import com.walmartlabs.concord.sdk.Constants; @@ -32,8 +31,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; import java.io.IOException; +import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -108,8 +107,7 @@ public List listSubProcesses(ListSubProcesses in) throws Exception return withClient(client -> { ProcessApi api = new ProcessApi(client); - List tl = tags != null ? new ArrayList<>(tags) : null; - return api.listSubprocesses(instanceId, tl); + return api.listSubprocesses(instanceId, tags); }); } @@ -133,7 +131,7 @@ public Map waitForCompletion(List ids, long timeout, Functi ProcessEntry e = ClientUtils.withRetry(3, 1000, () -> withClient(client -> { ProcessV2Api api = new ProcessV2Api(client); - return api.get(id, Collections.emptyList()); + return api.getProcess(id, Collections.emptySet()); })); ProcessEntry.StatusEnum s = e.getStatus(); @@ -261,7 +259,7 @@ private TaskResult start(StartParams in, UUID parentInstanceId) throws Exception } StartProcessResponse resp = withClient(in.baseUrl(), in.apiKey(), - client -> RequestUtils.request(client, "/api/v1/process", "POST", input, StartProcessResponse.class)); + client -> new ProcessApi(client).startProcess(input)); UUID processId = resp.getInstanceId(); @@ -340,7 +338,7 @@ private Result continueAfterSuspend(String baseUrl, String apiKey, UUID processI ProcessEntry e = ClientUtils.withRetry(3, 1000, () -> withClient(baseUrl, apiKey, client -> { ProcessV2Api api = new ProcessV2Api(client); - return api.get(processId, Collections.emptyList()); + return api.getProcess(processId, Collections.emptySet()); })); ProcessEntry.StatusEnum s = e.getStatus(); @@ -436,19 +434,15 @@ private Map getOutVars(String baseUrl, String apiKey, UUID proce return withClient(baseUrl, apiKey, client -> { ProcessApi api = new ProcessApi(client); - File f = null; - try { - f = api.downloadAttachment(processId, "out.json"); + try (InputStream is = api.downloadAttachment(processId, "out.json")) { ObjectMapper om = new ObjectMapper(); - return om.readValue(f, Map.class); + return om.readValue(is, Map.class); } catch (ApiException e) { if (e.getCode() == 404) { return Collections.emptyMap(); } log.error("Error while reading the out variables", e); throw e; - } finally { - IOUtils.delete(f); } }); } @@ -508,7 +502,7 @@ private Future forkOne(ForkStartParams in) { return executor.submit(() -> withClient(in.apiKey(), client -> { ProcessApi api = new ProcessApi(client); - StartProcessResponse resp = api.fork(currentProcessId, req, false, null); + StartProcessResponse resp = api.fork(currentProcessId, false, null, req); log.info("Forked a child process: {}", LogTags.instanceId(resp.getInstanceId())); return resp.getInstanceId(); })); @@ -670,4 +664,4 @@ private T withClient(ApiClientConfiguration cfg, CheckedFunction { R apply(T t) throws Exception; } -} +} \ No newline at end of file diff --git a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/InventoryTask.java b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/InventoryTask.java index 4654453a80..7b426d9479 100644 --- a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/InventoryTask.java +++ b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/InventoryTask.java @@ -20,6 +20,7 @@ * ===== */ +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.sdk.Constants; import com.walmartlabs.concord.sdk.Context; import com.walmartlabs.concord.sdk.InjectVariable; @@ -146,7 +147,7 @@ public List query(@InjectVariable("context") Context ctx, private List execQuery(Context ctx, String orgName, String inventoryName, String queryName, Map params) throws Exception { return ClientUtils.withRetry(RETRY_COUNT, RETRY_INTERVAL, () -> withClient(ctx, client -> { InventoryQueriesApi api = new InventoryQueriesApi(client); - return api.exec(orgName, inventoryName, queryName, params); + return api.executeInventoryQuery(orgName, inventoryName, queryName, params); })); } diff --git a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/JsonStoreTaskCommon.java b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/JsonStoreTaskCommon.java index 12bd2201cc..336207e043 100644 --- a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/JsonStoreTaskCommon.java +++ b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/JsonStoreTaskCommon.java @@ -20,8 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.ApiException; +import com.walmartlabs.concord.client2.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,7 +53,7 @@ public boolean isStoreExists(String orgName, String storeName) throws ApiExcepti JsonStoreEntry entry = ClientUtils.withRetry(RETRY_COUNT, RETRY_INTERVAL, () -> { try { JsonStoreApi api = new JsonStoreApi(apiClient); - return api.get(orgName, storeName); + return api.getJsonStore(orgName, storeName); } catch (ApiException e) { if (e.getCode() == 404) { return null; @@ -92,7 +91,7 @@ public boolean isExists(String orgName, String storeName, String itemPath) throw public void createOrUpdateStore(String orgName, JsonStoreRequest request) throws ApiException { ClientUtils.withRetry(RETRY_COUNT, RETRY_INTERVAL, () -> { JsonStoreApi api = new JsonStoreApi(apiClient); - GenericOperationResult result = api.createOrUpdate(orgName, request); + GenericOperationResult result = api.createOrUpdateJsonStore(orgName, request); log.info("The store '{}' has been successfully {}", request.getName(), result.getResult()); return null; }); @@ -105,9 +104,9 @@ public void createOrUpdateQuery(String orgName, String storeName, String queryNa ClientUtils.withRetry(RETRY_COUNT, RETRY_INTERVAL, () -> { JsonStoreQueryApi api = new JsonStoreQueryApi(apiClient); JsonStoreQueryRequest request = new JsonStoreQueryRequest() - .setName(queryName) - .setText(queryText); - GenericOperationResult result = api.createOrUpdate(orgName, storeName, request); + .name(queryName) + .text(queryText); + GenericOperationResult result = api.createOrUpdateJsonStoreQuery(orgName, storeName, request); log.info("The query '{}' in store '{}' has been successfully {}", queryName, storeName, result.getResult()); return null; }); @@ -133,14 +132,14 @@ public void put(String orgName, String storeName, String itemPath, Object data, assertNotEmpty("Item path", itemPath); if (createStore && !isStoreExists(orgName, storeName)) { - createOrUpdateStore(orgName, new JsonStoreRequest().setName(storeName)); + createOrUpdateStore(orgName, new JsonStoreRequest().name(storeName)); } log.info("Updating item '{}' (org={}, store={})", itemPath, orgName, storeName); ClientUtils.withRetry(RETRY_COUNT, RETRY_INTERVAL, () -> { JsonStoreDataApi api = new JsonStoreDataApi(apiClient); - return api.data(orgName, storeName, itemPath, data); + return api.updateJsonStoreData(orgName, storeName, itemPath, data); }); } @@ -158,7 +157,7 @@ public Object get(String orgName, String storeName, String itemPath) throws ApiE // differences between two libraries (e.g. deserialization of integers/decimals) // hence we're using custom "request" method instead of the standard swagger-codegen client return ClientUtils.withRetry(RETRY_COUNT, RETRY_INTERVAL, () -> - RequestUtils.request(apiClient, "/api/v1/org/" + orgName + "/jsonstore/" + storeName + "/item/" + itemPath, "GET", null, Map.class)); + new JsonStoreDataApi(apiClient).getJsonStoreData(orgName, storeName, itemPath)); } /** @@ -173,7 +172,7 @@ public boolean delete(String orgName, String storeName, String itemPath) throws return ClientUtils.withRetry(RETRY_COUNT, RETRY_INTERVAL, () -> { JsonStoreDataApi api = new JsonStoreDataApi(apiClient); - GenericOperationResult result = api.delete(orgName, storeName, itemPath); + GenericOperationResult result = api.deleteJsonStoreDataItem(orgName, storeName, itemPath); return result != null && result.getResult() == GenericOperationResult.ResultEnum.DELETED; }); } @@ -190,7 +189,7 @@ public List executeQuery(String orgName, String storeName, String queryN return ClientUtils.withRetry(RETRY_COUNT, RETRY_INTERVAL, () -> { JsonStoreQueryApi api = new JsonStoreQueryApi(apiClient); - return api.exec(orgName, storeName, queryName, params); + return api.execJsonStoreQuery(orgName, storeName, queryName, params); }); } diff --git a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/ProjectTaskCommon.java b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/ProjectTaskCommon.java index 507cf75ba2..8b7f4b86fe 100644 --- a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/ProjectTaskCommon.java +++ b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/ProjectTaskCommon.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; +import com.walmartlabs.concord.client2.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -55,7 +55,7 @@ private void create(ProjectTaskParams in) throws Exception { entry.setName(in.projectName()); entry.setRepositories(in.repositories()); - ProjectOperationResponse resp = api.createOrUpdate(in.orgName(defaultOrg), entry); + ProjectOperationResponse resp = api.createOrUpdateProject(in.orgName(defaultOrg), entry); log.info("The project was created (or updated): {}", resp); } } diff --git a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/ProjectTaskParams.java b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/ProjectTaskParams.java index da226cc318..5d7d29f611 100644 --- a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/ProjectTaskParams.java +++ b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/ProjectTaskParams.java @@ -21,6 +21,7 @@ */ import com.fasterxml.jackson.databind.ObjectMapper; +import com.walmartlabs.concord.client2.RepositoryEntry; import com.walmartlabs.concord.runtime.v2.sdk.Variables; import com.walmartlabs.concord.sdk.MapUtils; diff --git a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/RepositoryRefreshTaskCommon.java b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/RepositoryRefreshTaskCommon.java index a2b6a94c04..f1dc9cdd09 100644 --- a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/RepositoryRefreshTaskCommon.java +++ b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/RepositoryRefreshTaskCommon.java @@ -20,8 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.ApiException; +import com.walmartlabs.concord.client2.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,7 +40,7 @@ public RepositoryRefreshTaskCommon(ApiClient client) { public void execute(RepositoryRefreshTaskParams in) throws ApiException { List repositoriesUUIDs = in.repositories(); log.info("Repository ids to refresh: {}",repositoriesUUIDs); - api.refreshRepository(repositoriesUUIDs); + api.refreshRepositoryV2(repositoriesUUIDs); log.info("Repository refresh completed"); } } diff --git a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/RequestUtils.java b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/RequestUtils.java deleted file mode 100644 index 7f0d90b8c2..0000000000 --- a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/RequestUtils.java +++ /dev/null @@ -1,127 +0,0 @@ -package com.walmartlabs.concord.client; - -/*- - * ***** - * Concord - * ----- - * Copyright (C) 2017 - 2020 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.fasterxml.jackson.databind.ObjectMapper; -import com.squareup.okhttp.OkHttpClient; -import com.squareup.okhttp.Request; -import com.squareup.okhttp.RequestBody; -import com.squareup.okhttp.Response; -import com.squareup.okhttp.ResponseBody; -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.auth.ApiKeyAuth; -import com.walmartlabs.concord.sdk.Constants; - -import java.io.IOException; -import java.util.List; -import java.util.Map; - -public final class RequestUtils { - - private static final ObjectMapper objectMapper = new ObjectMapper(); - - public static T request(ApiClient client, String uri, String method, Map input, Class entityType) throws Exception { - RequestBody request = input != null ? ClientUtils.createMultipartBody(input).build() : null; - - Request.Builder b = new Request.Builder() - .url(client.getBasePath() + uri) - .header("Accept", "*/*") - .method(method, request); - - // we're going to use the "raw" OkHttpClient, so we need to set up the auth manually - ApiKeyAuth apiKeyAuth = (ApiKeyAuth) client.getAuthentications().get("api_key"); - ApiKeyAuth sessionKeyAuth = (ApiKeyAuth) client.getAuthentications().get("session_key"); - - if (apiKeyAuth != null && apiKeyAuth.getApiKey() != null) { - b.header("Authorization", apiKeyAuth.getApiKey()); - } else if (sessionKeyAuth != null && sessionKeyAuth.getApiKey() != null) { - b.header(Constants.Headers.SESSION_TOKEN, sessionKeyAuth.getApiKey()); - } - - OkHttpClient ok = client.getHttpClient(); - Response resp = ok.newCall(b.build()).execute(); - assertResponse(resp); - - if (resp.code() == 204) { // HTTP "No Content" - return null; - } - - try (ResponseBody body = resp.body()) { - return objectMapper.readValue(body.byteStream(), entityType); - } - } - - public static void assertResponse(Response resp) throws ApiException, IOException { - int code = resp.code(); - if (code < 200 || code >= 400) { - try (ResponseBody body = resp.body()) { - if (isJson(resp)) { - Object details = objectMapper.readValue(body.byteStream(), Object.class); - String msg = extractMessage(details); - throw new ApiException(code, msg); - } else { - if (code == 401) { - throw new ApiException(code, "Request error: " + code + ", please verify the credentials used"); - } else { - throw new ApiException(code, "Request error: " + code); - } - } - } - } - } - - private static boolean isJson(Response resp) { - String contentType = resp.header("Content-Type"); - if (contentType == null) { - return false; - } - - contentType = contentType.toLowerCase(); - return contentType.contains("json"); - } - - @SuppressWarnings("unchecked") - private static String extractMessage(Object details) { - if (details == null) { - return null; - } - - if (details instanceof List) { - List l = (List) details; - if (!l.isEmpty()) { - Object o = l.get(0); - if (o instanceof Map) { - Map m = (Map) o; - Object msg = m.get("message"); - if (msg != null) { - return msg.toString(); - } - } - } - } - - return details.toString(); - } - - private RequestUtils() { - } -} diff --git a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/SecretsTask.java b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/SecretsTask.java index d20411836c..1c75357318 100644 --- a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/SecretsTask.java +++ b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/SecretsTask.java @@ -21,6 +21,8 @@ */ import com.walmartlabs.concord.client.v1.ContextBackedVariables; +import com.walmartlabs.concord.client2.ApiClientConfiguration; +import com.walmartlabs.concord.client2.ApiClientFactory; import com.walmartlabs.concord.runtime.v2.sdk.TaskResult; import com.walmartlabs.concord.sdk.Constants; import com.walmartlabs.concord.sdk.Context; @@ -46,8 +48,12 @@ public SecretsTask(ApiClientFactory clientFactory) { @Override public void execute(Context ctx) throws Exception { + ApiClientConfiguration c = ApiClientConfiguration.builder() + .sessionToken(ContextUtils.getSessionToken(ctx)) + .build(); + SecretsTaskParams in = SecretsTaskParams.of(new ContextBackedVariables(ctx)); - TaskResult.SimpleResult result = new SecretsTaskCommon(clientFactory.create(ctx), getProcessOrgName(ctx)) + TaskResult.SimpleResult result = new SecretsTaskCommon(clientFactory.create(c), getProcessOrgName(ctx)) .execute(in); ctx.setVariable(RESULT_KEY, result.toMap()); } diff --git a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/SecretsTaskCommon.java b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/SecretsTaskCommon.java index b731d4225d..2a5b066ccd 100644 --- a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/SecretsTaskCommon.java +++ b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/SecretsTaskCommon.java @@ -20,14 +20,14 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.ApiResponse; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.runtime.v2.sdk.TaskResult; import com.walmartlabs.concord.sdk.Constants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.*; @@ -87,15 +87,12 @@ private TaskResult.SimpleResult getAsString(AsStringParams in) { addIfPresent(params, Constants.Multipart.STORE_PASSWORD, in.storePassword()); - try { - ApiResponse r = postWithRetry( "/api/v1/org/" + orgName + "/secret/" + secretName + "/data", params); - - String data = r.getData(); - if (data == null) { - return Result.ok(); - } - - return Result.ok(r.getData()); + SecretsApi api = new SecretsApi(apiClient); + try (InputStream is = ClientUtils.withRetry(RETRY_COUNT, RETRY_INTERVAL, () -> api.getSecretData(orgName, secretName, params))) { + String data = new String(is.readAllBytes()); + return Result.ok(data); + } catch (IOException e) { + throw new RuntimeException(e); } catch (ApiException e) { return handleErrors(in, secretName, e); } @@ -110,7 +107,7 @@ private Map makeCreateParams(CreateParams in) { String secretName = in.secretName(); m.put(Constants.Multipart.NAME, secretName); - SecretEntry.TypeEnum secretType = in.secretType(); + SecretEntryV2.TypeEnum secretType = in.secretType(); m.put(Constants.Multipart.TYPE, secretType.toString()); switch (secretType) { @@ -142,12 +139,8 @@ private TaskResult.SimpleResult create(CreateParams in) throws Exception { private TaskResult.SimpleResult create(CreateParams in, Map params) throws Exception { String orgName = in.orgName(defaultOrg); - String secretName = in.secretName(); - ApiResponse r = post( "/api/v1/org/" + orgName + "/secret", params, SecretOperationResponse.class); - if (r.getStatusCode() >= 400) { - return handleErrors(in, secretName, r.getStatusCode(), r.getData().toString()); - } + new SecretsApi(apiClient).createSecret(orgName, params); log.info("New secret was successfully created: {}", params.get(Constants.Multipart.NAME)); return Result.ok(); @@ -194,7 +187,7 @@ private TaskResult.SimpleResult update(UpdateParams in) throws Exception { if(data != null){ addIfPresent(params, Constants.Multipart.TYPE, in.secretType()); } - post("/api/v2/org/" + orgName + "/secret/" + secretName, params, SecretOperationResponse.class); + new SecretsV2Api(apiClient).updateSecret(orgName, secretName, params); log.info("The secret was successfully updated: {}", secretName); return Result.ok(); @@ -234,15 +227,6 @@ private TaskResult.SimpleResult delete(SecretsTaskParams in) { } } - private ApiResponse post(String path, Map params, Class type) throws ApiException { - return ClientUtils.postData(apiClient, path, params, type); - } - - private ApiResponse postWithRetry(String path, Map params) throws ApiException { - return ClientUtils.withRetry(RETRY_COUNT, RETRY_INTERVAL, - () -> ClientUtils.postData(apiClient, path, params, String.class)); - } - private static void addIfPresent(Map m, String key, Object value) { if (value != null) { m.put(key, value); diff --git a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/SecretsTaskParams.java b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/SecretsTaskParams.java index f41dd022e2..37eda37cbd 100644 --- a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/SecretsTaskParams.java +++ b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/SecretsTaskParams.java @@ -20,6 +20,7 @@ * ===== */ +import com.walmartlabs.concord.client2.SecretEntryV2; import com.walmartlabs.concord.runtime.v2.sdk.Variables; import com.walmartlabs.concord.sdk.Constants; @@ -119,10 +120,10 @@ private CreateParams(Variables variables) { super(variables); } - public SecretEntry.TypeEnum secretType() { - String type = variables.getString(Constants.Multipart.TYPE, SecretEntry.TypeEnum.DATA.toString()); + public SecretEntryV2.TypeEnum secretType() { + String type = variables.getString(Constants.Multipart.TYPE, SecretEntryV2.TypeEnum.DATA.toString()); try { - return SecretEntry.TypeEnum.valueOf(type.trim().toUpperCase()); + return SecretEntryV2.TypeEnum.valueOf(type.trim().toUpperCase()); } catch (Exception e) { String message = String.format("Invalid argument '%s', allowed values are: 'data' (default), 'key_pair' and 'username_password'", type); throw new IllegalArgumentException(message); diff --git a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/v2/ConcordTaskV2.java b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/v2/ConcordTaskV2.java index 1a74677a79..6a05e2d56c 100644 --- a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/v2/ConcordTaskV2.java +++ b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/v2/ConcordTaskV2.java @@ -21,6 +21,7 @@ */ import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.runtime.v2.sdk.*; import javax.inject.Inject; diff --git a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/v2/JsonStoreTaskV2.java b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/v2/JsonStoreTaskV2.java index 079bcdd92b..3fafd3d78e 100644 --- a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/v2/JsonStoreTaskV2.java +++ b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/v2/JsonStoreTaskV2.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; +import com.walmartlabs.concord.client2.ApiClient; import com.walmartlabs.concord.client.JsonStoreTaskCommon; import com.walmartlabs.concord.runtime.v2.sdk.Context; import com.walmartlabs.concord.runtime.v2.sdk.Task; diff --git a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/v2/ProjectTaskV2.java b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/v2/ProjectTaskV2.java index 06027ddf7d..b6144f6b3c 100644 --- a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/v2/ProjectTaskV2.java +++ b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/v2/ProjectTaskV2.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; +import com.walmartlabs.concord.client2.ApiClient; import com.walmartlabs.concord.client.ProjectTaskCommon; import com.walmartlabs.concord.client.ProjectTaskParams; import com.walmartlabs.concord.runtime.v2.sdk.Context; diff --git a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/v2/RepositoryRefreshTaskV2.java b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/v2/RepositoryRefreshTaskV2.java index 098222111d..49cc561d55 100644 --- a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/v2/RepositoryRefreshTaskV2.java +++ b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/v2/RepositoryRefreshTaskV2.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; +import com.walmartlabs.concord.client2.ApiClient; import com.walmartlabs.concord.client.RepositoryRefreshTaskCommon; import com.walmartlabs.concord.client.RepositoryRefreshTaskParams; import com.walmartlabs.concord.runtime.v2.sdk.Task; diff --git a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/v2/SecretsTaskV2.java b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/v2/SecretsTaskV2.java index 51e59e7479..51b6d60b90 100644 --- a/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/v2/SecretsTaskV2.java +++ b/plugins/tasks/concord/src/main/java/com/walmartlabs/concord/client/v2/SecretsTaskV2.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; +import com.walmartlabs.concord.client2.ApiClient; import com.walmartlabs.concord.client.SecretsTaskCommon; import com.walmartlabs.concord.client.SecretsTaskParams; import com.walmartlabs.concord.runtime.v2.sdk.Context; diff --git a/plugins/tasks/files/src/main/java/com/walmartlabs/concord/plugins/file/v2/FilesTaskV2.java b/plugins/tasks/files/src/main/java/com/walmartlabs/concord/plugins/file/v2/FilesTaskV2.java index 0b623606dc..9ebc701baf 100644 --- a/plugins/tasks/files/src/main/java/com/walmartlabs/concord/plugins/file/v2/FilesTaskV2.java +++ b/plugins/tasks/files/src/main/java/com/walmartlabs/concord/plugins/file/v2/FilesTaskV2.java @@ -28,7 +28,6 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.nio.file.StandardCopyOption; @Named("files") diff --git a/plugins/tasks/kv/pom.xml b/plugins/tasks/kv/pom.xml index 1d42d040c9..b7676660fc 100644 --- a/plugins/tasks/kv/pom.xml +++ b/plugins/tasks/kv/pom.xml @@ -20,7 +20,7 @@ com.walmartlabs.concord - concord-client + concord-client2 provided diff --git a/plugins/tasks/kv/src/main/java/com/walmartlabs/concord/plugins/kv/KvTask.java b/plugins/tasks/kv/src/main/java/com/walmartlabs/concord/plugins/kv/KvTask.java index 0e40a186c9..ecd8574acc 100644 --- a/plugins/tasks/kv/src/main/java/com/walmartlabs/concord/plugins/kv/KvTask.java +++ b/plugins/tasks/kv/src/main/java/com/walmartlabs/concord/plugins/kv/KvTask.java @@ -20,9 +20,9 @@ * ===== */ -import com.walmartlabs.concord.client.ApiClientConfiguration; -import com.walmartlabs.concord.client.ApiClientFactory; -import com.walmartlabs.concord.client.ProcessKvStoreApi; +import com.walmartlabs.concord.client2.ApiClientConfiguration; +import com.walmartlabs.concord.client2.ApiClientFactory; +import com.walmartlabs.concord.client2.ProcessKvStoreApi; import com.walmartlabs.concord.sdk.Constants; import com.walmartlabs.concord.sdk.*; @@ -142,7 +142,7 @@ public long incLong(@InjectVariable("context") Context ctx, String key) throws E private ProcessKvStoreApi getApi(Context ctx) { return new ProcessKvStoreApi(apiClientFactory.create(ApiClientConfiguration.builder() - .context(ctx) + .sessionToken(ContextUtils.getSessionToken(ctx)) .build())); } } diff --git a/plugins/tasks/kv/src/main/java/com/walmartlabs/concord/plugins/kv/KvTaskUtils.java b/plugins/tasks/kv/src/main/java/com/walmartlabs/concord/plugins/kv/KvTaskUtils.java index 681e339a2a..083567e622 100644 --- a/plugins/tasks/kv/src/main/java/com/walmartlabs/concord/plugins/kv/KvTaskUtils.java +++ b/plugins/tasks/kv/src/main/java/com/walmartlabs/concord/plugins/kv/KvTaskUtils.java @@ -20,8 +20,8 @@ * ===== */ -import com.walmartlabs.concord.client.ClientUtils; -import com.walmartlabs.concord.client.ProcessKvStoreApi; +import com.walmartlabs.concord.client2.ClientUtils; +import com.walmartlabs.concord.client2.ProcessKvStoreApi; import java.util.UUID; @@ -30,7 +30,7 @@ public final class KvTaskUtils { public static void remove(ProcessKvStoreApi api, UUID txId, String key) throws Exception { assertValidKey(key); ClientUtils.withRetry(Constants.RETRY_COUNT, Constants.RETRY_INTERVAL, () -> { - api.removeKey(txId, key); + api.deleteKv(txId, key); return null; }); } @@ -38,7 +38,7 @@ public static void remove(ProcessKvStoreApi api, UUID txId, String key) throws E public static void putString(ProcessKvStoreApi api, UUID txId, String key, String value) throws Exception { assertValidKey(key); ClientUtils.withRetry(Constants.RETRY_COUNT, Constants.RETRY_INTERVAL, () -> { - api.putString(txId, key, value); + api.putKvString(txId, key, value); return null; }); } @@ -46,13 +46,13 @@ public static void putString(ProcessKvStoreApi api, UUID txId, String key, Strin public static String getString(ProcessKvStoreApi api, UUID txId, String key) throws Exception { assertValidKey(key); return ClientUtils.withRetry(Constants.RETRY_COUNT, Constants.RETRY_INTERVAL, () -> - api.getString(txId, key)); + api.getKvString(txId, key)); } public static void putLong(ProcessKvStoreApi api, UUID txId, String key, Long value) throws Exception { assertValidKey(key); ClientUtils.withRetry(Constants.RETRY_COUNT, Constants.RETRY_INTERVAL, () -> { - api.putLong(txId, key, value); + api.putKvLong(txId, key, value); return null; }); } @@ -60,13 +60,13 @@ public static void putLong(ProcessKvStoreApi api, UUID txId, String key, Long va public static Long getLong(ProcessKvStoreApi api, UUID txId, String key) throws Exception { assertValidKey(key); return ClientUtils.withRetry(Constants.RETRY_COUNT, Constants.RETRY_INTERVAL, () -> - api.getLong(txId, key)); + api.getKvLong(txId, key)); } public static long incLong(ProcessKvStoreApi api, UUID txId, String key) throws Exception { assertValidKey(key); return ClientUtils.withRetry(Constants.RETRY_COUNT, Constants.RETRY_INTERVAL, () -> - api.incLong(txId, key)); + api.incKvLong(txId, key)); } private static void assertValidKey(String s) { diff --git a/plugins/tasks/kv/src/main/java/com/walmartlabs/concord/plugins/kv/KvTaskV2.java b/plugins/tasks/kv/src/main/java/com/walmartlabs/concord/plugins/kv/KvTaskV2.java index 1249359b8a..9ebb718c28 100644 --- a/plugins/tasks/kv/src/main/java/com/walmartlabs/concord/plugins/kv/KvTaskV2.java +++ b/plugins/tasks/kv/src/main/java/com/walmartlabs/concord/plugins/kv/KvTaskV2.java @@ -20,8 +20,8 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.client.ProcessKvStoreApi; +import com.walmartlabs.concord.client2.ApiClient; +import com.walmartlabs.concord.client2.ProcessKvStoreApi; import com.walmartlabs.concord.runtime.v2.sdk.Context; import com.walmartlabs.concord.runtime.v2.sdk.Task; diff --git a/plugins/tasks/lock/pom.xml b/plugins/tasks/lock/pom.xml index 3384ab3850..179d3320b6 100644 --- a/plugins/tasks/lock/pom.xml +++ b/plugins/tasks/lock/pom.xml @@ -25,7 +25,7 @@ com.walmartlabs.concord - concord-client + concord-client2 provided diff --git a/plugins/tasks/lock/src/main/java/com/walmartlabs/concord/plugins/lock/LockTask.java b/plugins/tasks/lock/src/main/java/com/walmartlabs/concord/plugins/lock/LockTask.java index 6c5a86ab58..ca967b9d4c 100644 --- a/plugins/tasks/lock/src/main/java/com/walmartlabs/concord/plugins/lock/LockTask.java +++ b/plugins/tasks/lock/src/main/java/com/walmartlabs/concord/plugins/lock/LockTask.java @@ -20,13 +20,12 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.client.ApiClientFactory; +import com.walmartlabs.concord.client2.ApiClient; +import com.walmartlabs.concord.client2.ApiClientConfiguration; +import com.walmartlabs.concord.client2.ApiClientFactory; import com.walmartlabs.concord.runtime.v2.sdk.TaskResult; +import com.walmartlabs.concord.sdk.*; import com.walmartlabs.concord.sdk.Constants; -import com.walmartlabs.concord.sdk.Context; -import com.walmartlabs.concord.sdk.InjectVariable; -import com.walmartlabs.concord.sdk.Task; import javax.inject.Inject; import javax.inject.Named; @@ -47,7 +46,9 @@ public LockTask(ApiClientFactory apiClientFactory) { } public void lock(@InjectVariable("txId") String instanceId, String lockName, String scope) throws Exception { - ApiClient apiClient = apiClientFactory.create(context); + ApiClient apiClient = apiClientFactory.create(ApiClientConfiguration.builder() + .sessionToken(ContextUtils.getSessionToken(context)) + .build()); TaskResult taskResult = new LockTaskCommon(apiClient, UUID.fromString(instanceId)) .lock(lockName, scope); @@ -57,7 +58,9 @@ public void lock(@InjectVariable("txId") String instanceId, String lockName, Str } public void unlock(@InjectVariable("txId") String instanceId, String lockName, String scope) throws Exception { - ApiClient apiClient = apiClientFactory.create(context); + ApiClient apiClient = apiClientFactory.create(ApiClientConfiguration.builder() + .sessionToken(ContextUtils.getSessionToken(context)) + .build()); new LockTaskCommon(apiClient, UUID.fromString(instanceId)) .unlock(lockName, scope); diff --git a/plugins/tasks/lock/src/main/java/com/walmartlabs/concord/plugins/lock/LockTaskCommon.java b/plugins/tasks/lock/src/main/java/com/walmartlabs/concord/plugins/lock/LockTaskCommon.java index 8e6e4148fa..04c27eae3f 100644 --- a/plugins/tasks/lock/src/main/java/com/walmartlabs/concord/plugins/lock/LockTaskCommon.java +++ b/plugins/tasks/lock/src/main/java/com/walmartlabs/concord/plugins/lock/LockTaskCommon.java @@ -20,9 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.runtime.v2.sdk.TaskResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,7 +56,7 @@ public TaskResult lock(String lockName, String lockScope) throws ApiException { LockResult lock = withRetry(() -> lockApi.tryLock(instanceId, lockName, checkScope(lockScope))); - boolean result = lock.isAcquired(); + boolean result = lock.getAcquired(); if (!result) { withRetry(() -> { processApi.setWaitCondition(instanceId, createCondition(lock.getInfo())); diff --git a/plugins/tasks/lock/src/main/java/com/walmartlabs/concord/plugins/lock/v2/LockTaskV2.java b/plugins/tasks/lock/src/main/java/com/walmartlabs/concord/plugins/lock/v2/LockTaskV2.java index 3856036f1e..27ba4f7133 100644 --- a/plugins/tasks/lock/src/main/java/com/walmartlabs/concord/plugins/lock/v2/LockTaskV2.java +++ b/plugins/tasks/lock/src/main/java/com/walmartlabs/concord/plugins/lock/v2/LockTaskV2.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; +import com.walmartlabs.concord.client2.ApiClient; import com.walmartlabs.concord.plugins.lock.LockTaskCommon; import com.walmartlabs.concord.plugins.lock.TaskParams; import com.walmartlabs.concord.runtime.v2.sdk.Context; diff --git a/plugins/tasks/lock/src/main/java/com/walmartlabs/concord/plugins/lock/v2/UnlockTaskV2.java b/plugins/tasks/lock/src/main/java/com/walmartlabs/concord/plugins/lock/v2/UnlockTaskV2.java index 7eb4c770dc..34af608aea 100644 --- a/plugins/tasks/lock/src/main/java/com/walmartlabs/concord/plugins/lock/v2/UnlockTaskV2.java +++ b/plugins/tasks/lock/src/main/java/com/walmartlabs/concord/plugins/lock/v2/UnlockTaskV2.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; +import com.walmartlabs.concord.client2.ApiClient; import com.walmartlabs.concord.plugins.lock.LockTaskCommon; import com.walmartlabs.concord.plugins.lock.TaskParams; import com.walmartlabs.concord.runtime.v2.sdk.Context; diff --git a/plugins/tasks/log/src/main/java/com/walmartlabs/concord/plugins/log/LoggingTaskV2.java b/plugins/tasks/log/src/main/java/com/walmartlabs/concord/plugins/log/LoggingTaskV2.java index f5b6c076bb..87b2e54ca1 100644 --- a/plugins/tasks/log/src/main/java/com/walmartlabs/concord/plugins/log/LoggingTaskV2.java +++ b/plugins/tasks/log/src/main/java/com/walmartlabs/concord/plugins/log/LoggingTaskV2.java @@ -25,7 +25,6 @@ import com.walmartlabs.concord.runtime.v2.sdk.Variables; import javax.inject.Named; -import java.io.Serializable; @Named("log") public class LoggingTaskV2 implements Task { diff --git a/plugins/tasks/noderoster/pom.xml b/plugins/tasks/noderoster/pom.xml index d2d04cdc31..1c554a76d3 100644 --- a/plugins/tasks/noderoster/pom.xml +++ b/plugins/tasks/noderoster/pom.xml @@ -26,12 +26,12 @@ com.walmartlabs.concord - concord-client + concord-client2 provided com.walmartlabs.concord.server.plugins.noderoster - concord-noderoster-plugin-client + concord-noderoster-plugin-client2 diff --git a/plugins/tasks/noderoster/src/main/java/com/walmartlabs/concord/plugins/noderoster/NodeRosterTask.java b/plugins/tasks/noderoster/src/main/java/com/walmartlabs/concord/plugins/noderoster/NodeRosterTask.java index cbd91d1fc0..69dd9c95bb 100644 --- a/plugins/tasks/noderoster/src/main/java/com/walmartlabs/concord/plugins/noderoster/NodeRosterTask.java +++ b/plugins/tasks/noderoster/src/main/java/com/walmartlabs/concord/plugins/noderoster/NodeRosterTask.java @@ -20,8 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.sdk.Context; import com.walmartlabs.concord.sdk.ContextUtils; import com.walmartlabs.concord.sdk.Task; diff --git a/plugins/tasks/noderoster/src/main/java/com/walmartlabs/concord/plugins/noderoster/NodeRosterTaskUtils.java b/plugins/tasks/noderoster/src/main/java/com/walmartlabs/concord/plugins/noderoster/NodeRosterTaskUtils.java index bc24e1ca4e..ebb0fa38d5 100644 --- a/plugins/tasks/noderoster/src/main/java/com/walmartlabs/concord/plugins/noderoster/NodeRosterTaskUtils.java +++ b/plugins/tasks/noderoster/src/main/java/com/walmartlabs/concord/plugins/noderoster/NodeRosterTaskUtils.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.sdk.MapUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -102,7 +102,7 @@ public static List findHostsWithArtifacts(NodeRosterHostsApi api, "(limit: {}, offset: {})...", artifactPattern, limit, offset); return ClientUtils.withRetry(Constants.RETRY_COUNT, Constants.RETRY_INTERVAL, () -> - api.list(null, artifactPattern, null, null, limit, offset)); + api.listKnownHosts(null, artifactPattern, null, null, limit, offset)); } /** @@ -123,6 +123,6 @@ public static List findDeployedArtifacts(NodeRosterArtifactsApi a log.info("Finding artifacts deployed on a host (hostName: {}, hostId: {})...", hostName, hostId); return ClientUtils.withRetry(Constants.RETRY_COUNT, Constants.RETRY_INTERVAL, () -> - api.list(hostId, hostName, null, limit, offset)); + api.listHostArtifacts(hostId, hostName, null, limit, offset)); } } diff --git a/plugins/tasks/noderoster/src/main/java/com/walmartlabs/concord/plugins/noderoster/NodeRosterTaskV2.java b/plugins/tasks/noderoster/src/main/java/com/walmartlabs/concord/plugins/noderoster/NodeRosterTaskV2.java index 3fa336e2ff..54a188e936 100644 --- a/plugins/tasks/noderoster/src/main/java/com/walmartlabs/concord/plugins/noderoster/NodeRosterTaskV2.java +++ b/plugins/tasks/noderoster/src/main/java/com/walmartlabs/concord/plugins/noderoster/NodeRosterTaskV2.java @@ -20,8 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.runtime.v2.sdk.Task; import com.walmartlabs.concord.runtime.v2.sdk.TaskResult; import com.walmartlabs.concord.runtime.v2.sdk.Variables; diff --git a/plugins/tasks/resource/src/main/java/com/walmartlabs/concord/plugins/resource/ResourceTaskCommon.java b/plugins/tasks/resource/src/main/java/com/walmartlabs/concord/plugins/resource/ResourceTaskCommon.java index fce035f440..659dab3c7e 100644 --- a/plugins/tasks/resource/src/main/java/com/walmartlabs/concord/plugins/resource/ResourceTaskCommon.java +++ b/plugins/tasks/resource/src/main/java/com/walmartlabs/concord/plugins/resource/ResourceTaskCommon.java @@ -33,10 +33,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; +import java.util.*; public class ResourceTaskCommon { diff --git a/plugins/tasks/sleep/pom.xml b/plugins/tasks/sleep/pom.xml index 0cfa9b7652..78d8dc82cd 100644 --- a/plugins/tasks/sleep/pom.xml +++ b/plugins/tasks/sleep/pom.xml @@ -20,7 +20,7 @@ com.walmartlabs.concord - concord-client + concord-client2 provided diff --git a/plugins/tasks/sleep/src/main/java/com/walmartlabs/concord/plugins/sleep/SleepTask.java b/plugins/tasks/sleep/src/main/java/com/walmartlabs/concord/plugins/sleep/SleepTask.java index d1199aee31..fd3c4c6262 100644 --- a/plugins/tasks/sleep/src/main/java/com/walmartlabs/concord/plugins/sleep/SleepTask.java +++ b/plugins/tasks/sleep/src/main/java/com/walmartlabs/concord/plugins/sleep/SleepTask.java @@ -20,9 +20,9 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.client.ApiClientConfiguration; -import com.walmartlabs.concord.client.ApiClientFactory; +import com.walmartlabs.concord.client2.ApiClient; +import com.walmartlabs.concord.client2.ApiClientConfiguration; +import com.walmartlabs.concord.client2.ApiClientFactory; import com.walmartlabs.concord.runtime.v2.sdk.TaskResult; import com.walmartlabs.concord.sdk.Context; import com.walmartlabs.concord.sdk.ContextUtils; @@ -53,7 +53,7 @@ public void ms(long t) { public void execute(Context ctx) throws Exception { Supplier suspender = () -> { ApiClient apiClient = apiClientFactory.create(ApiClientConfiguration.builder() - .context(ctx) + .sessionToken(ContextUtils.getSessionToken(ctx)) .build()); return new Suspender(apiClient, ContextUtils.getTxId(ctx)); diff --git a/plugins/tasks/sleep/src/main/java/com/walmartlabs/concord/plugins/sleep/Suspender.java b/plugins/tasks/sleep/src/main/java/com/walmartlabs/concord/plugins/sleep/Suspender.java index 3a75a72b19..bc2d90f85f 100644 --- a/plugins/tasks/sleep/src/main/java/com/walmartlabs/concord/plugins/sleep/Suspender.java +++ b/plugins/tasks/sleep/src/main/java/com/walmartlabs/concord/plugins/sleep/Suspender.java @@ -20,10 +20,10 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.ClientUtils; -import com.walmartlabs.concord.client.ProcessApi; +import com.walmartlabs.concord.client2.ApiClient; +import com.walmartlabs.concord.client2.ApiException; +import com.walmartlabs.concord.client2.ClientUtils; +import com.walmartlabs.concord.client2.ProcessApi; import com.walmartlabs.concord.runtime.v2.sdk.TaskResult; import java.time.Instant; diff --git a/plugins/tasks/sleep/src/main/java/com/walmartlabs/concord/plugins/sleep/v2/SleepTaskV2.java b/plugins/tasks/sleep/src/main/java/com/walmartlabs/concord/plugins/sleep/v2/SleepTaskV2.java index 82fd8920b3..e4a1341c4b 100644 --- a/plugins/tasks/sleep/src/main/java/com/walmartlabs/concord/plugins/sleep/v2/SleepTaskV2.java +++ b/plugins/tasks/sleep/src/main/java/com/walmartlabs/concord/plugins/sleep/v2/SleepTaskV2.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; +import com.walmartlabs.concord.client2.ApiClient; import com.walmartlabs.concord.plugins.sleep.SleepTaskCommon; import com.walmartlabs.concord.plugins.sleep.Suspender; import com.walmartlabs.concord.plugins.sleep.TaskParams; diff --git a/policy-engine/src/main/java/com/walmartlabs/concord/policyengine/RuntimePolicy.java b/policy-engine/src/main/java/com/walmartlabs/concord/policyengine/RuntimePolicy.java index f6e8c46f2e..8eadae62fc 100644 --- a/policy-engine/src/main/java/com/walmartlabs/concord/policyengine/RuntimePolicy.java +++ b/policy-engine/src/main/java/com/walmartlabs/concord/policyengine/RuntimePolicy.java @@ -23,7 +23,6 @@ import java.time.LocalTime; import java.time.OffsetDateTime; import java.time.ZoneOffset; -import java.util.Objects; import java.util.function.Supplier; public class RuntimePolicy { diff --git a/policy-engine/src/main/java/com/walmartlabs/concord/policyengine/RuntimeRule.java b/policy-engine/src/main/java/com/walmartlabs/concord/policyengine/RuntimeRule.java index d5fc979155..090ed78c97 100644 --- a/policy-engine/src/main/java/com/walmartlabs/concord/policyengine/RuntimeRule.java +++ b/policy-engine/src/main/java/com/walmartlabs/concord/policyengine/RuntimeRule.java @@ -30,7 +30,6 @@ import javax.annotation.Nullable; import java.io.Serializable; import java.time.LocalDate; -import java.time.OffsetDateTime; import java.util.Set; @Value.Immutable diff --git a/pom.xml b/pom.xml index f4e0b21669..d5474db0ea 100644 --- a/pom.xml +++ b/pom.xml @@ -393,12 +393,12 @@ org.revapi revapi-maven-plugin - 0.14.6 + 0.15.0 org.revapi revapi-java - 0.27.0 + 0.28.1 diff --git a/repository/src/test/java/com/walmartlabs/concord/repository/GitClientFetchTest.java b/repository/src/test/java/com/walmartlabs/concord/repository/GitClientFetchTest.java index 3d993a96e7..c31ae7a9fd 100644 --- a/repository/src/test/java/com/walmartlabs/concord/repository/GitClientFetchTest.java +++ b/repository/src/test/java/com/walmartlabs/concord/repository/GitClientFetchTest.java @@ -25,12 +25,10 @@ import com.walmartlabs.concord.sdk.Secret; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.errors.GitAPIException; -import org.eclipse.jgit.api.errors.InvalidRefNameException; import org.eclipse.jgit.revwalk.RevCommit; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; diff --git a/runtime/common/pom.xml b/runtime/common/pom.xml index 1b17daceb2..a350cbe96e 100644 --- a/runtime/common/pom.xml +++ b/runtime/common/pom.xml @@ -21,7 +21,7 @@ com.walmartlabs.concord - concord-client + concord-client2 com.walmartlabs.concord diff --git a/runtime/common/src/main/java/com/walmartlabs/concord/runtime/common/ProcessHeartbeat.java b/runtime/common/src/main/java/com/walmartlabs/concord/runtime/common/ProcessHeartbeat.java index 68bb9440fc..e806e2151a 100644 --- a/runtime/common/src/main/java/com/walmartlabs/concord/runtime/common/ProcessHeartbeat.java +++ b/runtime/common/src/main/java/com/walmartlabs/concord/runtime/common/ProcessHeartbeat.java @@ -20,8 +20,8 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.client.ProcessHeartbeatApi; +import com.walmartlabs.concord.client2.ApiClient; +import com.walmartlabs.concord.client2.ProcessHeartbeatApi; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -57,7 +57,7 @@ public synchronized void start() { long lastSuccessPing = System.currentTimeMillis(); while (!Thread.currentThread().isInterrupted()) { try { - processHeartbeatApi.ping(instanceId); + processHeartbeatApi.pingProcess(instanceId); lastSuccessPing = System.currentTimeMillis(); if (prevPingFailed) { log.info("heartbeat: ok"); diff --git a/runtime/common/src/main/java/com/walmartlabs/concord/runtime/common/cfg/LoggingConfiguration.java b/runtime/common/src/main/java/com/walmartlabs/concord/runtime/common/cfg/LoggingConfiguration.java index 45bd25415c..87fc6a6df6 100644 --- a/runtime/common/src/main/java/com/walmartlabs/concord/runtime/common/cfg/LoggingConfiguration.java +++ b/runtime/common/src/main/java/com/walmartlabs/concord/runtime/common/cfg/LoggingConfiguration.java @@ -25,8 +25,6 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import org.immutables.value.Value; -import javax.annotation.Nullable; - @Value.Immutable @Value.Style(jdkOnly = true) @JsonInclude(JsonInclude.Include.NON_EMPTY) diff --git a/runtime/loader/src/main/java/com/walmartlabs/concord/process/loader/model/SourceMap.java b/runtime/loader/src/main/java/com/walmartlabs/concord/process/loader/model/SourceMap.java index 2123575cb4..1a10ae29cc 100644 --- a/runtime/loader/src/main/java/com/walmartlabs/concord/process/loader/model/SourceMap.java +++ b/runtime/loader/src/main/java/com/walmartlabs/concord/process/loader/model/SourceMap.java @@ -20,7 +20,6 @@ * ===== */ -import com.fasterxml.jackson.core.JsonLocation; import com.walmartlabs.concord.runtime.v2.model.Location; import org.immutables.serial.Serial; import org.immutables.value.Value; diff --git a/runtime/v1/impl/pom.xml b/runtime/v1/impl/pom.xml index 8e2fb71505..7ea50d1c1b 100644 --- a/runtime/v1/impl/pom.xml +++ b/runtime/v1/impl/pom.xml @@ -18,6 +18,10 @@ com.walmartlabs.concord.runtime concord-runtime-common + + com.walmartlabs.concord.runtime.v2 + concord-runtime-sdk-v2 + com.walmartlabs.concord concord-sdk @@ -36,7 +40,7 @@ com.walmartlabs.concord - concord-client + concord-client2 com.walmartlabs.concord @@ -63,11 +67,6 @@ aopalliance aopalliance - - com.google.code.gson - gson - 2.10 - org.jboss.spec.javax.ws.rs jboss-jaxrs-api_2.0_spec @@ -125,11 +124,6 @@ org.apache.commons commons-compress - - com.squareup.okhttp - okhttp - 2.7.5 - diff --git a/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/ApiClientFactoryImpl.java b/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/ApiClientFactoryImpl.java index 417c317164..9d871e1eed 100644 --- a/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/ApiClientFactoryImpl.java +++ b/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/ApiClientFactoryImpl.java @@ -20,79 +20,30 @@ * ===== */ -import com.squareup.okhttp.OkHttpClient; -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.client.ApiClientConfiguration; -import com.walmartlabs.concord.client.ApiClientFactory; -import com.walmartlabs.concord.client.ConcordApiClient; +import com.walmartlabs.concord.client2.ApiClient; +import com.walmartlabs.concord.client2.ApiClientConfiguration; +import com.walmartlabs.concord.client2.ApiClientFactory; +import com.walmartlabs.concord.client2.DefaultApiClientFactory; 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.time.Duration; 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; + private final DefaultApiClientFactory clientFactory; + private UUID txId; - public ApiClientFactoryImpl(ApiConfiguration cfg, Path workDir) throws Exception { + public ApiClientFactoryImpl(ApiConfiguration cfg) 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; + this.clientFactory = new DefaultApiClientFactory(cfg.getBaseUrl(), Duration.ofMillis(cfg.connectTimeout())); } @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); + ApiClient client = this.clientFactory.create(overrides) + .setReadTimeout(Duration.ofMillis(cfg.readTimeout())); if (txId != null) { client = client.setUserAgent("Concord-Runner: txId=" + txId); @@ -101,23 +52,7 @@ public ApiClient create(ApiClientConfiguration overrides) { 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); + public void setTxId(UUID instanceId) { + this.txId = instanceId; } } diff --git a/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/ApiClientFactoryProvider.java b/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/ApiClientFactoryProvider.java index 8206a9d17f..c5625d928c 100644 --- a/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/ApiClientFactoryProvider.java +++ b/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/ApiClientFactoryProvider.java @@ -20,7 +20,7 @@ * ===== */ -import com.walmartlabs.concord.client.ApiClientFactory; +import com.walmartlabs.concord.client2.ApiClientFactory; import com.walmartlabs.concord.sdk.ApiConfiguration; import javax.inject.Inject; @@ -33,18 +33,16 @@ public class ApiClientFactoryProvider implements Provider { private final ApiConfiguration cfg; - private final WorkingDirectory workDir; @Inject - public ApiClientFactoryProvider(ApiConfiguration cfg, WorkingDirectory workDir) { + public ApiClientFactoryProvider(ApiConfiguration cfg) { this.cfg = cfg; - this.workDir = workDir; } @Override public ApiClientFactory get() { try { - return new ApiClientFactoryImpl(cfg, workDir.getValue()); + return new ApiClientFactoryImpl(cfg); } catch (RuntimeException e) { throw e; } catch (Exception e) { diff --git a/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/LockServiceImpl.java b/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/LockServiceImpl.java index 40d8c3d591..f7fadd7509 100644 --- a/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/LockServiceImpl.java +++ b/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/LockServiceImpl.java @@ -20,11 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.ApiClientFactory; -import com.walmartlabs.concord.client.ClientUtils; -import com.walmartlabs.concord.client.LockResult; -import com.walmartlabs.concord.client.ProcessLocksApi; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.sdk.Context; import com.walmartlabs.concord.sdk.ContextUtils; import com.walmartlabs.concord.sdk.LockService; @@ -58,13 +54,15 @@ public LockServiceImpl(ApiClientFactory apiClientFactory) { @Override public void projectLock(Context ctx, String lockName) throws Exception { - UUID instanceId = ContextUtils.getTxId(ctx); - ProcessLocksApi api = new ProcessLocksApi(apiClientFactory.create(ctx)); + ProcessLocksApi api = new ProcessLocksApi(apiClientFactory.create(ApiClientConfiguration.builder() + .sessionToken(ContextUtils.getSessionToken(ctx)) + .build())); // TODO: timeout + UUID instanceId = ContextUtils.getTxId(ctx); while (!Thread.currentThread().isInterrupted()) { LockResult lock = withRetry(() -> api.tryLock(instanceId, lockName, LockScope.PROJECT.name())); - if (lock.isAcquired()) { + if (lock.getAcquired()) { log.info("successfully acquired lock '{}' in '{}' scope...", lockName, LockScope.PROJECT); return; } @@ -76,8 +74,11 @@ public void projectLock(Context ctx, String lockName) throws Exception { @Override public void projectUnlock(Context ctx, String lockName) throws Exception { + ProcessLocksApi api = new ProcessLocksApi(apiClientFactory.create(ApiClientConfiguration.builder() + .sessionToken(ContextUtils.getSessionToken(ctx)) + .build())); + UUID instanceId = ContextUtils.getTxId(ctx); - ProcessLocksApi api = new ProcessLocksApi(apiClientFactory.create(ctx)); withRetry(() -> { api.unlock(instanceId, lockName, LockScope.PROJECT.name()); return null; diff --git a/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/Main.java b/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/Main.java index c54e10d9ef..327d1c007a 100644 --- a/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/Main.java +++ b/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/Main.java @@ -31,10 +31,10 @@ import com.google.inject.matcher.AbstractMatcher; import com.google.inject.spi.TypeEncounter; import com.google.inject.spi.TypeListener; -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.client.ApiClientConfiguration; -import com.walmartlabs.concord.client.ApiClientFactory; -import com.walmartlabs.concord.client.ProcessEntry; +import com.walmartlabs.concord.client2.ApiClient; +import com.walmartlabs.concord.client2.ApiClientConfiguration; +import com.walmartlabs.concord.client2.ApiClientFactory; +import com.walmartlabs.concord.client2.ProcessEntry; import com.walmartlabs.concord.common.IOUtils; import com.walmartlabs.concord.imports.ImportsListener; import com.walmartlabs.concord.imports.NoopImportManager; @@ -49,6 +49,7 @@ import com.walmartlabs.concord.runtime.common.ProcessHeartbeat; import com.walmartlabs.concord.runtime.common.StateManager; import com.walmartlabs.concord.runtime.common.cfg.RunnerConfiguration; +import com.walmartlabs.concord.runtime.v2.sdk.WorkingDirectory; import com.walmartlabs.concord.sdk.Constants; import com.walmartlabs.concord.sdk.MapUtils; import com.walmartlabs.concord.sdk.Task; @@ -106,6 +107,8 @@ public void run(RunnerConfiguration runnerCfg, Path baseDir) throws Exception { Path idPath = baseDir.resolve(Constants.Files.INSTANCE_ID_FILE_NAME); UUID instanceId = readInstanceId(idPath); + ((ApiClientFactoryImpl)apiClientFactory).setTxId(instanceId); + long t2 = System.currentTimeMillis(); if (runnerCfg.debug()) { log.info("Spent {}ms waiting for the payload", (t2 - t1)); @@ -125,7 +128,6 @@ public void run(RunnerConfiguration runnerCfg, Path baseDir) throws Exception { String sessionToken = getSessionToken(processCfg); ApiClient apiClient = apiClientFactory.create(ApiClientConfiguration.builder() .sessionToken(sessionToken) - .txId(instanceId) .build()); ProcessHeartbeat heartbeat = new ProcessHeartbeat(apiClient, instanceId, runnerCfg.api().maxNoHeartbeatInterval()); diff --git a/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/ObjectStorageImpl.java b/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/ObjectStorageImpl.java index 29840cf363..8f567ece78 100644 --- a/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/ObjectStorageImpl.java +++ b/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/ObjectStorageImpl.java @@ -20,8 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.sdk.ContextUtils; import com.walmartlabs.concord.sdk.*; import org.slf4j.Logger; @@ -63,12 +62,15 @@ public BucketInfo createBucket(Context ctx, String name) throws Exception { } InventoryEntry entry = new InventoryEntry() - .setName(name) - .setOrgId(projectInfo.orgId()) - .setVisibility(InventoryEntry.VisibilityEnum.PRIVATE); + .name(name) + .orgId(projectInfo.orgId()) + .visibility(InventoryEntry.VisibilityEnum.PRIVATE); - InventoriesApi api = new InventoriesApi(apiClientFactory.create(ctx)); - CreateInventoryResponse resp = withRetry(() -> api.createOrUpdate(projectInfo.orgName(), entry)); + ApiClientConfiguration c = ApiClientConfiguration.builder() + .sessionToken(ContextUtils.getSessionToken(ctx)) + .build(); + InventoriesApi api = new InventoriesApi(apiClientFactory.create(c)); + CreateInventoryResponse resp = withRetry(() -> api.createOrUpdateInventory(projectInfo.orgName(), entry)); log.info("createBucket ['{}', '{}'] -> done ({})", projectInfo.orgName(), name, resp.getId()); String address = String.format("%s/api/v1/org/%s/inventory/%s/data/%s?singleItem=true", diff --git a/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/ProcessApiClient.java b/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/ProcessApiClient.java index 34b2deaa9d..a3545e63d6 100644 --- a/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/ProcessApiClient.java +++ b/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/ProcessApiClient.java @@ -20,11 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.ClientUtils; -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.runtime.common.cfg.RunnerConfiguration; import java.util.Map; @@ -32,25 +28,23 @@ public class ProcessApiClient { - private final ApiClient apiClient; private final ProcessApi processApi; + private final CheckpointApi checkpointApi; private final int retryCount; private final long retryInterval; public ProcessApiClient(RunnerConfiguration runnerCfg, ApiClient apiClient) { - this.apiClient = apiClient; this.processApi = new ProcessApi(apiClient); + this.checkpointApi = new CheckpointApi(apiClient); this.retryCount = runnerCfg.api().retryCount(); this.retryInterval = runnerCfg.api().retryInterval(); } public void uploadCheckpoint(UUID instanceId, Map data) throws ApiException { - String path = "/api/v1/process/" + instanceId + "/checkpoint"; - ClientUtils.withRetry(retryCount, retryInterval, () -> { - ClientUtils.postData(apiClient, path, data, null); + checkpointApi.uploadCheckpoint(instanceId, data); return null; }); } diff --git a/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/SecretServiceImpl.java b/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/SecretServiceImpl.java index eef1bed552..9346f21094 100644 --- a/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/SecretServiceImpl.java +++ b/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/SecretServiceImpl.java @@ -20,11 +20,7 @@ * ===== */ -import com.google.gson.reflect.TypeToken; -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 com.walmartlabs.concord.common.secret.BinaryDataSecret; import com.walmartlabs.concord.common.secret.KeyPair; import com.walmartlabs.concord.common.secret.UsernamePassword; @@ -37,7 +33,6 @@ import javax.inject.Named; import javax.xml.bind.DatatypeConverter; import java.io.IOException; -import java.lang.reflect.Type; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -49,9 +44,6 @@ @Named public class SecretServiceImpl implements SecretService { - private static final int RETRY_COUNT = 3; - private static final long RETRY_INTERVAL = 5000; - private final ApiClientFactory clientFactory; @Inject @@ -66,7 +58,7 @@ public String exportAsString(Context ctx, String instanceId, String name, String @Override public String exportAsString(Context ctx, String instanceId, String orgName, String name, String password) throws Exception { - BinaryDataSecret s = get(ctx, orgName, name, password, SecretEntry.TypeEnum.DATA); + BinaryDataSecret s = get(ctx, orgName, name, password, SecretEntryV2.TypeEnum.DATA); return new String(s.getData()); } @@ -77,7 +69,7 @@ public Map exportKeyAsFile(Context ctx, String instanceId, Strin @Override public Map exportKeyAsFile(Context ctx, String instanceId, String workDir, String orgName, String name, String password) throws Exception { - KeyPair kp = get(ctx, orgName, name, password, SecretEntry.TypeEnum.KEY_PAIR); + KeyPair kp = get(ctx, orgName, name, password, SecretEntryV2.TypeEnum.KEY_PAIR); Path baseDir = Paths.get(workDir); Path tmpDir = assertTempDir(baseDir); @@ -102,7 +94,7 @@ public Map exportCredentials(Context ctx, String instanceId, Str @Override public Map exportCredentials(Context ctx, String instanceId, String workDir, String orgName, String name, String password) throws Exception { - UsernamePassword up = get(ctx, orgName, name, password, SecretEntry.TypeEnum.USERNAME_PASSWORD); + UsernamePassword up = get(ctx, orgName, name, password, SecretEntryV2.TypeEnum.USERNAME_PASSWORD); Map m = new HashMap<>(); m.put("username", up.getUsername()); @@ -117,7 +109,7 @@ public String exportAsFile(Context ctx, String instanceId, String workDir, Strin @Override public String exportAsFile(Context ctx, String instanceId, String workDir, String orgName, String name, String password) throws Exception { - BinaryDataSecret bds = get(ctx, orgName, name, password, SecretEntry.TypeEnum.DATA); + BinaryDataSecret bds = get(ctx, orgName, name, password, SecretEntryV2.TypeEnum.DATA); Path baseDir = Paths.get(workDir); Path tmpDir = assertTempDir(baseDir); @@ -130,23 +122,7 @@ public String exportAsFile(Context ctx, String instanceId, String workDir, Strin @Override public String encryptString(Context ctx, String instanceId, String orgName, String projectName, String value) throws Exception { - ApiClientConfiguration cfg = ApiClientConfiguration.builder() - .sessionToken(ContextUtils.getSessionToken(ctx)) - .txId(UUID.fromString(instanceId)) - .build(); - - ApiClient c = clientFactory.create(cfg); - - String path = "/api/v1/org/" + orgName + "/project/" + projectName + "/encrypt"; - Map headerParams = new HashMap<>(); - headerParams.put("Content-Type", "text/plain;charset=UTF-8"); - ApiResponse r = ClientUtils.postData(c, path, value, headerParams, EncryptValueResponse.class); - - if (r.getStatusCode() == 200 && r.getData().isOk()) { - return r.getData().getData(); - } - - throw new ApiException("Error encrypting string. Status code:" + r.getStatusCode() + " Data: " + r.getData()); + return new SecretClient(apiClient(ctx)).encryptString(orgName, projectName, value); } @Override @@ -159,22 +135,13 @@ public String decryptString(Context ctx, String instanceId, String s) throws Exc throw new IllegalArgumentException("Invalid encrypted string value, please verify that it was specified/copied correctly: " + e.getMessage()); } - ApiClient c = clientFactory.create(ctx); - - String path = "/api/v1/process/" + instanceId + "/decrypt"; - ApiResponse r = ClientUtils.withRetry(RETRY_COUNT, RETRY_INTERVAL, () -> { - Type returnType = new TypeToken() { - }.getType(); - return ClientUtils.postData(c, path, input, returnType); - }); - - return new String(r.getData()); + return new String(new SecretClient(apiClient(ctx)).decryptString(UUID.fromString(instanceId), input)); } - private T get(Context ctx, String orgName, String secretName, String password, SecretEntry.TypeEnum type) throws Exception { + private T get(Context ctx, String orgName, String secretName, String password, SecretEntryV2.TypeEnum type) throws Exception { try { - return new SecretClient(clientFactory.create(ctx)).getData(assertOrgName(ctx, orgName), secretName, password, type); - } catch (com.walmartlabs.concord.client.SecretNotFoundException e) { + return new SecretClient(apiClient(ctx)).getData(assertOrgName(ctx, orgName), secretName, password, type); + } catch (com.walmartlabs.concord.client2.SecretNotFoundException e) { throw new SecretNotFoundException(e.getOrgName(), e.getSecretName()); } } @@ -191,6 +158,14 @@ private String assertOrgName(Context ctx, String orgName) { .orElseThrow(() -> new IllegalArgumentException("Organization name not specified")); } + private ApiClient apiClient(Context ctx) { + ApiClientConfiguration cfg = ApiClientConfiguration.builder() + .sessionToken(ContextUtils.getSessionToken(ctx)) + .build(); + + return clientFactory.create(cfg); + } + private static Path assertTempDir(Path baseDir) throws IOException { Path p = baseDir.resolve(".tmp"); if (!Files.exists(p)) { diff --git a/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/WorkingDirectory.java b/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/WorkingDirectory.java deleted file mode 100644 index b9f0d5eaa1..0000000000 --- a/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/WorkingDirectory.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.walmartlabs.concord.runner; - -/*- - * ***** - * Concord - * ----- - * Copyright (C) 2017 - 2020 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 java.nio.file.Path; - -public class WorkingDirectory { - - private final Path value; - - public WorkingDirectory(Path value) { - this.value = value; - } - - public Path getValue() { - return value; - } -} diff --git a/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/engine/DefaultElementEventProcessor.java b/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/engine/DefaultElementEventProcessor.java index 0e9830e861..117c5ee314 100644 --- a/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/engine/DefaultElementEventProcessor.java +++ b/runtime/v1/impl/src/main/java/com/walmartlabs/concord/runner/engine/DefaultElementEventProcessor.java @@ -20,10 +20,10 @@ * ===== */ -import com.walmartlabs.concord.client.ApiClientConfiguration; -import com.walmartlabs.concord.client.ApiClientFactory; -import com.walmartlabs.concord.client.ProcessEventRequest; -import com.walmartlabs.concord.client.ProcessEventsApi; +import com.walmartlabs.concord.client2.ApiClientConfiguration; +import com.walmartlabs.concord.client2.ApiClientFactory; +import com.walmartlabs.concord.client2.ProcessEventRequest; +import com.walmartlabs.concord.client2.ProcessEventsApi; import io.takari.bpm.ProcessDefinitionProvider; import io.takari.bpm.ProcessDefinitionUtils; import io.takari.bpm.api.ExecutionException; @@ -99,7 +99,6 @@ public void process(ElementEvent event, EventParamsBuilder builder, Predicate { diff --git a/runtime/v2/runner/pom.xml b/runtime/v2/runner/pom.xml index ede9d4b001..87fafd81db 100644 --- a/runtime/v2/runner/pom.xml +++ b/runtime/v2/runner/pom.xml @@ -44,7 +44,7 @@ com.walmartlabs.concord - concord-client + concord-client2 com.walmartlabs.concord @@ -59,11 +59,6 @@ concord-dependency-manager - - com.squareup.okhttp - okhttp - 2.7.5 - javax.inject javax.inject diff --git a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/DefaultLockService.java b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/DefaultLockService.java index 2090736a3c..f2778d9b7b 100644 --- a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/DefaultLockService.java +++ b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/DefaultLockService.java @@ -20,11 +20,9 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.ClientUtils; -import com.walmartlabs.concord.client.LockResult; -import com.walmartlabs.concord.client.ProcessLocksApi; +import com.walmartlabs.concord.client2.*; +import com.walmartlabs.concord.client2.LockResult; +import com.walmartlabs.concord.client2.ProcessLocksApi; import com.walmartlabs.concord.runtime.common.injector.InstanceId; import com.walmartlabs.concord.runtime.v2.sdk.LockService; import org.slf4j.Logger; @@ -57,7 +55,7 @@ public void projectLock(String lockName) throws Exception { // TODO: timeout while (!Thread.currentThread().isInterrupted()) { LockResult lock = withRetry(() -> api.tryLock(instanceId.getValue(), lockName, LockScope.PROJECT.name())); - if (lock.isAcquired()) { + if (lock.getAcquired()) { log.info("successfully acquired lock '{}' in '{}' scope...", lockName, LockScope.PROJECT); return; } diff --git a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/DefaultSecretService.java b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/DefaultSecretService.java index ace1b6ed38..d70c47f1b3 100644 --- a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/DefaultSecretService.java +++ b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/DefaultSecretService.java @@ -20,8 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.client.*; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.common.secret.BinaryDataSecret; import com.walmartlabs.concord.runtime.common.cfg.RunnerConfiguration; import com.walmartlabs.concord.runtime.common.injector.InstanceId; @@ -34,6 +33,7 @@ import javax.xml.bind.DatatypeConverter; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Objects; public class DefaultSecretService implements SecretService { @@ -50,13 +50,13 @@ public DefaultSecretService(RunnerConfiguration cfg, ApiClient apiClient, FileSe @Override public String exportAsString(String orgName, String secretName, String password) throws Exception { - BinaryDataSecret s = get(orgName, secretName, password, SecretEntry.TypeEnum.DATA); + BinaryDataSecret s = get(orgName, secretName, password, SecretEntryV2.TypeEnum.DATA); return new String(s.getData()); } @Override public KeyPair exportKeyAsFile(String orgName, String secretName, String password) throws Exception { - com.walmartlabs.concord.common.secret.KeyPair kp = get(orgName, secretName, password, SecretEntry.TypeEnum.KEY_PAIR); + com.walmartlabs.concord.common.secret.KeyPair kp = get(orgName, secretName, password, SecretEntryV2.TypeEnum.KEY_PAIR); Path tmpDir = fileService.createTempDirectory("secret-service"); @@ -74,13 +74,13 @@ public KeyPair exportKeyAsFile(String orgName, String secretName, String passwor @Override public UsernamePassword exportCredentials(String orgName, String secretName, String password) throws Exception { - com.walmartlabs.concord.common.secret.UsernamePassword up = get(orgName, secretName, password, SecretEntry.TypeEnum.USERNAME_PASSWORD); + com.walmartlabs.concord.common.secret.UsernamePassword up = get(orgName, secretName, password, SecretEntryV2.TypeEnum.USERNAME_PASSWORD); return UsernamePassword.of(up.getUsername(), new String(up.getPassword())); } @Override public Path exportAsFile(String orgName, String secretName, String password) throws Exception { - BinaryDataSecret bds = get(orgName, secretName, password, SecretEntry.TypeEnum.DATA); + BinaryDataSecret bds = get(orgName, secretName, password, SecretEntryV2.TypeEnum.DATA); Path p = fileService.createTempFile("secret-service-file", ".bin"); Files.write(p, bds.getData()); @@ -137,22 +137,27 @@ private static SecretCreationResult toResult(SecretOperationResponse response) { .build(); } - private T get(String orgName, String secretName, String password, SecretEntry.TypeEnum type) throws Exception { + private T get(String orgName, String secretName, String password, SecretEntryV2.TypeEnum type) throws Exception { try { return secretClient.getData(orgName, secretName, password, type); - } catch (com.walmartlabs.concord.client.SecretNotFoundException e) { + } catch (com.walmartlabs.concord.client2.SecretNotFoundException e) { throw new SecretNotFoundException(e.getOrgName(), e.getSecretName()); } } private ImmutableCreateSecretRequest.Builder secretRequest(SecretParams secret) { SecretParams.Visibility visibility = secret.visibility(); - return CreateSecretRequest.builder() + ImmutableCreateSecretRequest .Builder result = CreateSecretRequest.builder() .org(secret.orgName()) .name(secret.secretName()) .generatePassword(secret.generatePassword()) .storePassword(secret.storePassword()) - .visibility(visibility != null ? SecretEntry.VisibilityEnum.fromValue(visibility.name()) : null) - .project(secret.project()); + .visibility(visibility != null ? SecretEntryV2.VisibilityEnum.fromValue(visibility.name()) : null); + + if (secret.project() != null) { + result.addProjectNames(Objects.requireNonNull(secret.project())); + } + + return result; } } diff --git a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/Main.java b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/Main.java index c510eddd5a..bf6d97c5f1 100644 --- a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/Main.java +++ b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/Main.java @@ -23,7 +23,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.inject.Inject; import com.google.inject.Injector; -import com.walmartlabs.concord.ApiClient; +import com.walmartlabs.concord.client2.ApiClient; import com.walmartlabs.concord.imports.ImportsListener; import com.walmartlabs.concord.imports.NoopImportManager; import com.walmartlabs.concord.runtime.common.ProcessHeartbeat; diff --git a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/MetadataProcessor.java b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/MetadataProcessor.java index 35a7192100..8775063ca2 100644 --- a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/MetadataProcessor.java +++ b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/MetadataProcessor.java @@ -20,10 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.ClientUtils; -import com.walmartlabs.concord.client.ProcessApi; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.common.ConfigurationUtils; import com.walmartlabs.concord.runtime.common.cfg.RunnerConfiguration; import com.walmartlabs.concord.runtime.common.injector.InstanceId; diff --git a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/StackTraceCollector.java b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/StackTraceCollector.java index 74e60e916c..da57f6760c 100644 --- a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/StackTraceCollector.java +++ b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/StackTraceCollector.java @@ -23,7 +23,6 @@ import com.walmartlabs.concord.runtime.v2.model.FlowCall; import com.walmartlabs.concord.runtime.v2.model.Location; import com.walmartlabs.concord.runtime.v2.runner.vm.FlowCallCommand; -import com.walmartlabs.concord.runtime.v2.runner.vm.VMUtils; import com.walmartlabs.concord.svm.Runtime; import com.walmartlabs.concord.svm.*; diff --git a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/checkpoints/DefaultCheckpointUploader.java b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/checkpoints/DefaultCheckpointUploader.java index ce390931f5..a9ae8ed4e3 100644 --- a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/checkpoints/DefaultCheckpointUploader.java +++ b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/checkpoints/DefaultCheckpointUploader.java @@ -20,8 +20,7 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.client.ClientUtils; +import com.walmartlabs.concord.client2.*; import com.walmartlabs.concord.runtime.common.cfg.ApiConfiguration; import com.walmartlabs.concord.runtime.common.cfg.RunnerConfiguration; import com.walmartlabs.concord.runtime.common.injector.InstanceId; @@ -56,7 +55,7 @@ public void upload(UUID checkpointId, UUID correlationId, String name, Path path data.put("data", path); ClientUtils.withRetry(apiConfiguration.retryCount(), apiConfiguration.retryInterval(), () -> { - ClientUtils.postData(apiClient, "/api/v1/process/" + instanceId.getValue() + "/checkpoint", data, null); + new CheckpointApi(apiClient).uploadCheckpoint(instanceId.getValue(), data); return null; }); } diff --git a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/guice/DefaultRunnerModule.java b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/guice/DefaultRunnerModule.java index d82f3912cb..b3b1cc9cee 100644 --- a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/guice/DefaultRunnerModule.java +++ b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/guice/DefaultRunnerModule.java @@ -22,7 +22,7 @@ import com.google.inject.AbstractModule; import com.google.inject.multibindings.Multibinder; -import com.walmartlabs.concord.ApiClient; +import com.walmartlabs.concord.client2.ApiClient; import com.walmartlabs.concord.runtime.v2.runner.*; import com.walmartlabs.concord.runtime.v2.runner.checkpoints.CheckpointService; import com.walmartlabs.concord.runtime.v2.runner.checkpoints.CheckpointUploader; diff --git a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/logging/DefaultLoggingClient.java b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/logging/DefaultLoggingClient.java index 95a9a7ec64..830c7f2fa0 100644 --- a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/logging/DefaultLoggingClient.java +++ b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/logging/DefaultLoggingClient.java @@ -20,12 +20,12 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.ClientUtils; -import com.walmartlabs.concord.client.LogSegmentOperationResponse; -import com.walmartlabs.concord.client.LogSegmentRequest; -import com.walmartlabs.concord.client.ProcessLogV2Api; +import com.walmartlabs.concord.client2.ApiClient; +import com.walmartlabs.concord.client2.ApiException; +import com.walmartlabs.concord.client2.ClientUtils; +import com.walmartlabs.concord.client2.LogSegmentOperationResponse; +import com.walmartlabs.concord.client2.LogSegmentRequest; +import com.walmartlabs.concord.client2.ProcessLogV2Api; import com.walmartlabs.concord.runtime.common.cfg.RunnerConfiguration; import com.walmartlabs.concord.runtime.v2.sdk.ProcessConfiguration; @@ -51,12 +51,12 @@ public DefaultLoggingClient(ApiClient apiClient, ProcessConfiguration processCfg public long createSegment(UUID correlationId, String name) { LogSegmentRequest request = new LogSegmentRequest() - .setCorrelationId(correlationId) - .setCreatedAt(OffsetDateTime.now(ZoneId.of("UTC"))) - .setName(name); + .correlationId(correlationId) + .createdAt(OffsetDateTime.now(ZoneId.of("UTC"))) + .name(name); try { - LogSegmentOperationResponse result = ClientUtils.withRetry(cfg.api().retryCount(), cfg.api().retryInterval(), () -> api.segment(instanceId, request)); + LogSegmentOperationResponse result = ClientUtils.withRetry(cfg.api().retryCount(), cfg.api().retryInterval(), () -> api.createProcessLogSegment(instanceId, request)); return result.getId(); } catch (ApiException e) { throw new RuntimeException(e); diff --git a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/remote/ApiClientProvider.java b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/remote/ApiClientProvider.java index 1a4f057e54..35eaa8cf23 100644 --- a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/remote/ApiClientProvider.java +++ b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/remote/ApiClientProvider.java @@ -20,9 +20,9 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.client.ApiClientConfiguration; -import com.walmartlabs.concord.client.ApiClientFactory; +import com.walmartlabs.concord.client2.ApiClient; +import com.walmartlabs.concord.client2.ApiClientConfiguration; +import com.walmartlabs.concord.client2.ApiClientFactory; import com.walmartlabs.concord.runtime.v2.sdk.ProcessConfiguration; import javax.inject.Inject; diff --git a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/remote/DefaultProcessStatusCallback.java b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/remote/DefaultProcessStatusCallback.java index 6a09c9d33c..1f6ad5bd21 100644 --- a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/remote/DefaultProcessStatusCallback.java +++ b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/remote/DefaultProcessStatusCallback.java @@ -20,11 +20,11 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.ClientUtils; -import com.walmartlabs.concord.client.ProcessApi; -import com.walmartlabs.concord.client.ProcessEntry; +import com.walmartlabs.concord.client2.ApiClient; +import com.walmartlabs.concord.client2.ApiException; +import com.walmartlabs.concord.client2.ClientUtils; +import com.walmartlabs.concord.client2.ProcessApi; +import com.walmartlabs.concord.client2.ProcessEntry; import com.walmartlabs.concord.runtime.common.cfg.RunnerConfiguration; import com.walmartlabs.concord.runtime.v2.runner.ProcessStatusCallback; diff --git a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/remote/EventRecordingExecutionListener.java b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/remote/EventRecordingExecutionListener.java index 76fc8c5d81..da172d8c5e 100644 --- a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/remote/EventRecordingExecutionListener.java +++ b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/remote/EventRecordingExecutionListener.java @@ -20,10 +20,10 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.ProcessEventRequest; -import com.walmartlabs.concord.client.ProcessEventsApi; +import com.walmartlabs.concord.client2.ApiClient; +import com.walmartlabs.concord.client2.ApiException; +import com.walmartlabs.concord.client2.ProcessEventRequest; +import com.walmartlabs.concord.client2.ProcessEventsApi; import com.walmartlabs.concord.runtime.common.injector.InstanceId; import com.walmartlabs.concord.runtime.v2.ProcessDefinitionUtils; import com.walmartlabs.concord.runtime.v2.model.*; diff --git a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/remote/TaskCallEventRecordingListener.java b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/remote/TaskCallEventRecordingListener.java index 8aa9fad812..f0720a5620 100644 --- a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/remote/TaskCallEventRecordingListener.java +++ b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/remote/TaskCallEventRecordingListener.java @@ -20,10 +20,10 @@ * ===== */ -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.ApiException; -import com.walmartlabs.concord.client.ProcessEventRequest; -import com.walmartlabs.concord.client.ProcessEventsApi; +import com.walmartlabs.concord.client2.ApiClient; +import com.walmartlabs.concord.client2.ApiException; +import com.walmartlabs.concord.client2.ProcessEventRequest; +import com.walmartlabs.concord.client2.ProcessEventsApi; import com.walmartlabs.concord.common.ConfigurationUtils; import com.walmartlabs.concord.runtime.common.ObjectTruncater; import com.walmartlabs.concord.runtime.common.injector.InstanceId; diff --git a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/sdk/ApiClientFactoryImpl.java b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/sdk/ApiClientFactoryImpl.java index ea5a54f629..b33f1b90c1 100644 --- a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/sdk/ApiClientFactoryImpl.java +++ b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/sdk/ApiClientFactoryImpl.java @@ -20,25 +20,18 @@ * ===== */ -import com.squareup.okhttp.OkHttpClient; -import com.walmartlabs.concord.ApiClient; -import com.walmartlabs.concord.client.ApiClientConfiguration; -import com.walmartlabs.concord.client.ApiClientFactory; -import com.walmartlabs.concord.client.ConcordApiClient; +import com.walmartlabs.concord.client2.ApiClient; +import com.walmartlabs.concord.client2.ApiClientConfiguration; +import com.walmartlabs.concord.client2.ApiClientFactory; +import com.walmartlabs.concord.client2.DefaultApiClientFactory; import com.walmartlabs.concord.runtime.common.injector.InstanceId; import com.walmartlabs.concord.runtime.v2.sdk.ApiConfiguration; -import com.walmartlabs.concord.runtime.v2.sdk.FileService; import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSocketFactory; -import java.nio.file.Path; -import java.security.KeyManagementException; -import java.security.NoSuchAlgorithmException; +import java.time.Duration; import java.util.UUID; -import java.util.concurrent.TimeUnit; @Named @Singleton @@ -47,50 +40,19 @@ public class ApiClientFactoryImpl implements ApiClientFactory { private final ApiConfiguration cfg; private final InstanceId instanceId; - private final Path tmpDir; - private final OkHttpClient httpClient; + private final DefaultApiClientFactory clientFactory; @Inject - public ApiClientFactoryImpl(ApiConfiguration cfg, InstanceId instanceId, FileService fileService) throws Exception { + public ApiClientFactoryImpl(ApiConfiguration cfg, InstanceId instanceId) throws Exception { this.cfg = cfg; this.instanceId = instanceId; - this.tmpDir = fileService.createTempDirectory("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; + this.clientFactory = new DefaultApiClientFactory(cfg.baseUrl(), Duration.ofMillis(cfg.connectTimeout())); } @Override public ApiClient create(ApiClientConfiguration overrides) { - String baseUrl = overrides.baseUrl() != null ? overrides.baseUrl() : cfg.baseUrl(); - - String sessionToken = null; - if (overrides.apiKey() == null) { - sessionToken = overrides.sessionToken(); - } - - 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()); + ApiClient client = this.clientFactory.create(overrides) + .setReadTimeout(Duration.ofMillis(cfg.readTimeout())); UUID txId = instanceId.getValue(); if (txId != null) { @@ -99,11 +61,4 @@ public ApiClient create(ApiClientConfiguration overrides) { return client; } - - 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/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/sdk/ApiConfigurationV1Impl.java b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/sdk/ApiConfigurationV1Impl.java new file mode 100644 index 0000000000..c443ab16ae --- /dev/null +++ b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/sdk/ApiConfigurationV1Impl.java @@ -0,0 +1,59 @@ +package com.walmartlabs.concord.runtime.v2.runner.sdk; + +/*- + * ***** + * 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.common.cfg.RunnerConfiguration; +import com.walmartlabs.concord.sdk.ApiConfiguration; +import com.walmartlabs.concord.sdk.Context; + +import javax.inject.Inject; +import javax.inject.Named; + +@Named +public class ApiConfigurationV1Impl implements ApiConfiguration { + + private final RunnerConfiguration runnerCfg; + + @Inject + public ApiConfigurationV1Impl(RunnerConfiguration runnerCfg) { + this.runnerCfg = runnerCfg; + } + + @Override + public String getBaseUrl() { + return runnerCfg.api().baseUrl(); + } + + @Override + public int connectTimeout() { + return runnerCfg.api().connectTimeout(); + } + + @Override + public int readTimeout() { + return runnerCfg.api().readTimeout(); + } + + @Override + public String getSessionToken(Context ctx) { + return null; + } +} diff --git a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/vm/CopyVariablesCommand.java b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/vm/CopyVariablesCommand.java index d68b2952d5..cca35d1f94 100644 --- a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/vm/CopyVariablesCommand.java +++ b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/vm/CopyVariablesCommand.java @@ -32,7 +32,7 @@ */ public class CopyVariablesCommand implements Command { - public interface FrameProducer extends BiFunction, Serializable {}; + public interface FrameProducer extends BiFunction, Serializable {} private static final long serialVersionUID = 1L; diff --git a/runtime/v2/runner/src/test/java/com/walmartlabs/concord/runtime/v2/runner/MainTest.java b/runtime/v2/runner/src/test/java/com/walmartlabs/concord/runtime/v2/runner/MainTest.java index 40d758066c..52f312b5d5 100644 --- a/runtime/v2/runner/src/test/java/com/walmartlabs/concord/runtime/v2/runner/MainTest.java +++ b/runtime/v2/runner/src/test/java/com/walmartlabs/concord/runtime/v2/runner/MainTest.java @@ -27,6 +27,7 @@ import com.google.inject.Module; import com.google.inject.multibindings.Multibinder; import com.google.inject.name.Names; +import com.walmartlabs.concord.client2.ApiClient; import com.walmartlabs.concord.common.ConfigurationUtils; import com.walmartlabs.concord.common.IOUtils; import com.walmartlabs.concord.forms.Form; @@ -135,6 +136,7 @@ protected void configure() { bind(PersistenceService.class).toInstance(mock(PersistenceService.class)); bind(ProcessStatusCallback.class).toInstance(processStatusCallback); bind(SecretService.class).to(DefaultSecretService.class); + bind(ApiClient.class).toInstance(mock(ApiClient.class)); Multibinder taskProviders = Multibinder.newSetBinder(binder(), TaskProvider.class); taskProviders.addBinding().to(TaskV2Provider.class); diff --git a/runtime/v2/runner/src/test/java/com/walmartlabs/concord/runtime/v2/runner/tasks/TaskCallInterceptorTest.java b/runtime/v2/runner/src/test/java/com/walmartlabs/concord/runtime/v2/runner/tasks/TaskCallInterceptorTest.java index 4772fac1b5..2192fe2cd8 100644 --- a/runtime/v2/runner/src/test/java/com/walmartlabs/concord/runtime/v2/runner/tasks/TaskCallInterceptorTest.java +++ b/runtime/v2/runner/src/test/java/com/walmartlabs/concord/runtime/v2/runner/tasks/TaskCallInterceptorTest.java @@ -1,5 +1,25 @@ package com.walmartlabs.concord.runtime.v2.runner.tasks; +/*- + * ***** + * 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 org.junit.Test; import java.util.Arrays; diff --git a/server/impl/pom.xml b/server/impl/pom.xml index 71ee58d537..0248ab2c8e 100644 --- a/server/impl/pom.xml +++ b/server/impl/pom.xml @@ -388,7 +388,6 @@ io.swagger.core.v3 swagger-maven-plugin - swagger ${project.build.directory}/classes/com/walmartlabs/concord/server/swagger YAML diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/boot/filters/ConcordAuthenticationHandler.java b/server/impl/src/main/java/com/walmartlabs/concord/server/boot/filters/ConcordAuthenticationHandler.java index a0d6ac71cc..dde523dd36 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/boot/filters/ConcordAuthenticationHandler.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/boot/filters/ConcordAuthenticationHandler.java @@ -27,7 +27,6 @@ import com.walmartlabs.concord.server.security.apikey.ApiKeyDao; import com.walmartlabs.concord.server.security.apikey.ApiKeyEntry; import com.walmartlabs.concord.server.security.sessionkey.SessionKey; -import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationToken; import org.apache.shiro.authc.UsernamePasswordToken; import org.apache.shiro.subject.support.DefaultSubjectContext; diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/SecretResource.java b/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/SecretResource.java index f31831a7fe..8d09c56f5d 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/SecretResource.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/SecretResource.java @@ -34,10 +34,10 @@ import com.walmartlabs.concord.server.user.UserManager; import com.walmartlabs.concord.server.user.UserType; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.headers.Header; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; @@ -98,7 +98,7 @@ public SecretResource(OrganizationManager orgManager, @Validate @Operation(description = "Create secret", operationId = "createSecret") public SecretOperationResponse create(@PathParam("orgName") @ConcordKey String orgName, - @RequestBody(content = @Content(schema = @Schema(type = "object"))) MultipartInput input) { + @Parameter(schema = @Schema(type = "object", implementation = Object.class)) MultipartInput input) { OrganizationEntry org = orgManager.assertAccess(orgName, true); @@ -199,8 +199,7 @@ public SecretEntry get(@PathParam("orgName") @ConcordKey String orgName, ) public Response getData(@PathParam("orgName") @ConcordKey String orgName, @PathParam("secretName") @ConcordKey String secretName, - @RequestBody(content = @Content(schema = @Schema(type = "object", implementation = GetDataRequest.class))) - MultipartInput input) { + @Parameter(schema = @Schema(type = "object", implementation = GetDataRequest.class)) MultipartInput input) { GetDataRequest request = GetDataRequest.from(input); diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/SecretResourceUtils.java b/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/SecretResourceUtils.java index 012c2c0d02..f4bd6427f2 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/SecretResourceUtils.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/SecretResourceUtils.java @@ -33,7 +33,6 @@ import java.io.IOException; import java.io.InputStream; import java.util.*; -import java.util.stream.Collectors; public final class SecretResourceUtils { diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/SecretResourceV2.java b/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/SecretResourceV2.java index 515363b197..a6765af89e 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/SecretResourceV2.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/SecretResourceV2.java @@ -33,9 +33,8 @@ import com.walmartlabs.concord.server.sdk.ConcordApplicationException; import com.walmartlabs.concord.server.sdk.metrics.WithTimer; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.tags.Tag; import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; import org.sonatype.siesta.Resource; @@ -103,7 +102,7 @@ public List list(@PathParam("orgName") @ConcordKey String orgName @Operation(description = "Updates an existing secret", operationId = "updateSecret") public GenericOperationResult update(@PathParam("orgName") @ConcordKey String orgName, @PathParam("secretName") @ConcordKey String secretName, - @RequestBody(content = @Content(schema = @Schema(type = "object"))) MultipartInput input) { + @Parameter(schema = @Schema(type = "object", implementation = Object.class)) MultipartInput input) { OrganizationEntry org = orgManager.assertAccess(orgName, true); Set projectIds = getProjectIds( diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/store/concord/ConcordSecretStore.java b/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/store/concord/ConcordSecretStore.java index 7ca1313cc1..8a2430fe0e 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/store/concord/ConcordSecretStore.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/store/concord/ConcordSecretStore.java @@ -26,8 +26,6 @@ import org.jooq.DSLContext; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import java.util.UUID; public class ConcordSecretStore implements SecretStore { diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessResource.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessResource.java index 25da421db2..12a5bfb60e 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessResource.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/ProcessResource.java @@ -265,8 +265,7 @@ public StartProcessResponse start(@PathParam("entryPoint") String entryPoint, @Produces(MediaType.APPLICATION_JSON) @WithTimer @Operation(description = "Start new process", operationId = "startProcess") - public StartProcessResponse start(@RequestBody(content = @Content(schema = @Schema(type = "object"))) - MultipartInput input, + public StartProcessResponse start(@Parameter(schema = @Schema(type = "object", implementation = Object.class)) MultipartInput input, @Parameter(hidden = true) @Deprecated @QueryParam("parentId") UUID parentInstanceId, @Parameter(hidden = true) @Deprecated @DefaultValue("false") @QueryParam("sync") boolean sync, @Parameter(hidden = true) @Deprecated @QueryParam("out") String[] out, diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/checkpoint/ProcessCheckpointResource.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/checkpoint/ProcessCheckpointResource.java index f1ed6ff698..9832455b6e 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/checkpoint/ProcessCheckpointResource.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/checkpoint/ProcessCheckpointResource.java @@ -32,9 +32,8 @@ import com.walmartlabs.concord.server.sdk.ProcessKey; import com.walmartlabs.concord.server.sdk.metrics.WithTimer; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.tags.Tag; import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; import org.slf4j.Logger; @@ -111,8 +110,7 @@ public ResumeProcessResponse restore(@PathParam("id") UUID instanceId, @Consumes(MediaType.MULTIPART_FORM_DATA) @Operation(description = "Upload checkpoint") public void uploadCheckpoint(@PathParam("id") UUID instanceId, - @RequestBody(content = @Content(schema = @Schema(type = "object"))) - MultipartInput input) { + @Parameter(schema = @Schema(type = "object", implementation = Object.class)) MultipartInput input) { // TODO replace with ProcessKeyCache ProcessEntry entry = processManager.assertProcess(instanceId); diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/checkpoint/ProcessCheckpointV2Resource.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/checkpoint/ProcessCheckpointV2Resource.java index ab2005f0a4..45a623adfb 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/checkpoint/ProcessCheckpointV2Resource.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/checkpoint/ProcessCheckpointV2Resource.java @@ -33,8 +33,6 @@ import org.sonatype.siesta.Resource; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import java.util.UUID; diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/event/ProcessEventResource.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/event/ProcessEventResource.java index a788a455b1..15b52deec4 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/event/ProcessEventResource.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/event/ProcessEventResource.java @@ -33,14 +33,11 @@ import com.walmartlabs.concord.server.security.Roles; import com.walmartlabs.concord.server.security.UserPrincipal; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import org.apache.shiro.authz.UnauthorizedException; import org.sonatype.siesta.Resource; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/form/FormResource.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/form/FormResource.java index 124eac37ef..5da0f0eeca 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/form/FormResource.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/form/FormResource.java @@ -24,6 +24,7 @@ import com.walmartlabs.concord.server.process.state.ProcessStateManager; import com.walmartlabs.concord.server.sdk.PartialProcessKey; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.parameters.RequestBody; @@ -117,7 +118,7 @@ public FormSubmitResponse submit(@PathParam("processInstanceId") UUID processIns @Operation(description = "Submit JSON form data", operationId = "submitFormAsMultipart") public FormSubmitResponse submit(@PathParam("processInstanceId") UUID processInstanceId, @PathParam("formName") String formName, - @RequestBody(content = @Content(schema = @Schema(type = "object"))) MultipartInput data) { + @Parameter(schema = @Schema(type = "object", implementation = Object.class)) MultipartInput data) { if (isV2(processInstanceId)) { return formResourceV2.submit(processInstanceId, formName, data); diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/form/FormResourceV1.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/form/FormResourceV1.java index 4639120c53..a77773a2af 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/form/FormResourceV1.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/form/FormResourceV1.java @@ -28,7 +28,6 @@ import com.walmartlabs.concord.server.sdk.ConcordApplicationException; import com.walmartlabs.concord.server.sdk.PartialProcessKey; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import io.takari.bpm.form.Form; import io.takari.bpm.model.form.FormDefinition; @@ -36,8 +35,6 @@ import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response.Status; diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/form/FormResourceV2.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/form/FormResourceV2.java index a749812294..0f6005623e 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/form/FormResourceV2.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/form/FormResourceV2.java @@ -29,8 +29,6 @@ import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import javax.ws.rs.core.Response.Status; import java.io.Serializable; import java.util.*; diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/locks/LockResult.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/locks/LockResult.java index c155b94038..d1b3c6f29b 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/locks/LockResult.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/locks/LockResult.java @@ -22,7 +22,6 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import io.swagger.v3.oas.annotations.media.Schema; import org.immutables.value.Value; @Value.Immutable @@ -32,7 +31,6 @@ public interface LockResult { LockEntry info(); -// @Schema(description = "is lock acquired?", required = true) boolean acquired(); static ImmutableLockResult.Builder builder() { diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/locks/ProcessLocksDao.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/locks/ProcessLocksDao.java index f2d5b339a4..0a474390dc 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/locks/ProcessLocksDao.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/locks/ProcessLocksDao.java @@ -31,7 +31,6 @@ import org.jooq.SelectConditionStep; import javax.inject.Inject; -import javax.inject.Named; import java.util.UUID; import static com.walmartlabs.concord.server.jooq.Tables.PROCESS_LOCKS; diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/locks/ProcessLocksResource.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/locks/ProcessLocksResource.java index f08b22eaaa..2a8718675c 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/locks/ProcessLocksResource.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/locks/ProcessLocksResource.java @@ -32,8 +32,6 @@ import org.sonatype.siesta.Resource; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/logs/ProcessLogsDao.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/logs/ProcessLogsDao.java index f10e0e84b2..d41ee934c3 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/logs/ProcessLogsDao.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/logs/ProcessLogsDao.java @@ -31,7 +31,6 @@ import org.jooq.*; import javax.inject.Inject; -import javax.inject.Named; import java.io.Serializable; import java.time.OffsetDateTime; import java.util.List; diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/waits/ProcessWaitManager.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/waits/ProcessWaitManager.java index 6ec4a12dd6..abd6fdcc60 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/waits/ProcessWaitManager.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/waits/ProcessWaitManager.java @@ -30,8 +30,6 @@ import org.jooq.DSLContext; import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import java.util.Collections; import java.util.HashMap; import java.util.List; diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/process/waits/WaitProcessStatusListener.java b/server/impl/src/main/java/com/walmartlabs/concord/server/process/waits/WaitProcessStatusListener.java index a14d736869..2c21a71956 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/process/waits/WaitProcessStatusListener.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/process/waits/WaitProcessStatusListener.java @@ -25,8 +25,6 @@ import com.walmartlabs.concord.server.sdk.ProcessStatus; import org.jooq.DSLContext; -import javax.inject.Named; - import static com.walmartlabs.concord.server.jooq.Tables.PROCESS_WAIT_CONDITIONS; public class WaitProcessStatusListener implements ProcessStatusListener { diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/security/ldap/UserLdapGroup.java b/server/impl/src/main/java/com/walmartlabs/concord/server/security/ldap/UserLdapGroup.java index 46868c0c5b..a68b5fa27f 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/security/ldap/UserLdapGroup.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/security/ldap/UserLdapGroup.java @@ -28,7 +28,6 @@ import com.walmartlabs.concord.server.user.UserManager; import com.walmartlabs.concord.server.user.UserType; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import org.apache.shiro.authz.UnauthorizedException; import org.sonatype.siesta.Resource; diff --git a/server/impl/src/main/java/com/walmartlabs/concord/server/user/UserResourceV2.java b/server/impl/src/main/java/com/walmartlabs/concord/server/user/UserResourceV2.java index dcae1bb14f..1778e61ee0 100644 --- a/server/impl/src/main/java/com/walmartlabs/concord/server/user/UserResourceV2.java +++ b/server/impl/src/main/java/com/walmartlabs/concord/server/user/UserResourceV2.java @@ -22,7 +22,6 @@ import com.walmartlabs.concord.server.sdk.metrics.WithTimer; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import org.sonatype.siesta.Resource; import org.sonatype.siesta.ValidationErrorsException; diff --git a/server/plugins/pfed-sso/src/main/java/com/walmartlabs/concord/server/plugins/pfedsso/RedirectHelper.java b/server/plugins/pfed-sso/src/main/java/com/walmartlabs/concord/server/plugins/pfedsso/RedirectHelper.java index 1d725851a4..fe25ddcf63 100644 --- a/server/plugins/pfed-sso/src/main/java/com/walmartlabs/concord/server/plugins/pfedsso/RedirectHelper.java +++ b/server/plugins/pfed-sso/src/main/java/com/walmartlabs/concord/server/plugins/pfedsso/RedirectHelper.java @@ -25,7 +25,6 @@ import org.slf4j.LoggerFactory; import javax.inject.Inject; -import javax.inject.Named; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.net.URL; diff --git a/server/plugins/pfed-sso/src/main/java/com/walmartlabs/concord/server/plugins/pfedsso/SsoConfiguration.java b/server/plugins/pfed-sso/src/main/java/com/walmartlabs/concord/server/plugins/pfedsso/SsoConfiguration.java index 880e3fce09..75a30ef06d 100644 --- a/server/plugins/pfed-sso/src/main/java/com/walmartlabs/concord/server/plugins/pfedsso/SsoConfiguration.java +++ b/server/plugins/pfed-sso/src/main/java/com/walmartlabs/concord/server/plugins/pfedsso/SsoConfiguration.java @@ -26,10 +26,7 @@ import javax.inject.Inject; import java.io.Serializable; import java.time.Duration; -import java.util.Collections; -import java.util.HashSet; import java.util.List; -import java.util.Set; public class SsoConfiguration implements Serializable { diff --git a/server/sdk/src/main/java/com/walmartlabs/concord/server/sdk/ProcessKey.java b/server/sdk/src/main/java/com/walmartlabs/concord/server/sdk/ProcessKey.java index 7d422fb64c..3d3cffc145 100644 --- a/server/sdk/src/main/java/com/walmartlabs/concord/server/sdk/ProcessKey.java +++ b/server/sdk/src/main/java/com/walmartlabs/concord/server/sdk/ProcessKey.java @@ -28,8 +28,6 @@ import java.util.Objects; import java.util.UUID; -import static java.time.temporal.ChronoField.NANO_OF_SECOND; - /** * Composite key of a process. Identifies process resources in partitioned tables. * @apiNote the "createdAt" portion of the key must be truncated to microseconds. diff --git a/targetplatform/pom.xml b/targetplatform/pom.xml index f3906c542c..970ae2edcd 100644 --- a/targetplatform/pom.xml +++ b/targetplatform/pom.xml @@ -120,7 +120,7 @@ 1.33 2.8.0 1.0.2 - 0.0.40 + 2.0.0 1.16.3 1.3.5 2.32.0