U
    Zf$                     @   s  d dl mZ d dlmZ d dlmZ G dd dejZeeZ	G dd deZ
ee
ZG dd	 d	ejZeeZG d
d dejZeeZG dd deZeeZG dd dejZeeZejddZee_dejie_e e
_de
jie
_e
jej e
de
_eej_edge_ dejjfge_!e e_"dej"ie_ede_#e e_dejie_ejej ede_e e_$e e_%e e_&ej$ej%ej&de_ede_'ede_(ede_)i Z*dS )    )unicode_literals)
stone_base)stone_validatorsc                       s@   e Zd ZdZdZedd Zdd Zdd Z fd	d
Z	  Z
S )LaunchResultBasea  
    Result returned by methods that launch an asynchronous job. A method who may
    either launch an asynchronous job, or complete the request synchronously,
    can use this union by extending it, and adding a 'complete' field with the
    type of the synchronous response. See :class:`LaunchEmptyResult` for an
    example.

    This class acts as a tagged union. Only one of the ``is_*`` methods will
    return true. To get the associated value of a tag (if one exists), use the
    corresponding ``get_*`` method.

    :ivar str async.LaunchResultBase.async_job_id: This response indicates that
        the processing is asynchronous. The string is an id that can be used to
        obtain the status of the asynchronous job.
    Nc                 C   s
   | d|S )z
        Create an instance of this class set to the ``async_job_id`` tag with
        value ``val``.

        :param str val:
        :rtype: LaunchResultBase
        async_job_id )clsvalr   r   2/tmp/pip-unpacked-wheel-qnjxxdf1/dropbox/async_.pyr      s    	zLaunchResultBase.async_job_idc                 C   s
   | j dkS )zS
        Check if the union tag is ``async_job_id``.

        :rtype: bool
        r   Z_tagselfr   r   r
   is_async_job_id(   s    z LaunchResultBase.is_async_job_idc                 C   s   |   std| jS )z
        This response indicates that the processing is asynchronous. The string
        is an id that can be used to obtain the status of the asynchronous job.

        Only call this if :meth:`is_async_job_id` is true.

        :rtype: str
        ztag 'async_job_id' not set)r   AttributeError_valuer   r   r   r
   get_async_job_id0   s    	z!LaunchResultBase.get_async_job_idc                    s   t t| ||| d S N)superr   _process_custom_annotationsr   Zannotation_typeZ
field_path	processor	__class__r   r
   r   =   s    z,LaunchResultBase._process_custom_annotations)__name__
__module____qualname____doc__
_catch_allclassmethodr   r   r   r   __classcell__r   r   r   r
   r   
   s   

