Skip to content

Commit 9818d65

Browse files
authored
Merge pull request #75 from serverlessworkflow/feat-alpha-6
Implement ServerlessWorkflow `v1.0.0-alpha6`
2 parents d5c6cf9 + 6883c40 commit 9818d65

17 files changed

+392
-26
lines changed

src/ServerlessWorkflow.Sdk.Builders/ServerlessWorkflow.Sdk.Builders.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<VersionPrefix>1.0.0</VersionPrefix>
8-
<VersionSuffix>alpha5.4</VersionSuffix>
8+
<VersionSuffix>alpha6</VersionSuffix>
99
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1010
<FileVersion>$(VersionPrefix)</FileVersion>
1111
<NeutralLanguage>en</NeutralLanguage>

src/ServerlessWorkflow.Sdk.IO/ServerlessWorkflow.Sdk.IO.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<VersionPrefix>1.0.0</VersionPrefix>
8-
<VersionSuffix>alpha5.4</VersionSuffix>
8+
<VersionSuffix>alpha6</VersionSuffix>
99
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1010
<FileVersion>$(VersionPrefix)</FileVersion>
1111
<NeutralLanguage>en</NeutralLanguage>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright © 2024-Present The Serverless Workflow Specification Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"),
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
namespace ServerlessWorkflow.Sdk;
15+
16+
/// <summary>
17+
/// Enumerates all supported container cleanup policies
18+
/// </summary>
19+
public static class ContainerCleanupPolicy
20+
{
21+
22+
/// <summary>
23+
/// Indicates that the runtime must delete the container immediately after execution
24+
/// </summary>
25+
public const string Always = "always";
26+
/// <summary>
27+
/// Indicates that the runtime must eventually delete the container, after waiting for a specific amount of time.
28+
/// </summary>
29+
public const string Eventually = "eventually";
30+
/// <summary>
31+
/// Indicates that the runtime must never delete the container.
32+
/// </summary>
33+
public const string Never = "never";
34+
35+
/// <summary>
36+
/// Gets a new <see cref="IEnumerable{T}"/> containing all supported values
37+
/// </summary>
38+
/// <returns>A new <see cref="IEnumerable{T}"/> containing all supported values</returns>
39+
public static IEnumerable<string> AsEnumerable()
40+
{
41+
yield return Always;
42+
yield return Eventually;
43+
yield return Never;
44+
}
45+
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright © 2024-Present The Serverless Workflow Specification Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"),
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
namespace ServerlessWorkflow.Sdk.Models;
15+
16+
/// <summary>
17+
/// Represents the definition of an AsyncAPI message
18+
/// </summary>
19+
[DataContract]
20+
public record AsyncApiMessageDefinition
21+
{
22+
23+
/// <summary>
24+
/// Gets/sets the message's payload, if any
25+
/// </summary>
26+
[DataMember(Name = "payload", Order = 1), JsonPropertyName("payload"), JsonPropertyOrder(1), YamlMember(Alias = "payload", Order = 1)]
27+
public virtual object? Payload { get; set; }
28+
29+
/// <summary>
30+
/// Gets/sets the message's headers, if any
31+
/// </summary>
32+
[DataMember(Name = "headers", Order = 2), JsonPropertyName("headers"), JsonPropertyOrder(2), YamlMember(Alias = "headers", Order = 2)]
33+
public virtual object? Headers { get; set; }
34+
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright © 2024-Present The Serverless Workflow Specification Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"),
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
namespace ServerlessWorkflow.Sdk.Models;
15+
16+
/// <summary>
17+
/// Represents an object used to configure an AsyncAPI subscription
18+
/// </summary>
19+
[DataContract]
20+
public record AsyncApiSubscriptionDefinition
21+
{
22+
23+
/// <summary>
24+
/// Gets/sets a runtime expression, if any, used to filter consumed messages
25+
/// </summary>
26+
[DataMember(Name = "filter", Order = 1), JsonPropertyName("filter"), JsonPropertyOrder(1), YamlMember(Alias = "filter", Order = 1)]
27+
public virtual string? Filter { get; set; }
28+
29+
/// <summary>
30+
/// Gets/sets an object used to configure the subscription's lifetime.
31+
/// </summary>
32+
[Required]
33+
[DataMember(Name = "consume", Order = 2), JsonPropertyName("consume"), JsonPropertyOrder(2), YamlMember(Alias = "consume", Order = 2)]
34+
public required virtual AsyncApiSubscriptionLifetimeDefinition Consume { get; set; }
35+
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright © 2024-Present The Serverless Workflow Specification Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"),
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
namespace ServerlessWorkflow.Sdk.Models;
15+
16+
/// <summary>
17+
/// Represents an object used to configure the lifetime of an AsyncAPI subscription
18+
/// </summary>
19+
[DataContract]
20+
public record AsyncApiSubscriptionLifetimeDefinition
21+
{
22+
23+
/// <summary>
24+
/// Gets/sets the duration that defines for how long to consume messages
25+
/// /// </summary>
26+
[DataMember(Name = "for", Order = 1), JsonPropertyName("for"), JsonPropertyOrder(1), YamlMember(Alias = "for", Order = 1)]
27+
public virtual Duration? For { get; set; }
28+
29+
/// <summary>
30+
/// Gets/sets the amount of messages to consume.<para></para>
31+
/// Required if <see cref="While"/> and <see cref="Until"/> have not been set.
32+
/// /// </summary>
33+
[DataMember(Name = "amount", Order = 2), JsonPropertyName("amount"), JsonPropertyOrder(2), YamlMember(Alias = "amount", Order = 2)]
34+
public virtual int? Amount { get; set; }
35+
36+
/// <summary>
37+
/// Gets/sets a runtime expression, if any, used to determine whether or not to keep consuming messages.<para></para>
38+
/// Required if <see cref="Amount"/> and <see cref="Until"/> have not been set.
39+
/// /// </summary>
40+
[DataMember(Name = "while", Order = 3), JsonPropertyName("while"), JsonPropertyOrder(3), YamlMember(Alias = "while", Order = 3)]
41+
public virtual int? While { get; set; }
42+
43+
/// <summary>
44+
/// Gets/sets a runtime expression, if any, used to determine until when to consume messages..<para></para>
45+
/// Required if <see cref="Amount"/> and <see cref="While"/> have not been set.
46+
/// /// </summary>
47+
[DataMember(Name = "until", Order = 4), JsonPropertyName("until"), JsonPropertyOrder(4), YamlMember(Alias = "until", Order = 4)]
48+
public virtual int? Until { get; set; }
49+
50+
}

src/ServerlessWorkflow.Sdk/Models/Calls/AsyncApiCallDefinition.cs

+28-17
Original file line numberDiff line numberDiff line change
@@ -29,40 +29,51 @@ public record AsyncApiCallDefinition
2929
public required virtual ExternalResourceDefinition Document { get; set; }
3030

3131
/// <summary>
32-
/// Gets/sets a reference to the AsyncAPI operation to call
32+
/// Gets/sets the name of the channel on which to perform the operation. The operation to perform is defined by declaring either message, in which case the channel's publish operation will be executed, or subscription, in which case the channel's subscribe operation will be executed.<para></para>
33+
/// Used only in case the referenced document uses AsyncAPI v2.6.0
3334
/// </summary>
34-
[Required]
35-
[DataMember(Name = "operationRef", Order = 2), JsonPropertyName("operationRef"), JsonPropertyOrder(2), JsonInclude, YamlMember(Alias = "operationRef", Order = 2)]
36-
public required virtual string OperationRef { get; set; }
35+
[DataMember(Name = "channel", Order = 2), JsonPropertyName("channel"), JsonPropertyOrder(2), JsonInclude, YamlMember(Alias = "channel", Order = 2)]
36+
public required virtual string? Channel { get; set; }
37+
38+
/// <summary>
39+
/// Gets/sets a reference to the AsyncAPI operation to call.<para></para>
40+
/// Used only in case the referenced document uses AsyncAPI v3.0.0.
41+
/// </summary>
42+
[DataMember(Name = "operation", Order = 3), JsonPropertyName("operation"), JsonPropertyOrder(3), JsonInclude, YamlMember(Alias = "operation", Order = 3)]
43+
public required virtual string? Operation { get; set; }
3744

3845
/// <summary>
39-
/// Gets/sets a reference to the server to call the specified AsyncAPI operation on. If not set, default to the first server matching the operation's channel.
46+
/// Gets/sets a object used to configure to the server to call the specified AsyncAPI operation on.<para></para>
47+
/// If not set, default to the first server matching the operation's channel.
4048
/// </summary>
41-
[DataMember(Name = "server", Order = 3), JsonPropertyName("server"), JsonPropertyOrder(3), JsonInclude, YamlMember(Alias = "server", Order = 3)]
49+
[DataMember(Name = "server", Order = 4), JsonPropertyName("server"), JsonPropertyOrder(4), JsonInclude, YamlMember(Alias = "server", Order = 4)]
4250
public virtual string? Server { get; set; }
4351

4452
/// <summary>
45-
/// Gets/sets the name of the message to use. If not set, defaults to the first message defined by the operation
53+
/// Gets/sets the protocol to use to select the target server.<para></para>
54+
/// Ignored if <see cref="Server"/> has been set.
4655
/// </summary>
47-
[DataMember(Name = "message", Order = 4), JsonPropertyName("message"), JsonPropertyOrder(4), JsonInclude, YamlMember(Alias = "message", Order = 4)]
48-
public virtual string? Message { get; set; }
56+
[DataMember(Name = "protocol", Order = 5), JsonPropertyName("protocol"), JsonPropertyOrder(5), JsonInclude, YamlMember(Alias = "protocol", Order = 5)]
57+
public virtual string? Protocol { get; set; }
4958

5059
/// <summary>
51-
/// Gets/sets the name of the binding to use. If not set, defaults to the first binding defined by the operation
60+
/// Gets/sets an object used to configure the message to publish using the target operation.<para></para>
61+
/// Required if <see cref="Subscription"/> has not been set.
5262
/// </summary>
53-
[DataMember(Name = "binding", Order = 5), JsonPropertyName("binding"), JsonPropertyOrder(5), JsonInclude, YamlMember(Alias = "binding", Order = 5)]
54-
public virtual string? Binding { get; set; }
63+
[DataMember(Name = "message", Order = 6), JsonPropertyName("message"), JsonPropertyOrder(6), JsonInclude, YamlMember(Alias = "message", Order = 6)]
64+
public virtual AsyncApiMessageDefinition? Message { get; set; }
5565

5666
/// <summary>
57-
/// Gets/sets the payload to call the AsyncAPI operation with
67+
/// Gets/sets an object used to configure the subscription to messages consumed using the target operation.<para></para>
68+
/// Required if <see cref="Message"/> has not been set.
5869
/// </summary>
59-
[DataMember(Name = "payload", Order = 6), JsonPropertyName("payload"), JsonPropertyOrder(6), JsonInclude, YamlMember(Alias = "payload", Order = 6)]
60-
public virtual object? Payload { get; set; }
70+
[DataMember(Name = "subscription", Order = 7), JsonPropertyName("subscription"), JsonPropertyOrder(7), JsonInclude, YamlMember(Alias = "subscription", Order = 7)]
71+
public virtual AsyncApiSubscriptionDefinition? Subscription { get; set; }
6172

6273
/// <summary>
6374
/// Gets/sets the authentication policy, if any, to use when calling the AsyncAPI operation
6475
/// </summary>
65-
[DataMember(Name = "authentication", Order = 7), JsonPropertyName("authentication"), JsonPropertyOrder(7), JsonInclude, YamlMember(Alias = "authentication", Order = 7)]
76+
[DataMember(Name = "authentication", Order = 8), JsonPropertyName("authentication"), JsonPropertyOrder(8), JsonInclude, YamlMember(Alias = "authentication", Order = 8)]
6677
public virtual AuthenticationPolicyDefinition? Authentication { get; set; }
6778

68-
}
79+
}

src/ServerlessWorkflow.Sdk/Models/Calls/HttpCallDefinition.cs

+8
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,12 @@ public virtual Uri EndpointUri
7373
[DataMember(Name = "output", Order = 5), JsonPropertyName("output"), JsonPropertyOrder(5), YamlMember(Alias = "output", Order = 5)]
7474
public virtual string? Output { get; set; }
7575

76+
/// <summary>
77+
/// Gets/sets a boolean indicating whether redirection status codes (300–399) should be treated as errors.<para></para>
78+
/// If set to 'false', runtimes must raise an error for response status codes outside the 200–299 range.<para></para>
79+
/// If set to 'true', they must raise an error for status codes outside the 200–399 range.
80+
/// </summary>
81+
[DataMember(Name = "redirect", Order = 6), JsonPropertyName("redirect"), JsonPropertyOrder(6), YamlMember(Alias = "redirect", Order = 6)]
82+
public virtual bool Redirect { get; set; }
83+
7684
}

