From ebf3919d4f0e2de700ddc04624e67fd94208fc2b Mon Sep 17 00:00:00 2001 From: Alex May Date: Fri, 30 Jun 2023 15:02:52 -0600 Subject: [PATCH] add new endpoint to conductor-client --- .../conductor/client/http/MetadataClient.java | 10 ++++++++++ .../client/http/MetadataClientSpec.groovy | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/client/src/main/java/com/netflix/conductor/client/http/MetadataClient.java b/client/src/main/java/com/netflix/conductor/client/http/MetadataClient.java index 1ea4efebaf..8db927b8c5 100644 --- a/client/src/main/java/com/netflix/conductor/client/http/MetadataClient.java +++ b/client/src/main/java/com/netflix/conductor/client/http/MetadataClient.java @@ -22,12 +22,16 @@ import com.netflix.conductor.common.metadata.workflow.WorkflowDef; import com.sun.jersey.api.client.ClientHandler; +import com.sun.jersey.api.client.GenericType; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.sun.jersey.api.client.filter.ClientFilter; public class MetadataClient extends ClientBase { + private static final GenericType> workflowDefList = + new GenericType>() {}; + /** Creates a default metadata client */ public MetadataClient() { this(new DefaultClientConfig(), new DefaultConductorClientConfiguration(), null); @@ -122,6 +126,12 @@ public WorkflowDef getWorkflowDef(String name, Integer version) { name); } + /** */ + public List getAllWorkflowsWithLatestVersions() { + return getForEntity( + "metadata/workflow/latest-versions", null, workflowDefList, (Object) null); + } + /** * Removes the workflow definition of a workflow from the conductor server. It does not remove * associated workflows. Use with caution. diff --git a/client/src/test/groovy/com/netflix/conductor/client/http/MetadataClientSpec.groovy b/client/src/test/groovy/com/netflix/conductor/client/http/MetadataClientSpec.groovy index f194f7180a..d82acc5090 100644 --- a/client/src/test/groovy/com/netflix/conductor/client/http/MetadataClientSpec.groovy +++ b/client/src/test/groovy/com/netflix/conductor/client/http/MetadataClientSpec.groovy @@ -13,7 +13,9 @@ package com.netflix.conductor.client.http import com.netflix.conductor.client.exception.ConductorClientException +import com.netflix.conductor.common.metadata.workflow.WorkflowDef +import com.sun.jersey.api.client.ClientResponse import spock.lang.Subject class MetadataClientSpec extends ClientSpecification { @@ -75,4 +77,18 @@ class MetadataClientSpec extends ClientSpecification { then: thrown(IllegalArgumentException.class) } + + def "workflow get all definitions latest version"() { + given: + List result = new ArrayList() + URI uri = createURI("metadata/workflow/latest-versions") + + when: + metadataClient.getAllWorkflowsWithLatestVersions() + + then: + 1 * requestHandler.get(uri) >> Mock(ClientResponse.class) { + getEntity(_) >> result + } + } }