示例#1
0
def respond_decision_task_completed(token, decisions, execution_context=None):
    """Used by deciders to tell the service that the DecisionTask identified by
    the task_token has successfully completed. The decisions argument specifies
    the list of decisions made while processing the task.

    A DecisionTaskCompleted event is added to the workflow history. The
    executionContext specified is attached to the event in the workflow
    execution history.

    token (string) -- [REQUIRED]
    The task_token from the DecisionTask .

    decisions (list) --
    The list of decisions (possibly empty) made by the decider while processing
    this decision task. See the docs for the decision structure for details.

    execution_context (string) --
    User defined context to add to workflow execution.

    returns Boolean
    """
    kwargs = {}

    if execution_context:
        kwargs["executionContext"] = execution_context

    result = make_request(SWF.respond_decision_task_completed, taskToken=token, decisions=decisions, **kwargs)

    if result.success:
        return result.result

    return None
示例#2
0
def respond_decision_task_completed(token, decisions, execution_context=None):
    """Used by deciders to tell the service that the DecisionTask identified by
    the task_token has successfully completed. The decisions argument specifies
    the list of decisions made while processing the task.

    A DecisionTaskCompleted event is added to the workflow history. The
    executionContext specified is attached to the event in the workflow
    execution history.

    token (string) -- [REQUIRED]
    The task_token from the DecisionTask .

    decisions (list) --
    The list of decisions (possibly empty) made by the decider while processing
    this decision task. See the docs for the decision structure for details.

    execution_context (string) --
    User defined context to add to workflow execution.

    returns Boolean
    """
    kwargs = {}

    if execution_context:
        kwargs['executionContext'] = execution_context

    result = make_request(SWF.respond_decision_task_completed,
                          taskToken=token,
                          decisions=decisions,
                          **kwargs)

    if result.success:
        return result.result

    return None
示例#3
0
def get_workflow_execution_history(domain, workflow_id, run_id,
                                   next_page_token=None,
                                   maximum_page_size=1000,
                                   reverse_order=False):
    """Returns the history of the specified workflow execution. The results may
    be split into multiple pages. To retrieve subsequent pages, make the call
    again using the nextPageToken returned by the initial call.

    ** Note **
        This operation is eventually consistent. The results are best effort and
        may not exactly reflect recent updates and changes.

    domain (string) -- [REQUIRED]
    The name of the domain containing the workflow execution.

    workflow_id (string) -- [REQUIRED]
    The user defined identifier associated with the workflow execution.

    run_id (string) -- [REQUIRED]
    A system-generated unique identifier for the workflow execution.

    next_page_token (string) --
    If a NextPageToken was returned by a previous call, there are more results
    available. To retrieve the next page of results, make the call again using
    the returned token in nextPageToken . Keep all other arguments unchanged.

    The configured maximumPageSize determines how many results can be returned
    in a single call.

    reverse_order (boolean) --
    When set to true , returns the events in reverse order. By default the
    results are returned in ascending order of the eventTimeStamp of the events.

    return dict
    """
    kwargs = {}

    if next_page_token:
        kwargs['nextPageToken'] = next_page_token

    result = make_request(
        SWF.get_workflow_execution_history,
        domain=domain,
        execution={'workflowId': workflow_id, 'runId': run_id},
        maximumPageSize=maximum_page_size,
        reverseOrder=reverse_order,
        **kwargs)

    if result.success:
        return [create_event_from_map(event_map)
                for event_map in result.result.get('events', [])]

    return None
示例#4
0
def get_workflow_execution_history(
    domain, workflow_id, run_id, next_page_token=None, maximum_page_size=1000, reverse_order=False
):
    """Returns the history of the specified workflow execution. The results may
    be split into multiple pages. To retrieve subsequent pages, make the call
    again using the nextPageToken returned by the initial call.

    ** Note **
        This operation is eventually consistent. The results are best effort and
        may not exactly reflect recent updates and changes.

    domain (string) -- [REQUIRED]
    The name of the domain containing the workflow execution.

    workflow_id (string) -- [REQUIRED]
    The user defined identifier associated with the workflow execution.

    run_id (string) -- [REQUIRED]
    A system-generated unique identifier for the workflow execution.

    next_page_token (string) --
    If a NextPageToken was returned by a previous call, there are more results
    available. To retrieve the next page of results, make the call again using
    the returned token in nextPageToken . Keep all other arguments unchanged.

    The configured maximumPageSize determines how many results can be returned
    in a single call.

    reverse_order (boolean) --
    When set to true , returns the events in reverse order. By default the
    results are returned in ascending order of the eventTimeStamp of the events.

    return dict
    """
    kwargs = {}

    if next_page_token:
        kwargs["nextPageToken"] = next_page_token

    result = make_request(
        SWF.get_workflow_execution_history,
        domain=domain,
        execution={"workflowId": workflow_id, "runId": run_id},
        maximumPageSize=maximum_page_size,
        reverseOrder=reverse_order,
        **kwargs
    )

    if result.success:
        return [create_event_from_map(event_map) for event_map in result.result.get("events", [])]

    return None