src/ServerlessWorkflow.Sdk/Models/Calls/OpenApiCallDefinition.cs

+8
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,12 @@ public record OpenApiCallDefinition
5353
[DataMember(Name = "output", Order = 6), JsonPropertyName("output"), JsonPropertyOrder(6), YamlMember(Alias = "output", Order = 6)]
5454
public virtual string? Output { get; set; }
5555

56+
/// <summary>
57+
/// Gets/sets a boolean indicating whether redirection status codes (300–399) should be treated as errors.<para></para>
58+
/// If set to 'false', runtimes must raise an error for response status codes outside the 200–299 range.<para></para>
59+
/// If set to 'true', they must raise an error for status codes outside the 200–399 range.
60+
/// </summary>
61+
[DataMember(Name = "redirect", Order = 7), JsonPropertyName("redirect"), JsonPropertyOrder(7), YamlMember(Alias = "redirect", Order = 7)]
62+
public virtual bool Redirect { get; set; }
63+
5664
}

src/ServerlessWorkflow.Sdk/Models/EventConsumptionStrategyDefinition.cs

+28-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public record EventConsumptionStrategyDefinition
2727
public virtual EquatableList<EventFilterDefinition>? All { get; set; }
2828

2929
/// <summary>
30-
/// Gets/sets a list containing any of the events to consume, if any
30+
/// Gets/sets a list containing any of the events to consume, if any.<para></para>
31+
/// If empty, listens to all incoming events, and requires <see cref="Until"/> to be set.
3132
/// </summary>
3233
[DataMember(Name = "any", Order = 2), JsonPropertyName("any"), JsonPropertyOrder(2), YamlMember(Alias = "any", Order = 2)]
3334
public virtual EquatableList<EventFilterDefinition>? Any { get; set; }
@@ -38,4 +39,30 @@ public record EventConsumptionStrategyDefinition
3839
[DataMember(Name = "one", Order = 3), JsonPropertyName("one"), JsonPropertyOrder(3), YamlMember(Alias = "one", Order = 3)]
3940
public virtual EventFilterDefinition? One { get; set; }
4041

