Skip to content

Commit

Permalink
Merge pull request #75 from serverlessworkflow/feat-alpha-6
Browse files Browse the repository at this point in the history
Implement ServerlessWorkflow `v1.0.0-alpha6`
  • Loading branch information
cdavernas authored Jan 10, 2025
2 parents d5c6cf9 + 6883c40 commit 9818d65
Show file tree
Hide file tree
Showing 17 changed files with 392 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>alpha5.4</VersionSuffix>
<VersionSuffix>alpha6</VersionSuffix>
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
<FileVersion>$(VersionPrefix)</FileVersion>
<NeutralLanguage>en</NeutralLanguage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>alpha5.4</VersionSuffix>
<VersionSuffix>alpha6</VersionSuffix>
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
<FileVersion>$(VersionPrefix)</FileVersion>
<NeutralLanguage>en</NeutralLanguage>
Expand Down
46 changes: 46 additions & 0 deletions src/ServerlessWorkflow.Sdk/ContainerCleanupPolicy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// 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.

namespace ServerlessWorkflow.Sdk;

/// <summary>
/// Enumerates all supported container cleanup policies
/// </summary>
public static class ContainerCleanupPolicy
{

/// <summary>
/// Indicates that the runtime must delete the container immediately after execution
/// </summary>
public const string Always = "always";
/// <summary>
/// Indicates that the runtime must eventually delete the container, after waiting for a specific amount of time.
/// </summary>
public const string Eventually = "eventually";
/// <summary>
/// Indicates that the runtime must never delete the container.
/// </summary>
public const string Never = "never";

/// <summary>
/// Gets a new <see cref="IEnumerable{T}"/> containing all supported values
/// </summary>
/// <returns>A new <see cref="IEnumerable{T}"/> containing all supported values</returns>
public static IEnumerable<string> AsEnumerable()
{
yield return Always;
yield return Eventually;
yield return Never;
}

}
35 changes: 35 additions & 0 deletions src/ServerlessWorkflow.Sdk/Models/AsyncApiMessageDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// 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.

namespace ServerlessWorkflow.Sdk.Models;

