B
    `                 @   s   d dl mZ d dlmZmZ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G dd deZdS )    )UnexpectedResponseError)BaseDerivedBasePropertyRegionc               @   s,   e Zd ZdZdZeddeedddZdS )IPv6Poolz/networking/ipv6/pools/{}rangeT)
identifier)slug_relationship
filterable)r   regionN)__name__
__module____qualname__api_endpointid_attributer   r   
properties r   r   M/home/dcms/DCMS/lib/python3.7/site-packages/linode_api4/objects/networking.pyr      s   r   c               @   s,   e Zd ZdZdZeddeedddZdS )	IPv6Rangez/networking/ipv6/ranges/{}r   T)r	   )r
   r   )r   r   N)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edde e e e e edde eeddd	Zedd	 Z	d
d Z
dS )	IPAddressz/networking/ips/{address}addressT)r	   )mutable)r
   r   )	r   ZgatewayZsubnet_maskprefixtypepublicZrdns	linode_idr   c             C   s2   ddl m} t| ds,| d|| j| j | jS )N   )Instance_linode)linoder   hasattrZ_set_clientr   r   )selfr   r   r   r   r    )   s    
zIPAddress.linodec             C   s,   ddl m} t||std| j|jdS )z
        This is a helper method for ip-assign, and should not be used outside
        of that context.  It's used to cleanly build an IP Assign request with
        pretty python syntax.
        r   )r   z,IP Address can only be assigned to a Linode!)r   r   )r    r   
isinstance
ValueErrorr   id)r#   r    r   r   r   r   to0   s    
zIPAddress.toN)r   r   r   r   r   r   r   r   propertyr    r'   r   r   r   r   r      s   r   c               @   s@   e Zd ZdZdZdZeddeddeddeeddd	Zd
S )VLANz
    .. note:: At this time, the Linode API only supports listing VLANs.
    .. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
    z/networking/vlans/{}labelT)r	   )is_datetime)r   )r
   r   )r*   createdZlinodesr   N)	r   r   r   __doc__r   r   r   r   r   r   r   r   r   r)   =   s   r)   c               @   s>   e Zd ZdZdZdZedddeddde edddZdS )	FirewallDevicez0/networking/firewalls/{firewall_id}/devices/{id}devicesZfirewall_idT)r   r+   )r	   )r,   updatedentityr&   N)r   r   r   r   Zderived_url_pathZparent_id_namer   r   r   r   r   r   r.   M   s   

r.   c            	   @   sp   e Zd ZdZdZeddedddedddeddedddedddeede d	Zd
d ZdddZ	dS )Firewallz|
    .. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.
    z/networking/firewalls/{id}T)r	   )r   r   )r   )r   r+   )Zderived_class)r&   r*   tagsstatusr,   r0   r/   rulesc             C   s&   | j jd| j| |d |   dS )z7
        Sets the JSON rules for this Firewall
        z{}/rules)modeldataN)r"   putformatr   
invalidate)r#   r5   r   r   r   update_rulesk   s    zFirewall.update_rulesr    c             K   sd   ||d}| | | jjdtj| |d}|   d|krJtd|dt| j|d | j	|}|S )a  
        Creates and attaches a device to this Firewall

        :param id: The ID of the entity to create a device for.
        :type id: int

        :param type: The type of entity the device is being created for. (`linode`)
        :type type: str
        )r&   r   z
{}/devices)r6   r7   r&   z$Unexpected response creating device!)json)
updater"   postr9   r2   r   r:   r   r.   r&   )r#   r&   r   kwargsparamsresultcr   r   r   device_creater   s    
zFirewall.device_createN)r    )
r   r   r   r-   r   r   r.   r   r;   rC   r   r   r   r   r2   Z   s   




r2   N)Zlinode_api4.errorsr   Zlinode_api4.objectsr   r   r   r   r   r   r   r)   r.   r2   r   r   r   r   <module>   s   

$