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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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jZeeZee_ee_e e_ ejejej de_!ede_"e e
_#e e
_$e e
_%e e
_&e e
_'ee
_(e e
_)e e
_ e
j#e
j$e
j%e
j&e
j'e
j(e
j)e
j de
_!e
de
_*e
de
_+e
de
_,e
de
_-e
de
_.e
d e
_/e
de
_"e e_0e e_1e e_ ej0ej1ej d!e_!ed"e_2ed#e_3ede_"e e_4e e_5e e_ ej4ej5ej d$e_!ed%e_6ed&e_7ede_"eej8_9e: ej;_9e<d'd(ge_=d'ej8j9fd(ej;j9fge_>e e_?e e_@e e_ ej?ej@ej d)e_!ed*e_Aed+e_Bede_"ejCd,d-ejD_9ejCd,d-ejE_9e<d.d/ge_=d.ejDj9fd/ejEj9fge_>e e_Fe e_Ge e_ ejFejGej d0e_!ed1e_Hed2e_Iede_"ejCd,d-ejJ_9e<d3ge_=d3ejJj9fge_>eC ejK_9e<d4ge_=d4ejKj9fge_>d,ej;_LeMd5d,d6eeed7d8d9d:ZNeMd;d,d<e e e d=d8d9d:ZOeNeOd>ZPd?S )@    )unicode_literals)
stone_base)stone_validatorsc                       sh   e 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 fddZ  ZS )AccessErrora  
    Error occurred because the account doesn't have permission to access the
    resource.

    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 InvalidAccountTypeError AccessError.invalid_account_type: Current
        account type cannot access the resource.
    :ivar PaperAccessError AccessError.paper_access_denied: Current account
        cannot access Paper.
    otherNc                 C   s
   | d|S )z
        Create an instance of this class set to the ``invalid_account_type`` tag
        with value ``val``.

        :param InvalidAccountTypeError val:
        :rtype: AccessError
        invalid_account_type clsvalr   r   0/tmp/pip-unpacked-wheel-qnjxxdf1/dropbox/auth.pyr      s    	z AccessError.invalid_account_typec                 C   s
   | d|S )z
        Create an instance of this class set to the ``paper_access_denied`` tag
        with value ``val``.

        :param PaperAccessError val:
        :rtype: AccessError
        paper_access_deniedr   r	   r   r   r   r   (   s    	zAccessError.paper_access_deniedc                 C   s
   | j dkS )z[
        Check if the union tag is ``invalid_account_type``.

        :rtype: bool
        r   Z_tagselfr   r   r   is_invalid_account_type3   s    z#AccessError.is_invalid_account_typec                 C   s
   | j dkS )zZ
        Check if the union tag is ``paper_access_denied``.

        :rtype: bool
        r   r   r   r   r   r   is_paper_access_denied;   s    z"AccessError.is_paper_access_deniedc                 C   s
   | j dkS zL
        Check if the union tag is ``other``.

        :rtype: bool
        r   r   r   r   r   r   is_otherC   s    zAccessError.is_otherc                 C   s   |   std| jS )z
        Current account type cannot access the resource.

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

        :rtype: InvalidAccountTypeError
        z"tag 'invalid_account_type' not set)r   AttributeError_valuer   r   r   r   get_invalid_account_typeK   s    z$AccessError.get_invalid_account_typec                 C   s   |   std| jS )z
        Current account cannot access Paper.

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

        :rtype: PaperAccessError
        z!tag 'paper_access_denied' not set)r   r   r   r   r   r   r   get_paper_access_deniedW   s    z#AccessError.get_paper_access_deniedc                    s   t t| ||| d S N)superr   _process_custom_annotationsr   Zannotation_typeZ
field_path	processor	__class__r   r   r   c   s    z'AccessError._process_custom_annotations)__name__
__module____qualname____doc__
_catch_allr   classmethodr   r   r   r   r   r   r   r   __classcell__r   r   r   r   r   
   s   



r   c                       s   e Zd ZdZdZdZd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dd Zdd Zdd Zdd Zdd Z fddZ  ZS )	AuthErrora  
    Errors occurred during authentication.

    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 auth.AuthError.invalid_access_token: The access token is invalid.
    :ivar auth.AuthError.invalid_select_user: The user specified in
        'Dropbox-API-Select-User' is no longer on the team.
    :ivar auth.AuthError.invalid_select_admin: The user specified in
        'Dropbox-API-Select-Admin' is not a Dropbox Business team admin.
    :ivar auth.AuthError.user_suspended: The user has been suspended.
    :ivar auth.AuthError.expired_access_token: The access token has expired.
    :ivar TokenScopeError AuthError.missing_scope: The access token does not
        have the required scope to access the route.
    :ivar auth.AuthError.route_access_denied: The route is not available to
        public.
    r   Nc                 C   s
   | d|S )z
        Create an instance of this class set to the ``missing_scope`` tag with
        value ``val``.

        :param TokenScopeError val:
        :rtype: AuthError
        missing_scoper   r	   r   r   r   r(      s    	zAuthError.missing_scopec                 C   s
   | j dkS )z[
        Check if the union tag is ``invalid_access_token``.

        :rtype: bool
        invalid_access_tokenr   r   r   r   r   is_invalid_access_token   s    z!AuthError.is_invalid_access_tokenc                 C   s
   | j dkS )zZ
        Check if the union tag is ``invalid_select_user``.

        :rtype: bool
        invalid_select_userr   r   r   r   r   is_invalid_select_user   s    z AuthError.is_invalid_select_userc                 C   s
   | j dkS )z[
        Check if the union tag is ``invalid_select_admin``.

        :rtype: bool
        invalid_select_adminr   r   r   r   r   is_invalid_select_admin   s    z!AuthError.is_invalid_select_adminc                 C   s
   | j dkS )zU
        Check if the union tag is ``user_suspended``.

        :rtype: bool
        user_suspendedr   r   r   r   r   is_user_suspended   s    zAuthError.is_user_suspendedc                 C   s
   | j dkS )z[
        Check if the union tag is ``expired_access_token``.

        :rtype: bool
        expired_access_tokenr   r   r   r   r   is_expired_access_token   s    z!AuthError.is_expired_access_tokenc                 C   s
   | j dkS )zT
        Check if the union tag is ``missing_scope``.

        :rtype: bool
        r(   r   r   r   r   r   is_missing_scope   s    zAuthError.is_missing_scopec                 C   s
   | j dkS )zZ
        Check if the union tag is ``route_access_denied``.

        :rtype: bool
        route_access_deniedr   r   r   r   r   is_route_access_denied   s    z AuthError.is_route_access_deniedc                 C   s
   | j dkS r   r   r   r   r   r   r      s    zAuthError.is_otherc                 C   s   |   std| jS )z
        The access token does not have the required scope to access the route.

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

        :rtype: TokenScopeError
        ztag 'missing_scope' not set)r3   r   r   r   r   r   r   get_missing_scope   s    zAuthError.get_missing_scopec                    s   t t| ||| d S r   )r   r'   r   r   r   r   r   r      s    z%AuthError._process_custom_annotations)r    r!   r"   r#   r$   r)   r+   r-   r/   r1   r4   r   r%   r(   r*   r,   r.   r0   r2   r3   r5   r   r6   r   r&   r   r   r   r   r'   h   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 )InvalidAccountTypeErrora  
    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 auth.InvalidAccountTypeError.endpoint: Current account type doesn't
        have permission to access this route endpoint.
    :ivar auth.InvalidAccountTypeError.feature: Current account type doesn't
        have permission to access this feature.
    r   Nc                 C   s
   | j dkS )zO
        Check if the union tag is ``endpoint``.

        :rtype: bool
        endpointr   r   r   r   r   is_endpoint   s    z#InvalidAccountTypeError.is_endpointc                 C   s
   | j dkS )zN
        Check if the union tag is ``feature``.

        :rtype: bool
        featurer   r   r   r   r   
is_feature  s    z"InvalidAccountTypeError.is_featurec                 C   s
   | j dkS r   r   r   r   r   r   r     s    z InvalidAccountTypeError.is_otherc                    s   t t| ||| d S r   )r   r7   r   r   r   r   r   r     s    z3InvalidAccountTypeError._process_custom_annotations)r    r!   r"   r#   r$   r8   r:   r   r9   r;   r   r   r&   r   r   r   r   r7      s   r7   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 )PaperAccessErrorak  
    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 auth.PaperAccessError.paper_disabled: Paper is disabled.
    :ivar auth.PaperAccessError.not_paper_user: The provided user has not used
        Paper yet.
    r   Nc                 C   s
   | j dkS )zU
        Check if the union tag is ``paper_disabled``.

        :rtype: bool
        paper_disabledr   r   r   r   r   is_paper_disabled-  s    z"PaperAccessError.is_paper_disabledc                 C   s
   | j dkS )zU
        Check if the union tag is ``not_paper_user``.

        :rtype: bool
        not_paper_userr   r   r   r   r   is_not_paper_user5  s    z"PaperAccessError.is_not_paper_userc                 C   s
   | j dkS r   r   r   r   r   r   r   =  s    zPaperAccessError.is_otherc                    s   t t| ||| d S r   )r   r<   r   r   r   r   r   r   E  s    z,PaperAccessError._process_custom_annotations)r    r!   r"   r#   r$   r=   r?   r   r>   r@   r   r   r&   r   r   r   r   r<     s   
r<   c                       sN   e Zd ZdZddgZdZdddZejddd	Z	ed
Z
 fddZ  ZS )RateLimitErrora  
    Error occurred because the app is being rate limited.

    :ivar auth.RateLimitError.reason: The reason why the app is being rate
        limited.
    :ivar auth.RateLimitError.retry_after: The number of seconds that the app
        should wait before making another request.
    _reason_value_retry_after_valueTNc                 C   s0   t j| _t j| _|d k	r|| _|d k	r,|| _d S r   )bbNOT_SETrB   rC   reasonretry_after)r   rF   rG   r   r   r   __init__[  s    zRateLimitError.__init__rF   )Zuser_definedrG   c                    s   t t| ||| d S r   )r   rA   r   r   r   r   r   r   k  s    z*RateLimitError._process_custom_annotations)NN)r    r!   r"   r#   	__slots___has_required_fieldsrH   rD   	AttributerF   rG   r   r&   r   r   r   r   rA   J  s   
  

rA   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 )RateLimitReasona  
    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 auth.RateLimitReason.too_many_requests: You are making too many
        requests in the past few minutes.
    :ivar auth.RateLimitReason.too_many_write_operations: There are currently
        too many write operations happening in the user's Dropbox.
    r   Nc                 C   s
   | j dkS )zX
        Check if the union tag is ``too_many_requests``.

        :rtype: bool
        too_many_requestsr   r   r   r   r   is_too_many_requests  s    z$RateLimitReason.is_too_many_requestsc                 C   s
   | j dkS )z`
        Check if the union tag is ``too_many_write_operations``.

        :rtype: bool
        too_many_write_operationsr   r   r   r   r   is_too_many_write_operations  s    z,RateLimitReason.is_too_many_write_operationsc                 C   s
   | j dkS r   r   r   r   r   r   r     s    zRateLimitReason.is_otherc                    s   t t| ||| d S r   )r   rL   r   r   r   r   r   r     s    z+RateLimitReason._process_custom_annotations)r    r!   r"   r#   r$   rM   rO   r   rN   rP   r   r   r&   r   r   r   r   rL   p  s   rL   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 )TokenFromOAuth1Argz
    :ivar auth.TokenFromOAuth1Arg.oauth1_token: The supplied OAuth 1.0 access
        token.
    :ivar auth.TokenFromOAuth1Arg.oauth1_token_secret: The token secret
        associated with the supplied access token.
    _oauth1_token_value_oauth1_token_secret_valueTNc                 C   s0   t j| _t j| _|d k	r|| _|d k	r,|| _d S r   )rD   rE   rR   rS   oauth1_tokenoauth1_token_secret)r   rT   rU   r   r   r   rH     s    zTokenFromOAuth1Arg.__init__rT   rU   c                    s   t t| ||| d S r   )r   rQ   r   r   r   r   r   r     s    z.TokenFromOAuth1Arg._process_custom_annotations)NN)r    r!   r"   r#   rI   rJ   rH   rD   rK   rT   rU   r   r&   r   r   r   r   rQ     s     


rQ   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 )TokenFromOAuth1Errora  
    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 auth.TokenFromOAuth1Error.invalid_oauth1_token_info: Part or all of
        the OAuth 1.0 access token info is invalid.
    :ivar auth.TokenFromOAuth1Error.app_id_mismatch: The authorized app does not
        match the app associated with the supplied access token.
    r   Nc                 C   s
   | j dkS )z`
        Check if the union tag is ``invalid_oauth1_token_info``.

        :rtype: bool
        invalid_oauth1_token_infor   r   r   r   r   is_invalid_oauth1_token_info  s    z1TokenFromOAuth1Error.is_invalid_oauth1_token_infoc                 C   s
   | j dkS )zV
        Check if the union tag is ``app_id_mismatch``.

        :rtype: bool
        app_id_mismatchr   r   r   r   r   is_app_id_mismatch  s    z'TokenFromOAuth1Error.is_app_id_mismatchc                 C   s
   | j dkS r   r   r   r   r   r   r     s    zTokenFromOAuth1Error.is_otherc                    s   t t| ||| d S r   )r   rV   r   r   r   r   r   r     s    z0TokenFromOAuth1Error._process_custom_annotations)r    r!   r"   r#   r$   rW   rY   r   rX   rZ   r   r   r&   r   r   r   r   rV     s   rV   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 )TokenFromOAuth1Resultz
    :ivar auth.TokenFromOAuth1Result.oauth2_token: The OAuth 2.0 token generated
        from the supplied OAuth 1.0 token.
    _oauth2_token_valueTNc                 C   s   t j| _|d k	r|| _d S r   )rD   rE   r\   oauth2_token)r   r]   r   r   r   rH     s    zTokenFromOAuth1Result.__init__r]   c                    s   t t| ||| d S r   )r   r[   r   r   r   r   r   r     s    z1TokenFromOAuth1Result._process_custom_annotations)N)r    r!   r"   r#   rI   rJ   rH   rD   rK   r]   r   r&   r   r   r   r   r[     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 )TokenScopeErrorzd
    :ivar auth.TokenScopeError.required_scope: The required scope to access the
        route.
    _required_scope_valueTNc                 C   s   t j| _|d k	r|| _d S r   )rD   rE   r_   required_scope)r   r`   r   r   r   rH     s    zTokenScopeError.__init__r`   c                    s   t t| ||| d S r   )r   r^   r   r   r   r   r   r   %  s    z+TokenScopeError._process_custom_annotations)N)r    r!   r"   r#   rI   rJ   rH   rD   rK   r`   r   r&   r   r   r   r   r^     s    

