amazonka-ec2-1.3.7: gen/Network/AWS/EC2/CreateNatGateway.hs
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
-- Derived from AWS service descriptions, licensed under Apache 2.0.
-- |
-- Module : Network.AWS.EC2.CreateNatGateway
-- Copyright : (c) 2013-2015 Brendan Hay
-- License : Mozilla Public License, v. 2.0.
-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com>
-- Stability : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a NAT gateway in the specified subnet. A NAT gateway can be used
-- to enable instances in a private subnet to connect to the Internet. This
-- action creates a network interface in the specified subnet with a
-- private IP address from the IP address range of the subnet. For more
-- information, see
-- <http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-nat-gateway.html NAT Gateways>
-- in the /Amazon Virtual Private Cloud User Guide/.
--
-- /See:/ <http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-CreateNatGateway.html AWS API Reference> for CreateNatGateway.
module Network.AWS.EC2.CreateNatGateway
(
-- * Creating a Request
createNatGateway
, CreateNatGateway
-- * Request Lenses
, cngClientToken
, cngSubnetId
, cngAllocationId
-- * Destructuring the Response
, createNatGatewayResponse
, CreateNatGatewayResponse
-- * Response Lenses
, cngrsClientToken
, cngrsNatGateway
, cngrsResponseStatus
) where
import Network.AWS.EC2.Types
import Network.AWS.EC2.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
-- | /See:/ 'createNatGateway' smart constructor.
data CreateNatGateway = CreateNatGateway'
{ _cngClientToken :: !(Maybe Text)
, _cngSubnetId :: !Text
, _cngAllocationId :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
-- | Creates a value of 'CreateNatGateway' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'cngClientToken'
--
-- * 'cngSubnetId'
--
-- * 'cngAllocationId'
createNatGateway
:: Text -- ^ 'cngSubnetId'
-> Text -- ^ 'cngAllocationId'
-> CreateNatGateway
createNatGateway pSubnetId_ pAllocationId_ =
CreateNatGateway'
{ _cngClientToken = Nothing
, _cngSubnetId = pSubnetId_
, _cngAllocationId = pAllocationId_
}
-- | Unique, case-sensitive identifier you provide to ensure the idempotency
-- of the request. For more information, see
-- <http://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html How to Ensure Idempotency>.
--
-- Constraint: Maximum 64 ASCII characters.
cngClientToken :: Lens' CreateNatGateway (Maybe Text)
cngClientToken = lens _cngClientToken (\ s a -> s{_cngClientToken = a});
-- | The subnet in which to create the NAT gateway.
cngSubnetId :: Lens' CreateNatGateway Text
cngSubnetId = lens _cngSubnetId (\ s a -> s{_cngSubnetId = a});
-- | The allocation ID of an Elastic IP address to associate with the NAT
-- gateway. If the Elastic IP address is associated with another resource,
-- you must first disassociate it.
cngAllocationId :: Lens' CreateNatGateway Text
cngAllocationId = lens _cngAllocationId (\ s a -> s{_cngAllocationId = a});
instance AWSRequest CreateNatGateway where
type Rs CreateNatGateway = CreateNatGatewayResponse
request = postQuery eC2
response
= receiveXML
(\ s h x ->
CreateNatGatewayResponse' <$>
(x .@? "clientToken") <*> (x .@? "natGateway") <*>
(pure (fromEnum s)))
instance ToHeaders CreateNatGateway where
toHeaders = const mempty
instance ToPath CreateNatGateway where
toPath = const "/"
instance ToQuery CreateNatGateway where
toQuery CreateNatGateway'{..}
= mconcat
["Action" =: ("CreateNatGateway" :: ByteString),
"Version" =: ("2015-10-01" :: ByteString),
"ClientToken" =: _cngClientToken,
"SubnetId" =: _cngSubnetId,
"AllocationId" =: _cngAllocationId]
-- | /See:/ 'createNatGatewayResponse' smart constructor.
data CreateNatGatewayResponse = CreateNatGatewayResponse'
{ _cngrsClientToken :: !(Maybe Text)
, _cngrsNatGateway :: !(Maybe NatGateway)
, _cngrsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
-- | Creates a value of 'CreateNatGatewayResponse' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'cngrsClientToken'
--
-- * 'cngrsNatGateway'
--
-- * 'cngrsResponseStatus'
createNatGatewayResponse
:: Int -- ^ 'cngrsResponseStatus'
-> CreateNatGatewayResponse
createNatGatewayResponse pResponseStatus_ =
CreateNatGatewayResponse'
{ _cngrsClientToken = Nothing
, _cngrsNatGateway = Nothing
, _cngrsResponseStatus = pResponseStatus_
}
-- | Unique, case-sensitive identifier to ensure the idempotency of the
-- request. Only returned if a client token was provided in the request.
cngrsClientToken :: Lens' CreateNatGatewayResponse (Maybe Text)
cngrsClientToken = lens _cngrsClientToken (\ s a -> s{_cngrsClientToken = a});
-- | Information about the NAT gateway.
cngrsNatGateway :: Lens' CreateNatGatewayResponse (Maybe NatGateway)
cngrsNatGateway = lens _cngrsNatGateway (\ s a -> s{_cngrsNatGateway = a});
-- | The response status code.
cngrsResponseStatus :: Lens' CreateNatGatewayResponse Int
cngrsResponseStatus = lens _cngrsResponseStatus (\ s a -> s{_cngrsResponseStatus = a});