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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ZeeZedZejddZe ZedZejdddZejddZejddddZejddZejdddZe ZeZ e! e_"ee_#ee_$e! e_%ej"ej#ej$ej%de_&ede_'ede_(ee
_)e! e
_*e! e
_%e
j)e
j*e
j%de
_&e
de
_+e
de
_(eej,_-eej._-e/d d!ge_0ej0e_1d ej,j-fd!ej.j-fge_2ej2e_3eed"e_4ed#efed$efie_5d%e_6e ej7_-e/d&ge_0ej18ej0e_1d&ej7j-fge_2ej3ej2 e_3e/g e_0ej18ej0e_1g e_2ej3ej2 e_3i Z9d'S )(    )unicode_literals)
stone_base)stone_validatorsc                       st   e Zd ZdZdZdZdZedd Zedd Z	dd	 Z
d
d Zdd Zdd Zdd Zdd Z fddZ  ZS )PathRoota  
    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 common.PathRoot.home: Paths are relative to the authenticating user's
        home namespace, whether or not that user belongs to a team.
    :ivar str common.PathRoot.root: Paths are relative to the authenticating
        user's root namespace (This results in
        :field:`PathRootError.invalid_root` if the user's root namespace has
        changed.).
    :ivar str common.PathRoot.namespace_id: Paths are relative to given
        namespace id (This results in :field:`PathRootError.no_permission` if
        you don't have access to this namespace.).
    otherNc                 C   s
   | d|S )z
        Create an instance of this class set to the ``root`` tag with value
        ``val``.

        :param str val:
        :rtype: PathRoot
        root clsvalr   r   2/tmp/pip-unpacked-wheel-qnjxxdf1/dropbox/common.pyr   !   s    	zPathRoot.rootc                 C   s
   | d|S )z
        Create an instance of this class set to the ``namespace_id`` tag with
        value ``val``.

        :param str val:
        :rtype: PathRoot
        namespace_idr   r	   r   r   r   r   ,   s    	zPathRoot.namespace_idc                 C   s
   | j dkS )zK
        Check if the union tag is ``home``.

        :rtype: bool
        homeZ_tagselfr   r   r   is_home7   s    zPathRoot.is_homec                 C   s
   | j dkS )zK
        Check if the union tag is ``root``.

        :rtype: bool
        r   r   r   r   r   r   is_root?   s    zPathRoot.is_rootc                 C   s
   | j dkS )zS
        Check if the union tag is ``namespace_id``.

        :rtype: bool
        r   r   r   r   r   r   is_namespace_idG   s    zPathRoot.is_namespace_idc                 C   s
   | j dkS zL
        Check if the union tag is ``other``.

        :rtype: bool
        r   r   r   r   r   r   is_otherO   s    zPathRoot.is_otherc                 C   s   |   std| jS )a  
        Paths are relative to the authenticating user's root namespace (This
        results in ``PathRootError.invalid_root`` if the user's root namespace
        has changed.).

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

        :rtype: str
        ztag 'root' not set)r   AttributeError_valuer   r   r   r   get_rootW   s    
zPathRoot.get_rootc                 C   s   |   std| jS )z
        Paths are relative to given namespace id (This results in
        ``PathRootError.no_permission`` if you don't have access to this
        namespace.).

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

        :rtype: str
        ztag 'namespace_id' not set)r   r   r   r   r   r   r   get_namespace_ide   s    
zPathRoot.get_namespace_idc                    s   t t| ||| d S N)superr   _process_custom_annotationsr   Zannotation_typeZ
field_path	processor	__class__r   r   r   s   s    z$PathRoot._process_custom_annotations)__name__
__module____qualname____doc__
_catch_allr   r   classmethodr   r   r   r   r   r   r   r   r   __classcell__r   r   r    r   r   
   s   



r   c                       sX   e Zd ZdZdZdZdZedd Zdd Z	dd	 Z
d
d Zdd Z fddZ  ZS )PathRootErrora  
    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 RootInfo PathRootError.invalid_root: The root namespace id in
        Dropbox-API-Path-Root header is not valid. The value of this error is
        the user's latest root info.
    :ivar common.PathRootError.no_permission: You don't have permission to
        access the namespace id in Dropbox-API-Path-Root  header.
    r   Nc                 C   s
   | d|S )z
        Create an instance of this class set to the ``invalid_root`` tag with
        value ``val``.

        :param RootInfo val:
        :rtype: PathRootError
        invalid_rootr   r	   r   r   r   r*      s    	zPathRootError.invalid_rootc                 C   s
   | j dkS )zS
        Check if the union tag is ``invalid_root``.

        :rtype: bool
        r*   r   r   r   r   r   is_invalid_root   s    zPathRootError.is_invalid_rootc                 C   s
   | j dkS )zT
        Check if the union tag is ``no_permission``.

        :rtype: bool
        no_permissionr   r   r   r   r   is_no_permission   s    zPathRootError.is_no_permissionc                 C   s
   | j dkS r   r   r   r   r   r   r      s    zPathRootError.is_otherc                 C   s   |   std| jS )z
        The root namespace id in Dropbox-API-Path-Root header is not valid. The
        value of this error is the user's latest root info.

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

        :rtype: RootInfo
        ztag 'invalid_root' not set)r+   r   r   r   r   r   r   get_invalid_root   s    	zPathRootError.get_invalid_rootc                    s   t t| ||| d S r   )r   r)   r   r   r    r   r   r      s    z)PathRootError._process_custom_annotations)r"   r#   r$   r%   r&   r,   r   r'   r*   r+   r-   r   r.   r   r(   r   r   r    r   r)   x   s   