/// <summary>
/// Represents the definition of an AsyncAPI message
/// </summary>
[DataContract]
public record AsyncApiMessageDefinition
{

/// <summary>
/// Gets/sets the message's payload, if any
/// </summary>
[DataMember(Name = "payload", Order = 1), JsonPropertyName("payload"), JsonPropertyOrder(1), YamlMember(Alias = "payload", Order = 1)]
public virtual object? Payload { get; set; }

/// <summary>
/// Gets/sets the message's headers, if any
/// </summary>
[DataMember(Name = "headers", Order = 2), JsonPropertyName("headers"), JsonPropertyOrder(2), YamlMember(Alias = "headers", Order = 2)]
public virtual object? Headers { get; set; }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// 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.

namespace ServerlessWorkflow.Sdk.Models;

/// <summary>
/// Represents an object used to configure an AsyncAPI subscription
/// </summary>
[DataContract]
public record AsyncApiSubscriptionDefinition
{

/// <summary>
/// Gets/sets a runtime expression, if any, used to filter consumed messages
/// </summary>
[DataMember(Name = "filter", Order = 1), JsonPropertyName("filter"), JsonPropertyOrder(1), YamlMember(Alias = "filter", Order = 1)]
public virtual string? Filter { get; set; }

/// <summary>
/// Gets/sets an object used to configure the subscription's lifetime.
/// </summary>
[Required]
[DataMember(Name = "consume", Order = 2), JsonPropertyName("consume"), JsonPropertyOrder(2), YamlMember(Alias = "consume", Order = 2)]
public required virtual AsyncApiSubscriptionLifetimeDefinition Consume { get; set; }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// 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.

namespace ServerlessWorkflow.Sdk.Models;

/// <summary>
/// Represents an object used to configure the lifetime of an AsyncAPI subscription
/// </summary>
[DataContract]
public record AsyncApiSubscriptionLifetimeDefinition
{

/// <summary>
/// Gets/sets the duration that defines for how long to consume messages
/// /// </summary>
[DataMember(Name = "for", Order = 1), JsonPropertyName("for"), JsonPropertyOrder(1), YamlMember(Alias = "for", Order = 1)]
public virtual Duration? For { get; set; }

/// <summary>
/// Gets/sets the amount of messages to consume.<para></para>
/// Required if <see cref="While"/> and <see cref="Until"/> have not been set.
/// /// </summary>
[DataMember(Name = "amount", Order = 2), JsonPropertyName("amount"), JsonPropertyOrder(2), YamlMember(Alias = "amount", Order = 2)]
public virtual int? Amount { get; set; }

/// <summary>
/// Gets/sets a runtime expression, if any, used to determine whether or not to keep consuming messages.<para></para>
/// Required if <see cref="Amount"/> and <see cref="Until"/> have not been set.
/// /// </summary>
[DataMember(Name = "while", Order = 3), JsonPropertyName("while"), JsonPropertyOrder(3), YamlMember(Alias = "while", Order = 3)]
public virtual int? While { get; set; }

/// <summary>
/// Gets/sets a runtime expression, if any, used to determine until when to consume messages..<para></para>
/// Required if <see cref="Amount"/> and <see cref="While"/> have not been set.
/// /// </summary>
[DataMember(Name = "until", Order = 4), JsonPropertyName("until"), JsonPropertyOrder(4), YamlMember(Alias = "until", Order = 4)]
public virtual int? Until { get; set; }

}
45 changes: 28 additions & 17 deletions src/ServerlessWorkflow.Sdk/Models/Calls/AsyncApiCallDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,40 +29,51 @@ public record AsyncApiCallDefinition
public required virtual ExternalResourceDefinition Document { get; set; }

/// <summary>
/// Gets/sets a reference to the AsyncAPI operation to call
/// 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>
/// Used only in case the referenced document uses AsyncAPI v2.6.0
/// </summary>
[Required]
[DataMember(Name = "operationRef", Order = 2), JsonPropertyName("operationRef"), JsonPropertyOrder(2), JsonInclude, YamlMember(Alias = "operationRef", Order = 2)]
public required virtual string OperationRef { get; set; }
[DataMember(Name = "channel", Order = 2), JsonPropertyName("channel"), JsonPropertyOrder(2), JsonInclude, YamlMember(Alias = "channel", Order = 2)]
public required virtual string? Channel { get; set; }

/// <summary>
/// Gets/sets a reference to the AsyncAPI operation to call.<para></para>
/// Used only in case the referenced document uses AsyncAPI v3.0.0.
/// </summary>
[DataMember(Name = "operation", Order = 3), JsonPropertyName("operation"), JsonPropertyOrder(3), JsonInclude, YamlMember(Alias = "operation", Order = 3)]
public required virtual string? Operation { get; set; }

/// <summary>
/// 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.
/// Gets/sets a object used to configure to the server to call the specified AsyncAPI operation on.<para></para>
/// If not set, default to the first server matching the operation's channel.
/// </summary>
[DataMember(Name = "server", Order = 3), JsonPropertyName("server"), JsonPropertyOrder(3), JsonInclude, YamlMember(Alias = "server", Order = 3)]
[DataMember(Name = "server", Order = 4), JsonPropertyName("server"), JsonPropertyOrder(4), JsonInclude, YamlMember(Alias = "server", Order = 4)]
public virtual string? Server { get; set; }

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

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

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

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

}
}
8 changes: 8 additions & 0 deletions src/ServerlessWorkflow.Sdk/Models/Calls/HttpCallDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,12 @@ public virtual Uri EndpointUri
[DataMember(Name = "output", Order = 5), JsonPropertyName("output"), JsonPropertyOrder(5), YamlMember(Alias = "output", Order = 5)]
public virtual string? Output { get; set; }

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

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

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public record EventConsumptionStrategyDefinition
public virtual EquatableList<EventFilterDefinition>? All { get; set; }

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

