U
    W+d.                     @   s   d Z G dd deZdS )z/
Helper class for creating decision responses.
c                   @   s   e Zd ZdZdd ZdddZdd Zdd	d
ZdddZd ddZ	d!ddZ
d"ddZd#ddZdd Zd$ddZd%ddZd&ddZdS )'Layer1Decisionsz
    Use this object to build a list of decisions for a decision response.
    Each method call will add append a new decision.  Retrieve the list
    of decisions from the _data attribute.

    c                 C   s
   g | _ d S )N)_data)self r   =/tmp/pip-unpacked-wheel-dlxw5sjy/boto/swf/layer1_decisions.py__init__   s    zLayer1Decisions.__init__Nc                 C   s   i }d|d< i  }|d< ||d< ||d|d< |dk	rBd|i|d	< |dk	rR||d
< |dk	rb||d< |dk	rr||d< |dk	r||d< |	dk	r|	|d< |
dk	r|
|d< | j | dS )a  
        Schedules an activity task.

        :type activity_id: string
        :param activity_id: The activityId of the type of the activity
            being scheduled.

        :type activity_type_name: string
        :param activity_type_name: The name of the type of the activity
            being scheduled.

        :type activity_type_version: string
        :param activity_type_version: The version of the type of the
            activity being scheduled.

        :type task_list: string
        :param task_list: If set, specifies the name of the task list in
            which to schedule the activity task. If not specified, the
            defaultTaskList registered with the activity type will be used.
            Note: a task list for this activity task must be specified either
            as a default for the activity type or through this field. If
            neither this field is set nor a default task list was specified
            at registration time then a fault will be returned.
        ZScheduleActivityTaskdecisionTypeZ&scheduleActivityTaskDecisionAttributes
activityIdnameversionZactivityTypeNr
   taskListcontrolZheartbeatTimeoutZscheduleToCloseTimeoutZscheduleToStartTimeoutZstartToCloseTimeoutinputr   append)r   activity_idZactivity_type_nameZactivity_type_version	task_listr   Zheartbeat_timeoutZschedule_to_close_timeoutZschedule_to_start_timeoutstart_to_close_timeoutr   oattrsr   r   r   schedule_activity_task   s,    #
z&Layer1Decisions.schedule_activity_taskc                 C   s0   i }d|d< i  }|d< ||d< | j | dS )a  
        Attempts to cancel a previously scheduled activity task. If
        the activity task was scheduled but has not been assigned to a
        worker, then it will be canceled. If the activity task was
        already assigned to a worker, then the worker will be informed
        that cancellation has been requested in the response to
        RecordActivityTaskHeartbeat.
        ZRequestCancelActivityTaskr   Z+requestCancelActivityTaskDecisionAttributesr   Nr   )r   r   r   r   r   r   r   request_cancel_activity_taskK   s
    	z,Layer1Decisions.request_cancel_activity_taskc                 C   s@   i }d|d< i  }|d< ||d< |dk	r0||d< | j | dS )a  
        Records a MarkerRecorded event in the history. Markers can be
        used for adding custom information in the history for instance
        to let deciders know that they do not need to look at the
        history beyond the marker event.
        ZRecordMarkerr   ZrecordMarkerDecisionAttributesZ
markerNameNdetailsr   )r   Zmarker_namer   r   r   r   r   r   record_markerZ   s    zLayer1Decisions.record_markerc                 C   s8   i }d|d< i  }|d< |dk	r(||d< | j | dS )zu
        Closes the workflow execution and records a WorkflowExecutionCompleted
        event in the history
        ZCompleteWorkflowExecutionr   Z+completeWorkflowExecutionDecisionAttributesNresultr   )r   r   r   r   r   r   r   complete_workflow_executioni   s    z+Layer1Decisions.complete_workflow_executionc                 C   sH   i }d|d< i  }|d< |dk	r(||d< |dk	r8||d< | j | dS )zs
        Closes the workflow execution and records a
        WorkflowExecutionFailed event in the history.
        ZFailWorkflowExecutionr   Z'failWorkflowExecutionDecisionAttributesNreasonr   r   )r   r   r   r   r   r   r   r   fail_workflow_executionu   s    z'Layer1Decisions.fail_workflow_executionc                 C   s8   i }d|d< i  }|d< |dk	r(||d< | j | dS )zu
        Closes the workflow execution and records a WorkflowExecutionCanceled
        event in the history.
        ZCancelWorkflowExecutionr   Z*cancelWorkflowExecutionsDecisionAttributesNr   r   )r   r   r   r   r   r   r   cancel_workflow_executions   s    z*Layer1Decisions.cancel_workflow_executionsc           
      C   s   i }d|d< i  }	|d< |dk	r(||	d< |dk	r8||	d< |dk	rH||	d< |dk	rX||	d< |dk	rld	|i|	d
< |dk	r|||	d< |dk	r||	d< | j | dS )z
        Closes the workflow execution and starts a new workflow execution of
        the same type using the same workflow id and a unique run Id. A
        WorkflowExecutionContinuedAsNew event is recorded in the history.
        ZContinueAsNewWorkflowExecutionr   Z0continueAsNewWorkflowExecutionDecisionAttributesNchildPolicyexecutionStartToCloseTimeoutr   tagListr
   r   taskStartToCloseTimeoutZworkflowTypeVersionr   )
