-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathTaskDefinition.cs
108 lines (93 loc) · 4.28 KB
/
TaskDefinition.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Copyright © 2024-Present The Serverless Workflow Specification Authors
//
// 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.
using ServerlessWorkflow.Sdk.Serialization.Json;
namespace ServerlessWorkflow.Sdk.Models;
/// <summary>
/// Represents the definition of a task
/// </summary>
[DataContract, JsonConverter(typeof(TaskDefinitionJsonConverter))]
public abstract record TaskDefinition
: ComponentDefinition
{
/// <summary>
/// Gets the type of the defined task
/// </summary>
[IgnoreDataMember, JsonIgnore, YamlIgnore]
public abstract string Type { get; }
/// <summary>
/// Gets/sets a runtime expression, if any, used to determine whether or not the execute the task in the current context
/// </summary>
[DataMember(Name = "if", Order = 0), JsonPropertyName("if"), JsonPropertyOrder(0), YamlMember(Alias = "if", Order = 0)]
public virtual string? If { get; set; }
/// <summary>
/// Gets/sets the definition, if any, of the task's input data
/// </summary>
[DataMember(Name = "input", Order = 10), JsonPropertyName("input"), JsonPropertyOrder(10), YamlMember(Alias = "input", Order = 10)]
public virtual InputDataModelDefinition? Input { get; set; }
/// <summary>
/// Gets/sets the definition, if any, of the task's output data
/// </summary>
[DataMember(Name = "output", Order = 11), JsonPropertyName("output"), JsonPropertyOrder(11), YamlMember(Alias = "output", Order = 11)]
public virtual OutputDataModelDefinition? Output { get; set; }
/// <summary>
/// Gets/sets the optional configuration for exporting data within the task's context
/// </summary>
[DataMember(Name = "export", Order = 12), JsonPropertyName("export"), JsonPropertyOrder(12), YamlMember(Alias = "export", Order = 12)]
public virtual OutputDataModelDefinition? Export { get; set; }
/// <summary>
/// Gets/sets the task's timeout, if any
/// </summary>
[IgnoreDataMember, JsonIgnore, YamlIgnore]
public virtual TimeoutDefinition? Timeout
{
get => this.TimeoutValue?.T1Value;
set
{
ArgumentNullException.ThrowIfNull(value);
this.TimeoutValue = value;
}
}
/// <summary>
/// Gets/sets the reference to the task's timeout, if any
/// </summary>
[IgnoreDataMember, JsonIgnore, YamlIgnore]
public virtual string? TimeoutReference
{
get => this.TimeoutValue?.T2Value;
set
{
ArgumentException.ThrowIfNullOrWhiteSpace(value);
this.TimeoutValue = value;
}
}
/// <summary>
/// Gets/sets the task's timeout, if any
/// </summary>
[DataMember(Name = "timeout", Order = 13), JsonPropertyName("timeout"), JsonPropertyOrder(13), YamlMember(Alias = "timeout", Order = 13)]
protected virtual OneOf<TimeoutDefinition, string>? TimeoutValue { get; set; } = null!;
/// <summary>
/// Gets/sets the flow directive to be performed upon completion of the task
/// </summary>
[DataMember(Name = "then", Order = 14), JsonPropertyName("then"), JsonPropertyOrder(14), YamlMember(Alias = "then", Order = 14)]
public virtual string? Then { get; set; }
/// <summary>
/// Gets/sets a key/value mapping of additional information associated with the task
/// </summary>
[DataMember(Name = "metadata", Order = 15), JsonPropertyName("metadata"), JsonPropertyOrder(15), YamlMember(Alias = "metadata", Order = 15)]
public virtual EquatableDictionary<string, object>? Metadata { get; set; }
/// <summary>
/// Gets/sets the object used to define the errors to catch
/// </summary>
[DataMember(Name = "catch", Order = 16), JsonPropertyName("catch"), JsonPropertyOrder(16), YamlMember(Alias = "catch", Order = 16)]
public virtual ErrorCatcherDefinition? Catch { get; set; }
}