Skip to content

Commit f1a9798

Browse files
committed
fixup
Signed-off-by: Neil South <[email protected]>
1 parent 478b15b commit f1a9798

File tree

1 file changed

+86
-6
lines changed

1 file changed

+86
-6
lines changed
Lines changed: 86 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,92 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
1+
/*
2+
* Copyright 2021-2023 MONAI Consortium
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
616

17+
using System.ComponentModel.DataAnnotations;
18+
using System.Text.Json.Serialization;
19+
using Ardalis.GuardClauses;
20+
using Newtonsoft.Json;
21+
using Newtonsoft.Json.Converters;
722
namespace Monai.Deploy.Messaging.Events
823
{
9-
internal class ExternalAppRequestEvent
24+
public class ExternalAppRequestEvent
1025
{
26+
/// <summary>
27+
/// Gets or sets the workflow instanceID generated by the Workflow Manager.
28+
/// </summary>
29+
[JsonProperty(PropertyName = "workflow_instance_id")]
30+
[JsonPropertyName("workflow_instance_id")]
31+
[Required]
32+
public string WorkflowInstanceId { get; set; } = default!;
33+
34+
/// <summary>
35+
/// Gets or sets the export task ID generated by the Workflow Manager.
36+
/// </summary>
37+
[JsonProperty(PropertyName = "export_task_id")]
38+
[JsonPropertyName("export_task_id")]
39+
[Required]
40+
public string ExportTaskId { get; set; } = default!;
41+
42+
/// <summary>
43+
/// Gets or sets the state of the export task.
44+
/// </summary>
45+
[JsonProperty(PropertyName = "status")]
46+
[JsonPropertyName("status")]
47+
[Newtonsoft.Json.JsonConverter(typeof(StringEnumConverter))]
48+
[System.Text.Json.Serialization.JsonConverter(typeof(JsonStringEnumConverter))]
49+
[Required]
50+
public ExportStatus Status { get; set; }
51+
52+
/// <summary>
53+
/// Gets or sets error messages, if any, when exporting.
54+
/// </summary>
55+
[JsonProperty(PropertyName = "message")]
56+
[JsonPropertyName("message")]
57+
public string Message { get; set; } = default!;
58+
59+
/// <summary>
60+
/// Gets or sets files exported with its status
61+
/// </summary>
62+
[JsonProperty(PropertyName = "file_statuses")]
63+
[JsonPropertyName("file_statuses")]
64+
public Dictionary<string, FileExportStatus> FileStatuses { get; set; }
65+
66+
/// <summary>
67+
/// the target to export too
68+
/// </summary>
69+
public DataOrigin? Target { get; set; }
70+
71+
[Newtonsoft.Json.JsonConstructor]
72+
[System.Text.Json.Serialization.JsonConstructor]
73+
public ExternalAppRequestEvent()
74+
{
75+
Status = ExportStatus.Unknown;
76+
FileStatuses = new Dictionary<string, FileExportStatus>();
77+
}
78+
79+
public ExternalAppRequestEvent(ExportRequestEvent exportRequest, ExportStatus exportStatus, Dictionary<string, FileExportStatus> fileStatuses)
80+
{
81+
Guard.Against.Null(exportRequest, nameof(exportRequest));
82+
Guard.Against.Null(exportStatus, nameof(exportStatus));
83+
Guard.Against.Null(fileStatuses, nameof(fileStatuses));
84+
85+
WorkflowInstanceId = exportRequest.WorkflowInstanceId;
86+
ExportTaskId = exportRequest.ExportTaskId;
87+
Message = string.Join(System.Environment.NewLine, exportRequest.ErrorMessages);
88+
Status = exportStatus;
89+
FileStatuses = fileStatuses;
90+
}
1191
}
1292
}

0 commit comments

Comments
 (0)