r   child_policy execution_start_to_close_timeoutr   tag_listr   r   workflow_type_versionr   r   r   r   r   "continue_as_new_workflow_execution   s$    z2Layer1Decisions.continue_as_new_workflow_executionc                 C   sH   i }d|d< i  }|d< ||d< ||d< |dk	r8||d< | j | dS )z
        Starts a timer for this workflow execution and records a TimerStarted
        event in the history.  This timer will fire after the specified delay
        and record a TimerFired event.
        Z
StartTimerr   ZstartTimerDecisionAttributesZstartToFireTimeouttimerIdNr   r   )r   Zstart_to_fire_timeouttimer_idr   r   r   r   r   r   start_timer   s    	zLayer1Decisions.start_timerc                 C   s0   i }d|d< i  }|d< ||d< | j | dS )zn
        Cancels a previously started timer and records a TimerCanceled
        event in the history.
        ZCancelTimerr   ZcancelTimerDecisionAttributesr(   Nr   )r   r)   r   r   r   r   r   cancel_timer   s
    zLayer1Decisions.cancel_timerc                 C   sh   i }d|d< i  }|d< ||d< ||d< |dk	r8||d< |dk	rH||d< |dk	rX||d	< | j | dS )
z
        Requests a signal to be delivered to the specified external workflow
        execution and records a SignalExternalWorkflowExecutionInitiated
        event in the history.
        ZSignalExternalWorkflowExecutionr   Z1signalExternalWorkflowExecutionDecisionAttributes
workflowIdZ
signalNameNrunIdr   r   r   )r   workflow_idZsignal_namerun_idr   r   r   r   r   r   r   "signal_external_workflow_execution   s    z2Layer1Decisions.signal_external_workflow_executionc                 C   sP   i }d|d< i  }|d< ||d< |dk	r0||d< |dk	r@||d< | j | dS )z
        Requests that a request be made to cancel the specified
        external workflow execution and records a
        RequestCancelExternalWorkflowExecutionInitiated event in the
        history.
        Z&RequestCancelExternalWorkflowExecutionr   Z8requestCancelExternalWorkflowExecutionDecisionAttributesr,   Nr   r-   r   )r   r.   r   r/   r   r   r   r   r   *request_cancel_external_workflow_execution   s    
z:Layer1Decisions.request_cancel_external_workflow_executionc                 C   s   i }d|d< i  }|d< ||d|d< ||d< |dk	r>||d< |dk	rN||d	< |dk	r^||d
< |dk	rn||d< |dk	r~||d< |	dk	rd|	i|d< |
dk	r|
|d< | j | dS )z
        Requests that a child workflow execution be started and
        records a StartChildWorkflowExecutionInitiated event in the
        history.  The child workflow execution is a separate workflow
        execution with its own history.
        ZStartChildWorkflowExecutionr   Z-startChildWorkflowExecutionDecisionAttributesr	   ZworkflowTyper,   Nr   r   r    r   r!   r
   r   r"   r   )r   Zworkflow_type_namer&   r.   r#   r   r$   r   r%   r   Ztask_start_to_close_timeoutr   r   r   r   r   start_child_workflow_execution   s,    
z.Layer1Decisions.start_child_workflow_execution)NNNNNNN)N)N)NN)N)NNNNNNN)N)NNN)NN)NNNNNNN)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r'   r*   r+   r0   r1   r2   r   r   r   r   r      sR          
;



       
# 
   
  
       r   N)r6   objectr   r   r   r   r   <module>   s   