From 79e9df82ec0714d8d953973224aa0c7d2f2882e9 Mon Sep 17 00:00:00 2001 From: Nikola Babic Date: Wed, 9 Aug 2023 16:26:57 +0200 Subject: [PATCH 1/3] Add names and versions endpoint --- .../WorkflowsNamesAndVersionsResponse.cs | 18 ++++++++++++++++++ .../Service/IMetadataService.cs | 2 ++ .../Service/MetadataService.cs | 4 ++++ src/ConductorSharp.Client/Util/ApiUrls.cs | 3 +++ 4 files changed, 27 insertions(+) create mode 100644 src/ConductorSharp.Client/Model/Response/WorkflowsNamesAndVersionsResponse.cs diff --git a/src/ConductorSharp.Client/Model/Response/WorkflowsNamesAndVersionsResponse.cs b/src/ConductorSharp.Client/Model/Response/WorkflowsNamesAndVersionsResponse.cs new file mode 100644 index 00000000..3fd5f359 --- /dev/null +++ b/src/ConductorSharp.Client/Model/Response/WorkflowsNamesAndVersionsResponse.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ConductorSharp.Client.Model.Response +{ + public class NameAndVersion + { + public string Name { get; set; } + public int Version { get; set; } + public long CreateTime { get; set; } + } + + public class WorkflowNamesAndVersionsResponse + { + public Dictionary> Data { get; set; } + } +} diff --git a/src/ConductorSharp.Client/Service/IMetadataService.cs b/src/ConductorSharp.Client/Service/IMetadataService.cs index e47e2006..fc1be585 100644 --- a/src/ConductorSharp.Client/Service/IMetadataService.cs +++ b/src/ConductorSharp.Client/Service/IMetadataService.cs @@ -1,4 +1,5 @@ using ConductorSharp.Client.Model.Common; +using ConductorSharp.Client.Model.Response; using System.Collections.Generic; using System.Threading.Tasks; @@ -15,6 +16,7 @@ public interface IMetadataService Task UpdateWorkflowDefinition(WorkflowDefinition workflowDefinition); Task DeleteWorkflowDefinition(string name, int version); Task GetAllWorkflowDefinitions(); + Task GetAllWorkflowNamesAndVersions(); Task GetAllEventHandlerDefinitions(); Task UpdateEventHandlerDefinition(EventHandlerDefinition definition); Task DeleteEventHandlerDefinition(string name); diff --git a/src/ConductorSharp.Client/Service/MetadataService.cs b/src/ConductorSharp.Client/Service/MetadataService.cs index 6f0a2502..c18f2084 100644 --- a/src/ConductorSharp.Client/Service/MetadataService.cs +++ b/src/ConductorSharp.Client/Service/MetadataService.cs @@ -1,4 +1,5 @@ using ConductorSharp.Client.Model.Common; +using ConductorSharp.Client.Model.Response; using ConductorSharp.Client.Util; using System.Collections.Generic; using System.Net.Http; @@ -42,6 +43,9 @@ public async Task CreateWorkflowDefinitions(List workflowDef public async Task GetAllWorkflowDefinitions() => (await _conductorClient.ExecuteRequestAsync(ApiUrls.GetAlleWorkflowDefinitions(), HttpMethod.Get)); + public async Task GetAllWorkflowNamesAndVersions() => + (await _conductorClient.ExecuteRequestAsync(ApiUrls.GetAllWorkflowNamesAndVersions(), HttpMethod.Get)); + public async Task GetAllEventHandlerDefinitions() => await _conductorClient.ExecuteRequestAsync(ApiUrls.GetAllEventDefinitions(), HttpMethod.Get); diff --git a/src/ConductorSharp.Client/Util/ApiUrls.cs b/src/ConductorSharp.Client/Util/ApiUrls.cs index 425e6f9a..61b8b635 100644 --- a/src/ConductorSharp.Client/Util/ApiUrls.cs +++ b/src/ConductorSharp.Client/Util/ApiUrls.cs @@ -16,6 +16,7 @@ internal static class ApiUrls private readonly static Uri _updateWorkflowDefinition = new("metadata/workflow", UriKind.Relative); private readonly static Uri _getAllWorkflowDefinitions = new("metadata/workflow", UriKind.Relative); private readonly static Uri _createWorkflowDefinitions = new("metadata/workflow", UriKind.Relative); + private readonly static Uri _getAllWorkflowNamesAndVersions = new("metadata/workflow/names-and-versions", UriKind.Relative); private readonly static Uri _queueWorkflow = new("workflow", UriKind.Relative); @@ -85,6 +86,8 @@ public static Uri SearchWorkflows(WorkflowSearchRequest request) public static Uri GetAlleWorkflowDefinitions() => _getAllWorkflowDefinitions; + public static Uri GetAllWorkflowNamesAndVersions() => _getAllWorkflowNamesAndVersions; + public static Uri CreateWorkflowDefinitions() => _createWorkflowDefinitions; public static Uri QueueWorkflow() => _queueWorkflow; From 6359be9f71d4f12b7c7026877e42e068b6480dea Mon Sep 17 00:00:00 2001 From: Nikola Babic Date: Thu, 10 Aug 2023 15:46:34 +0200 Subject: [PATCH 2/3] Add JsonProperty annotation --- .../WorkflowsNamesAndVersionsResponse.cs | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/ConductorSharp.Client/Model/Response/WorkflowsNamesAndVersionsResponse.cs b/src/ConductorSharp.Client/Model/Response/WorkflowsNamesAndVersionsResponse.cs index 3fd5f359..9c1edccf 100644 --- a/src/ConductorSharp.Client/Model/Response/WorkflowsNamesAndVersionsResponse.cs +++ b/src/ConductorSharp.Client/Model/Response/WorkflowsNamesAndVersionsResponse.cs @@ -1,18 +1,24 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace ConductorSharp.Client.Model.Response -{ - public class NameAndVersion - { - public string Name { get; set; } - public int Version { get; set; } - public long CreateTime { get; set; } - } - - public class WorkflowNamesAndVersionsResponse - { - public Dictionary> Data { get; set; } - } -} +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace ConductorSharp.Client.Model.Response +{ + public class NameAndVersion + { + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("version")] + public int Version { get; set; } + + [JsonProperty("createTime")] + public long CreateTime { get; set; } + } + + public class WorkflowNamesAndVersionsResponse + { + public Dictionary> Data { get; set; } + } +} From b91dfe2fa92795eae80e7eb23f696d43db353c24 Mon Sep 17 00:00:00 2001 From: "bojan.malinic" Date: Mon, 25 Sep 2023 20:18:05 +0200 Subject: [PATCH 3/3] Fix method return type --- .../Model/Response/WorkflowsNamesAndVersionsResponse.cs | 8 -------- src/ConductorSharp.Client/Service/IMetadataService.cs | 2 +- src/ConductorSharp.Client/Service/MetadataService.cs | 9 +++++++-- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/ConductorSharp.Client/Model/Response/WorkflowsNamesAndVersionsResponse.cs b/src/ConductorSharp.Client/Model/Response/WorkflowsNamesAndVersionsResponse.cs index 9c1edccf..072acc59 100644 --- a/src/ConductorSharp.Client/Model/Response/WorkflowsNamesAndVersionsResponse.cs +++ b/src/ConductorSharp.Client/Model/Response/WorkflowsNamesAndVersionsResponse.cs @@ -1,7 +1,4 @@ using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Text; namespace ConductorSharp.Client.Model.Response { @@ -16,9 +13,4 @@ public class NameAndVersion [JsonProperty("createTime")] public long CreateTime { get; set; } } - - public class WorkflowNamesAndVersionsResponse - { - public Dictionary> Data { get; set; } - } } diff --git a/src/ConductorSharp.Client/Service/IMetadataService.cs b/src/ConductorSharp.Client/Service/IMetadataService.cs index fc1be585..88d6062d 100644 --- a/src/ConductorSharp.Client/Service/IMetadataService.cs +++ b/src/ConductorSharp.Client/Service/IMetadataService.cs @@ -16,7 +16,7 @@ public interface IMetadataService Task UpdateWorkflowDefinition(WorkflowDefinition workflowDefinition); Task DeleteWorkflowDefinition(string name, int version); Task GetAllWorkflowDefinitions(); - Task GetAllWorkflowNamesAndVersions(); + Task>> GetAllWorkflowNamesAndVersions(); Task GetAllEventHandlerDefinitions(); Task UpdateEventHandlerDefinition(EventHandlerDefinition definition); Task DeleteEventHandlerDefinition(string name); diff --git a/src/ConductorSharp.Client/Service/MetadataService.cs b/src/ConductorSharp.Client/Service/MetadataService.cs index c18f2084..6a347f1d 100644 --- a/src/ConductorSharp.Client/Service/MetadataService.cs +++ b/src/ConductorSharp.Client/Service/MetadataService.cs @@ -43,8 +43,13 @@ public async Task CreateWorkflowDefinitions(List workflowDef public async Task GetAllWorkflowDefinitions() => (await _conductorClient.ExecuteRequestAsync(ApiUrls.GetAlleWorkflowDefinitions(), HttpMethod.Get)); - public async Task GetAllWorkflowNamesAndVersions() => - (await _conductorClient.ExecuteRequestAsync(ApiUrls.GetAllWorkflowNamesAndVersions(), HttpMethod.Get)); + public async Task>> GetAllWorkflowNamesAndVersions() => + ( + await _conductorClient.ExecuteRequestAsync>>( + ApiUrls.GetAllWorkflowNamesAndVersions(), + HttpMethod.Get + ) + ); public async Task GetAllEventHandlerDefinitions() => await _conductorClient.ExecuteRequestAsync(ApiUrls.GetAllEventDefinitions(), HttpMethod.Get);