U
    W+d(\                     @   sX   d dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 G dd deZdS )	    N)AWSQueryConnection)
RegionInfo)JSONResponseError)
exceptions)jsonc                       s   e Zd ZdZdZdZdZdZdZe	Z
ejejdZ fdd	Zd
d Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! Zd"d# Zd$d% Zd5d'd(Zd)d* Zd6d+d,Z d-d. Z!d/d0 Z"d7d1d2Z#d3d4 Z$  Z%S )8DirectConnectConnectiona  
    AWS Direct Connect makes it easy to establish a dedicated network
    connection from your premises to Amazon Web Services (AWS). Using
    AWS Direct Connect, you can establish private connectivity between
    AWS and your data center, office, or colocation environment, which
    in many cases can reduce your network costs, increase bandwidth
    throughput, and provide a more consistent network experience than
    Internet-based connections.

    The AWS Direct Connect API Reference provides descriptions,
    syntax, and usage examples for each of the actions and data types
    for AWS Direct Connect. Use the following links to get started
    using the AWS Direct Connect API Reference :


    + `Actions`_: An alphabetical list of all AWS Direct Connect
      actions.
    + `Data Types`_: An alphabetical list of all AWS Direct Connect
      data types.
    + `Common Query Parameters`_: Parameters that all Query actions
      can use.
    + `Common Errors`_: Client and server errors that all actions can
      return.
    z
2012-10-25z	us-east-1z%directconnect.us-east-1.amazonaws.comZDirectConnectZOvertureService)DirectConnectClientExceptionDirectConnectServerExceptionc                    sN   | dd }|s t| | j| j}d|kr2|j|d< tt| jf | || _d S )Nregionhost)	popr   DefaultRegionNameDefaultRegionEndpointendpointsuperr   __init__r
   )selfkwargsr
   	__class__ =/tmp/pip-unpacked-wheel-dlxw5sjy/boto/directconnect/layer1.pyr   D   s    
