B
    ?F[*                 @   sp   d dl Z d dlmZ d dlmZ d dlmZ G dd deZG dd deZG d	d
 d
eZ	G dd deZ
dS )    N)datetime)	ResultSet)TaggedEC2Objectc               @   s2   e Zd ZdZdddZdd Zdd Zd	d
 ZdS )VpnConnectionOptionsz
    Represents VPN connection options

    :ivar static_routes_only: Indicates whether the VPN connection uses static
        routes only.  Static routes must be used for devices that don't support
        BGP.

    Nc             C   s
   || _ d S )N)static_routes_only)selfr    r   5lib/python3.7/site-packages/boto/vpc/vpnconnection.py__init__(   s    zVpnConnectionOptions.__init__c             C   s   dS )Nr   r   )r   r   r   r	   __repr__+   s    zVpnConnectionOptions.__repr__c             C   s   d S )Nr   )r   nameattrs
connectionr   r   r	   startElement.   s    z!VpnConnectionOptions.startElementc             C   s,   |dkr|dkrdnd| _ nt| || d S )NZstaticRoutesOnlytrueTF)r   setattr)r   r   valuer   r   r   r	   
endElement1   s    zVpnConnectionOptions.endElement)N)__name__
__module____qualname____doc__r
   r   r   r   r   r   r   r	   r      s
   
r   c               @   s2   e Zd ZdZdddZdd Zdd Zd	d
 ZdS )VpnStaticRoutea#  
    Represents a static route for a VPN connection.

    :ivar destination_cidr_block: The CIDR block associated with the local
        subnet of the customer data center.
    :ivar source: Indicates how the routes were provided.
    :ivar state: The current state of the static route.
    Nc             C   s   || _ || _|| _d S )N)destination_cidr_blocksourceZ	available)r   r   r   stater   r   r	   r
   @   s    zVpnStaticRoute.__init__c             C   s
   d| j  S )NzVpnStaticRoute: %s)r   )r   r   r   r	   r   E   s    zVpnStaticRoute.__repr__c             C   s   d S )Nr   )r   r   r   r   r   r   r	   r   H   s    zVpnStaticRoute.startElementc             C   s@   |dkr|| _ n,|dkr || _n|dkr0|| _nt| || d S )NZdestinationCidrBlockr   r   )r   r   r   r   )r   r   r   r   r   r   r	   r   K   s    zVpnStaticRoute.endElement)NNN)r   r   r   r   r
   r   r   r   r   r   r   r	   r   7   s
   
r   c               @   s2   e Zd ZdZdddZdd Zdd Zd	d
 ZdS )	VpnTunnela  
    Represents telemetry for a VPN tunnel

    :ivar outside_ip_address: The Internet-routable IP address of the
        virtual private gateway's outside interface.
    :ivar status: The status of the VPN tunnel. Valid values: UP | DOWN
    :ivar last_status_change: The date and time of the last change in status.
    :ivar status_message: If an error occurs, a description of the error.
    :ivar accepted_route_count: The number of accepted routes.
    Nc             C   s"   || _ || _|| _|| _|| _d S )N)outside_ip_addressstatuslast_status_changestatus_messageaccepted_route_count)r   r   r   r   r    r!   r   r   r	   r
   `   s
    zVpnTunnel.__init__c             C   s
   d| j  S )NzVpnTunnel: %s)r   )r   r   r   r	   r   h   s    zVpnTunnel.__repr__c             C   s   d S )Nr   )r   r   r   r   r   r   r	   r   k   s    zVpnTunnel.startElementc             C   s   |dkr|| _ n|dkr || _nv|dkr8t|d| _n^|dkrH|| _nN|dkryt|}W n$ tk
r   tj	
d|  Y nX || _nt| || d S )NZoutsideIpAddressr   ZlastStatusChangez%Y-%m-%dT%H:%M:%S.%fZZstatusMessageZacceptedRouteCountz!Error converting code (%s) to int)r   r   r   Zstrptimer   r    int
ValueErrorbotologZwarningr!   r   )r   r   r   r   r   r   r	   r   n   s     
zVpnTunnel.endElement)NNNNN)r   r   r   r   r
   r   r   r   r   r   r   r	   r   U   s   
 
r   c                   sH   e Zd ZdZd fdd	Zdd Z fddZd	d
 ZdddZ  Z	S )VpnConnectionaq  
    Represents a VPN Connection

    :ivar id: The ID of the VPN connection.
    :ivar state: The current state of the VPN connection.
        Valid values: pending | available | deleting | deleted
    :ivar customer_gateway_configuration: The configuration information for the
        VPN connection's customer gateway (in the native XML format). This
        element is always present in the
        :class:`boto.vpc.VPCConnection.create_vpn_connection` response;
        however, it's present in the
        :class:`boto.vpc.VPCConnection.get_all_vpn_connections` response only
        if the VPN connection is in the pending or available state.
    :ivar type: The type of VPN connection (ipsec.1).
    :ivar customer_gateway_id: The ID of the customer gateway at your end of
        the VPN connection.
    :ivar vpn_gateway_id: The ID of the virtual private gateway
        at the AWS side of the VPN connection.
    :ivar tunnels: A list of the vpn tunnels (always 2)
    :ivar options: The option set describing the VPN connection.
    :ivar static_routes: A list of static routes associated with a VPN
        connection.

    Nc                sJ   t t| | d | _d | _d | _d | _d | _d | _g | _	d | _
g | _d S )N)superr&   r
   idr   customer_gateway_configurationtypecustomer_gateway_idvpn_gateway_idtunnelsoptionsstatic_routes)r   r   )	__class__r   r	   r
      s    zVpnConnection.__init__c             C   s
   d| j  S )NzVpnConnection:%s)r(   )r   r   r   r	   r      s    zVpnConnection.__repr__c                sv   t t| |||}|d k	r |S |dkr>tdtfg| _| jS |dkr\tdtfg| _| jS |dkrrt | _	| j	S d S )NZvgwTelemetryitemZroutesr.   )
r'   r&   r   r   r   r-   r   r/   r   r.   )r   r   r   r   Zretval)r0   r   r	   r      s    zVpnConnection.startElementc             C   sp   |dkr|| _ n\|dkr || _nL|dkr0|| _n<|dkr@|| _n,|dkrP|| _n|dkr`|| _nt| || d S )NZvpnConnectionIdr   ZcustomerGatewayConfigurationr*   ZcustomerGatewayIdZvpnGatewayId)r(   r   r)   r*   r+   r,   r   )r   r   r   r   r   r   r	   r      s    zVpnConnection.endElementFc             C   s   | j j| j|dS )N)dry_run)r   Zdelete_vpn_connectionr(   )r   r2   r   r   r	   delete   s    zVpnConnection.delete)N)F)
r   r   r   r   r
   r   r   r   r3   __classcell__r   r   )r0   r	   r&      s   r&   )r$   r   Zboto.resultsetr   Zboto.ec2.ec2objectr   objectr   r   r   r&   r   r   r   r	   <module>   s   ,