Add SWF endpoints: RegisterWorkflowType, DeprecateWorkflowType, ListWorkflowTypes, DescribeWorkflowType
This commit is contained in:
parent
b680b2ec3c
commit
c4e903706c
4 changed files with 364 additions and 45 deletions
|
|
@ -85,9 +85,9 @@ class SWFResponse(BaseResponse):
|
|||
domain_name = self._params.get("domain")
|
||||
status = self._params.get("registrationStatus")
|
||||
reverse_order = self._params.get("reverseOrder", None)
|
||||
actypes = self.swf_backend.list_activity_types(domain_name, status, reverse_order=reverse_order)
|
||||
types = self.swf_backend.list_activity_types(domain_name, status, reverse_order=reverse_order)
|
||||
template = self.response_template(LIST_ACTIVITY_TYPES_TEMPLATE)
|
||||
return template.render(actypes=actypes)
|
||||
return template.render(types=types)
|
||||
|
||||
def register_activity_type(self):
|
||||
domain = self._params.get("domain")
|
||||
|
|
@ -117,22 +117,78 @@ class SWFResponse(BaseResponse):
|
|||
|
||||
def deprecate_activity_type(self):
|
||||
domain = self._params.get("domain")
|
||||
actype = self._params.get("activityType")
|
||||
name = actype["name"]
|
||||
version = actype["version"]
|
||||
_type = self._params.get("activityType")
|
||||
name = _type["name"]
|
||||
version = _type["version"]
|
||||
domain = self.swf_backend.deprecate_activity_type(domain, name, version)
|
||||
template = self.response_template("")
|
||||
return template.render()
|
||||
|
||||
def describe_activity_type(self):
|
||||
domain = self._params.get("domain")
|
||||
actype = self._params.get("activityType")
|
||||
_type = self._params.get("activityType")
|
||||
|
||||
name = actype["name"]
|
||||
version = actype["version"]
|
||||
actype = self.swf_backend.describe_activity_type(domain, name, version)
|
||||
name = _type["name"]
|
||||
version = _type["version"]
|
||||
_type = self.swf_backend.describe_activity_type(domain, name, version)
|
||||
template = self.response_template(DESCRIBE_ACTIVITY_TYPE_TEMPLATE)
|
||||
return template.render(actype=actype)
|
||||
return template.render(_type=_type)
|
||||
|
||||
# TODO: implement pagination
|
||||
# TODO: refactor with list_activity_types()
|
||||
def list_workflow_types(self):
|
||||
domain_name = self._params.get("domain")
|
||||
status = self._params.get("registrationStatus")
|
||||
reverse_order = self._params.get("reverseOrder", None)
|
||||
types = self.swf_backend.list_workflow_types(domain_name, status, reverse_order=reverse_order)
|
||||
template = self.response_template(LIST_WORKFLOW_TYPES_TEMPLATE)
|
||||
return template.render(types=types)
|
||||
|
||||
def register_workflow_type(self):
|
||||
domain = self._params.get("domain")
|
||||
name = self._params.get("name")
|
||||
version = self._params.get("version")
|
||||
default_task_list = self._params.get("defaultTaskList")
|
||||
if default_task_list:
|
||||
task_list = default_task_list.get("name")
|
||||
else:
|
||||
task_list = None
|
||||
default_child_policy = self._params.get("defaultChildPolicy")
|
||||
default_task_start_to_close_timeout = self._params.get("defaultTaskStartToCloseTimeout")
|
||||
default_execution_start_to_close_timeout = self._params.get("defaultTaskExecutionStartToCloseTimeout")
|
||||
description = self._params.get("description")
|
||||
# TODO: add defaultTaskPriority when boto gets to support it
|
||||
# TODO: add defaultLambdaRole when boto gets to support it
|
||||
workflow_type = self.swf_backend.register_workflow_type(
|
||||
domain, name, version, task_list=task_list,
|
||||
default_child_policy=default_child_policy,
|
||||
default_task_start_to_close_timeout=default_task_start_to_close_timeout,
|
||||
default_execution_start_to_close_timeout=default_execution_start_to_close_timeout,
|
||||
description=description,
|
||||
)
|
||||
template = self.response_template("")
|
||||
return template.render()
|
||||
|
||||
# TODO: refactor with deprecate_activity_type()
|
||||
def deprecate_workflow_type(self):
|
||||
domain = self._params.get("domain")
|
||||
_type = self._params.get("workflowType")
|
||||
name = _type["name"]
|
||||
version = _type["version"]
|
||||
domain = self.swf_backend.deprecate_workflow_type(domain, name, version)
|
||||
template = self.response_template("")
|
||||
return template.render()
|
||||
|
||||
# TODO: refactor with describe_activity_type()
|
||||
def describe_workflow_type(self):
|
||||
domain = self._params.get("domain")
|
||||
_type = self._params.get("workflowType")
|
||||
|
||||
name = _type["name"]
|
||||
version = _type["version"]
|
||||
_type = self.swf_backend.describe_workflow_type(domain, name, version)
|
||||
template = self.response_template(DESCRIBE_WORKFLOW_TYPE_TEMPLATE)
|
||||
return template.render(_type=_type)
|
||||
|
||||
|
||||
LIST_DOMAINS_TEMPLATE = """{
|
||||
|
|
@ -160,16 +216,16 @@ DESCRIBE_DOMAIN_TEMPLATE = """{
|
|||
|
||||
LIST_ACTIVITY_TYPES_TEMPLATE = """{
|
||||
"typeInfos": [
|
||||
{%- for actype in actypes %}
|
||||
{%- for _type in types %}
|
||||
{
|
||||
"activityType": {
|
||||
"name": "{{ actype.name }}",
|
||||
"version": "{{ actype.version }}"
|
||||
"name": "{{ _type.name }}",
|
||||
"version": "{{ _type.version }}"
|
||||
},
|
||||
"creationDate": 1420066800,
|
||||
{% if actype.status == "DEPRECATED" %}"deprecationDate": 1422745200,{% endif %}
|
||||
{% if actype.description %}"description": "{{ actype.description }}",{% endif %}
|
||||
"status": "{{ actype.status }}"
|
||||
{% if _type.status == "DEPRECATED" %}"deprecationDate": 1422745200,{% endif %}
|
||||
{% if _type.description %}"description": "{{ _type.description }}",{% endif %}
|
||||
"status": "{{ _type.status }}"
|
||||
}{% if not loop.last %},{% endif %}
|
||||
{%- endfor %}
|
||||
]
|
||||
|
|
@ -177,22 +233,43 @@ LIST_ACTIVITY_TYPES_TEMPLATE = """{
|
|||
|
||||
DESCRIBE_ACTIVITY_TYPE_TEMPLATE = """{
|
||||
"configuration": {
|
||||
{% if actype.default_task_heartbeat_timeout %}"defaultTaskHeartbeatTimeout": "{{ actype.default_task_heartbeat_timeout }}",{% endif %}
|
||||
{% if actype.task_list %}"defaultTaskList": { "name": "{{ actype.task_list }}" },{% endif %}
|
||||
{% if actype.default_task_schedule_to_close_timeout %}"defaultTaskScheduleToCloseTimeout": "{{ actype.default_task_schedule_to_close_timeout }}",{% endif %}
|
||||
{% if actype.default_task_schedule_to_start_timeout %}"defaultTaskScheduleToStartTimeout": "{{ actype.default_task_schedule_to_start_timeout }}",{% endif %}
|
||||
{% if actype.default_task_start_to_close_timeout %}"defaultTaskStartToCloseTimeout": "{{ actype.default_task_start_to_close_timeout }}",{% endif %}
|
||||
{% if _type.default_task_heartbeat_timeout %}"defaultTaskHeartbeatTimeout": "{{ _type.default_task_heartbeat_timeout }}",{% endif %}
|
||||
{% if _type.task_list %}"defaultTaskList": { "name": "{{ _type.task_list }}" },{% endif %}
|
||||
{% if _type.default_task_schedule_to_close_timeout %}"defaultTaskScheduleToCloseTimeout": "{{ _type.default_task_schedule_to_close_timeout }}",{% endif %}
|
||||
{% if _type.default_task_schedule_to_start_timeout %}"defaultTaskScheduleToStartTimeout": "{{ _type.default_task_schedule_to_start_timeout }}",{% endif %}
|
||||
{% if _type.default_task_start_to_close_timeout %}"defaultTaskStartToCloseTimeout": "{{ _type.default_task_start_to_close_timeout }}",{% endif %}
|
||||
"__moto_placeholder": "(avoid dealing with coma in json)"
|
||||
},
|
||||
"typeInfo": {
|
||||
"activityType": {
|
||||
"name": "{{ actype.name }}",
|
||||
"version": "{{ actype.version }}"
|
||||
"name": "{{ _type.name }}",
|
||||
"version": "{{ _type.version }}"
|
||||
},
|
||||
"creationDate": 1420066800,
|
||||
{% if actype.status == "DEPRECATED" %}"deprecationDate": 1422745200,{% endif %}
|
||||
{% if actype.description %}"description": "{{ actype.description }}",{% endif %}
|
||||
"status": "{{ actype.status }}"
|
||||
{% if _type.status == "DEPRECATED" %}"deprecationDate": 1422745200,{% endif %}
|
||||
{% if _type.description %}"description": "{{ _type.description }}",{% endif %}
|
||||
"status": "{{ _type.status }}"
|
||||
}
|
||||
}"""
|
||||
|
||||
LIST_WORKFLOW_TYPES_TEMPLATE = LIST_ACTIVITY_TYPES_TEMPLATE.replace("activityType", "workflowType")
|
||||
|
||||
DESCRIBE_WORKFLOW_TYPE_TEMPLATE = """{
|
||||
"configuration": {
|
||||
{% if _type.default_child_policy %}"defaultChildPolicy": "{{ _type.default_child_policy }}",{% endif %}
|
||||
{% if _type.default_execution_start_to_close_timeout %}"defaultExecutionStartToCloseTimeout": "{{ _type.default_execution_start_to_close_timeout }}",{% endif %}
|
||||
{% if _type.task_list %}"defaultTaskList": { "name": "{{ _type.task_list }}" },{% endif %}
|
||||
{% if _type.default_task_start_to_close_timeout %}"defaultTaskStartToCloseTimeout": "{{ _type.default_task_start_to_close_timeout }}",{% endif %}
|
||||
"__moto_placeholder": "(avoid dealing with coma in json)"
|
||||
},
|
||||
"typeInfo": {
|
||||
"workflowType": {
|
||||
"name": "{{ _type.name }}",
|
||||
"version": "{{ _type.version }}"
|
||||
},
|
||||
"creationDate": 1420066800,
|
||||
{% if _type.status == "DEPRECATED" %}"deprecationDate": 1422745200,{% endif %}
|
||||
{% if _type.description %}"description": "{{ _type.description }}",{% endif %}
|
||||
"status": "{{ _type.status }}"
|
||||
}
|
||||
}"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue