U
    d/e                     @   sV   d Z ddlmZ ddlmZmZmZ ddlmZm	Z	m
Z
mZ dZdZG dd	 d	Zd
S )zU
Request/response of PutObjectLockConfiguration and GetObjectLockConfiguration
APIs.
    )absolute_import   )
COMPLIANCEENABLED
GOVERNANCE)Element
SubElementfindfindtextZDaysZYearsc                   @   sD   e Zd ZdZdd Zedd Zedd Zedd	 Z	d
d Z
dS )ObjectLockConfigzObject lock configuration.c                 C   s   |d k	|d k	A r(|d kr t dt d|d k	rP|ttfkrPt dt dt |r\| }|d k	r|ttfkrt dt dt || _|| _|| _d S )Nzmode must be providedzduration must be providedzmode must be z or zduration unit must be )	
ValueErrorr   r   titleDAYSYEARS_mode	_duration_duration_unit)selfmodedurationduration_unit r   :/tmp/pip-unpacked-wheel-xery97c7/minio/objectlockconfig.py__init__"   s    zObjectLockConfig.__init__c                 C   s   | j S )z	Get mode.)r   r   r   r   r   r   1   s    zObjectLockConfig.modec                 C   s   | j | jfS )zGet duration and it's unit.)r   r   r   r   r   r   r   6   s    zObjectLockConfig.durationc                 C   sf   t |d}|dkr| dddS t |d}t|d}t}t||}|sRt}t||}t|}| |||S )z/Create new object with values from XML element.RuleNDefaultRetentionMode)r	   r
   r   r   int)clselementr   r   r   r   r   r   fromxml;   s    




zObjectLockConfig.fromxmlc                 C   sT   t d}t|dt | jrPt|d}t|d}t|d| j t|| jt| j |S )zConvert to XML.ZObjectLockConfigurationZObjectLockEnabledr   r   r   )r   r   r   r   r   strr   )r   r    ZruleZ	retentionr   r   r   toxmlK   s    

zObjectLockConfig.toxmlN)__name__
__module____qualname____doc__r   propertyr   r   classmethodr!   r#   r   r   r   r   r      s   


r   N)r'   
__future__r   Zcommonconfigr   r   r   xmlr   r   r	   r
   r   r   r   r   r   r   r   <module>   s   