Skip to content

ghuntley/sdk-net

 
 

Repository files navigation

Publish Packages

Serverless Workflow Specification - .NET SDK

Provides .NET 5.0 API/SPI and Model Validation for the Serverless Workflow Specification

With the SDK, you can:

  • Read and write workflow JSON and YAML definitions
  • Programmatically build workflow definitions
  • Validate workflow definitions (both schema and workflow integrity validation)

Status

Latest Releases Conformance to spec version
0.6.1 v0.6

Getting Started

dotnet nuget add package ServerlessWorkflow.Sdk

How to use

Building workflows programatically

var workflow = WorkflowDefinition.Create("MyWorkflow", "MyWorkflow", "1.0")
  .StartsWith("inject", flow => 
      flow.Inject(new { username = "test", password = "123456" }))
  .Then("operation", flow =>
      flow.Execute("fakeApiFunctionCall", action =>
      {
          action.Invoke(function =>
              function.WithName("fakeFunction")
                  .SetOperationUri(new Uri("https://fake.com/swagger.json#fake")))
              .WithArgument("username", "${ .username }")
              .WithArgument("password", "${ .password }");
      })      
          .Execute("fakeEventTrigger", action =>
          {
              action.Consume(e =>
                  e.WithName("fakeEvent")
                      .WithSource(new Uri("https://fakesource.com"))
                      .WithType("fakeType"));
          }))
  .End()
  .Build();

Reading workflows

var reader = WorkflowReader.Create();
using(Stream stream = File.OpenRead("myWorkflow.json"))
{
  var definition = reader.Read(stream, WorkflowDefinitionFormat.Json);
}

Writing workflows

  var writer = WorkflowWriter.Create();
  using(Stream stream = new MemoryStream())
  {
      writer.Write(workflow, stream);
      stream.Flush();
      stream.Position = 0;
      using(StreamReader reader = new StreamReader(stream))
      {
          var yaml = reader.ReadToEnd();
          Console.WriteLine(yaml);
          Console.ReadLine();
      }
  }

About

.NET SDK for Serverless Workflow

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages

  • C# 100.0%