r   c                       s,   e Zd ZdZdZdd Z fddZ  ZS )LaunchEmptyResulta  
    Result returned by methods that may either launch an asynchronous job or
    complete synchronously. Upon synchronous completion of the job, no
    additional information is returned.

    This class acts as a tagged union. Only one of the ``is_*`` methods will
    return true. To get the associated value of a tag (if one exists), use the
    corresponding ``get_*`` method.

    :ivar async.LaunchEmptyResult.complete: The job finished synchronously and
        successfully.
    Nc                 C   s
   | j dkS zO
        Check if the union tag is ``complete``.

        :rtype: bool
        completer   r   r   r   r
   is_completeS   s    zLaunchEmptyResult.is_completec                    s   t t| ||| d S r   )r   r    r   r   r   r   r
   r   [   s    z-LaunchEmptyResult._process_custom_annotationsr   r   r   r   r"   r#   r   r   r   r   r   r
   r    B   s   r    c                       s>   e Zd ZdZdgZdZd
ddZedZ	 fdd	Z
  ZS )PollArgz
    Arguments for methods that poll the status of an asynchronous job.

    :ivar async.PollArg.async_job_id: Id of the asynchronous job. This is the
        value of a response returned from the method that launched the job.
    _async_job_id_valueTNc                 C   s   t j| _|d k	r|| _d S r   )bbZNOT_SETr&   r   )r   r   r   r   r
   __init__n   s    zPollArg.__init__r   c                    s   t t| ||| d S r   )r   r%   r   r   r   r   r
   r   w   s    z#PollArg._process_custom_annotations)N)r   r   r   r   	__slots__Z_has_required_fieldsr(   r'   	Attributer   r   r   r   r   r   r
   r%   `   s    

r%   c                       s0   e Zd ZdZdZdZdd Z fddZ  ZS )PollResultBasea(  
    Result returned by methods that poll for the status of an asynchronous job.
    Unions that extend this union should add a 'complete' field with a type of
    the information returned upon job completion. See :class:`PollEmptyResult`
    for an example.

    This class acts as a tagged union. Only one of the ``is_*`` methods will
    return true. To get the associated value of a tag (if one exists), use the
    corresponding ``get_*`` method.

    :ivar async.PollResultBase.in_progress: The asynchronous job is still in
        progress.
    Nc                 C   s
   | j dkS )zR
        Check if the union tag is ``in_progress``.

        :rtype: bool
        in_progressr   r   r   r   r
   is_in_progress   s    zPollResultBase.is_in_progressc                    s   t t| ||| d S r   )r   r+   r   r   r   r   r
   r      s    z*PollResultBase._process_custom_annotations)	r   r   r   r   r   r,   r-   r   r   r   r   r   r
   r+   |   s
   r+   c                       s,   e Zd ZdZdZdd Z fddZ  ZS )PollEmptyResulta  
    Result returned by methods that poll for the status of an asynchronous job.
    Upon completion of the job, no additional information is returned.

    This class acts as a tagged union. Only one of the ``is_*`` methods will
    return true. To get the associated value of a tag (if one exists), use the
    corresponding ``get_*`` method.

    :ivar async.PollEmptyResult.complete: The asynchronous job has completed
        successfully.
    Nc                 C   s
   | j dkS r!   r   r   r   r   r
   r#      s    zPollEmptyResult.is_completec                    s   t t| ||| d S r   )r   r.   r   r   r   r   r
   r      s    z+PollEmptyResult._process_custom_annotationsr$   r   r   r   r
   r.      s   r.   c                       sH   e Zd ZdZdZdZdZdZdd Zdd Z	dd	 Z
 fd
dZ  ZS )	PollErrora>  
    Error returned by methods for polling the status of asynchronous job.

    This class acts as a tagged union. Only one of the ``is_*`` methods will
    return true. To get the associated value of a tag (if one exists), use the
    corresponding ``get_*`` method.

    :ivar async.PollError.invalid_async_job_id: The job ID is invalid.
    :ivar async.PollError.internal_error: Something went wrong with the job on
        Dropbox's end. You'll need to verify that the action you were taking
        succeeded, and if not, try again. This should happen very rarely.
    otherNc                 C   s
   | j dkS )z[
        Check if the union tag is ``invalid_async_job_id``.

        :rtype: bool
        invalid_async_job_idr   r   r   r   r
   is_invalid_async_job_id   s    z!PollError.is_invalid_async_job_idc                 C   s
   | j dkS )zU
        Check if the union tag is ``internal_error``.

        :rtype: bool
        internal_errorr   r   r   r   r
   is_internal_error   s    zPollError.is_internal_errorc                 C   s
   | j dkS )zL
        Check if the union tag is ``other``.

        :rtype: bool
        r0   r   r   r   r   r
   is_other   s    zPollError.is_otherc                    s   t t| ||| d S r   )r   r/   r   r   r   r   r
   r      s    z%PollError._process_custom_annotations)r   r   r   r   r   r1   r3   r0   r2   r4   r5   r   r   r   r   r   r
   r/      s   r/      )Z
min_lengthr   r"   r,   )r1   r3   r0   r1   r3   r0   N)+
__future__r   Zstone.backends.python_rsrcr   r'   r   ZbvUnionr   ZLaunchResultBase_validatorr    ZLaunchEmptyResult_validatorStructr%   ZPollArg_validatorr+   ZPollResultBase_validatorr.   ZPollEmptyResult_validatorr/   ZPollError_validatorStringZAsyncJobId_validatorZ_async_job_id_validatorZ_tagmapZVoidZ_complete_validatorupdater"   r   Z	validatorsetZ_all_field_names_Z_all_fields_Z_in_progress_validatorr,   Z_invalid_async_job_id_validatorZ_internal_error_validatorZ_other_validatorr1   r3   r0   ZROUTESr   r   r   r
   <module>   sd   6




1
 
 

 

 