z DirectConnectConnection.__init__c                 C   s   dgS )Nzhmac-v4r   )r   r   r   r   _required_auth_capabilityP   s    z1DirectConnectConnection._required_auth_capabilityc                 C   s$   |||||d}| j dt|dS )a5  
        Creates a hosted connection on an interconnect.

        Allocates a VLAN number and a specified amount of bandwidth
        for use by a hosted connection on the given interconnect.

        :type bandwidth: string
        :param bandwidth: Bandwidth of the connection.
        Example: " 500Mbps "

        Default: None

        :type connection_name: string
        :param connection_name: Name of the provisioned connection.
        Example: " 500M Connection to AWS "

        Default: None

        :type owner_account: string
        :param owner_account: Numeric account Id of the customer for whom the
            connection will be provisioned.
        Example: 123443215678

        Default: None

        :type interconnect_id: string
        :param interconnect_id: ID of the interconnect on which the connection
            will be provisioned.
        Example: dxcon-456abc78

        Default: None

        :type vlan: integer
        :param vlan: The dedicated VLAN provisioned to the connection.
        Example: 101

        Default: None

        )	bandwidthconnectionNameownerAccountinterconnectIdvlanZ AllocateConnectionOnInterconnectactionbodymake_requestr   dumps)r   r   connection_nameowner_accountinterconnect_idr   paramsr   r   r   #allocate_connection_on_interconnectS   s    +z;DirectConnectConnection.allocate_connection_on_interconnectc                 C   s    |||d}| j dt|dS )aw  
        Provisions a private virtual interface to be owned by a
        different customer.

        The owner of a connection calls this function to provision a
        private virtual interface which will be owned by another AWS
        customer.

        Virtual interfaces created using this function must be
        confirmed by the virtual interface owner by calling
        ConfirmPrivateVirtualInterface. Until this step has been
        completed, the virtual interface will be in 'Confirming'
        state, and will not be available for handling traffic.

        :type connection_id: string
        :param connection_id: The connection ID on which the private virtual
            interface is provisioned.
        Default: None

        :type owner_account: string
        :param owner_account: The AWS account that will own the new private
            virtual interface.
        Default: None

        :type new_private_virtual_interface_allocation: dict
        :param new_private_virtual_interface_allocation: Detailed information
            for the private virtual interface to be provisioned.
        Default: None

        )connectionIdr   Z$newPrivateVirtualInterfaceAllocationZAllocatePrivateVirtualInterfacer   r!   )r   connection_idr%   Z(new_private_virtual_interface_allocationr'   r   r   r   "allocate_private_virtual_interface   s    "z:DirectConnectConnection.allocate_private_virtual_interfacec                 C   s    |||d}| j dt|dS )ao  
        Provisions a public virtual interface to be owned by a
        different customer.

        The owner of a connection calls this function to provision a
        public virtual interface which will be owned by another AWS
        customer.

        Virtual interfaces created using this function must be
        confirmed by the virtual interface owner by calling
        ConfirmPublicVirtualInterface. Until this step has been
        completed, the virtual interface will be in 'Confirming'
        state, and will not be available for handling traffic.

        :type connection_id: string
        :param connection_id: The connection ID on which the public virtual
            interface is provisioned.
        Default: None

        :type owner_account: string
        :param owner_account: The AWS account that will own the new public
            virtual interface.
        Default: None

        :type new_public_virtual_interface_allocation: dict
        :param new_public_virtual_interface_allocation: Detailed information
            for the public virtual interface to be provisioned.
        Default: None

        )r)   r   Z#newPublicVirtualInterfaceAllocationZAllocatePublicVirtualInterfacer   r!   )r   r*   r%   Z'new_public_virtual_interface_allocationr'   r   r   r   !allocate_public_virtual_interface   s    !z9DirectConnectConnection.allocate_public_virtual_interfacec                 C   s   d|i}| j dt|dS )a  
        Confirm the creation of a hosted connection on an
        interconnect.

        Upon creation, the hosted connection is initially in the
        'Ordering' state, and will remain in this state until the
        owner calls ConfirmConnection to confirm creation of the
        hosted connection.

        :type connection_id: string
        :param connection_id: ID of the connection.
        Example: dxcon-fg5678gh

        Default: None

        r)   ZConfirmConnectionr   r!   r   r*   r'   r   r   r   confirm_connection   s    z*DirectConnectConnection.confirm_connectionc                 C   s   ||d}| j dt|dS )aB  
        Accept ownership of a private virtual interface created by
        another customer.

        After the virtual interface owner calls this function, the
        virtual interface will be created and attached to the given
        virtual private gateway, and will be available for handling
        traffic.

        :type virtual_interface_id: string
        :param virtual_interface_id: ID of the virtual interface.
        Example: dxvif-123dfg56

        Default: None

        :type virtual_gateway_id: string
        :param virtual_gateway_id: ID of the virtual private gateway that will
            be attached to the virtual interface.
        A virtual private gateway can be managed via the Amazon Virtual Private
            Cloud (VPC) console or the `EC2 CreateVpnGateway`_ action.

        Default: None

        )virtualInterfaceIdZvirtualGatewayIdZConfirmPrivateVirtualInterfacer   r!   )r   virtual_interface_idZvirtual_gateway_idr'   r   r   r   !confirm_private_virtual_interface   s    z9DirectConnectConnection.confirm_private_virtual_interfacec                 C   s   d|i}| j dt|dS )a  
        Accept ownership of a public virtual interface created by
        another customer.

        After the virtual interface owner calls this function, the
        specified virtual interface will be created and made available
        for handling traffic.

        :type virtual_interface_id: string
        :param virtual_interface_id: ID of the virtual interface.
        Example: dxvif-123dfg56

        Default: None

        r/   ZConfirmPublicVirtualInterfacer   r!   r   r0   r'   r   r   r    confirm_public_virtual_interface  s    z8DirectConnectConnection.confirm_public_virtual_interfacec                 C   s    |||d}| j dt|dS )ar  
        Creates a new connection between the customer network and a
        specific AWS Direct Connect location.

        A connection links your internal network to an AWS Direct
        Connect location over a standard 1 gigabit or 10 gigabit
        Ethernet fiber-optic cable. One end of the cable is connected
        to your router, the other to an AWS Direct Connect router. An
        AWS Direct Connect location provides access to Amazon Web
        Services in the region it is associated with. You can
        establish connections with AWS Direct Connect locations in
        multiple regions, but a connection in one region does not
        provide connectivity to other regions.

        :type location: string
        :param location: Where the connection is located.
        Example: EqSV5

        Default: None

        :type bandwidth: string
        :param bandwidth: Bandwidth of the connection.
        Example: 1Gbps

        Default: None

        :type connection_name: string
        :param connection_name: The name of the connection.
        Example: " My Connection to AWS "

        Default: None

        )locationr   r   ZCreateConnectionr   r!   )r   r4   r   r$   r'   r   r   r   create_connection"  s    #z)DirectConnectConnection.create_connectionc                 C   s    |||d}| j dt|dS )a%  
        Creates a new interconnect between a AWS Direct Connect
        partner's network and a specific AWS Direct Connect location.

        An interconnect is a connection which is capable of hosting
        other connections. The AWS Direct Connect partner can use an
        interconnect to provide sub-1Gbps AWS Direct Connect service
        to tier 2 customers who do not have their own connections.
        Like a standard connection, an interconnect links the AWS
        Direct Connect partner's network to an AWS Direct Connect
        location over a standard 1 Gbps or 10 Gbps Ethernet fiber-
        optic cable. One end is connected to the partner's router, the
        other to an AWS Direct Connect router.

        For each end customer, the AWS Direct Connect partner
        provisions a connection on their interconnect by calling
        AllocateConnectionOnInterconnect. The end customer can then
        connect to AWS resources by creating a virtual interface on
        their connection, using the VLAN assigned to them by the AWS
        Direct Connect partner.

        :type interconnect_name: string
        :param interconnect_name: The name of the interconnect.
        Example: " 1G Interconnect to AWS "

        Default: None

        :type bandwidth: string
        :param bandwidth: The port bandwidth
        Example: 1Gbps

        Default: None

        Available values: 1Gbps,10Gbps

        :type location: string
        :param location: Where the interconnect is located
        Example: EqSV5

        Default: None

        )ZinterconnectNamer   r4   ZCreateInterconnectr   r!   )r   Zinterconnect_namer   r4   r'   r   r   r   create_interconnectL  s    ,z+DirectConnectConnection.create_interconnectc                 C   s   ||d}| j dt|dS )aV  
        Creates a new private virtual interface. A virtual interface
        is the VLAN that transports AWS Direct Connect traffic. A
        private virtual interface supports sending traffic to a single
        virtual private cloud (VPC).

        :type connection_id: string
        :param connection_id: ID of the connection.
        Example: dxcon-fg5678gh

        Default: None

        :type new_private_virtual_interface: dict
        :param new_private_virtual_interface: Detailed information for the
            private virtual interface to be created.
        Default: None

        )r)   ZnewPrivateVirtualInterfaceZCreatePrivateVirtualInterfacer   r!   )r   r*   Znew_private_virtual_interfacer'   r   r   r    create_private_virtual_interface  s    z8DirectConnectConnection.create_private_virtual_interfacec                 C   s   ||d}| j dt|dS )au  
        Creates a new public virtual interface. A virtual interface is
        the VLAN that transports AWS Direct Connect traffic. A public
        virtual interface supports sending traffic to public services
        of AWS such as Amazon Simple Storage Service (Amazon S3).

        :type connection_id: string
        :param connection_id: ID of the connection.
        Example: dxcon-fg5678gh

        Default: None

        :type new_public_virtual_interface: dict
        :param new_public_virtual_interface: Detailed information for the
            public virtual interface to be created.
        Default: None

        )r)   ZnewPublicVirtualInterfaceZCreatePublicVirtualInterfacer   r!   )r   r*   Znew_public_virtual_interfacer'   r   r   r   create_public_virtual_interface  s    z7DirectConnectConnection.create_public_virtual_interfacec                 C   s   d|i}| j dt|dS )a  
        Deletes the connection.

        Deleting a connection only stops the AWS Direct Connect port
        hour and data transfer charges. You need to cancel separately
        with the providers any services or charges for cross-connects
        or network circuits that connect you to the AWS Direct Connect
        location.

        :type connection_id: string
        :param connection_id: ID of the connection.
        Example: dxcon-fg5678gh

        Default: None

        r)   ZDeleteConnectionr   r!   r-   r   r   r   delete_connection  s    z)DirectConnectConnection.delete_connectionc                 C   s   d|i}| j dt|dS )z
        Deletes the specified interconnect.

        :type interconnect_id: string
        :param interconnect_id: The ID of the interconnect.
        Example: dxcon-abc123

        r   ZDeleteInterconnectr   r!   r   r&   r'   r   r   r   delete_interconnect  s    	z+DirectConnectConnection.delete_interconnectc                 C   s   d|i}| j dt|dS )z
        Deletes a virtual interface.

        :type virtual_interface_id: string
        :param virtual_interface_id: ID of the virtual interface.
        Example: dxvif-123dfg56

        Default: None

        r/   ZDeleteVirtualInterfacer   r!   r2   r   r   r   delete_virtual_interface  s    z0DirectConnectConnection.delete_virtual_interfaceNc                 C   s(   i }|dk	r||d< | j dt|dS )a.  
        Displays all connections in this region.

        If a connection ID is provided, the call returns only that
        particular connection.

        :type connection_id: string
        :param connection_id: ID of the connection.
        Example: dxcon-fg5678gh

        Default: None

        Nr)   ZDescribeConnectionsr   r!   r-   r   r   r   describe_connections  s    z,DirectConnectConnection.describe_connectionsc                 C   s   d|i}| j dt|dS )a:  
        Return a list of connections that have been provisioned on the
        given interconnect.

        :type interconnect_id: string
        :param interconnect_id: ID of the interconnect on which a list of
            connection is provisioned.
        Example: dxcon-abc123

        Default: None

        r   Z!DescribeConnectionsOnInterconnectr   r!   r:   r   r   r   $describe_connections_on_interconnect  s    z<DirectConnectConnection.describe_connections_on_interconnectc                 C   s(   i }|dk	r||d< | j dt|dS )a3  
        Returns a list of interconnects owned by the AWS account.

        If an interconnect ID is provided, it will only return this
        particular interconnect.

        :type interconnect_id: string
        :param interconnect_id: The ID of the interconnect.
        Example: dxcon-abc123

        Nr   ZDescribeInterconnectsr   r!   r:   r   r   r   describe_interconnects  s    z.DirectConnectConnection.describe_interconnectsc                 C   s   i }| j dt|dS )z
        Returns the list of AWS Direct Connect locations in the
        current AWS region. These are the locations that may be
        selected when calling CreateConnection or CreateInterconnect.
        ZDescribeLocationsr   r!   r   r'   r   r   r   describe_locations  s    z*DirectConnectConnection.describe_locationsc                 C   s   i }| j dt|dS )am  
        Returns a list of virtual private gateways owned by the AWS
        account.

        You can create one or more AWS Direct Connect private virtual
        interfaces linking to a virtual private gateway. A virtual
        private gateway can be managed via Amazon Virtual Private
        Cloud (VPC) console or the `EC2 CreateVpnGateway`_ action.
        ZDescribeVirtualGatewaysr   r!   r@   r   r   r   describe_virtual_gateways'  s    