示例#5
0
def poll_for_activity_task(domain, task_list, identity=None):
    """Used by workers to get an ActivityTask from the specified activity
    taskList . This initiates a long poll, where the service holds the HTTP
    connection open and responds as soon as a task becomes available. The
    maximum time the service holds on to the request before responding is 60
    seconds. If no task is available within 60 seconds, the poll will return an
    empty result. An empty result, in this context, means that an ActivityTask
    is returned, but that the value of task_token is an empty string. If a task
    is returned, the worker should use its type to identify and process it
    correctly.

    ** Warning **
        Workers should set their client side socket timeout to at least 70
        seconds (10 seconds higher than the maximum time service may hold the
        poll request).

    domain (string) -- [REQUIRED]
    The name of the domain that contains the task lists being polled.

    task_list (dict) -- [REQUIRED]
    Specifies the task list to poll for activity tasks.
    The specified string must not start or end with whitespace. It must not
    contain a : (colon), / (slash), | (vertical bar), or any control characters
    (u0000-u001f | u007f - u009f). Also, it must not contain the literal string
    quotarnquot.

        name (string) -- [REQUIRED]
        The name of the task list.

    identity (string) --
    Identity of the worker making the request, recorded in the
    ActivityTaskStarted event in the workflow history. This enables diagnostic
    tracing when problems arise. The form of this identity is user defined.

    return dict
    """
    kwargs = {}

    if identity:
        kwargs['identity'] = identity

    result = make_request(
        SWF.poll_for_activity_task,
        domain=domain,
        taskList=task_list,
        **kwargs)

    if result.success:
        return result.result

    return None
示例#6
0
def poll_for_activity_task(domain, task_list, identity=None):
    """Used by workers to get an ActivityTask from the specified activity
    taskList . This initiates a long poll, where the service holds the HTTP
    connection open and responds as soon as a task becomes available. The
    maximum time the service holds on to the request before responding is 60
    seconds. If no task is available within 60 seconds, the poll will return an
    empty result. An empty result, in this context, means that an ActivityTask
    is returned, but that the value of task_token is an empty string. If a task
    is returned, the worker should use its type to identify and process it
    correctly.

    ** Warning **
        Workers should set their client side socket timeout to at least 70
        seconds (10 seconds higher than the maximum time service may hold the
        poll request).

    domain (string) -- [REQUIRED]
    The name of the domain that contains the task lists being polled.

    task_list (dict) -- [REQUIRED]
    Specifies the task list to poll for activity tasks.
    The specified string must not start or end with whitespace. It must not
    contain a : (colon), / (slash), | (vertical bar), or any control characters
    (u0000-u001f | u007f - u009f). Also, it must not contain the literal string
    quotarnquot.

        name (string) -- [REQUIRED]
        The name of the task list.

    identity (string) --
    Identity of the worker making the request, recorded in the
    ActivityTaskStarted event in the workflow history. This enables diagnostic
    tracing when problems arise. The form of this identity is user defined.

    return dict
    """
    kwargs = {}

    if identity:
        kwargs['identity'] = identity

    result = make_request(SWF.poll_for_activity_task,
                          domain=domain,
                          taskList=task_list,
                          **kwargs)

    if result.success:
        return result.result

    return None
示例#7
0
def register_domain(domain_config):
    """Registers a new domain.

    Returns None
    """
    try:
        result = make_request(SWF.register_domain,
            name=domain_config.domain,
            description=domain_config.description,
            workflowExecutionRetentionPeriodInDays=domain_config.retention_period)
    except swf_exceptions.SWFDomainAlreadyExistsError:
        logging.debug("Domain already exists.")

    if result.success:
        return

    if result.result.code == DOMAIN_ALREADY_EXISTS:
        raise DomainAlreadyExistsError("Domain already exists.")

    raise RegisterDomainError(result.result.message)
示例#8
0
def respond_activity_task_completed(task_token, result=None):
    """Used by workers to tell the service that the ActivityTask identified by
    the task_token completed successfully with a result (if provided). The result
    appears in the ActivityTaskCompleted event in the workflow history.

    ** Warning **
        If the requested task does not complete successfully, use
        RespondActivityTaskFailed instead. If the worker finds that the task is
        canceled through the canceled flag returned by
        RecordActivityTaskHeartbeat, it should cancel the task, clean up and
        then call RespondActivityTaskCanceled.

    A task is considered open from the time that it is scheduled until it is
    closed. Therefore a task is reported as open while a worker is processing
    it. A task is closed after it has been specified in a call to
    RespondActivityTaskCompleted, RespondActivityTaskCanceled,
    RespondActivityTaskFailed, or the task has timed out.

    task_token (string) -- [REQUIRED]
    The task_token of the ActivityTask .

    result (string) --
    The result of the activity task. It is a free form string that is
    implementation specific.

    returns success/fail
    """
    kwargs = {}

    if result:
        kwargs['result'] = result

    res = make_request(
        SWF.respond_activity_task_completed,
        taskToken=task_token,
        **kwargs)

    if res.success:
        return res.result

    return None
