U
    W+d                     @   s$   d Z ddlmZ G dd deZdS )z%
Represents a Virtual Private Cloud.
    )TaggedEC2Objectc                       s   e Zd Zd fdd	Zdd Zdd Zdd	 Zd
d ZdddZdddZ	dddZ
dddZd ddZd!ddZd"ddZ  ZS )#VPCNc                    s>   t t| | d| _d| _d| _d| _d| _d| _d| _	dS )ah  
        Represents a VPC.

        :ivar id: The unique ID of the VPC.
        :ivar dhcp_options_id: The ID of the set of DHCP options you've associated with the VPC
                                (or default if the default options are associated with the VPC).
        :ivar state: The current state of the VPC.
        :ivar cidr_block: The CIDR block for the VPC.
        :ivar is_default: Indicates whether the VPC is the default VPC.
        :ivar instance_tenancy: The allowed tenancy of instances launched into the VPC.
        :ivar classic_link_enabled: Indicates whether ClassicLink is enabled.
        N)
superr   __init__iddhcp_options_idstate
cidr_block
is_defaultinstance_tenancyclassic_link_enabled)self
connection	__class__ 0/tmp/pip-unpacked-wheel-dlxw5sjy/boto/vpc/vpc.pyr      s    zVPC.__init__c                 C   s
   d| j  S )NzVPC:%s)r   r   r   r   r   __repr__4   s    zVPC.__repr__c                 C   s   |dkr|| _ nx|dkr || _nh|dkr0|| _nX|dkr@|| _nH|dkr\|dkrTdnd| _n,|d	krl|| _n|d
kr||| _nt| || d S )NZvpcIdZdhcpOptionsIdr   Z	cidrBlockZ	isDefaulttrueTFZinstanceTenancyZclassicLinkEnabled)r   r   r   r	   r
   r   r   setattr)r   namevaluer   r   r   r   
endElement7   s    zVPC.endElementc                 C   s   | j | jS N)r   Z
delete_vpcr   r   r   r   r   deleteI   s    z
VPC.deletec                 C   s   | j |j  d S r   )__dict__update)r   updatedr   r   r   _updateL   s    zVPC._updateFc                 C   sD   || j g|d}t|r,|d }| | n|r@td| j f d S )Ndry_runr   z%s is not a valid VPC ID)r   lenr   
ValueError)r   Zget_status_methodvalidater!   Zvpc_listZupdated_vpcr   r   r   _get_status_then_update_vpcO   s    zVPC._get_status_then_update_vpcc                 C   s   | j | jj||d | jS )Nr$   r!   )r%   r   Zget_all_vpcsr   r   r$   r!   r   r   r   r   [   s    z
VPC.updatec                 C   s   | j | jj||d | jS )z
        Updates instance's classic_link_enabled attribute

        :rtype: bool
        :return: self.classic_link_enabled after update has occurred.
        r&   )r%   r   Zget_all_classic_link_vpcsr   r'   r   r   r   update_classic_link_enabledc   s    zVPC.update_classic_link_enabledc                 C   s   | j j| j|dS )a7  
        Disables  ClassicLink  for  a VPC. You cannot disable ClassicLink for a
        VPC that has EC2-Classic instances linked to it.

        :type dry_run: bool
        :param dry_run: Set to True if the operation should not actually run.

        :rtype: bool
        :return: True if successful
        r    )r   Zdisable_vpc_classic_linkr   r   r!   r   r   r   disable_classic_linkq   s    
zVPC.disable_classic_linkc                 C   s   | j j| j|dS )aj  
        Enables a VPC for ClassicLink. You can then link EC2-Classic instances
        to your ClassicLink-enabled VPC to allow communication over private IP
        addresses. You cannot enable your VPC for ClassicLink if any of your
        VPC's route tables have existing routes for address ranges within the
        10.0.0.0/8 IP address range, excluding local routes for VPCs in the
        10.0.0.0/16 and 10.1.0.0/16 IP address ranges.

        :type dry_run: bool
        :param dry_run: Set to True if the operation should not actually run.

        :rtype: bool
        :return: True if successful
        r    )r   Zenable_vpc_classic_linkr   r)   r   r   r   enable_classic_link   s    
zVPC.enable_classic_linkc                 C   s   | j j| j|||dS )aC  
        Links  an EC2-Classic instance to a ClassicLink-enabled VPC through one
        or more of the VPC's security groups. You cannot link an EC2-Classic
        instance to more than one VPC at a time. You can only link an instance
        that's in the running state. An instance is automatically unlinked from
        a VPC when it's stopped. You can link it to the VPC again when you
        restart it.

        After you've linked an instance, you cannot  change  the VPC security
        groups  that are associated with it. To change the security groups, you
        must first unlink the instance, and then link it again.

        Linking your instance to a VPC is sometimes referred  to  as  attaching
        your instance.

        :type intance_id: str
        :param instance_is: The ID of a ClassicLink-enabled VPC.

        :tye groups: list
        :param groups: The ID of one or more of the VPC's security groups.
            You cannot specify security groups from a different VPC. The
            members of the list can be
            :class:`boto.ec2.securitygroup.SecurityGroup` objects or
            strings of the id's of the security groups.

        :type dry_run: bool
        :param dry_run: Set to True if the operation should not actually run.

        :rtype: bool
        :return: True if successful
        )vpc_idinstance_idgroupsr!   )r   Zattach_classic_link_vpcr   )r   r-   r.   r!   r   r   r   attach_classic_instance   s     zVPC.attach_classic_instancec                 C   s   | j j| j||dS )a  
        Unlinks a linked EC2-Classic instance from a VPC. After the instance
        has been unlinked, the VPC security groups are no longer associated
        with it. An instance is automatically unlinked from a VPC when
        it's stopped.

        :type intance_id: str
        :param instance_is: The ID of the VPC to which the instance is linked.

        :type dry_run: bool
        :param dry_run: Set to True if the operation should not actually run.

        :rtype: bool
        :return: True if successful
        )r,   r-   r!   )r   Zdetach_classic_link_vpcr   )r   r-   r!   r   r   r   detach_classic_instance   s
    zVPC.detach_classic_instance)N)FF)FF)FF)F)F)F)F)__name__
__module____qualname__r   r   r   r   r   r%   r   r(   r*   r+   r/   r0   __classcell__r   r   r   r   r      s     





'r   N)__doc__Zboto.ec2.ec2objectr   r   r   r   r   r   <module>   s   