B
    `                 @   s8   d dl mZ d dlmZmZmZmZ G dd deZdS )    )UnexpectedResponseError)BaseInstancePropertyRegionc               @   s   e Zd ZdZeddeddeddeededddeddeddeededd	d
	ZdddZdd Z	dd Z
dd ZdS )Volumez/volumes/{id}T)
identifier)Zis_datetime)Zid_relationship)mutable
filterable)r
   )Zslug_relationship)r	   )	idcreatedupdated	linode_idlabelsizestatusZregiontagsNc             C   sr   | j jdtj| tt|tr&|jn||s0dntt|trD|jn|dd}d|krdt	d|d| 
| dS )	z:
        Attaches this Volume to the given Linode
        z	{}/attachN)r   config)modeldatar   z*Unexpected response when attaching volume!)jsonT)_clientpostformatr   api_endpoint
issubclasstyper   r   r   	_populate)selfZ	to_linoder   result r    I/home/dcms/DCMS/lib/python3.7/site-packages/linode_api4/objects/volume.pyattach   s    (
zVolume.attachc             C   s   | j jdtj| d dS )z8
        Detaches this Volume if it is attached
        z	{}/detach)r   T)r   r   r   r   r   )r   r    r    r!   detach$   s    zVolume.detachc             C   s,   | j jdtj| d|id}| | dS )z%
        Resizes this Volume
        z	{}/resizer   )r   r   T)r   r   r   r   r   r   )r   r   r   r    r    r!   resize,   s    
zVolume.resizec             C   s@   | j jdtj| d|id}d|kr.tdt| j |d |S )z
        Clones this volume to a new volume in the same region with the given label

        :param label: The label for the new volume.

        :returns: The new volume object.
        z{}/cloner   )r   r   r   z#Unexpected response cloning volume!)r   r   r   r   r   r   )r   r   r   r    r    r!   clone7   s
    zVolume.clone)N)__name__
__module____qualname__r   r   r   r   Z
propertiesr"   r#   r$   r%   r    r    r    r!   r      s   

r   N)Zlinode_api4.errorsr   Zlinode_api4.objectsr   r   r   r   r   r    r    r    r!   <module>   s   