示例#9
0
def respond_activity_task_completed(task_token, result=None):
    """Used by workers to tell the service that the ActivityTask identified by
    the task_token completed successfully with a result (if provided). The result
    appears in the ActivityTaskCompleted event in the workflow history.

    ** Warning **
        If the requested task does not complete successfully, use
        RespondActivityTaskFailed instead. If the worker finds that the task is
        canceled through the canceled flag returned by
        RecordActivityTaskHeartbeat, it should cancel the task, clean up and
        then call RespondActivityTaskCanceled.

    A task is considered open from the time that it is scheduled until it is
    closed. Therefore a task is reported as open while a worker is processing
    it. A task is closed after it has been specified in a call to
    RespondActivityTaskCompleted, RespondActivityTaskCanceled,
    RespondActivityTaskFailed, or the task has timed out.

    task_token (string) -- [REQUIRED]
    The task_token of the ActivityTask .

    result (string) --
    The result of the activity task. It is a free form string that is
    implementation specific.

    returns success/fail
    """
    kwargs = {}

    if result:
        kwargs['result'] = result

    res = make_request(SWF.respond_activity_task_completed,
                       taskToken=task_token,
                       **kwargs)

    if res.success:
        return res.result

    return None
示例#10
0
def respond_activity_task_failed(task_token, reason=None, details=None):
    """Used by workers to tell the service that the ActivityTask identified by
    the task_token has failed with reason (if specified). The reason and details
    appear in the ActivityTaskFailed event added to the workflow history.

    A task is considered open from the time that it is scheduled until it is
    closed. Therefore a task is reported as open while a worker is processing
    it. A task is closed after it has been specified in a call to
    RespondActivityTaskCompleted, RespondActivityTaskCanceled,
    RespondActivityTaskFailed, or the task has timed out .

    task_token (string) -- [REQUIRED]
    The task_token of the ActivityTask .

    reason (string) --
    Description of the error that may assist in diagnostics.

    details (string) --
    Optional. Detailed information about the failure.

    returns None
    """
    kwargs = {}

    if reason:
        kwargs['reason'] = reason

    if details:
        kwargs['details'] = details

    result = make_request(
        SWF.respond_activity_task_failed,
        taskToken=task_token,
        **kwargs)

    if result.success:
        return result.result

    return None
示例#11
0
def respond_activity_task_failed(task_token, reason=None, details=None):
    """Used by workers to tell the service that the ActivityTask identified by
    the task_token has failed with reason (if specified). The reason and details
    appear in the ActivityTaskFailed event added to the workflow history.

    A task is considered open from the time that it is scheduled until it is
    closed. Therefore a task is reported as open while a worker is processing
    it. A task is closed after it has been specified in a call to
    RespondActivityTaskCompleted, RespondActivityTaskCanceled,
    RespondActivityTaskFailed, or the task has timed out .

    task_token (string) -- [REQUIRED]
    The task_token of the ActivityTask .

    reason (string) --
    Description of the error that may assist in diagnostics.

    details (string) --
    Optional. Detailed information about the failure.

    returns None
    """
    kwargs = {}

    if reason:
        kwargs['reason'] = reason

    if details:
        kwargs['details'] = details

    result = make_request(SWF.respond_activity_task_failed,
                          taskToken=task_token,
                          **kwargs)

    if result.success:
        return result.result

    return None
示例#12
0
def register_workflow_type(
    domain, name, version, description=None,
    default_task_start_to_close_timeout=None,
    default_execution_start_to_close_timeout=None, default_task_list=None,
    default_task_priority=None, default_child_policy="TERMINATE",
    default_lambda_role=None):
    """Register a workflow type.

    Registers a new workflow type and its configuration settings in the
    specified domain.

    The retention period for the workflow history is set by the RegisterDomain
    action.

    Warning
    If the type already exists, then a TypeAlreadyExists fault is returned. You
    cannot change the configuration settings of a workflow type once it is
    registered and it must be registered as a new version.

    http://boto3.readthedocs.org/en/latest/reference/services/swf.html#SWF.Client.register_workflow_type

    domain (string) -- [REQUIRED]
    The name of the domain in which to register the workflow type.

    name (string) -- [REQUIRED]
    The name of the workflow type.

    version (string) -- [REQUIRED]
    The version of the workflow type.

    description (string) --
    Textual description of the workflow type.

    default_task_start_to_close_timeout (string) --
    If set, specifies the default maximum duration of decision tasks for this
    workflow type. This default can be overridden when starting a workflow
    execution using the StartWorkflowExecution action or the
    StartChildWorkflowExecution decision.

    default_execution_start_to_close_timeout (string) --
    If set, specifies the default maximum duration for executions of this
    workflow type. You can override this default when starting an execution
    through the StartWorkflowExecution action or StartChildWorkflowExecution
    decision.

    default_task_list (dict) --
    If set, specifies the default task list to use for scheduling decision tasks
    for executions of this workflow type. This default is used only if a task
    list is not provided when starting the execution through the
    StartWorkflowExecution action or StartChildWorkflowExecution decision.

        name (string) -- [REQUIRED]
        The name of the task list.

    default_task_priority (int) --
    The default task priority to assign to the workflow type. If not assigned,
    then "0" will be used. Valid values are integers that range from Java's
    Integer.MIN_VALUE (-2147483648) to Integer.MAX_VALUE (2147483647). Higher
    numbers indicate higher priority.

    default_child_policy (string) --
    If set, specifies the default policy to use for the child workflow
    executions when a workflow execution of this type is terminated, by calling
    the TerminateWorkflowExecution action explicitly or due to an expired
    timeout. This default can be overridden when starting a workflow execution
    using the StartWorkflowExecution action or the StartChildWorkflowExecution
    decision.

        The supported child policies are:
        TERMINATE: the child executions will be terminated.
        REQUEST_CANCEL: a request to cancel will be attempted for each child
                        execution by recording a WorkflowExecutionCancelRequested
                        event in its history.  It is up to the decider to take
                        appropriate actions when it receives an execution history
                        with this event.
        ABANDON: no action will be taken. The child executions will continue to run.

    default_lambda_role (string) --
    The ARN of the default IAM role to use when a workflow execution of this
    type invokes AWS Lambda functions.

    return None
    """
    kwargs = {}

    for aws_prop, value, conversion in (
        ('description', description, None),
        ('defaultTaskStartToCloseTimeout', default_task_start_to_close_timeout,
         None),
        ('defaultExecutionStartToCloseTimeout',
         default_execution_start_to_close_timeout, None),
        ('defaultTaskList', default_task_list, None),
        ('defaultTaskPriority', default_task_priority, str),
        ('defaultChildPolicy', default_child_policy, None),
        ('defaultLambdaRole', default_lambda_role, None)):

        kwargs = check_and_add_kwargs(aws_prop, value, conversion, kwargs)

    result = make_request(
        SWF.register_workflow_type,
        domain=domain,
        name=name,
        version=version,
        **kwargs)

    if result.success:
        return

    if result.result.code == WORKFLOW_TYPE_ALREADY_EXISTS:
        raise WorkflowTypeAlreadyExistsError("Workflow type already exists.")

    raise RegisterWorkflowTypeError(result.result.message)
