U
    W+d                     @   sd   d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlm	Z
 d dlmZ d ZG dd deZdS )	    N)AWSAuthConnection)Provider)SWFResponseError)
exceptions)jsonc                       s  e Zd ZdZdZdZejejej	ej
ejdZeZdQ fdd		Zd
d Zedd ZdRddZdSddZdTddZdUddZdVddZdWddZdXddZdYddZdZd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/d0 Z#dad1d2Z$d3d4 Z%dbd5d6Z&d7d8 Z'dcd9d:Z(d;d< Z)d=d> Z*ddd?d@Z+dedAdBZ,dfdCdDZ-dgdEdFZ.dhdGdHZ/didIdJZ0dKdL Z1dMdN Z2dOdP Z3  Z4S )jLayer1z9
    Low-level interface to Simple WorkFlow Service.
    z	us-east-1z5com.amazonaws.swf.service.model.SimpleWorkflowService)z5com.amazonaws.swf.base.model#DomainAlreadyExistsFaultz/com.amazonaws.swf.base.model#LimitExceededFaultz7com.amazonaws.swf.base.model#OperationNotPermittedFaultz3com.amazonaws.swf.base.model#TypeAlreadyExistsFaultzAcom.amazonaws.swf.base.model#WorkflowExecutionAlreadyStartedFaultNTr   c                    sj   |	s8t jdd| j}t j D ]}|j|kr |}	 q8q |	| _tt	| j
| jj|||||||||
d
 d S )NZSWFregion)profile_name)botoconfiggetDefaultRegionNameZswfZregionsnamer   superr   __init__endpoint)selfZaws_access_key_idZaws_secret_access_keyZ	is_secureportproxyZ
proxy_portdebugZsession_tokenr   r	   Zregion_namereg	__class__ 3/tmp/pip-unpacked-wheel-dlxw5sjy/boto/swf/layer1.pyr   F   s(    

      zLayer1.__init__c                 C   s   dgS )Nzhmac-v4r   )r   r   r   r   _required_auth_capabilityW   s    z Layer1._required_auth_capabilityc                 C   sH   t | D ]6}t|| tr,| ||  || di fkr||= qdS )z
        This class method recurses through request data dictionary and removes
        any default values.

        :type data: dict
        :param data: Specifies request parameters with default values to be removed.
        N)listkeys
isinstancedict_normalize_request_dict)clsdataitemr   r   r   r    Z   s
    	zLayer1._normalize_request_dictc                 C   s"   |  | t|}| |||S )a:  
        This method wraps around make_request() to normalize and serialize the
        dictionary with request parameters.

        :type action: string
        :param action: Specifies an SWF action.

        :type data: dict
        :param data: Specifies request parameters associated with the action.
        )r    r   dumpsmake_request)r   actionr"   object_hookZ
json_inputr   r   r   json_requesti   s    

zLayer1.json_request c              	   C   s   d| j |f | jjddtt|d}| dddi ||d}| j|ddd	}| d
}t	j
| |jdkr|rtj||dS dS n8t|}|dd}	| j|	| j}
|
|j|j|ddS )zN
        :raises: ``SWFResponseError`` if response status is not 200.
        z%s.%szapplication/json; charset=UTF-8zamz-1.0)zX-Amz-TargetHostzContent-TypezContent-EncodingzContent-LengthPOST/N
   )ZsenderZoverride_num_retrieszutf-8   )r'   Z__type)body)ServiceNamer   r   strlenZbuild_base_http_requestZ_mexereaddecoder
   logr   statusr   loadsr   _fault_excpResponseErrorreason)r   r&   r/   r'   headershttp_requestresponseZresponse_bodyZ	json_bodyZ
fault_nameZexcp_clsr   r   r   r%   x   s2    

   

zLayer1.make_requestc                 C   s   |  d|d|i|dS )a  
        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 taskToken is
        an empty string. If a task is returned, the worker should use
        its type to identify and process it correctly.

        :type domain: string
        :param domain: The name of the domain that contains the task
            lists being polled.

        :type task_list: string
        :param task_list: Specifies the task list to poll for activity tasks.

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

        :raises: UnknownResourceFault, SWFOperationNotPermittedError
        ZPollForActivityTaskr   )domaintaskListidentityr(   )r   r>   	task_listr@   r   r   r   poll_for_activity_task   s
    zLayer1.poll_for_activity_taskc                 C   s   |  d||dS )a  
        Used by workers to tell the service that the ActivityTask
        identified by the taskToken completed successfully with a
        result (if provided).

        :type task_token: string
        :param task_token: The taskToken of the ActivityTask.

        :type result: string
        :param result: The result of the activity task. It is a free
            form string that is implementation specific.

        :raises: UnknownResourceFault, SWFOperationNotPermittedError
        ZRespondActivityTaskCompleted)	taskTokenresultrA   )r   