r^   )r   r   r   r   )r)   r+   r-   r/   r1   r(   r4   r   r)   r+   r-   r/   r1   r4   )r8   r:   r   r8   r:   )r=   r?   r   r=   r?   rF   rG   )rM   rO   r   rM   rO      )Z
min_lengthrT   rU   )rW   rY   r   rW   rY   r]   r`   token/from_oauth1TZappapiZrpc)authhoststyletoken/revokeFuser)rb   rg   N)Q
__future__r   Zstone.backends.python_rsrcr   rD   r   ZbvUnionr   ZAccessError_validatorr'   ZAuthError_validatorr7   Z!InvalidAccountTypeError_validatorr<   ZPaperAccessError_validatorStructrA   ZRateLimitError_validatorrL   ZRateLimitReason_validatorrQ   ZTokenFromOAuth1Arg_validatorrV   ZTokenFromOAuth1Error_validatorr[   ZTokenFromOAuth1Result_validatorr^   ZTokenScopeError_validatorZ_invalid_account_type_validatorZ_paper_access_denied_validatorZVoidZ_other_validatorZ_tagmapr   Z_invalid_access_token_validatorZ_invalid_select_user_validatorZ_invalid_select_admin_validatorZ_user_suspended_validatorZ_expired_access_token_validatorZ_missing_scope_validatorZ_route_access_denied_validatorr)   r+   r-   r/   r1   r4   Z_endpoint_validatorZ_feature_validatorr8   r:   Z_paper_disabled_validatorZ_not_paper_user_validatorr=   r?   rF   Z	validatorZUInt64rG   setZ_all_field_names_Z_all_fields_Z_too_many_requests_validatorZ$_too_many_write_operations_validatorrM   rO   StringrT   rU   Z$_invalid_oauth1_token_info_validatorZ_app_id_mismatch_validatorrW   rY   r]   r`   defaultZRouteZtoken_from_oauth1Ztoken_revokeZROUTESr   r   r   r   <module>   s$  \

/
.
$
/
"
/














