示例#13
0
def register_workflow_type(domain,
                           name,
                           version,
                           description=None,
                           default_task_start_to_close_timeout=None,
                           default_execution_start_to_close_timeout=None,
                           default_task_list=None,
                           default_task_priority=None,
                           default_child_policy="TERMINATE",
                           default_lambda_role=None):
    """Register a workflow type.

    Registers a new workflow type and its configuration settings in the
    specified domain.

    The retention period for the workflow history is set by the RegisterDomain
    action.

    Warning
    If the type already exists, then a TypeAlreadyExists fault is returned. You
    cannot change the configuration settings of a workflow type once it is
    registered and it must be registered as a new version.

    http://boto3.readthedocs.org/en/latest/reference/services/swf.html#SWF.Client.register_workflow_type

    domain (string) -- [REQUIRED]
    The name of the domain in which to register the workflow type.

    name (string) -- [REQUIRED]
    The name of the workflow type.

    version (string) -- [REQUIRED]
    The version of the workflow type.

    description (string) --
    Textual description of the workflow type.

    default_task_start_to_close_timeout (string) --
    If set, specifies the default maximum duration of decision tasks for this
    workflow type. This default can be overridden when starting a workflow
    execution using the StartWorkflowExecution action or the
    StartChildWorkflowExecution decision.

    default_execution_start_to_close_timeout (string) --
    If set, specifies the default maximum duration for executions of this
    workflow type. You can override this default when starting an execution
    through the StartWorkflowExecution action or StartChildWorkflowExecution
    decision.

    default_task_list (dict) --
    If set, specifies the default task list to use for scheduling decision tasks
    for executions of this workflow type. This default is used only if a task
    list is not provided when starting the execution through the
    StartWorkflowExecution action or StartChildWorkflowExecution decision.

        name (string) -- [REQUIRED]
        The name of the task list.

    default_task_priority (int) --
    The default task priority to assign to the workflow type. If not assigned,
    then "0" will be used. Valid values are integers that range from Java's
    Integer.MIN_VALUE (-2147483648) to Integer.MAX_VALUE (2147483647). Higher
    numbers indicate higher priority.

    default_child_policy (string) --
    If set, specifies the default policy to use for the child workflow
    executions when a workflow execution of this type is terminated, by calling
    the TerminateWorkflowExecution action explicitly or due to an expired
    timeout. This default can be overridden when starting a workflow execution
    using the StartWorkflowExecution action or the StartChildWorkflowExecution
    decision.

        The supported child policies are:
        TERMINATE: the child executions will be terminated.
        REQUEST_CANCEL: a request to cancel will be attempted for each child
                        execution by recording a WorkflowExecutionCancelRequested
                        event in its history.  It is up to the decider to take
                        appropriate actions when it receives an execution history
                        with this event.
        ABANDON: no action will be taken. The child executions will continue to run.

    default_lambda_role (string) --
    The ARN of the default IAM role to use when a workflow execution of this
    type invokes AWS Lambda functions.

    return None
    """
    kwargs = {}

    for aws_prop, value, conversion in (
        ('description', description, None),
        ('defaultTaskStartToCloseTimeout', default_task_start_to_close_timeout,
         None), ('defaultExecutionStartToCloseTimeout',
                 default_execution_start_to_close_timeout,
                 None), ('defaultTaskList', default_task_list, None),
        ('defaultTaskPriority', default_task_priority,
         str), ('defaultChildPolicy', default_child_policy,
                None), ('defaultLambdaRole', default_lambda_role, None)):

        kwargs = check_and_add_kwargs(aws_prop, value, conversion, kwargs)

    result = make_request(SWF.register_workflow_type,
                          domain=domain,
                          name=name,
                          version=version,
                          **kwargs)

    if result.success:
        return

    if result.result.code == WORKFLOW_TYPE_ALREADY_EXISTS:
        raise WorkflowTypeAlreadyExistsError("Workflow type already exists.")

    raise RegisterWorkflowTypeError(result.result.message)