task_tokenrE   r   r   r   respond_activity_task_completed   s    z&Layer1.respond_activity_task_completedc                 C   s   |  d|||dS )a  
        Used by workers to tell the service that the ActivityTask
        identified by the taskToken has failed with reason (if
        specified).

        :type task_token: string
        :param task_token: The taskToken of the ActivityTask.

        :type details: string
        :param details: Optional detailed information about the failure.

        :type reason: string
        :param reason: Description of the error that may assist in diagnostics.

        :raises: UnknownResourceFault, SWFOperationNotPermittedError
        ZRespondActivityTaskFailed)rD   detailsr:   rA   )r   rF   rH   r:   r   r   r   respond_activity_task_failed   s
    z#Layer1.respond_activity_task_failedc                 C   s   |  d||dS )a  
        Used by workers to tell the service that the ActivityTask
        identified by the taskToken was successfully
        canceled. Additional details can be optionally provided using
        the details argument.

        :type task_token: string
        :param task_token: The taskToken of the ActivityTask.

        :type details: string
        :param details: Optional detailed information about the failure.

        :raises: UnknownResourceFault, SWFOperationNotPermittedError
        ZRespondActivityTaskCanceledrD   rH   rA   r   rF   rH   r   r   r   respond_activity_task_canceled   s    z%Layer1.respond_activity_task_canceledc                 C   s   |  d||dS )a  
        Used by activity workers to report to the service that the
        ActivityTask represented by the specified taskToken is still
        making progress. The worker can also (optionally) specify
        details of the progress, for example percent complete, using
        the details parameter. This action can also be used by the
        worker as a mechanism to check if cancellation is being
        requested for the activity task. If a cancellation is being
        attempted for the specified task, then the boolean
        cancelRequested flag returned by the service is set to true.

        :type task_token: string
        :param task_token: The taskToken of the ActivityTask.

        :type details: string
        :param details: If specified, contains details about the
            progress of the task.

        :raises: UnknownResourceFault, SWFOperationNotPermittedError
        ZRecordActivityTaskHeartbeatrJ   rA   rK   r   r   r   record_activity_task_heartbeat   s    z%Layer1.record_activity_task_heartbeatc              
   C   s   |  d|d|i||||dS )au  
        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.

        :type domain: string
        :param domain: The name of the domain containing the task
            lists to poll.

        :type task_list: string
        :param task_list: Specifies the task list to poll for decision tasks.

        :type identity: string
        :param identity: 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.

        :type maximum_page_size: integer :param maximum_page_size: The
            maximum number of history events returned in each page. The
            default is 100, but the caller can override this value to a
            page size smaller than the default. You cannot specify a page
            size greater than 100.

        :type next_page_token: string
        :param next_page_token: If on a previous call to this method a
            NextPageToken was returned, the results are being paginated.
            To get the next page of results, repeat the call with the
            returned token and all other arguments unchanged.

        :type reverse_order: boolean
        :param reverse_order: 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.

        :raises: UnknownResourceFault, SWFOperationNotPermittedError
        ZPollForDecisionTaskr   )r>   r?   r@   maximumPageSizenextPageTokenreverseOrderrA   )r   r>   rB   r@   maximum_page_sizenext_page_tokenreverse_orderr   r   r   poll_for_decision_task  s    ,zLayer1.poll_for_decision_taskc                 C   s   |  d|||dS )a	  
        Used by deciders to tell the service that the DecisionTask
        identified by the taskToken has successfully completed.
        The decisions argument specifies the list of decisions
        made while processing the task.

        :type task_token: string
        :param task_token: The taskToken of the ActivityTask.

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

        :type execution_context: string
        :param execution_context: User defined context to add to
            workflow execution.

        :raises: UnknownResourceFault, SWFOperationNotPermittedError
        ZRespondDecisionTaskCompleted)rD   	decisionsZexecutionContextrA   )r   rF   rU   Zexecution_contextr   r   r   respond_decision_task_completedH  s
    z&Layer1.respond_decision_task_completedc                 C   s   |  d|||dS )a5  
        Records a WorkflowExecutionCancelRequested event in the
        currently running workflow execution identified by the given
        domain, workflowId, and runId. This logically requests the
        cancellation of the workflow execution as a whole. It is up to
        the decider to take appropriate actions when it receives an
        execution history with this event.

        :type domain: string
        :param domain: The name of the domain containing the workflow
            execution to cancel.

        :type run_id: string
        :param run_id: The runId of the workflow execution to cancel.

        :type workflow_id: string
        :param workflow_id: The workflowId of the workflow execution
            to cancel.

        :raises: UnknownResourceFault, SWFOperationNotPermittedError
        ZRequestCancelWorkflowExecution)r>   