z1DirectConnectConnection.describe_virtual_gatewaysc                 C   s8   i }|dk	r||d< |dk	r$||d< | j dt|dS )aT  
        Displays all virtual interfaces for an AWS account. Virtual
        interfaces deleted fewer than 15 minutes before
        DescribeVirtualInterfaces is called are also returned. If a
        connection ID is included then only virtual interfaces
        associated with this connection will be returned. If a virtual
        interface ID is included then only a single virtual interface
        will be returned.

        A virtual interface (VLAN) transmits the traffic between the
        AWS Direct Connect location and the customer.

        If a connection ID is provided, only virtual interfaces
        provisioned on the specified connection will be returned. If a
        virtual interface ID is provided, only this particular virtual
        interface will be returned.

        :type connection_id: string
        :param connection_id: ID of the connection.
        Example: dxcon-fg5678gh

        Default: None

        :type virtual_interface_id: string
        :param virtual_interface_id: ID of the virtual interface.
        Example: dxvif-123dfg56

        Default: None

        Nr)   r/   ZDescribeVirtualInterfacesr   r!   )r   r*   r0   r'   r   r   r   describe_virtual_interfaces5  s     z3DirectConnectConnection.describe_virtual_interfacesc           
      C   s   d| j |f | jjdtt|d}| jdddi ||d}| j|d dd}| d	}t	j
