B
    `z                 @   sp   d dl mZ d dlmZmZ G dd deZG dd deZG dd deZG d	d
 d
eZG dd deZ	dS )    )UnexpectedResponseError)BasePropertyc               @   s>   e Zd ZdZedde e eddedde e dZdS )AuthorizedAppz/profile/apps/{id}T)
identifier)is_datetime)idscopeslabelcreatedexpiryZthumbnail_urlZwebsiteN)__name__
__module____qualname__api_endpointr   
properties r   r   J/home/dcms/DCMS/lib/python3.7/site-packages/linode_api4/objects/profile.pyr      s   r   c               @   s>   e Zd ZdZedde eddedde edddZdS )PersonalAccessTokenz/profile/tokens/{id}T)r   )mutable)r   )r   r	   r
   r   tokenr   N)r   r   r   r   r   r   r   r   r   r   r      s   r   c               @   s*   e Zd ZdZedde e e dZdS )WhitelistEntryz/profile/whitelist/{id}T)r   )r   addressnetmasknoteN)r   r   r   r   r   r   r   r   r   r   r       s
   r   c               @   s   e Zd ZdZdZedde eddeddedde eddeddedde e dZdd Zd	d
 Zdd Z	e
dd Ze
dd ZdddZdS )Profilez/profileusernameT)r   )r   )r   uidemailtimezoneZemail_notificationsZ	referralsZip_whitelist_enabledZlish_auth_methodZauthorized_keysZtwo_factor_authZ
restrictedc             C   s   | j d}|d S )z
        Enables TFA for the token's user.  This requies a follow-up request
        to confirm TFA.  Returns the TFA secret that needs to be confirmed.
        z/profile/tfa-enablesecret)_clientpost)selfresultr   r   r   
enable_tfa=   s    zProfile.enable_tfac             C   s   | j jdd|id dS )zX
        Confirms TFA for an account.  Needs a TFA code generated by enable_tfa
        z/profile/tfa-enable-confirmZtfa_code)dataT)r!   r"   )r#   coder   r   r   confirm_tfaF   s    zProfile.confirm_tfac             C   s   | j d dS )z8
        Turns off TFA for this user's account.
        z/profile/tfa-disableT)r!   r"   )r#   r   r   r   disable_tfaP   s    zProfile.disable_tfac             C   s8   ddl m} | jd}d}|dk	r4|| j| j|}|S )z5
        Returns grants for the current user
        r   )
UserGrantsz/profile/grantsN)Zlinode_api4.objects.accountr*   r!   getr   )r#   r*   respgrantsr   r   r   r-   X   s    zProfile.grantsc             C   s   | j tS )zO
        Returns the user's whitelist entries, if whitelist is enabled
        )r!   Z_get_and_filterr   )r#   r   r   r   	whitelistg   s    zProfile.whitelistNc             C   sD   | j jdtj|||dd}d|kr0tdt|d | j |dS )zJ
        Adds a new entry to this user's IP whitelist, if enabled
        z{}/whitelist)r   r   r   )r&   r   z-Unexpected response creating whitelist entry!)json)r!   r"   formatr   r   r   r   )r#   r   r   r   r$   r   r   r   add_whitelist_entryn   s    zProfile.add_whitelist_entry)N)r   r   r   r   Zid_attributer   r   r%   r(   r)   propertyr-   r.   r1   r   r   r   r   r   +   s&   
	
r   c               @   s6   e Zd ZdZdZeddedde edddZdS )	SSHKeyz\
    An SSH Public Key uploaded to your profile for use in Linode Instance deployments.
    z/profile/sshkeys/{id}T)r   )r   )r   )r   r
   Zssh_keyr   N)r   r   r   __doc__r   r   r   r   r   r   r   r3      s   r3   N)
Zlinode_api4.errorsr   Zlinode_api4.objectsr   r   r   r   r   r   r3   r   r   r   r   <module>   s   T