42+
/// <summary>
43+
/// Gets/sets the condition or the consumption strategy that defines the events that must be consumed to stop listening
44+
/// </summary>
45+
[DataMember(Name = "until", Order = 4), JsonInclude, JsonPropertyName("until"), JsonPropertyOrder(4), YamlMember(Alias = "until", Order = 4)]
46+
protected virtual OneOf<EventConsumptionStrategyDefinition, string>? UntilValue { get; set; }
47+
48+
/// <summary>
49+
/// Gets/sets the consumption strategy, if any, that defines the events that must be consumed to stop listening
50+
/// </summary>
51+
[IgnoreDataMember, JsonIgnore, YamlIgnore]
52+
public virtual EventConsumptionStrategyDefinition? Until
53+
{
54+
get => this.UntilValue?.T1Value;
55+
set => this.UntilValue = value!;
56+
}
57+
58+
/// <summary>
59+
/// Gets/sets a runtime expression, if any, that represents the condition that must be met to stop listening
60+
/// </summary>
61+
[IgnoreDataMember, JsonIgnore, YamlIgnore]
62+
public virtual string? UntilExpression
63+
{
64+
get => this.UntilValue?.T2Value;
65+
set => this.UntilValue = value!;
66+
}
67+
4168
}

src/ServerlessWorkflow.Sdk/Models/EventEmissionDefinition.cs

