用于定义aws step函数的amazon状态语言pythonic api

stairstep的Python项目详细描述


楼梯踏步

stairstep是一个pythonic api,用于使用Amazon's State Language

设计AWS Step Functions

state_machine

stairstep不需要手工构建json,而是允许您使用python代码定义步骤函数,该代码允许您轻松地从外部源导入信息并动态地创建步骤函数。

开发进度/覆盖范围

Lanuage FeatureTypeProgress
StatePass
StateTask
StateSucceed
StateFail
StateChoice
FieldCommon Validations
StateWaitNext ?
StateParallelNext ?

示例

Hello World

Using the example from the Amazon's State Language第页

{
    "Comment": "A simple minimal example of the States language",
    "StartAt": "Hello World",
    "States": {
    "Hello World": { 
      "Type": "Task",
      "Resource": "arn:aws:lambda:us-east-1:123456789012:function:HelloWorld",
      "End": true
    }
  }
}

我们可以很容易地在楼梯间制作出这样的东西,如下所示

# Create a parent StairStep object
ss = StairStep(comment="A simple minimal example of the States language", startAt="Hello World")

# Create the HelloWorld step
StateTask(name="Hello World", resource="arn:aws:lambda:us-east-1:123456789012:function:HelloWorld", end=True)

# Add the step into the StairStep object
ss.addState(hello)

# Create the Amazon State Language Export
ss.json()

{  
   "Comment":"A simple minimal example of the States language",
   "StartAt":"Hello World",
   "States":{  
      "Hello World":{  
         "Type":"Task",
         "Resource":"arn:aws:lambda:us-east-1:123456789012:function:HelloWorld",
         "End":true
      }
   }
}

hello_world

复杂的选择状态

ss = StairStep(
    comment = "Example Choice State",
    startAt = "ChoiceStateX"
)
# Create a ChoiceRule, which is composed of choice expression(s)
# This checks to see if the variable $.type is not "Private"
typeNotPrivate = ChoiceRule(operator="Not", snext="Public", conditions=
    ChoiceExpression(operator="StringEquals", variable="$.type", value="Private")
)

# This checks to see if the value of $.value is >=20 or <30
valueInTwenties = ChoiceRule(operator="And", snext="ValueInTwenties", conditions=
    [
        ChoiceExpression(operator="NumericGreaterThanEquals", variable="$.value", value=20),
        ChoiceExpression(operator="NumericLessThan", variable="$.value", value=30)
    ]
)
state = StateChoice(name="ChoiceStateX", choices=[typeNotPrivate,valueInTwenties],default="DefaultState")

default = StatePass(name="DefaultState", end=True)
in_twenties = StatePass(name="ValueInTwenties", end=True)
public = StatePass(name="Public", end=True)

ss.addState(state)
ss.addState(in_twenties)
ss.addState(public)
ss.addState(default)
ss.json()
{
	"Comment": "Example Choice State",
	"StartAt": "ChoiceStateX",
	"States": {
		"ChoiceStateX": {
			"Type": "Choice",
			"Default": "DefaultState",
			"Choices": [{
				"Next": "Public",
				"Not": {
					"Variable": "$.type",
					"StringEquals": "Private"
				}
			}, {
				"Next": "ValueInTwenties",
				"And": [{
					"Variable": "$.value",
					"NumericGreaterThanEquals": 20
				}, {
					"Variable": "$.value",
					"NumericLessThan": 30
				}]
			}]
		},
		"ValueInTwenties": {
			"Type": "Pass",
			"End": true
		},
		"Public": {
			"Type": "Pass",
			"End": true
		},
		"DefaultState": {
			"Type": "Pass",
			"End": true
		}
	}
}

choice_state

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java JPA。Eclipselink没有为mySQL提供密码,但它应该提供   我的Servlet和@FormDataParam存在java问题   java将什么作为上下文参数传递到文件I/O方法中?   如果两个值相同,java无法找到其中一个单选按钮   java在变量和方法名中使用下划线   JavaSpringMVC单线程安全?   klazz类的java Arraylist(反射Api)   java如何在数字字符串中查找最频繁的数字?   JavaAPI设计:使数据更易于阅读与强制更多API调用   JavaHadoopMapReduceforGoogleWebGraph   java无法启动gauge API:Runner意外退出   java如何在bluemix上使用ibm工作负载调度器?   拉取一年中某一周特定日期的所有日期   java为什么是我的角节点。js应用程序将图像上传到S3� 邮递员正确上传时的符号?   在不使用任何第三方jar的情况下将文件从本地传输到linux系统(java代码)   java将现有文件夹复制到Eclipse工作区中新创建的项目中   Java中的regex RegExp帮助   当使用“系统”外观时,Java组合框setSelectedItem会出现故障   JavaASM:在类的方法中获取局部变量名和值