
?F[c           @   sV   d  Z  d d l m Z d d l m Z d e f d     YZ d e f d     YZ d S(	   s0   
Represents an EC2 Elastic Block Store Snapshot
i(   t   TaggedEC2Object(   t   Zonet   Snapshotc           B   s   e  Z d  Z d Z d d  Z d   Z d   Z d   Z e	 e	 d  Z
 e	 d  Z e	 d  Z d d e	 d	  Z d d e	 d
  Z e	 d  Z d d d e	 d  Z RS(   s  
    Represents an EBS snapshot.
    :ivar id: The unique ID of the snapshot.
    :ivar volume_id: The ID of the volume this snapshot was created
    from.
    :ivar status: The status of the snapshot.
    :ivar progress: The percent complete of the snapshot.
    :ivar start_time: The timestamp of when the snapshot was created.
    :ivar owner_id: The id of the account that owns the snapshot.
    :ivar owner_alias: The alias of the account that owns the snapshot.
    :ivar volume_size: The size (in GB) of the volume the snapshot was created from.
    :ivar description: The description of the snapshot.
    :ivar encrypted: True if this snapshot is encrypted
    t   createVolumePermissionc         C   st   t  t |   j |  d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _	 d  |  _
 d  |  _ d  |  _ d  |  _ d  S(   N(   t   superR   t   __init__t   Nonet   idt	   volume_idt   statust   progresst
   start_timet   owner_idt   owner_aliast   volume_sizet   descriptiont	   encrypted(   t   selft
   connection(    (    s0   lib/python2.7/site-packages/boto/ec2/snapshot.pyR   0   s    									c         C   s   d |  j  S(   Ns   Snapshot:%s(   R   (   R   (    (    s0   lib/python2.7/site-packages/boto/ec2/snapshot.pyt   __repr__=   s    c         C   s  | d k r | |  _  n | d k r0 | |  _ n | d k rH | |  _ n | d k r` | |  _ n | d k rx | |  _ n | d k r | |  _ n | d k r y t |  |  _ Wq| |  _ qXnL | d k r | |  _ n4 | d	 k r| j	   d
 k |  _
 n t |  | |  d  S(   Nt
   snapshotIdt   volumeIdR	   t	   startTimet   ownerIdt
   ownerAliast
   volumeSizeR   R   t   true(   R   R   R	   R   R   R   t   intR   R   t   lowerR   t   setattr(   R   t   namet   valueR   (    (    s0   lib/python2.7/site-packages/boto/ec2/snapshot.pyt
   endElement@   s,    c         C   s   | j  |  _  | j |  _ d  S(   N(   R
   R	   (   R   t   updated(    (    s0   lib/python2.7/site-packages/boto/ec2/snapshot.pyt   _updateY   s    c         C   sg   |  j  j |  j g d | } t |  d k rD |  j | d  n | r` t d |  j   n  |  j S(   s  
        Update the data associated with this snapshot by querying EC2.

        :type validate: bool
        :param validate: By default, if EC2 returns no data about the
                         snapshot the update method returns quietly.  If
                         the validate param is True, however, it will
                         raise a ValueError exception if no data is
                         returned from EC2.
        t   dry_runi    s   %s is not a valid Snapshot ID(   R   t   get_all_snapshotsR   t   lenR"   t
   ValueErrorR
   (   R   t   validateR#   t   rs(    (    s0   lib/python2.7/site-packages/boto/ec2/snapshot.pyt   update]   s    c         C   s   |  j  j |  j d | S(   NR#   (   R   t   delete_snapshotR   (   R   R#   (    (    s0   lib/python2.7/site-packages/boto/ec2/snapshot.pyt   deleteo   s    c         C   s(   |  j  j |  j |  j d | } | j S(   NR#   (   R   t   get_snapshot_attributeR   t   AttrNamet   attrs(   R   R#   R.   (    (    s0   lib/python2.7/site-packages/boto/ec2/snapshot.pyt   get_permissionsr   s
    			c         C   s(   |  j  j |  j |  j d | | d | S(   Nt   addR#   (   R   t   modify_snapshot_attributeR   R-   (   R   t   user_idst   groupsR#   (    (    s0   lib/python2.7/site-packages/boto/ec2/snapshot.pyt   sharez   s    c         C   s(   |  j  j |  j |  j d | | d | S(   Nt   removeR#   (   R   R1   R   R-   (   R   R2   R3   R#   (    (    s0   lib/python2.7/site-packages/boto/ec2/snapshot.pyt   unshare   s    c         C   s   |  j  j |  j |  j d | S(   NR#   (   R   t   reset_snapshot_attributeR   R-   (   R   R#   (    (    s0   lib/python2.7/site-packages/boto/ec2/snapshot.pyt   reset_permissions   s    		c      	   C   sF   t  | t  r | j } n  |  j j | | |  j | | |  j d | S(   sq  
        Create a new EBS Volume from this Snapshot

        :type zone: string or :class:`boto.ec2.zone.Zone`
        :param zone: The availability zone in which the Volume will be created.

        :type size: int
        :param size: The size of the new volume, in GiB. (optional). Defaults to
            the size of the snapshot.

        :type volume_type: string
        :param volume_type: The type of the volume. (optional).  Valid
            values are: standard | io1 | gp2.

        :type iops: int
        :param iops: The provisioned IOPs you want to associate with
            this volume. (optional)
        R#   (   t
   isinstanceR   R   R   t   create_volumeR   R   (   R   t   zonet   sizet   volume_typet   iopsR#   (    (    s0   lib/python2.7/site-packages/boto/ec2/snapshot.pyR:      s    		N(   t   __name__t
   __module__t   __doc__R-   R   R   R   R    R"   t   FalseR)   R+   R/   R4   R6   R8   R:   (    (    (    s0   lib/python2.7/site-packages/boto/ec2/snapshot.pyR      s   				t   SnapshotAttributec           B   s&   e  Z d d   Z d   Z d   Z RS(   c         C   s   d  |  _ i  |  _ d  S(   N(   R   t   snapshot_idR.   (   R   t   parent(    (    s0   lib/python2.7/site-packages/boto/ec2/snapshot.pyR      s    	c         C   s   d  S(   N(   R   (   R   R   R.   R   (    (    s0   lib/python2.7/site-packages/boto/ec2/snapshot.pyt   startElement   s    c         C   s   | d k r d |  _  n | d k r] d |  j k rJ |  j d j |  q | g |  j d <nm | d k r d |  j k r |  j d j |  q | g |  j d <n( | d k r | |  _ n t |  | |  d  S(   NR   t   create_volume_permissiont   groupR3   t   userIdR2   R   (   R   R.   t   appendRD   R   (   R   R   R   R   (    (    s0   lib/python2.7/site-packages/boto/ec2/snapshot.pyR       s    N(   R?   R@   R   R   RF   R    (    (    (    s0   lib/python2.7/site-packages/boto/ec2/snapshot.pyRC      s   	N(   RA   t   boto.ec2.ec2objectR    t   boto.ec2.zoneR   R   t   objectRC   (    (    (    s0   lib/python2.7/site-packages/boto/ec2/snapshot.pyt   <module>   s   