PageRenderTime 39ms CodeModel.GetById 1ms app.highlight 33ms RepoModel.GetById 2ms app.codeStats 0ms

/boto-2.5.2/boto/swf/layer1_decisions.py

#
Python | 316 lines | 189 code | 17 blank | 110 comment | 64 complexity | 4107feeaf8c9aeb5bd516a9fea7bdba2 MD5 | raw file
  1"""
  2helper class for creating decision responses
  3"""
  4
  5class Layer1Decisions:
  6    """
  7    Use this object to build a list of decisions for a decision response.
  8    Each method call will add append a new decision.  Retrieve the list
  9    of decisions from the _data attribute.
 10
 11    """
 12    def __init__(self):
 13        self._data = []
 14
 15    def schedule_activity_task(self,
 16                               activity_id,
 17                               activity_type_name,
 18                               activity_type_version,
 19                               task_list=None,
 20                               control=None,
 21                               heartbeat_timeout=None,
 22                               schedule_to_close_timeout=None,
 23                               schedule_to_start_timeout=None,
 24                               start_to_close_timeout=None,
 25                               input=None):
 26        """
 27        schedules an activity task
 28
 29        :type activity_id: string
 30        :param activity_id: The activityId of the type of the activity 
 31            being scheduled.
 32
 33        :type activity_type_name: string
 34        :param activity_type_name: The name of the type of the activity 
 35            being scheduled.
 36
 37        :type activity_type_version: string
 38        :param activity_type_version: The version of the type of the 
 39            activity being scheduled.
 40
 41        :type task_list: string
 42        :param task_list: If set, specifies the name of the task list in 
 43            which to schedule the activity task. If not specified, the 
 44            defaultTaskList registered with the activity type will be used.
 45            Note: a task list for this activity task must be specified either 
 46            as a default for the activity type or through this field. If 
 47            neither this field is set nor a default task list was specified 
 48            at registration time then a fault will be returned.
 49
 50        FINISH DOCS
 51        """
 52        o = {}
 53        o['decisionType'] = 'ScheduleActivityTask'
 54        attrs = o['scheduleActivityTaskDecisionAttributes'] = {}
 55        attrs['activityId'] = activity_id
 56        attrs['activityType'] = {
 57            'name': activity_type_name,
 58            'version': activity_type_version,
 59        }
 60        if task_list is not None:
 61            attrs['taskList'] = {'name': task_list}
 62        if control is not None:
 63            attrs['control'] = control
 64        if heartbeat_timeout is not None:
 65            attrs['heartbeatTimeout'] = heartbeat_timeout
 66        if schedule_to_close_timeout is not None:
 67            attrs['scheduleToCloseTimeout'] = schedule_to_close_timeout
 68        if schedule_to_start_timeout is not None:
 69            attrs['scheduleToStartTimeout'] = schedule_to_start_timeout
 70        if start_to_close_timeout is not None:
 71            attrs['startToCloseTimeout'] = start_to_close_timeout
 72        if input is not None:
 73            attrs['input'] = input
 74        self._data.append(o)
 75
 76    def request_cancel_activity_task(self,
 77                                     activity_id):
 78        """
 79        attempts to cancel a previously scheduled activity task. If the activity 
 80        task was scheduled but has not been assigned to a worker, then it will 
 81        be canceled. If the activity task was already assigned to a worker, then 
 82        the worker will be informed that cancellation has been requested in the 
 83        response to RecordActivityTaskHeartbeat.
 84    
 85        FINISH DOCS
 86        """
 87        o = {}
 88        o['decisionType'] = 'RequestCancelActivityTask'
 89        attrs = o['requestCancelActivityTaskDecisionAttributes'] = {}
 90        attrs['activityId'] = activity_id
 91        self._data.append(o)
 92
 93    def record_marker(self,
 94                      marker_name,
 95                      details=None):
 96        """
 97        records a MarkerRecorded event in the history. Markers can be used for 
 98        adding custom information in the history for instance to let deciders know 
 99        that they do not need to look at the history beyond the marker event.
100        
101        FINISH DOCS
102        """
103        o = {}
104        o['decisionType'] = 'RecordMarker'
105        attrs = o['recordMarkerDecisionAttributes'] = {}
106        attrs['markerName'] = marker_name
107        if details is not None:
108            attrs['details'] = details
109        self._data.append(o)
110
111    def complete_workflow_execution(self,
112                                    result=None):
113        """
114        closes the workflow execution and records a WorkflowExecutionCompleted 
115        event in the history 
116
117        FINISH DOCS
118        """
119        o = {}
120        o['decisionType'] = 'CompleteWorkflowExecution'
121        attrs = o['completeWorkflowExecutionDecisionAttributes'] = {}
122        if result is not None:
123            attrs['result'] = result
124        self._data.append(o)
125
126    def fail_workflow_execution(self,
127                                reason=None,
128                                details=None):
129        """
130        closes the workflow execution and records a WorkflowExecutionFailed event 
131        in the history.
132
133        FINISH DOCS
134        """
135        o = {}
136        o['decisionType'] = 'FailWorkflowExecution'
137        attrs = o['failWorkflowExecutionDecisionAttributes'] = {}
138        if reason is not None:
139            attrs['reason'] = reason
140        if details is not None:
141            attrs['details'] = details
142        self._data.append(o)
143
144    def cancel_workflow_executions(self,
145                                   details=None):
146        """
147        closes the workflow execution and records a WorkflowExecutionCanceled 
148        event in the history.
149
150        FINISH DOCS
151        """
152        o = {}
153        o['decisionType'] = 'CancelWorkflowExecutions'
154        attrs = o['cancelWorkflowExecutionsDecisionAttributes'] = {}
155        if details is not None:
156            attrs['details'] = details
157        self._data.append(o)
158
159    def continue_as_new_workflow_execution(self,
160                                           child_policy=None,
161                                           execution_start_to_close_timeout=None,
162                                           input=None,
163                                           tag_list=None,
164                                           task_list=None,
165                                           start_to_close_timeout=None,
166                                           workflow_type_version=None):
167        """
168        closes the workflow execution and starts a new workflow execution of 
169        the same type using the same workflow id and a unique run Id. A 
170        WorkflowExecutionContinuedAsNew event is recorded in the history.
171
172        FINISH DOCS
173        """
174        o = {}
175        o['decisionType'] = 'ContinueAsNewWorkflowExecution'
176        attrs = o['continueAsNewWorkflowExecutionDecisionAttributes'] = {}
177        if child_policy is not None:
178            attrs['childPolicy'] = child_policy
179        if execution_start_to_close_timeout is not None:
180            attrs['executionStartToCloseTimeout'] = execution_start_to_close_timeout
181        if input is not None:
182            attrs['input'] = input
183        if tag_list is not None:
184            attrs['tagList'] = tag_list
185        if task_list is not None:
186            attrs['taskList'] = {'name': task_list}
187        if start_to_close_timeout is not None:
188            attrs['startToCloseTimeout'] = start_to_close_timeout
189        if workflow_type_version is not None:
190            attrs['workflowTypeVersion'] = workflow_type_version
191        self._data.append(o)
192
193    def start_timer(self,
194                    start_to_fire_timeout,
195                    timer_id,
196                    control=None):
197        """
198        starts a timer for this workflow execution and records a TimerStarted 
199        event in the history.  This timer will fire after the specified delay 
200        and record a TimerFired event.
201
202        FINISH DOCS
203        """
204        o = {}
205        o['decisionType'] = 'StartTimer'
206        attrs = o['startTimerDecisionAttributes'] = {}
207        attrs['startToFireTimeout'] = start_to_fire_timeout
208        attrs['timerId'] = timer_id
209        if control is not None:
210            attrs['control'] = control
211        self._data.append(o)
212
213    def cancel_timer(self,
214                     timer_id):
215        """
216        cancels a previously started timer and records a TimerCanceled event in the 
217        history.
218
219        FINISH DOCS
220        """
221        o = {}
222        o['decisionType'] = 'CancelTimer'
223        attrs = o['cancelTimerDecisionAttributes'] = {}
224        attrs['timerId'] = timer_id
225        self._data.append(o)
226
227    def signal_external_workflow_execution(self,
228                                           workflow_id,
229                                           signal_name,
230                                           run_id=None,
231                                           control=None,
232                                           input=None):
233        """
234        requests a signal to be delivered to the specified external workflow 
235        execution and records a SignalExternalWorkflowExecutionInitiated 
236        event in the history.
237
238        FINISH DOCS
239        """
240        o = {}
241        o['decisionType'] = 'SignalExternalWorkflowExecution'
242        attrs = o['signalExternalWorkflowExecutionDecisionAttributes'] = {}
243        attrs['workflowId'] = workflow_id
244        attrs['signalName'] = signal_name
245        if run_id is not None:
246            attrs['runId'] = run_id
247        if control is not None:
248            attrs['control'] = control
249        if input is not None:
250            attrs['input'] = input
251        self._data.append(o)
252
253    def request_cancel_external_workflow_execution(self,
254                                                   workflow_id,
255                                                   control=None,
256                                                   run_id=None):
257        """
258        requests that a request be made to cancel the specified external workflow 
259        execution and records a 
260        RequestCancelExternalWorkflowExecutionInitiated event in the history.
261
262        FINISH DOCS
263        """
264        o = {}
265        o['decisionType'] = 'RequestCancelExternalWorkflowExecution'
266        attrs = o['requestCancelExternalWorkflowExecutionDecisionAttributes'] = {}
267        attrs['workflowId'] = workflow_id
268        if control is not None:
269            attrs['control'] = control
270        if run_id is not None:
271            attrs['runId'] = run_id
272        self._data.append(o)
273
274    def start_child_workflow_execution(self,
275                                       workflow_type_name,
276                                       workflow_type_version,
277                                       child_policy=None,
278                                       control=None,
279                                       execution_start_to_close_timeout=None,
280                                       input=None,
281                                       tag_list=None,
282                                       task_list=None,
283                                       task_start_to_close_timeout=None):
284        """
285        requests that a child workflow execution be started and records a 
286        StartChildWorkflowExecutionInitiated event in the history.  The child 
287        workflow execution is a separate workflow execution with its own history.
288
289        FINISH DOCS
290        """
291        o = {}
292        o['decisionType'] = 'StartChildWorkflowExecution'
293        attrs = o['startChildWorkflowExecutionDecisionAttributes'] = {}
294        attrs['workflowType'] = {
295            'name': workflow_type_name,
296            'version': workflow_type_version,
297        }
298        if child_policy is not None:
299            attrs['childPolicy'] = child_policy
300        if control is not None:
301            attrs['control'] = control
302        if execution_start_to_close_timeout is not None:
303            attrs['executionStartToCloseTimeout'] = execution_start_to_close_timeout
304        if input is not None:
305            attrs['input'] = input
306        if tag_list is not None:
307            attrs['tagList'] = tag_list
308        if task_list is not None:
309            attrs['taskList'] = {'name': task_list}
310        if task_start_to_close_timeout is not None:
311            attrs['taskStartToCloseTimeout'] = task_start_to_close_timeout
312        self._data.append(o)
313
314
315
316