示例#14
0
def poll_for_decision_task(
    domain, task_list, identity=None, next_page_token=None, maximum_page_size=1000, reverse_order=False
):
    """Used by deciders to get a DecisionTask from the specified decision
    taskList . A decision task may be returned for any open workflow execution
    that is using the specified task list. The task includes a paginated view of
    the history of the workflow execution. The decider should use the workflow
    type and the history to determine how to properly handle the task.

    This action initiates a long poll, where the service holds the HTTP
    connection open and responds as soon a task becomes available. If no
    decision task is available in the specified task list before the timeout of
    60 seconds expires, an empty result is returned. An empty result, in this
    context, means that a DecisionTask is returned, but that the value of
    task_token is an empty string.

    http://boto3.readthedocs.org/en/latest/reference/services/swf.html#SWF.Client.poll_for_decision_task

    domain (string) -- [REQUIRED]
    The name of the domain containing the task lists to poll.

    task_list (dict) -- [REQUIRED]
    Specifies the task list to poll for decision tasks.

        ITEMS:
            name (string) -- [REQUIRED]
            The name of the task list.

    identity (string) -- Identity of the decider making the request, which is
    recorded in the DecisionTaskStarted event in the workflow history. This
    enables diagnostic tracing when problems arise. The form of this identity is
    user defined.

    next_page_token (string) --
    If a NextPageToken was returned by a previous call, there are more results
    available. To retrieve the next page of results, make the call again using
    the returned token in nextPageToken . Keep all other arguments unchanged.

    maximum_page_size (integer) --
    The maximum number of results that will be returned per call. nextPageToken
    can be used to obtain futher pages of results. The default is 1000, which is
    the maximum allowed page size. You can, however, specify a page size smaller
    than the maximum.

    reverse_order (boolean) --
    When set to true , returns the events in reverse order. By default the
    results are returned in ascending order of the eventTimestamp of the events.

    returns dict
    """
    kwargs = {}

    for aws_prop, value, conversion in (
        ("identity", identity, None),
        ("maximumPageSize", maximum_page_size, None),
        ("reverseOrder", reverse_order, None),
        ("nextPageToken", next_page_token, None),
    ):

        kwargs = check_and_add_kwargs(aws_prop, value, conversion, kwargs)

    result = make_request(SWF.poll_for_decision_task, domain=domain, taskList=task_list, **kwargs)

    if result.success:
        return result.result

    return None
示例#15
0
def poll_for_decision_task(domain,
                           task_list,
                           identity=None,
                           next_page_token=None,
                           maximum_page_size=1000,
                           reverse_order=False):
    """Used by deciders to get a DecisionTask from the specified decision
    taskList . A decision task may be returned for any open workflow execution
    that is using the specified task list. The task includes a paginated view of
    the history of the workflow execution. The decider should use the workflow
    type and the history to determine how to properly handle the task.

    This action initiates a long poll, where the service holds the HTTP
    connection open and responds as soon a task becomes available. If no
    decision task is available in the specified task list before the timeout of
    60 seconds expires, an empty result is returned. An empty result, in this
    context, means that a DecisionTask is returned, but that the value of
    task_token is an empty string.

    http://boto3.readthedocs.org/en/latest/reference/services/swf.html#SWF.Client.poll_for_decision_task

    domain (string) -- [REQUIRED]
    The name of the domain containing the task lists to poll.

    task_list (dict) -- [REQUIRED]
    Specifies the task list to poll for decision tasks.

        ITEMS:
            name (string) -- [REQUIRED]
            The name of the task list.

    identity (string) -- Identity of the decider making the request, which is
    recorded in the DecisionTaskStarted event in the workflow history. This
    enables diagnostic tracing when problems arise. The form of this identity is
    user defined.

    next_page_token (string) --
    If a NextPageToken was returned by a previous call, there are more results
    available. To retrieve the next page of results, make the call again using
    the returned token in nextPageToken . Keep all other arguments unchanged.

    maximum_page_size (integer) --
    The maximum number of results that will be returned per call. nextPageToken
    can be used to obtain futher pages of results. The default is 1000, which is
    the maximum allowed page size. You can, however, specify a page size smaller
    than the maximum.

    reverse_order (boolean) --
    When set to true , returns the events in reverse order. By default the
    results are returned in ascending order of the eventTimestamp of the events.

    returns dict
    """
    kwargs = {}

    for aws_prop, value, conversion in (('identity', identity,
                                         None), ('maximumPageSize',
                                                 maximum_page_size, None),
                                        ('reverseOrder', reverse_order,
                                         None), ('nextPageToken',
                                                 next_page_token, None)):

        kwargs = check_and_add_kwargs(aws_prop, value, conversion, kwargs)

    result = make_request(SWF.poll_for_decision_task,
                          domain=domain,
                          taskList=task_list,
                          **kwargs)

    if result.success:
        return result.result

    return None