| |jd
kr~|rt|S n8t|}|dd }| j|| j}	|	|j|j|dd S )Nz%s.%szapplication/x-amz-json-1.1)zX-Amz-TargetHostzContent-TypezContent-LengthPOST/)methodpathZ	auth_pathr'   headersdata
   )ZsenderZoverride_num_retrieszutf-8   Z__type)r    )TargetPrefixr
   r   strlenZbuild_base_http_requestZ_mexereaddecodebotologdebugstatusr   loadsget_faultsResponseErrorreason)
r   r   r    rI   http_requestresponseZresponse_bodyZ	json_bodyZ
fault_nameZexception_classr   r   r   r"   ]  s6    
    


z$DirectConnectConnection.make_request)N)N)NN)&__name__
__module____qualname____doc__Z
APIVersionr   r   ZServiceNamerM   r   rY   r   r   r	   rX   r   r   r(   r+   r,   r.   r1   r3   r5   r6   r7   r8   r9   r;   r<   r=   r>   r?   rA   rB   rC   r"   __classcell__r   r   r   r   r      sD   4)(!*3


  
(r   )rR   Zboto.connectionr   Zboto.regioninfor   Zboto.exceptionr   Zboto.directconnectr   Zboto.compatr   r   r   r   r   r   <module>   s   