+8
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,12 @@ public record EventEmissionDefinition
2727
[DataMember(Name = "event", Order = 1), JsonPropertyName("event"), JsonPropertyOrder(1), YamlMember(Alias = "event", Order = 1)]
2828
public required virtual EventDefinition Event { get; set; }
2929

30+
/// <summary>
31+
/// Gets/sets an additional endpoint for emitting a carbon copy of the event.
32+
/// While the runtime's default cloud event endpoint remains the primary destination, setting this property ensures that the event is also published to the specified endpoint.
33+
/// Ideally, this property is left unset so that event delivery relies solely on the runtime's configured endpoint, but when provided, the event will be sent to both endpoints concurrently.
34+
/// </summary>
35+
[DataMember(Name = "cc", Order = 2), JsonPropertyName("cc"), JsonPropertyOrder(2), YamlMember(Alias = "cc", Order = 2)]
36+
public virtual EndpointDefinition? Cc { get; set; }
37+
3038
}

src/ServerlessWorkflow.Sdk/Models/ProcessTypeDefinition.cs

+8
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ public record ProcessTypeDefinition
5252
[DataMember(Name = "await", Order = 5), JsonPropertyName("await"), JsonPropertyOrder(5), YamlMember(Alias = "await", Order = 5)]
5353
public virtual bool? Await { get; set; }
5454