workflowIdrunIdrA   )r   r>   workflow_idrun_idr   r   r   !request_cancel_workflow_executione  s
    z(Layer1.request_cancel_workflow_executionc                 C   s*   |  d||||dd|i||||	|
d	S )a  
        Starts an execution of the workflow type in the specified
        domain using the provided workflowId and input data.

        :type domain: string
        :param domain: The name of the domain in which the workflow
            execution is created.

        :type workflow_id: string
        :param workflow_id: 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.

        :type workflow_name: string
        :param workflow_name: The name of the workflow type.

        :type workflow_version: string
        :param workflow_version: The version of the workflow type.

        :type task_list: string
        :param task_list: The task list to use for the decision tasks
            generated for this workflow execution. This overrides the
            defaultTaskList specified when registering the workflow type.

        :type child_policy: string
        :param child_policy: 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. 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.

        :type execution_start_to_close_timeout: string
        :param execution_start_to_close_timeout: The total duration for
            this workflow execution. This overrides the
            defaultExecutionStartToCloseTimeout specified when
            registering the workflow type.

        :type input: string
        :param input: 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.

        :type tag_list: list :param tag_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 list_open_workflow_executions or
            list_closed_workflow_executions and specifying a TagFilter.

        :type task_start_to_close_timeout: string :param
        task_start_to_close_timeout: Specifies the maximum duration of
            decision tasks for this workflow execution. This parameter
            overrides the defaultTaskStartToCloseTimout specified when
            registering the workflow type using register_workflow_type.

        :raises: UnknownResourceFault, TypeDeprecatedFault,
            SWFWorkflowExecutionAlreadyStartedError, SWFLimitExceededError,
            SWFOperationNotPermittedError, DefaultUndefinedFault
        ZStartWorkflowExecutionr   versionr   )	r>   rW   workflowTyper?   childPolicyZexecutionStartToCloseTimeoutinputZtagListZtaskStartToCloseTimeoutrA   )r   r>   rY   workflow_nameworkflow_versionrB   child_policyZ execution_start_to_close_timeoutr`   Ztag_listZtask_start_to_close_timeoutr   r   r   start_workflow_execution  s    QzLayer1.start_workflow_executionc              	   C   s   |  d|||||dS )a+  
        Records a WorkflowExecutionSignaled event in the workflow
        execution history and creates a decision task for the workflow
        execution identified by the given domain, workflowId and
        runId. The event is recorded with the specified user defined
        signalName and input (if provided).

        :type domain: string
        :param domain: The name of the domain containing the workflow
            execution to signal.

        :type signal_name: string
        :param signal_name: The name of the signal. This name must be
            meaningful to the target workflow.

        :type workflow_id: string
        :param workflow_id: The workflowId of the workflow execution
            to signal.

        :type input: string
        :param input: Data to attach to the WorkflowExecutionSignaled
            event in the target workflow execution's history.

        :type run_id: string
        :param run_id: The runId of the workflow execution to signal.

        :raises: UnknownResourceFault, SWFOperationNotPermittedError
        ZSignalWorkflowExecution)r>   Z
signalNamerW   r`   rX   rA   )r   r>   Zsignal_namerY   r`   rZ   r   r   r   signal_workflow_execution  s    z Layer1.signal_workflow_executionc              
   C   s   |  d||||||dS )a  
        Records a WorkflowExecutionTerminated event and forces closure
        of the workflow execution identified by the given domain,
        runId, and workflowId. The child policy, registered with the
        workflow type or specified when starting this execution, is
        applied to any open child workflow executions of this workflow
        execution.

        :type domain: string
        :param domain: The domain of the workflow execution to terminate.

        :type workflow_id: string
        :param workflow_id: The workflowId of the workflow execution
            to terminate.

        :type child_policy: string
        :param child_policy: If set, specifies the policy to use for
            the child workflow executions of the workflow execution being
            terminated. This policy overrides the child policy specified
            for the workflow execution at registration time or when
            starting the execution. 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.

        :type details: string
        :param details: Optional details for terminating the
            workflow execution.

        :type reason: string
        :param reason: An optional descriptive reason for terminating
            the workflow execution.

        :type run_id: string
        :param run_id: The runId of the workflow execution to terminate.

        :raises: UnknownResourceFault, SWFOperationNotPermittedError
        ZTerminateWorkflowExecution)r>   rW   r_   rH   r:   rX   rA   )r   r>   rY   rc   rH   r:   rZ   r   r   r   terminate_workflow_execution  s    2z#Layer1.terminate_workflow_executionc
           
      C   s$   |  d|||d|i|||||	d	S )a  
        Registers a new activity type along with its configuration
        settings in the specified domain.

        :type domain: string
        :param domain: The name of the domain in which this activity is
            to be registered.

        :type name: string
        :param name: The name of the activity type within the domain.

        :type version: string
        :param version: The version of the activity type.

        :type task_list: string
        :param task_list: 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 schedule_activity_task Decision.

        :type default_task_heartbeat_timeout: string
        :param default_task_heartbeat_timeout: 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.no docs

        :type default_task_schedule_to_close_timeout: string
        :param default_task_schedule_to_close_timeout: 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.no
            docs

        :type default_task_schedule_to_start_timeout: string
        :param default_task_schedule_to_start_timeout: 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.

        :type default_task_start_to_close_timeout: string
        :param default_task_start_to_close_timeout: 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.

        :type description: string
        :param description: A textual description of the activity type.

        :raises: SWFTypeAlreadyExistsError, SWFLimitExceededError,
            UnknownResourceFault, SWFOperationNotPermittedError
        ZRegisterActivityTyper   )	r>   r   r]   defaultTaskListZdefaultTaskHeartbeatTimeoutZ!defaultTaskScheduleToCloseTimeoutZ!defaultTaskScheduleToStartTimeoutdefaultTaskStartToCloseTimeoutdescriptionrA   )
r   r>   r   r]   rB   Zdefault_task_heartbeat_timeoutZ&default_task_schedule_to_close_timeoutZ&default_task_schedule_to_start_timeout#default_task_start_to_close_timeoutri   r   r   r   register_activity_typeF  s    CzLayer1.register_activity_typec                 C   s   |  d|||ddS )a  
        Deprecates the specified activity type. After an activity 
        type has been deprecated, you cannot create new tasks of 
        that activity type. Tasks of this type that were scheduled 
        before the type was deprecated will continue to run.

        :type domain: string
        :param domain: The name of the domain in which the activity
            type is registered.

        :type activity_name: string
        :param activity_name: The name of this activity.

        :type activity_version: string
        :param activity_version: The version of this activity.

        :raises: UnknownResourceFault, TypeDeprecatedFault,
            SWFOperationNotPermittedError
        ZDeprecateActivityTyper\   r>   ZactivityTyperA   r   r>   Zactivity_nameZactivity_versionr   r   r   deprecate_activity_type  s    zLayer1.deprecate_activity_typec	           	      C   s"   |  d|||d|i||||dS )a  
        Registers a new workflow type and its configuration settings
        in the specified domain.

        :type domain: string
        :param domain: The name of the domain in which to register
            the workflow type.

        :type name: string
        :param name: The name of the workflow type.

        :type version: string
        :param version: The version of the workflow type.

        :type task_list: list of name, version of tasks
        :param task_list: 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.

        :type default_child_policy: string

        :param default_child_policy: 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.no docs

        :type default_execution_start_to_close_timeout: string
        :param default_execution_start_to_close_timeout: 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.

        :type default_task_start_to_close_timeout: string
        :param default_task_start_to_close_timeout: 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.

        :type description: string
        :param description: Textual description of the workflow type.

        :raises: SWFTypeAlreadyExistsError, SWFLimitExceededError,
            UnknownResourceFault, SWFOperationNotPermittedError
        ZRegisterWorkflowTyper   )r>   r   r]   rg   ZdefaultChildPolicyZ#defaultExecutionStartToCloseTimeoutrh   ri   rA   )	r   r>   r   r]   rB   Zdefault_child_policyZ(default_execution_start_to_close_timeoutrj   ri   r   r   r   register_workflow_type  s    FzLayer1.register_workflow_typec                 C   s   |  d|||ddS )a	  
        Deprecates the specified workflow type. After a workflow type
        has been deprecated, you cannot create new executions of that
        type. Executions that were started before the type was
        deprecated will continue to run. A deprecated workflow type
        may still be used when calling visibility actions.

        :type domain: string
        :param domain: The name of the domain in which the workflow
            type is registered.

        :type workflow_name: string
        :param workflow_name: The name of the workflow type.

        :type workflow_version: string
        :param workflow_version: The version of the workflow type.

        :raises: UnknownResourceFault, TypeDeprecatedFault,
            SWFOperationNotPermittedError
        ZDeprecateWorkflowTyper\   r>   r^   rA   r   r>   ra   rb   r   r   r   deprecate_workflow_type  s    zLayer1.deprecate_workflow_typec                 C   s   |  d|||dS )a  
        Registers a new domain.

        :type name: string
        :param name: Name of the domain to register. The name must be unique.

        :type workflow_execution_retention_period_in_days: string

        :param workflow_execution_retention_period_in_days: Specifies
            the duration *in days* for which the record (including the
            history) of workflow executions in this domain should be kept
            by the service. After the retention period, the workflow
            execution will not be available in the results of visibility
            calls. If a duration of NONE is specified, the records for
            workflow executions in this domain are not retained at all.

        :type description: string
        :param description: Textual description of the domain.

        :raises: SWFDomainAlreadyExistsError, SWFLimitExceededError,
            SWFOperationNotPermittedError
        ZRegisterDomain)r   Z&workflowExecutionRetentionPeriodInDaysri   rA   )r   r   Z+workflow_execution_retention_period_in_daysri   r   r   r   register_domain  s
    zLayer1.register_domainc                 C   s   |  dd|iS )a  
        Deprecates the specified domain. After a domain has been
        deprecated it cannot be used to create new workflow executions
        or register new types. However, you can still use visibility
        actions on this domain. Deprecating a domain also deprecates
        all activity and workflow types registered in the
        domain. Executions that were started before the domain was
        deprecated will continue to run.

        :type name: string
        :param name: The name of the domain to deprecate.

        :raises: UnknownResourceFault, DomainDeprecatedFault,
            SWFOperationNotPermittedError
        ZDeprecateDomainr   rA   r   r   r   r   r   deprecate_domain>  s    zLayer1.deprecate_domainc              
   C   s   |  d||||||dS )aj  
        Returns information about all activities registered in the
        specified domain that match the specified name and
        registration status. The result includes information like
        creation date, current status of the activity, etc. The
        results may be split into multiple pages. To retrieve
        subsequent pages, make the call again using the nextPageToken
        returned by the initial call.

        :type domain: string
        :param domain: The name of the domain in which the activity
            types have been registered.

        :type registration_status: string
        :param registration_status: Specifies the registration status
            of the activity types to list.  Valid values are:

            * REGISTERED
            * DEPRECATED

        :type name: string
        :param name: If specified, only lists the activity types that
            have this name.

        :type maximum_page_size: integer
        :param maximum_page_size: The maximum number of results
            returned in each page. The default is 100, but the caller can
            override this value to a page size smaller than the
            default. You cannot specify a page size greater than 100.

        :type next_page_token: string
        :param next_page_token: If on a previous call to this method a
            NextResultToken was returned, the results have more than one
            page. To get the next page of results, repeat the call with
            the nextPageToken and keep all other arguments unchanged.

        :type reverse_order: boolean

        :param reverse_order: When set to true, returns the results in
            reverse order. By default the results are returned in
            ascending alphabetical order of the name of the activity
            types.

        :raises: SWFOperationNotPermittedError, UnknownResourceFault
        ZListActivityTypesr>   r   registrationStatusrN   rO   rP   rA   )r   r>   registration_statusr   rQ   rR   rS   r   r   r   list_activity_typesT  s    1zLayer1.list_activity_typesc                 C   s   |  d|||ddS )a]  
        Returns information about the specified activity type. This
        includes configuration settings provided at registration time
        as well as other general information about the type.

        :type domain: string
        :param domain: The name of the domain in which the activity
            type is registered.

        :type activity_name: string
        :param activity_name: The name of this activity.

        :type activity_version: string
        :param activity_version: The version of this activity.

        :raises: UnknownResourceFault, SWFOperationNotPermittedError
        ZDescribeActivityTyper\   rl   rA   rm   r   r   r   describe_activity_type  s    zLayer1.describe_activity_typec              
   C   s   |  d||||||dS )aZ  
        Returns information about workflow types in the specified
        domain. The results may be split into multiple pages that can
        be retrieved by making the call repeatedly.

        :type domain: string
        :param domain: The name of the domain in which the workflow
            types have been registered.

        :type registration_status: string
        :param registration_status: Specifies the registration status
            of the activity types to list.  Valid values are:

            * REGISTERED
            * DEPRECATED

        :type name: string
        :param name: If specified, lists the workflow type with this name.

        :type maximum_page_size: integer
        :param maximum_page_size: The maximum number of results
            returned in each page. The default is 100, but the caller can
            override this value to a page size smaller than the
            default. You cannot specify a page size greater than 100.

        :type next_page_token: string
        :param next_page_token: If on a previous call to this method a
            NextPageToken was returned, the results are being
            paginated. To get the next page of results, repeat the call
            with the returned token and all other arguments unchanged.

        :type reverse_order: boolean
        :param reverse_order: When set to true, returns the results in
            reverse order. By default the results are returned in
            ascending alphabetical order of the name of the workflow
            types.

        :raises: SWFOperationNotPermittedError, UnknownResourceFault
        ZListWorkflowTypesrv   rA   )r   r>   rx   rQ   r   rR   rS   r   r   r   list_workflow_types  s    *zLayer1.list_workflow_typesc                 C   s   |  d|||ddS )a  
        Returns information about the specified workflow type. This
        includes configuration settings specified when the type was
        registered and other information such as creation date,
        current status, etc.

        :type domain: string
        :param domain: The name of the domain in which this workflow
            type is registered.

        :type workflow_name: string
        :param workflow_name: The name of the workflow type.

        :type workflow_version: string
        :param workflow_version: The version of the workflow type.

        :raises: UnknownResourceFault, SWFOperationNotPermittedError
        ZDescribeWorkflowTyper\   rp   rA   rq   r   r   r   describe_workflow_type  s    zLayer1.describe_workflow_typec                 C   s   |  d|||ddS )aN  
        Returns information about the specified workflow execution
        including its type and some statistics.

        :type domain: string
        :param domain: The name of the domain containing the
            workflow execution.

        :type run_id: string
        :param run_id: A system generated unique identifier for the
            workflow execution.

        :type workflow_id: string
        :param workflow_id: The user defined identifier associated
            with the workflow execution.

        :raises: UnknownResourceFault, SWFOperationNotPermittedError
        ZDescribeWorkflowExecutionrX   rW   )r>   	executionrA   )r   r>   rZ   rY   r   r   r   describe_workflow_execution  s    z"Layer1.describe_workflow_executionc              	   C   s   |  d|||d|||dS )a  
        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.

        :type domain: string
        :param domain: The name of the domain containing the
            workflow execution.

        :type run_id: string
        :param run_id: A system generated unique identifier for the
            workflow execution.

        :type workflow_id: string
        :param workflow_id: The user defined identifier associated
            with the workflow execution.

        :type maximum_page_size: integer
        :param maximum_page_size: Specifies the maximum number of
            history events returned in one page. The next page in the
            result is identified by the NextPageToken returned. By default
            100 history events are returned in a page but the caller can
            override this value to a page size smaller than the
            default. You cannot specify a page size larger than 100.

        :type next_page_token: string
        :param next_page_token: If a NextPageToken is returned, the
            result has more than one pages. To get the next page, repeat
            the call and specify the nextPageToken with all other
            arguments unchanged.

        :type reverse_order: boolean
        :param reverse_order: 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.

        :raises: UnknownResourceFault, SWFOperationNotPermittedError
        ZGetWorkflowExecutionHistoryr}   )r>   r~   rN   rO   rP   rA   )r   r>   rZ   rY   rQ   rR   rS   r   r   r   get_workflow_execution_history  s    +z%Layer1.get_workflow_execution_historyc              	   C   s,   |  d|||d||dd|id|idS )a  
        Returns the number of open workflow executions within the
        given domain that meet the specified filtering criteria.

        .. note:
            workflow_id, workflow_name/workflow_version and tag are mutually
            exclusive. You can specify at most one of these in a request.

        :type domain: string
        :param domain: The name of the domain containing the
            workflow executions to count.

        :type latest_date: timestamp
        :param latest_date: Specifies the latest start or close date
            and time to return.

        :type oldest_date: timestamp
        :param oldest_date: Specifies the oldest start or close date
            and time to return.

        :type workflow_name: string
        :param workflow_name: Name of the workflow type to filter on.

        :type workflow_version: string
        :param workflow_version: Version of the workflow type to filter on.

        :type tag: string
        :param tag: If specified, only executions that have a tag
            that matches the filter are counted.

        :type workflow_id: string
        :param workflow_id: If specified, only workflow executions
            matching the workflow_id are counted.

        :raises: UnknownResourceFault, SWFOperationNotPermittedError
        ZCountOpenWorkflowExecutionsZ
oldestDateZ
latestDater\   rW   tag)r>   startTimeFilter
typeFilterexecutionFilter	tagFilterrA   )r   r>   latest_dateoldest_dater   rY   ra   rb   r   r   r   count_open_workflow_executionsC  s    )z%Layer1.count_open_workflow_executionsc                 C   s2   |  d|||dd|i||dd|i||	|
dS )a  
        Returns the list of open workflow executions within the
        given domain that meet the specified filtering criteria.

        .. note:
            workflow_id, workflow_name/workflow_version
            and tag are mutually exclusive. You can specify at most
            one of these in a request.

        :type domain: string
        :param domain: The name of the domain containing the
            workflow executions to count.

        :type latest_date: timestamp
        :param latest_date: Specifies the latest start or close date
            and time to return.

        :type oldest_date: timestamp
        :param oldest_date: Specifies the oldest start or close date
            and time to return.

        :type tag: string
        :param tag: If specified, only executions that have a tag
            that matches the filter are counted.

        :type workflow_id: string
        :param workflow_id: If specified, only workflow executions
            matching the workflow_id are counted.

        :type workflow_name: string
        :param workflow_name: Name of the workflow type to filter on.

        :type workflow_version: string
        :param workflow_version: Version of the workflow type to filter on.

        :type maximum_page_size: integer
        :param maximum_page_size: The maximum number of results
            returned in each page. The default is 100, but the caller can
            override this value to a page size smaller than the
            default. You cannot specify a page size greater than 100.

        :type next_page_token: string
        :param next_page_token: If on a previous call to this method a
            NextPageToken was returned, the results are being
            paginated. To get the next page of results, repeat the call
            with the returned token and all other arguments unchanged.

        :type reverse_order: boolean
        :param reverse_order: When set to true, returns the results in
            reverse order. By default the results are returned in
            descending order of the start or the close time of the
            executions.

        :raises: UnknownResourceFault, SWFOperationNotPermittedError

        ZListOpenWorkflowExecutionsr   r   r\   rW   )r>   r   r   r   r   rN   rO   rP   rA   )r   r>   r   r   r   rY   ra   rb   rQ   rR   rS   r   r   r   list_open_workflow_executionsv  s    Bz$Layer1.list_open_workflow_executionsc                 C   s:   |  d|||d||dd|id|i|	|
dd|idS )aT	  
        Returns the number of closed workflow executions within the
        given domain that meet the specified filtering criteria.

        .. note:
            close_status, workflow_id, workflow_name/workflow_version
            and tag are mutually exclusive. You can specify at most
            one of these in a request.

        .. note:
            start_latest_date/start_oldest_date and
            close_latest_date/close_oldest_date are mutually
            exclusive. You can specify at most one of these in a request.

        :type domain: string
        :param domain: The name of the domain containing the
            workflow executions to count.

        :type start_latest_date: timestamp
        :param start_latest_date: If specified, only workflow executions
            that meet the start time criteria of the filter are counted.

        :type start_oldest_date: timestamp
        :param start_oldest_date: If specified, only workflow executions
            that meet the start time criteria of the filter are counted.

        :type close_latest_date: timestamp
        :param close_latest_date: If specified, only workflow executions
            that meet the close time criteria of the filter are counted.

        :type close_oldest_date: timestamp
        :param close_oldest_date: If specified, only workflow executions
            that meet the close time criteria of the filter are counted.

        :type close_status: string
        :param close_status: The close status that must match the close status
            of an execution for it to meet the criteria of this filter.
            Valid values are:

            * COMPLETED
            * FAILED
            * CANCELED
            * TERMINATED
            * CONTINUED_AS_NEW
            * TIMED_OUT

        :type tag: string
        :param tag: If specified, only executions that have a tag
            that matches the filter are counted.

        :type workflow_id: string
        :param workflow_id: If specified, only workflow executions
            matching the workflow_id are counted.

        :type workflow_name: string
        :param workflow_name: Name of the workflow type to filter on.

        :type workflow_version: string
        :param workflow_version: Version of the workflow type to filter on.

        :raises: UnknownResourceFault, SWFOperationNotPermittedError
        ZCountClosedWorkflowExecutionsr   r6   r   r\   rW   )r>   r   closeTimeFiltercloseStatusFilterr   r   r   rA   )r   r>   start_latest_datestart_oldest_dateclose_latest_dateclose_oldest_dateclose_statusr   rY   ra   rb   r   r   r    count_closed_workflow_executions  s    Hz'Layer1.count_closed_workflow_executionsc                 C   s@   |  d|||d||dd|id|id|i|	|
d|||d
S )a  
        Returns the number of closed workflow executions within the
        given domain that meet the specified filtering criteria.

        .. note:
            close_status, workflow_id, workflow_name/workflow_version
            and tag are mutually exclusive. You can specify at most
            one of these in a request.

        .. note:
            start_latest_date/start_oldest_date and
            close_latest_date/close_oldest_date are mutually
            exclusive. You can specify at most one of these in a request.

        :type domain: string
        :param domain: The name of the domain containing the
            workflow executions to count.

        :type start_latest_date: timestamp
        :param start_latest_date: If specified, only workflow executions
            that meet the start time criteria of the filter are counted.

        :type start_oldest_date: timestamp
        :param start_oldest_date: If specified, only workflow executions
            that meet the start time criteria of the filter are counted.

        :type close_latest_date: timestamp
        :param close_latest_date: If specified, only workflow executions
            that meet the close time criteria of the filter are counted.

        :type close_oldest_date: timestamp
        :param close_oldest_date: If specified, only workflow executions
            that meet the close time criteria of the filter are counted.

        :type close_status: string
        :param close_status: The close status that must match the close status
            of an execution for it to meet the criteria of this filter.
            Valid values are:

            * COMPLETED
            * FAILED
            * CANCELED
            * TERMINATED
            * CONTINUED_AS_NEW
            * TIMED_OUT

        :type tag: string
        :param tag: If specified, only executions that have a tag
            that matches the filter are counted.

        :type workflow_id: string
        :param workflow_id: If specified, only workflow executions
            matching the workflow_id are counted.

        :type workflow_name: string
        :param workflow_name: Name of the workflow type to filter on.

        :type workflow_version: string
        :param workflow_version: Version of the workflow type to filter on.

        :type maximum_page_size: integer
        :param maximum_page_size: The maximum number of results
            returned in each page. The default is 100, but the caller can
            override this value to a page size smaller than the
            default. You cannot specify a page size greater than 100.

        :type next_page_token: string
        :param next_page_token: If on a previous call to this method a
            NextPageToken was returned, the results are being
            paginated. To get the next page of results, repeat the call
            with the returned token and all other arguments unchanged.

        :type reverse_order: boolean
        :param reverse_order: When set to true, returns the results in
            reverse order. By default the results are returned in
            descending order of the start or the close time of the
            executions.

        :raises: UnknownResourceFault, SWFOperationNotPermittedError
        ZListClosedWorkflowExecutionsr   rW   r6   r   r\   )
r>   r   r   r   r   r   r   rN   rO   rP   rA   )r   r>   r   r   r   r   r   r   rY   ra   rb   rQ   rR   rS   r   r   r   list_closed_workflow_executions  s$    ]z&Layer1.list_closed_workflow_executionsc                 C   s   |  d||||dS )ah  
        Returns the list of domains registered in the account. The
        results may be split into multiple pages. To retrieve
        subsequent pages, make the call again using the nextPageToken
        returned by the initial call.

        :type registration_status: string
        :param registration_status: Specifies the registration status
            of the domains to list.  Valid Values:

            * REGISTERED
            * DEPRECATED

        :type maximum_page_size: integer
        :param maximum_page_size: The maximum number of results
            returned in each page. The default is 100, but the caller can
            override this value to a page size smaller than the
            default. You cannot specify a page size greater than 100.

        :type next_page_token: string
        :param next_page_token: If on a previous call to this method a
            NextPageToken was returned, the result has more than one
            page. To get the next page of results, repeat the call with
            the returned token and all other arguments unchanged.

        :type reverse_order: boolean
        :param reverse_order: When set to true, returns the results in
            reverse order. By default the results are returned in
            ascending alphabetical order of the name of the domains.

        :raises: SWFOperationNotPermittedError
        ZListDomains)rw   rN   rO   rP   rA   )r   rx   rQ   rR   rS   r   r   r   list_domains  s    #zLayer1.list_domainsc                 C   s   |  dd|iS )a  
        Returns information about the specified domain including
        description and status.

        :type name: string
        :param name: The name of the domain to describe.

        :raises: UnknownResourceFault, SWFOperationNotPermittedError
        ZDescribeDomainr   rA   rt   r   r   r   describe_domain  s    
zLayer1.describe_domainc                 C   s   |  d|d|idS )a+  
        Returns the estimated number of decision tasks in the
        specified task list. The count returned is an approximation
        and is not guaranteed to be exact. If you specify a task list
        that no decision task was ever scheduled in then 0 will be
        returned.

        :type domain: string
        :param domain: The name of the domain that contains the task list.

        :type task_list: string
        :param task_list: The name of the task list.

        :raises: UnknownResourceFault, SWFOperationNotPermittedError
        ZCountPendingDecisionTasksr   r>   r?   rA   r   r>   rB   r   r   r   count_pending_decision_tasks  s    z#Layer1.count_pending_decision_tasksc                 C   s   |  d|d|idS )a+  
        Returns the estimated number of activity tasks in the
        specified task list. The count returned is an approximation
        and is not guaranteed to be exact. If you specify a task list
        that no activity task was ever scheduled in then 0 will be
        returned.

        :type domain: string
        :param domain: The name of the domain that contains the task list.

        :type task_list: string
        :param task_list: The name of the task list.

        :raises: UnknownResourceFault, SWFOperationNotPermittedError
        ZCountPendingActivityTasksr   r   rA   r   r   r   r   count_pending_activity_tasks  s    z#Layer1.count_pending_activity_tasks)
NNTNNNr   NNN)N)r)   N)N)N)NN)N)N)NNNN)NN)N)NNNNNN)NN)NNNN)NNNNNN)NNNNN)N)NNNN)NNNN)NNN)NNNN)NNNNNNNN)	NNNNNNNNN)NNNNNNNNNNNN)NNN)5__name__
__module____qualname____doc__r   r0   swf_exceptionsZSWFDomainAlreadyExistsErrorZSWFLimitExceededErrorZSWFOperationNotPermittedErrorZSWFTypeAlreadyExistsErrorZ'SWFWorkflowExecutionAlreadyStartedErrorr8   r   r9   r   r   classmethodr    r(   r%   rC   rG   rI   rL   rM   rT   rV   r[   rd   re   rf   rk   rn   ro   rr   rs   ru   ry   rz   r{   r|   r   r   r   r   r   r   r   r   r   r   __classcell__r   r   r   r   r   *   s                 



"
   


    
6  
 
        
`   
'      
?      
O     
Q 
     
:      
3   
5    
5        
P         
V            
p    
*r   )timer
   Zboto.connectionr   Zboto.providerr   Zboto.exceptionr   Zboto.swfr   r   Zboto.compatr   ZDebugr   r   r   r   r   <module>   s   