U
    W+d                     @   s,   d dl mZ d dlmZ G dd deZdS )    )Layer1)Vaultc                   @   s8   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d ZdS )Layer2zT
    Provides a more pythonic and friendly interface to Glacier based on Layer1
    c                 O   s$   d|kr|d | _ nt||| _ d S )Nlayer1)r   r   )selfargskwargs r	   7/tmp/pip-unpacked-wheel-dlxw5sjy/boto/glacier/layer2.py__init__!   s    zLayer2.__init__c                 C   s   | j | | |S )zCreates a vault.

        :type name: str
        :param name: The name of the vault

        :rtype: :class:`boto.glacier.vault.Vault`
        :return: A Vault object representing the vault.
        )r   create_vault	get_vaultr   namer	   r	   r
   r   (   s    	zLayer2.create_vaultc                 C   s   | j |S )a  Delete a vault.

        This operation deletes a vault. Amazon Glacier will delete a
        vault only if there are no archives in the vault as per the
        last inventory and there have been no writes to the vault
        since the last inventory. If either of these conditions is not
        satisfied, the vault deletion fails (that is, the vault is not
        removed) and Amazon Glacier returns an error.

        This operation is idempotent, you can send the same request
        multiple times and it has no further effect after the first
        time Amazon Glacier delete the specified vault.

        :type vault_name: str
        :param vault_name: The name of the vault to delete.
        )r   delete_vaultr   r	   r	   r
   r   4   s    zLayer2.delete_vaultc                 C   s   | j |}t| j |S )a;  
        Get an object representing a named vault from Glacier. This
        operation does not check if the vault actually exists.

        :type name: str
        :param name: The name of the vault

        :rtype: :class:`boto.glacier.vault.Vault`
        :return: A Vault object representing the vault.
        )r   Zdescribe_vaultr   )r   r   response_datar	   r	   r
   r   G   s    zLayer2.get_vaultc                    sJ   g }d} j j|dd}| fdd|d D  |d}|sqFq|S )z
        Return a list of all vaults associated with the account ID.

        :rtype: List of :class:`boto.glacier.vault.Vault`
        :return: A list of Vault objects.
        Ni  )markerlimitc                    s   g | ]}t  j|qS r	   )r   r   ).0rdr   r	   r
   
<listcomp>`   s     z&Layer2.list_vaults.<locals>.<listcomp>Z	VaultListMarker)r   list_vaultsextendget)r   Zvaultsr   r   r	   r   r
   r   U   s    
zLayer2.list_vaultsN)	__name__
__module____qualname____doc__r   r   r   r   r   r	   r	   r	   r
   r      s   r   N)Zboto.glacier.layer1r   Zboto.glacier.vaultr   objectr   r	   r	   r	   r
   <module>   s   