55+
/// <summary>
56+
/// Gets/sets the output of the process.<para></para>
57+
/// See <see cref="ProcessReturnType"/><para></para>
58+
/// Defaults to <see cref="ProcessReturnType.Stdout"/>
59+
/// </summary>
60+
[DataMember(Name = "return", Order = 6), JsonPropertyName("return"), JsonPropertyOrder(6), YamlMember(Alias = "return", Order = 6)]
61+
public virtual string? Return { get; set; }
62+
5563
/// <summary>
5664
/// Gets the type of the defined process tasks
5765
/// </summary>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright © 2024-Present The Serverless Workflow Specification Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"),
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
namespace ServerlessWorkflow.Sdk.Models.Processes;
15+
16+
/// <summary>
17+
/// Represents an object used to configure the lifetime of a container
18+
/// </summary>
19+
[DataContract]
20+
public record ContainerLifetimeDefinition
21+
{
22+
23+
/// <summary>
24+
/// Gets/sets the cleanup policy to use.<para></para>
25+
/// See <see cref="ContainerCleanupPolicy"/><para></para>
26+
/// Defaults to <see cref="ContainerCleanupPolicy.Never"/>
27+
/// </summary>
28+
[Required, MinLength(1)]
29+
[DataMember(Name = "cleanup", Order = 1), JsonPropertyName("cleanup"), JsonPropertyOrder(1), YamlMember(Alias = "cleanup", Order = 1)]
30+
public required virtual string Cleanup { get; set; }
31+
32+
/// <summary>
33+
/// Gets/sets the duration, if any, after which to delete the container once executed.<para></para>
34+
/// Required if <see cref="Cleanup"/> has been set to <see cref="ContainerCleanupPolicy.Eventually"/>, otherwise ignored.
35+
/// </summary>
36+
[DataMember(Name = "duration", Order = 2), JsonPropertyName("duration"), JsonPropertyOrder(2), YamlMember(Alias = "duration", Order = 2)]
37+
public virtual Duration? Duration { get; set; }
38+
}

0 commit comments

Comments
 (0)