/// <summary>
/// Gets/sets the condition or the consumption strategy that defines the events that must be consumed to stop listening
/// </summary>
[DataMember(Name = "until", Order = 4), JsonInclude, JsonPropertyName("until"), JsonPropertyOrder(4), YamlMember(Alias = "until", Order = 4)]
protected virtual OneOf<EventConsumptionStrategyDefinition, string>? UntilValue { get; set; }

/// <summary>
/// Gets/sets the consumption strategy, if any, that defines the events that must be consumed to stop listening
/// </summary>
[IgnoreDataMember, JsonIgnore, YamlIgnore]
public virtual EventConsumptionStrategyDefinition? Until
{
get => this.UntilValue?.T1Value;
set => this.UntilValue = value!;
}

/// <summary>
/// Gets/sets a runtime expression, if any, that represents the condition that must be met to stop listening
/// </summary>
[IgnoreDataMember, JsonIgnore, YamlIgnore]
public virtual string? UntilExpression
{
get => this.UntilValue?.T2Value;
set => this.UntilValue = value!;
}

}
8 changes: 8 additions & 0 deletions src/ServerlessWorkflow.Sdk/Models/EventEmissionDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,12 @@ public record EventEmissionDefinition
[DataMember(Name = "event", Order = 1), JsonPropertyName("event"), JsonPropertyOrder(1), YamlMember(Alias = "event", Order = 1)]
public required virtual EventDefinition Event { get; set; }

/// <summary>
/// Gets/sets an additional endpoint for emitting a carbon copy of the event.
/// 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.
/// 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.
/// </summary>
[DataMember(Name = "cc", Order = 2), JsonPropertyName("cc"), JsonPropertyOrder(2), YamlMember(Alias = "cc", Order = 2)]
public virtual EndpointDefinition? Cc { get; set; }

}
8 changes: 8 additions & 0 deletions src/ServerlessWorkflow.Sdk/Models/ProcessTypeDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ public record ProcessTypeDefinition
[DataMember(Name = "await", Order = 5), JsonPropertyName("await"), JsonPropertyOrder(5), YamlMember(Alias = "await", Order = 5)]
public virtual bool? Await { get; set; }

/// <summary>
/// Gets/sets the output of the process.<para></para>
/// See <see cref="ProcessReturnType"/><para></para>
/// Defaults to <see cref="ProcessReturnType.Stdout"/>
/// </summary>
[DataMember(Name = "return", Order = 6), JsonPropertyName("return"), JsonPropertyOrder(6), YamlMember(Alias = "return", Order = 6)]
public virtual string? Return { get; set; }

/// <summary>
/// Gets the type of the defined process tasks
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// 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.

namespace ServerlessWorkflow.Sdk.Models.Processes;

/// <summary>
/// Represents an object used to configure the lifetime of a container
/// </summary>
[DataContract]
public record ContainerLifetimeDefinition
{

/// <summary>
/// Gets/sets the cleanup policy to use.<para></para>
/// See <see cref="ContainerCleanupPolicy"/><para></para>
/// Defaults to <see cref="ContainerCleanupPolicy.Never"/>
/// </summary>
[Required, MinLength(1)]
[DataMember(Name = "cleanup", Order = 1), JsonPropertyName("cleanup"), JsonPropertyOrder(1), YamlMember(Alias = "cleanup", Order = 1)]
public required virtual string Cleanup { get; set; }

/// <summary>
/// Gets/sets the duration, if any, after which to delete the container once executed.<para></para>
/// Required if <see cref="Cleanup"/> has been set to <see cref="ContainerCleanupPolicy.Eventually"/>, otherwise ignored.
/// </summary>
[DataMember(Name = "duration", Order = 2), JsonPropertyName("duration"), JsonPropertyOrder(2), YamlMember(Alias = "duration", Order = 2)]
public virtual Duration? Duration { get; set; }
}
Loading

0 comments on commit 9818d65

Please sign in to comment.