r)   c                       sJ   e Zd ZdZddgZdZdddZedZ	ed	Z
 fd
dZ  ZS )RootInfoa  
    Information about current user's root.

    :ivar common.RootInfo.root_namespace_id: The namespace ID for user's root
        namespace. It will be the namespace ID of the shared team root if the
        user is member of a team with a separate team root. Otherwise it will be
        same as ``RootInfo.home_namespace_id``.
    :ivar common.RootInfo.home_namespace_id: The namespace ID for user's home
        namespace.
    _root_namespace_id_value_home_namespace_id_valueTNc                 C   s0   t j| _t j| _|d k	r|| _|d k	r,|| _d S r   )bbNOT_SETr0   r1   root_namespace_idhome_namespace_idr   r4   r5   r   r   r   __init__   s    zRootInfo.__init__r4   r5   c                    s   t t| ||| d S r   )r   r/   r   r   r    r   r   r      s    z$RootInfo._process_custom_annotations)NN)r"   r#   r$   r%   	__slots___has_required_fieldsr7   r2   	Attributer4   r5   r   r(   r   r   r    r   r/      s     


r/   c                       sB   e Zd ZdZdgZdZd
 fdd	ZedZ	 fdd	Z
  ZS )TeamRootInfoz
    Root info when user is member of a team with a separate root namespace ID.

    :ivar common.TeamRootInfo.home_path: The path for user's home directory
        under the shared team root.
    _home_path_valueTNc                    s,   t t| || tj| _|d k	r(|| _d S r   )r   r;   r7   r2   r3   r<   	home_path)r   r4   r5   r=   r    r   r   r7      s    zTeamRootInfo.__init__r=   c                    s   t t| ||| d S r   )r   r;   r   r   r    r   r   r     s    z(TeamRootInfo._process_custom_annotations)NNN)r"   r#   r$   r%   r8   r9   r7   r2   r:   r=   r   r(   r   r   r    r   r;      s      
r;   c                       s6   e Zd ZdZg ZdZd fdd	Z fddZ  ZS )	UserRootInfoz
    Root info when user is not member of a team or the user is a member of a
    team and the team does not have a separate root namespace.
    TNc                    s   t t| || d S r   )r   r>   r7   r6   r    r   r   r7     s    zUserRootInfo.__init__c                    s   t t| ||| d S r   )r   r>   r   r   r    r   r   r     s    z(UserRootInfo._process_custom_annotations)NN)	r"   r#   r$   r%   r8   r9   r7   r   r(   r   r   r    r   r>     s     r>   z%Y-%m-%dz[^/:?*<>"|]*)patternz%Y-%m-%dT%H:%M:%SZ   zA^['#&A-Za-z0-9._%+-]+@[A-Za-z0-9-][A-Za-z0-9.-]*\.[A-Za-z]{2,15}$)
max_lengthr?      )
min_length   d   )rC   rA   r?   z[-_0-9a-zA-Z:]+)r   r   r   r   r   r   )r*   r,   r   r,   r4   r5   )ZteamuserrF   rG   Tr=   N):
__future__r   Zstone.backends.python_rsrcr   r2   r   ZbvUnionr   ZPathRoot_validatorr)   ZPathRootError_validatorStructr/   Z
StructTreeZRootInfo_validatorr;   ZTeamRootInfo_validatorr>   ZUserRootInfo_validatorZ	TimestampZDate_validatorStringZDisplayName_validatorZDisplayNameLegacy_validatorZDropboxTimestamp_validatorZEmailAddress_validatorZLanguageCode_validatorZNamePart_validatorZNamespaceId_validatorZOptionalNamePart_validatorZSessionId_validatorZSharedFolderId_validatorZVoidZ_home_validatorZ_root_validatorZ_namespace_id_validatorZ_other_validatorZ_tagmapr   r   Z_invalid_root_validatorZ_no_permission_validatorr,   r4   Z	validatorr5   setZ_field_names_Z_all_field_names__fields_Z_all_fields_Z_tag_to_subtype_Z_pytype_to_tag_and_subtype_Z_is_catch_all_r=   unionZROUTESr   r   r   r   <module>   s   l
F
&














  