示例#16
0
def register_activity_type(
    domain, name, version, description=None,
    default_task_start_to_close_timeout=None,
    default_task_heartbeat_timeout=None, default_task_list=None,
    default_task_priority=None, default_task_schedule_to_start_timeout=None,
    default_task_schedule_to_close_timeout=None):
    """Registers a new activity type along with its configuration settings in
    the specified domain.

    WARNING
    A TypeAlreadyExists fault is returned if the type already exists in the
    domain. You cannot change any configuration settings of the type after its
    registration, and it must be registered as a new version.

    http://boto3.readthedocs.org/en/latest/reference/services/swf.html#SWF.Client.register_activity_type

    domain (string) -- [REQUIRED]
    The name of the domain in which this activity is to be registered.

    name (string) -- [REQUIRED]
    The name of the activity type within the domain.

    version (string) -- [REQUIRED]
    The version of the activity type.

    description (string) --
    A textual description of the activity type.

    default_task_start_to_close_timeout (string) --
    If set, specifies the default maximum duration that a worker can take to
    process tasks of this activity type. This default can be overridden when
    scheduling an activity task using the ScheduleActivityTask decision.

    default_task_heartbeat_timeout (string) --
    If set, specifies the default maximum time before which a worker processing
    a task of this type must report progress by calling
    RecordActivityTaskHeartbeat. If the timeout is exceeded, the activity task
    is automatically timed out. This default can be overridden when scheduling
    an activity task using the ScheduleActivityTask decision. If the activity
    worker subsequently attempts to record a heartbeat or returns a result, the
    activity worker receives an UnknownResource fault. In this case, Amazon SWF
    no longer considers the activity task to be valid; the activity worker
    should clean up the activity task.

        The duration is specified in seconds; an integer greater than or equal
        to 0. The value "NONE" can be used to specify unlimited duration.

    default_task_list (dict) --
    If set, specifies the default task list to use for scheduling tasks of this
    activity type. This default task list is used if a task list is not provided
    when a task is scheduled through the ScheduleActivityTask decision.

        name (string) -- [REQUIRED]
        The name of the task list.

    default_task_priority (int) --
    The default task priority to assign to the activity type. If not assigned,
    then "0" will be used. Valid values are integers that range from Java's
    Integer.MIN_VALUE (-2147483648) to Integer.MAX_VALUE (2147483647). Higher
    numbers indicate higher priority.

    default_task_schedule_to_start_timeout (string) --
    If set, specifies the default maximum duration that a task of this activity
    type can wait before being assigned to a worker. This default can be
    overridden when scheduling an activity task using the ScheduleActivityTask
    decision.

    default_task_schedule_to_close_timeout (string) --
    If set, specifies the default maximum duration for a task of this activity
    type. This default can be overridden when scheduling an activity task using
    the ScheduleActivityTask decision.

    return None
    """
    kwargs = {}

    for aws_prop, value, conversion in (
        ('description', description, None),
        ('defaultTaskStartToCloseTimeout', default_task_start_to_close_timeout,
         None),
        ('defaultTaskHeartbeatTimeout', default_task_heartbeat_timeout, None),
        ('defaultTaskList', default_task_list, None),
        ('defaultTaskPriority', default_task_priority, str),
        ('defaultTaskScheduleToStartTimeout',
         default_task_schedule_to_start_timeout, None),
        ('defaultTaskScheduleToCloseTimeout',
         default_task_schedule_to_close_timeout, None)):

        kwargs = check_and_add_kwargs(aws_prop, value, conversion, kwargs)

    result = make_request(
        SWF.register_activity_type,
        domain=domain,
        name=name,
        version=version,
        **kwargs)

    if result.success:
        return

    if result.result.code == ACITVITY_TYPE_ALREADY_EXISTS:
        raise ActivityTypeAlreadyExistsError("Workflow type already exists.")

    raise RegisterActivityError(result.result.message)
示例#17
0
def start_workflow_execution(
    domain,
    workflow_id,
    workflow_type_name,
    workflow_type_version,
    task_list=None,
    task_priority=None,
    _input=None,
    execution_start_to_close_timeout=None,
    tag_list=None,
    child_policy=None,
    task_start_to_close_timeout=None,
    lambda_role=None,
):
    """Starts an execution of the workflow type in the specified domain using
    the provided workflowId and input data.

    This action returns the newly started workflow execution.

    http://boto3.readthedocs.org/en/latest/reference/services/swf.html#SWF.Client.start_workflow_execution

    domain (string) -- [REQUIRED]
    The name of the domain in which the workflow execution is created.

    workflow_id (string) -- [REQUIRED]
    The user defined identifier associated with the workflow execution. You can
    use this to associate a custom identifier with the workflow execution. You
    may specify the same identifier if a workflow execution is logically a
    restart of a previous execution. You cannot have two open workflow
    executions with the same workflowId at the same time.

    workflow_type (dict) -- [REQUIRED]
    The type of the workflow to start.

        ITEMS:
        name (string) -- [REQUIRED]
        Required. The name of the workflow type.

        version (string) -- [REQUIRED]
        Required. The version of the workflow type.

    task_list (dict) --
    The task list to use for the decision tasks generated for this workflow
    execution. This overrides the defaultTaskList specified when registering the
    workflow type.

        ITEMS:
        name (string) -- [REQUIRED]
        The name of the task list.

    task_priority (int) --
    The task priority to use for this workflow execution. This will override any
    default priority that was assigned when the workflow type was registered. If
    not set, then the default task priority for the workflow type will be used.
    Valid values are integers that range from Java's Integer.MIN_VALUE
    (-2147483648) to Integer.MAX_VALUE (2147483647). Higher numbers indicate
    higher priority.

    _input (string) --
    The input for the workflow execution. This is a free form string which
    should be meaningful to the workflow you are starting. This input is made
    available to the new workflow execution in the WorkflowExecutionStarted
    history event.

    execution_start_to_close_timeout (string) --
    The total duration for this workflow execution. This overrides the
    defaultExecutionStartToCloseTimeout specified when registering the workflow
    type.

    tag_list (list) --
    The list of tags to associate with the workflow execution. You can specify a
    maximum of 5 tags. You can list workflow executions with a specific tag by
    calling ListOpenWorkflowExecutions or ListClosedWorkflowExecutions and
    specifying a TagFilter .

    task_start_to_close_timeout (string) --
    Specifies the maximum duration of decision tasks for this workflow
    execution. This parameter overrides the defaultTaskStartToCloseTimout
    specified when registering the workflow type using RegisterWorkflowType .

    child_policy (string) --
    If set, specifies the policy to use for the child workflow executions of
    this workflow execution if it is terminated, by calling the
    TerminateWorkflowExecution action explicitly or due to an expired timeout.
    This policy overrides the default child policy specified when registering
    the workflow type using RegisterWorkflowType .

    lambda_role (string) --
    The ARN of an IAM role that authorizes Amazon SWF to invoke AWS Lambda
    functions.

    Returns the run id (string).
    The runId of a workflow execution. This ID is generated by the service and
    can be used to uniquely identify the workflow execution within a domain.

    return run_id (string)
    """
    kwargs = {}

    for aws_prop, value, conversion in (
        ("taskList", task_list, None),
        ("taskPriority", task_priority, str),
        ("input", _input, None),
        ("executionStartToCloseTimeout", execution_start_to_close_timeout, None),
        ("tagList", tag_list, None),
        ("taskStartToCloseTimeout", task_start_to_close_timeout, None),
        ("childPolicy", child_policy, None),
        ("lambdaRole", lambda_role, None),
    ):

        kwargs = check_and_add_kwargs(aws_prop, value, conversion, kwargs)

    result = make_request(
        SWF.start_workflow_execution,
        domain=domain,
        workflowId=workflow_id,
        workflowType={"name": workflow_type_name, "version": workflow_type_version},
        **kwargs
    )

    if result.success:
        return result.result.get("runId")

    return StartWorkflowExecutionError(result.result.message)
示例#18
0
def start_workflow_execution(domain, workflow_id, workflow_type_name,
                             workflow_type_version, task_list=None,
                             task_priority=None, _input=None,
                             execution_start_to_close_timeout=None,
                             tag_list=None, child_policy=None,
                             task_start_to_close_timeout=None,
                             lambda_role=None):
    """Starts an execution of the workflow type in the specified domain using
    the provided workflowId and input data.

    This action returns the newly started workflow execution.

    http://boto3.readthedocs.org/en/latest/reference/services/swf.html#SWF.Client.start_workflow_execution

    domain (string) -- [REQUIRED]
    The name of the domain in which the workflow execution is created.

    workflow_id (string) -- [REQUIRED]
    The user defined identifier associated with the workflow execution. You can
    use this to associate a custom identifier with the workflow execution. You
    may specify the same identifier if a workflow execution is logically a
    restart of a previous execution. You cannot have two open workflow
    executions with the same workflowId at the same time.

    workflow_type (dict) -- [REQUIRED]
    The type of the workflow to start.

        ITEMS:
        name (string) -- [REQUIRED]
        Required. The name of the workflow type.

        version (string) -- [REQUIRED]
        Required. The version of the workflow type.

    task_list (dict) --
    The task list to use for the decision tasks generated for this workflow
    execution. This overrides the defaultTaskList specified when registering the
    workflow type.

        ITEMS:
        name (string) -- [REQUIRED]
        The name of the task list.

    task_priority (int) --
    The task priority to use for this workflow execution. This will override any
    default priority that was assigned when the workflow type was registered. If
    not set, then the default task priority for the workflow type will be used.
    Valid values are integers that range from Java's Integer.MIN_VALUE
    (-2147483648) to Integer.MAX_VALUE (2147483647). Higher numbers indicate
    higher priority.

    _input (string) --
    The input for the workflow execution. This is a free form string which
    should be meaningful to the workflow you are starting. This input is made
    available to the new workflow execution in the WorkflowExecutionStarted
    history event.

    execution_start_to_close_timeout (string) --
    The total duration for this workflow execution. This overrides the
    defaultExecutionStartToCloseTimeout specified when registering the workflow
    type.

    tag_list (list) --
    The list of tags to associate with the workflow execution. You can specify a
    maximum of 5 tags. You can list workflow executions with a specific tag by
    calling ListOpenWorkflowExecutions or ListClosedWorkflowExecutions and
    specifying a TagFilter .

    task_start_to_close_timeout (string) --
    Specifies the maximum duration of decision tasks for this workflow
    execution. This parameter overrides the defaultTaskStartToCloseTimout
    specified when registering the workflow type using RegisterWorkflowType .

    child_policy (string) --
    If set, specifies the policy to use for the child workflow executions of
    this workflow execution if it is terminated, by calling the
    TerminateWorkflowExecution action explicitly or due to an expired timeout.
    This policy overrides the default child policy specified when registering
    the workflow type using RegisterWorkflowType .

    lambda_role (string) --
    The ARN of an IAM role that authorizes Amazon SWF to invoke AWS Lambda
    functions.

    Returns the run id (string).
    The runId of a workflow execution. This ID is generated by the service and
    can be used to uniquely identify the workflow execution within a domain.

    return run_id (string)
    """
    kwargs = {}

    for aws_prop, value, conversion in (
        ('taskList', task_list, None),
        ('taskPriority', task_priority, str),
        ('input', _input, None),
        ('executionStartToCloseTimeout', execution_start_to_close_timeout,
         None),
        ('tagList', tag_list, None),
        ('taskStartToCloseTimeout', task_start_to_close_timeout, None),
        ('childPolicy', child_policy, None),
        ('lambdaRole', lambda_role, None)):

        kwargs = check_and_add_kwargs(aws_prop, value, conversion, kwargs)

    result = make_request(
        SWF.start_workflow_execution,
        domain=domain,
        workflowId=workflow_id,
        workflowType={
            'name': workflow_type_name,
            'version': workflow_type_version
        },
        **kwargs)

    if result.success:
        return result.result.get('runId')

    return StartWorkflowExecutionError(result.result.message)
示例#19
0
def register_activity_type(domain,
                           name,
                           version,
                           description=None,
                           default_task_start_to_close_timeout=None,
                           default_task_heartbeat_timeout=None,
                           default_task_list=None,
                           default_task_priority=None,
                           default_task_schedule_to_start_timeout=None,
                           default_task_schedule_to_close_timeout=None):
    """Registers a new activity type along with its configuration settings in
    the specified domain.

    WARNING
    A TypeAlreadyExists fault is returned if the type already exists in the
    domain. You cannot change any configuration settings of the type after its
    registration, and it must be registered as a new version.

    http://boto3.readthedocs.org/en/latest/reference/services/swf.html#SWF.Client.register_activity_type

    domain (string) -- [REQUIRED]
    The name of the domain in which this activity is to be registered.

    name (string) -- [REQUIRED]
    The name of the activity type within the domain.

    version (string) -- [REQUIRED]
    The version of the activity type.

    description (string) --
    A textual description of the activity type.

    default_task_start_to_close_timeout (string) --
    If set, specifies the default maximum duration that a worker can take to
    process tasks of this activity type. This default can be overridden when
    scheduling an activity task using the ScheduleActivityTask decision.

    default_task_heartbeat_timeout (string) --
    If set, specifies the default maximum time before which a worker processing
    a task of this type must report progress by calling
    RecordActivityTaskHeartbeat. If the timeout is exceeded, the activity task
    is automatically timed out. This default can be overridden when scheduling
    an activity task using the ScheduleActivityTask decision. If the activity
    worker subsequently attempts to record a heartbeat or returns a result, the
    activity worker receives an UnknownResource fault. In this case, Amazon SWF
    no longer considers the activity task to be valid; the activity worker
    should clean up the activity task.

        The duration is specified in seconds; an integer greater than or equal
        to 0. The value "NONE" can be used to specify unlimited duration.

    default_task_list (dict) --
    If set, specifies the default task list to use for scheduling tasks of this
    activity type. This default task list is used if a task list is not provided
    when a task is scheduled through the ScheduleActivityTask decision.

        name (string) -- [REQUIRED]
        The name of the task list.

    default_task_priority (int) --
    The default task priority to assign to the activity type. If not assigned,
    then "0" will be used. Valid values are integers that range from Java's
    Integer.MIN_VALUE (-2147483648) to Integer.MAX_VALUE (2147483647). Higher
    numbers indicate higher priority.

    default_task_schedule_to_start_timeout (string) --
    If set, specifies the default maximum duration that a task of this activity
    type can wait before being assigned to a worker. This default can be
    overridden when scheduling an activity task using the ScheduleActivityTask
    decision.

    default_task_schedule_to_close_timeout (string) --
    If set, specifies the default maximum duration for a task of this activity
    type. This default can be overridden when scheduling an activity task using
    the ScheduleActivityTask decision.

    return None
    """
    kwargs = {}

    for aws_prop, value, conversion in (
        ('description', description, None),
        ('defaultTaskStartToCloseTimeout', default_task_start_to_close_timeout,
         None), ('defaultTaskHeartbeatTimeout', default_task_heartbeat_timeout,
                 None), ('defaultTaskList', default_task_list, None),
        ('defaultTaskPriority', default_task_priority,
         str), ('defaultTaskScheduleToStartTimeout',
                default_task_schedule_to_start_timeout,
                None), ('defaultTaskScheduleToCloseTimeout',
                        default_task_schedule_to_close_timeout, None)):

        kwargs = check_and_add_kwargs(aws_prop, value, conversion, kwargs)

    result = make_request(SWF.register_activity_type,
                          domain=domain,
                          name=name,
                          version=version,
                          **kwargs)

    if result.success:
        return

    if result.result.code == ACITVITY_TYPE_ALREADY_EXISTS:
        raise ActivityTypeAlreadyExistsError("Workflow type already exists.")

    raise RegisterActivityError(result.result.message)