{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.EC2.AssociateAddress
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Associates an Elastic IP address, or carrier IP address (for instances
-- that are in subnets in Wavelength Zones) with an instance or a network
-- interface. Before you can use an Elastic IP address, you must allocate
-- it to your account.
--
-- An Elastic IP address is for use in either the EC2-Classic platform or
-- in a VPC. For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html Elastic IP Addresses>
-- in the /Amazon Elastic Compute Cloud User Guide/.
--
-- [EC2-Classic, VPC in an EC2-VPC-only account] If the Elastic IP address
-- is already associated with a different instance, it is disassociated
-- from that instance and associated with the specified instance. If you
-- associate an Elastic IP address with an instance that has an existing
-- Elastic IP address, the existing address is disassociated from the
-- instance, but remains allocated to your account.
--
-- [VPC in an EC2-Classic account] If you don\'t specify a private IP
-- address, the Elastic IP address is associated with the primary IP
-- address. If the Elastic IP address is already associated with a
-- different instance or a network interface, you get an error unless you
-- allow reassociation. You cannot associate an Elastic IP address with an
-- instance or network interface that has an existing Elastic IP address.
--
-- [Subnets in Wavelength Zones] You can associate an IP address from the
-- telecommunication carrier to the instance or network interface.
--
-- You cannot associate an Elastic IP address with an interface in a
-- different network border group.
--
-- This is an idempotent operation. If you perform the operation more than
-- once, Amazon EC2 doesn\'t return an error, and you may be charged for
-- each time the Elastic IP address is remapped to the same instance. For
-- more information, see the /Elastic IP Addresses/ section of
-- <http://aws.amazon.com/ec2/pricing/ Amazon EC2 Pricing>.
--
-- We are retiring EC2-Classic. We recommend that you migrate from
-- EC2-Classic to a VPC. For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/vpc-migrate.html Migrate from EC2-Classic to a VPC>
-- in the /Amazon Elastic Compute Cloud User Guide/.
module Amazonka.EC2.AssociateAddress
  ( -- * Creating a Request
    AssociateAddress (..),
    newAssociateAddress,

    -- * Request Lenses
    associateAddress_allocationId,
    associateAddress_allowReassociation,
    associateAddress_dryRun,
    associateAddress_instanceId,
    associateAddress_networkInterfaceId,
    associateAddress_privateIpAddress,
    associateAddress_publicIp,

    -- * Destructuring the Response
    AssociateAddressResponse (..),
    newAssociateAddressResponse,

    -- * Response Lenses
    associateAddressResponse_associationId,
    associateAddressResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newAssociateAddress' smart constructor.
data AssociateAddress = AssociateAddress'
  { -- | [EC2-VPC] The allocation ID. This is required for EC2-VPC.
    AssociateAddress -> Maybe Text
allocationId :: Prelude.Maybe Prelude.Text,
    -- | [EC2-VPC] For a VPC in an EC2-Classic account, specify true to allow an
    -- Elastic IP address that is already associated with an instance or
    -- network interface to be reassociated with the specified instance or
    -- network interface. Otherwise, the operation fails. In a VPC in an
    -- EC2-VPC-only account, reassociation is automatic, therefore you can
    -- specify false to ensure the operation fails if the Elastic IP address is
    -- already associated with another resource.
    AssociateAddress -> Maybe Bool
allowReassociation :: Prelude.Maybe Prelude.Bool,
    -- | Checks whether you have the required permissions for the action, without
    -- actually making the request, and provides an error response. If you have
    -- the required permissions, the error response is @DryRunOperation@.
    -- Otherwise, it is @UnauthorizedOperation@.
    AssociateAddress -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | The ID of the instance. The instance must have exactly one attached
    -- network interface. For EC2-VPC, you can specify either the instance ID
    -- or the network interface ID, but not both. For EC2-Classic, you must
    -- specify an instance ID and the instance must be in the running state.
    AssociateAddress -> Maybe Text
instanceId :: Prelude.Maybe Prelude.Text,
    -- | [EC2-VPC] The ID of the network interface. If the instance has more than
    -- one network interface, you must specify a network interface ID.
    --
    -- For EC2-VPC, you can specify either the instance ID or the network
    -- interface ID, but not both.
    AssociateAddress -> Maybe Text
networkInterfaceId :: Prelude.Maybe Prelude.Text,
    -- | [EC2-VPC] The primary or secondary private IP address to associate with
    -- the Elastic IP address. If no private IP address is specified, the
    -- Elastic IP address is associated with the primary private IP address.
    AssociateAddress -> Maybe Text
privateIpAddress :: Prelude.Maybe Prelude.Text,
    -- | [EC2-Classic] The Elastic IP address to associate with the instance.
    -- This is required for EC2-Classic.
    AssociateAddress -> Maybe Text
publicIp :: Prelude.Maybe Prelude.Text
  }
  deriving (AssociateAddress -> AssociateAddress -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateAddress -> AssociateAddress -> Bool
$c/= :: AssociateAddress -> AssociateAddress -> Bool
== :: AssociateAddress -> AssociateAddress -> Bool
$c== :: AssociateAddress -> AssociateAddress -> Bool
Prelude.Eq, ReadPrec [AssociateAddress]
ReadPrec AssociateAddress
Int -> ReadS AssociateAddress
ReadS [AssociateAddress]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateAddress]
$creadListPrec :: ReadPrec [AssociateAddress]
readPrec :: ReadPrec AssociateAddress
$creadPrec :: ReadPrec AssociateAddress
readList :: ReadS [AssociateAddress]
$creadList :: ReadS [AssociateAddress]
readsPrec :: Int -> ReadS AssociateAddress
$creadsPrec :: Int -> ReadS AssociateAddress
Prelude.Read, Int -> AssociateAddress -> ShowS
[AssociateAddress] -> ShowS
AssociateAddress -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateAddress] -> ShowS
$cshowList :: [AssociateAddress] -> ShowS
show :: AssociateAddress -> String
$cshow :: AssociateAddress -> String
showsPrec :: Int -> AssociateAddress -> ShowS
$cshowsPrec :: Int -> AssociateAddress -> ShowS
Prelude.Show, forall x. Rep AssociateAddress x -> AssociateAddress
forall x. AssociateAddress -> Rep AssociateAddress x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssociateAddress x -> AssociateAddress
$cfrom :: forall x. AssociateAddress -> Rep AssociateAddress x
Prelude.Generic)

-- |
-- Create a value of 'AssociateAddress' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'allocationId', 'associateAddress_allocationId' - [EC2-VPC] The allocation ID. This is required for EC2-VPC.
--
-- 'allowReassociation', 'associateAddress_allowReassociation' - [EC2-VPC] For a VPC in an EC2-Classic account, specify true to allow an
-- Elastic IP address that is already associated with an instance or
-- network interface to be reassociated with the specified instance or
-- network interface. Otherwise, the operation fails. In a VPC in an
-- EC2-VPC-only account, reassociation is automatic, therefore you can
-- specify false to ensure the operation fails if the Elastic IP address is
-- already associated with another resource.
--
-- 'dryRun', 'associateAddress_dryRun' - Checks whether you have the required permissions for the action, without
-- actually making the request, and provides an error response. If you have
-- the required permissions, the error response is @DryRunOperation@.
-- Otherwise, it is @UnauthorizedOperation@.
--
-- 'instanceId', 'associateAddress_instanceId' - The ID of the instance. The instance must have exactly one attached
-- network interface. For EC2-VPC, you can specify either the instance ID
-- or the network interface ID, but not both. For EC2-Classic, you must
-- specify an instance ID and the instance must be in the running state.
--
-- 'networkInterfaceId', 'associateAddress_networkInterfaceId' - [EC2-VPC] The ID of the network interface. If the instance has more than
-- one network interface, you must specify a network interface ID.
--
-- For EC2-VPC, you can specify either the instance ID or the network
-- interface ID, but not both.
--
-- 'privateIpAddress', 'associateAddress_privateIpAddress' - [EC2-VPC] The primary or secondary private IP address to associate with
-- the Elastic IP address. If no private IP address is specified, the
-- Elastic IP address is associated with the primary private IP address.
--
-- 'publicIp', 'associateAddress_publicIp' - [EC2-Classic] The Elastic IP address to associate with the instance.
-- This is required for EC2-Classic.
newAssociateAddress ::
  AssociateAddress
newAssociateAddress :: AssociateAddress
newAssociateAddress =
  AssociateAddress'
    { $sel:allocationId:AssociateAddress' :: Maybe Text
allocationId = forall a. Maybe a
Prelude.Nothing,
      $sel:allowReassociation:AssociateAddress' :: Maybe Bool
allowReassociation = forall a. Maybe a
Prelude.Nothing,
      $sel:dryRun:AssociateAddress' :: Maybe Bool
dryRun = forall a. Maybe a
Prelude.Nothing,
      $sel:instanceId:AssociateAddress' :: Maybe Text
instanceId = forall a. Maybe a
Prelude.Nothing,
      $sel:networkInterfaceId:AssociateAddress' :: Maybe Text
networkInterfaceId = forall a. Maybe a
Prelude.Nothing,
      $sel:privateIpAddress:AssociateAddress' :: Maybe Text
privateIpAddress = forall a. Maybe a
Prelude.Nothing,
      $sel:publicIp:AssociateAddress' :: Maybe Text
publicIp = forall a. Maybe a
Prelude.Nothing
    }

-- | [EC2-VPC] The allocation ID. This is required for EC2-VPC.
associateAddress_allocationId :: Lens.Lens' AssociateAddress (Prelude.Maybe Prelude.Text)
associateAddress_allocationId :: Lens' AssociateAddress (Maybe Text)
associateAddress_allocationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateAddress' {Maybe Text
allocationId :: Maybe Text
$sel:allocationId:AssociateAddress' :: AssociateAddress -> Maybe Text
allocationId} -> Maybe Text
allocationId) (\s :: AssociateAddress
s@AssociateAddress' {} Maybe Text
a -> AssociateAddress
s {$sel:allocationId:AssociateAddress' :: Maybe Text
allocationId = Maybe Text
a} :: AssociateAddress)

-- | [EC2-VPC] For a VPC in an EC2-Classic account, specify true to allow an
-- Elastic IP address that is already associated with an instance or
-- network interface to be reassociated with the specified instance or
-- network interface. Otherwise, the operation fails. In a VPC in an
-- EC2-VPC-only account, reassociation is automatic, therefore you can
-- specify false to ensure the operation fails if the Elastic IP address is
-- already associated with another resource.
associateAddress_allowReassociation :: Lens.Lens' AssociateAddress (Prelude.Maybe Prelude.Bool)
associateAddress_allowReassociation :: Lens' AssociateAddress (Maybe Bool)
associateAddress_allowReassociation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateAddress' {Maybe Bool
allowReassociation :: Maybe Bool
$sel:allowReassociation:AssociateAddress' :: AssociateAddress -> Maybe Bool
allowReassociation} -> Maybe Bool
allowReassociation) (\s :: AssociateAddress
s@AssociateAddress' {} Maybe Bool
a -> AssociateAddress
s {$sel:allowReassociation:AssociateAddress' :: Maybe Bool
allowReassociation = Maybe Bool
a} :: AssociateAddress)

-- | Checks whether you have the required permissions for the action, without
-- actually making the request, and provides an error response. If you have
-- the required permissions, the error response is @DryRunOperation@.
-- Otherwise, it is @UnauthorizedOperation@.
associateAddress_dryRun :: Lens.Lens' AssociateAddress (Prelude.Maybe Prelude.Bool)
associateAddress_dryRun :: Lens' AssociateAddress (Maybe Bool)
associateAddress_dryRun = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateAddress' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:AssociateAddress' :: AssociateAddress -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: AssociateAddress
s@AssociateAddress' {} Maybe Bool
a -> AssociateAddress
s {$sel:dryRun:AssociateAddress' :: Maybe Bool
dryRun = Maybe Bool
a} :: AssociateAddress)

-- | The ID of the instance. The instance must have exactly one attached
-- network interface. For EC2-VPC, you can specify either the instance ID
-- or the network interface ID, but not both. For EC2-Classic, you must
-- specify an instance ID and the instance must be in the running state.
associateAddress_instanceId :: Lens.Lens' AssociateAddress (Prelude.Maybe Prelude.Text)
associateAddress_instanceId :: Lens' AssociateAddress (Maybe Text)
associateAddress_instanceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateAddress' {Maybe Text
instanceId :: Maybe Text
$sel:instanceId:AssociateAddress' :: AssociateAddress -> Maybe Text
instanceId} -> Maybe Text
instanceId) (\s :: AssociateAddress
s@AssociateAddress' {} Maybe Text
a -> AssociateAddress
s {$sel:instanceId:AssociateAddress' :: Maybe Text
instanceId = Maybe Text
a} :: AssociateAddress)

-- | [EC2-VPC] The ID of the network interface. If the instance has more than
-- one network interface, you must specify a network interface ID.
--
-- For EC2-VPC, you can specify either the instance ID or the network
-- interface ID, but not both.
associateAddress_networkInterfaceId :: Lens.Lens' AssociateAddress (Prelude.Maybe Prelude.Text)
associateAddress_networkInterfaceId :: Lens' AssociateAddress (Maybe Text)
associateAddress_networkInterfaceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateAddress' {Maybe Text
networkInterfaceId :: Maybe Text
$sel:networkInterfaceId:AssociateAddress' :: AssociateAddress -> Maybe Text
networkInterfaceId} -> Maybe Text
networkInterfaceId) (\s :: AssociateAddress
s@AssociateAddress' {} Maybe Text
a -> AssociateAddress
s {$sel:networkInterfaceId:AssociateAddress' :: Maybe Text
networkInterfaceId = Maybe Text
a} :: AssociateAddress)

-- | [EC2-VPC] The primary or secondary private IP address to associate with
-- the Elastic IP address. If no private IP address is specified, the
-- Elastic IP address is associated with the primary private IP address.
associateAddress_privateIpAddress :: Lens.Lens' AssociateAddress (Prelude.Maybe Prelude.Text)
associateAddress_privateIpAddress :: Lens' AssociateAddress (Maybe Text)
associateAddress_privateIpAddress = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateAddress' {Maybe Text
privateIpAddress :: Maybe Text
$sel:privateIpAddress:AssociateAddress' :: AssociateAddress -> Maybe Text
privateIpAddress} -> Maybe Text
privateIpAddress) (\s :: AssociateAddress
s@AssociateAddress' {} Maybe Text
a -> AssociateAddress
s {$sel:privateIpAddress:AssociateAddress' :: Maybe Text
privateIpAddress = Maybe Text
a} :: AssociateAddress)

-- | [EC2-Classic] The Elastic IP address to associate with the instance.
-- This is required for EC2-Classic.
associateAddress_publicIp :: Lens.Lens' AssociateAddress (Prelude.Maybe Prelude.Text)
associateAddress_publicIp :: Lens' AssociateAddress (Maybe Text)
associateAddress_publicIp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateAddress' {Maybe Text
publicIp :: Maybe Text
$sel:publicIp:AssociateAddress' :: AssociateAddress -> Maybe Text
publicIp} -> Maybe Text
publicIp) (\s :: AssociateAddress
s@AssociateAddress' {} Maybe Text
a -> AssociateAddress
s {$sel:publicIp:AssociateAddress' :: Maybe Text
publicIp = Maybe Text
a} :: AssociateAddress)

instance Core.AWSRequest AssociateAddress where
  type
    AWSResponse AssociateAddress =
      AssociateAddressResponse
  request :: (Service -> Service)
-> AssociateAddress -> Request AssociateAddress
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy AssociateAddress
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AssociateAddress)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Text -> Int -> AssociateAddressResponse
AssociateAddressResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"associationId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable AssociateAddress where
  hashWithSalt :: Int -> AssociateAddress -> Int
hashWithSalt Int
_salt AssociateAddress' {Maybe Bool
Maybe Text
publicIp :: Maybe Text
privateIpAddress :: Maybe Text
networkInterfaceId :: Maybe Text
instanceId :: Maybe Text
dryRun :: Maybe Bool
allowReassociation :: Maybe Bool
allocationId :: Maybe Text
$sel:publicIp:AssociateAddress' :: AssociateAddress -> Maybe Text
$sel:privateIpAddress:AssociateAddress' :: AssociateAddress -> Maybe Text
$sel:networkInterfaceId:AssociateAddress' :: AssociateAddress -> Maybe Text
$sel:instanceId:AssociateAddress' :: AssociateAddress -> Maybe Text
$sel:dryRun:AssociateAddress' :: AssociateAddress -> Maybe Bool
$sel:allowReassociation:AssociateAddress' :: AssociateAddress -> Maybe Bool
$sel:allocationId:AssociateAddress' :: AssociateAddress -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
allocationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
allowReassociation
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
dryRun
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
instanceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
networkInterfaceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
privateIpAddress
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
publicIp

instance Prelude.NFData AssociateAddress where
  rnf :: AssociateAddress -> ()
rnf AssociateAddress' {Maybe Bool
Maybe Text
publicIp :: Maybe Text
privateIpAddress :: Maybe Text
networkInterfaceId :: Maybe Text
instanceId :: Maybe Text
dryRun :: Maybe Bool
allowReassociation :: Maybe Bool
allocationId :: Maybe Text
$sel:publicIp:AssociateAddress' :: AssociateAddress -> Maybe Text
$sel:privateIpAddress:AssociateAddress' :: AssociateAddress -> Maybe Text
$sel:networkInterfaceId:AssociateAddress' :: AssociateAddress -> Maybe Text
$sel:instanceId:AssociateAddress' :: AssociateAddress -> Maybe Text
$sel:dryRun:AssociateAddress' :: AssociateAddress -> Maybe Bool
$sel:allowReassociation:AssociateAddress' :: AssociateAddress -> Maybe Bool
$sel:allocationId:AssociateAddress' :: AssociateAddress -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
allocationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
allowReassociation
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
dryRun
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
instanceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
networkInterfaceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
privateIpAddress
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
publicIp

instance Data.ToHeaders AssociateAddress where
  toHeaders :: AssociateAddress -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath AssociateAddress where
  toPath :: AssociateAddress -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery AssociateAddress where
  toQuery :: AssociateAddress -> QueryString
toQuery AssociateAddress' {Maybe Bool
Maybe Text
publicIp :: Maybe Text
privateIpAddress :: Maybe Text
networkInterfaceId :: Maybe Text
instanceId :: Maybe Text
dryRun :: Maybe Bool
allowReassociation :: Maybe Bool
allocationId :: Maybe Text
$sel:publicIp:AssociateAddress' :: AssociateAddress -> Maybe Text
$sel:privateIpAddress:AssociateAddress' :: AssociateAddress -> Maybe Text
$sel:networkInterfaceId:AssociateAddress' :: AssociateAddress -> Maybe Text
$sel:instanceId:AssociateAddress' :: AssociateAddress -> Maybe Text
$sel:dryRun:AssociateAddress' :: AssociateAddress -> Maybe Bool
$sel:allowReassociation:AssociateAddress' :: AssociateAddress -> Maybe Bool
$sel:allocationId:AssociateAddress' :: AssociateAddress -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"AssociateAddress" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2016-11-15" :: Prelude.ByteString),
        ByteString
"AllocationId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
allocationId,
        ByteString
"AllowReassociation" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
allowReassociation,
        ByteString
"DryRun" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
dryRun,
        ByteString
"InstanceId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
instanceId,
        ByteString
"NetworkInterfaceId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
networkInterfaceId,
        ByteString
"PrivateIpAddress" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
privateIpAddress,
        ByteString
"PublicIp" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
publicIp
      ]

-- | /See:/ 'newAssociateAddressResponse' smart constructor.
data AssociateAddressResponse = AssociateAddressResponse'
  { -- | [EC2-VPC] The ID that represents the association of the Elastic IP
    -- address with an instance.
    AssociateAddressResponse -> Maybe Text
associationId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    AssociateAddressResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (AssociateAddressResponse -> AssociateAddressResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateAddressResponse -> AssociateAddressResponse -> Bool
$c/= :: AssociateAddressResponse -> AssociateAddressResponse -> Bool
== :: AssociateAddressResponse -> AssociateAddressResponse -> Bool
$c== :: AssociateAddressResponse -> AssociateAddressResponse -> Bool
Prelude.Eq, ReadPrec [AssociateAddressResponse]
ReadPrec AssociateAddressResponse
Int -> ReadS AssociateAddressResponse
ReadS [AssociateAddressResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateAddressResponse]
$creadListPrec :: ReadPrec [AssociateAddressResponse]
readPrec :: ReadPrec AssociateAddressResponse
$creadPrec :: ReadPrec AssociateAddressResponse
readList :: ReadS [AssociateAddressResponse]
$creadList :: ReadS [AssociateAddressResponse]
readsPrec :: Int -> ReadS AssociateAddressResponse
$creadsPrec :: Int -> ReadS AssociateAddressResponse
Prelude.Read, Int -> AssociateAddressResponse -> ShowS
[AssociateAddressResponse] -> ShowS
AssociateAddressResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateAddressResponse] -> ShowS
$cshowList :: [AssociateAddressResponse] -> ShowS
show :: AssociateAddressResponse -> String
$cshow :: AssociateAddressResponse -> String
showsPrec :: Int -> AssociateAddressResponse -> ShowS
$cshowsPrec :: Int -> AssociateAddressResponse -> ShowS
Prelude.Show, forall x.
Rep AssociateAddressResponse x -> AssociateAddressResponse
forall x.
AssociateAddressResponse -> Rep AssociateAddressResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssociateAddressResponse x -> AssociateAddressResponse
$cfrom :: forall x.
AssociateAddressResponse -> Rep AssociateAddressResponse x
Prelude.Generic)

-- |
-- Create a value of 'AssociateAddressResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'associationId', 'associateAddressResponse_associationId' - [EC2-VPC] The ID that represents the association of the Elastic IP
-- address with an instance.
--
-- 'httpStatus', 'associateAddressResponse_httpStatus' - The response's http status code.
newAssociateAddressResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AssociateAddressResponse
newAssociateAddressResponse :: Int -> AssociateAddressResponse
newAssociateAddressResponse Int
pHttpStatus_ =
  AssociateAddressResponse'
    { $sel:associationId:AssociateAddressResponse' :: Maybe Text
associationId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:AssociateAddressResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | [EC2-VPC] The ID that represents the association of the Elastic IP
-- address with an instance.
associateAddressResponse_associationId :: Lens.Lens' AssociateAddressResponse (Prelude.Maybe Prelude.Text)
associateAddressResponse_associationId :: Lens' AssociateAddressResponse (Maybe Text)
associateAddressResponse_associationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateAddressResponse' {Maybe Text
associationId :: Maybe Text
$sel:associationId:AssociateAddressResponse' :: AssociateAddressResponse -> Maybe Text
associationId} -> Maybe Text
associationId) (\s :: AssociateAddressResponse
s@AssociateAddressResponse' {} Maybe Text
a -> AssociateAddressResponse
s {$sel:associationId:AssociateAddressResponse' :: Maybe Text
associationId = Maybe Text
a} :: AssociateAddressResponse)

-- | The response's http status code.
associateAddressResponse_httpStatus :: Lens.Lens' AssociateAddressResponse Prelude.Int
associateAddressResponse_httpStatus :: Lens' AssociateAddressResponse Int
associateAddressResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateAddressResponse' {Int
httpStatus :: Int
$sel:httpStatus:AssociateAddressResponse' :: AssociateAddressResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: AssociateAddressResponse
s@AssociateAddressResponse' {} Int
a -> AssociateAddressResponse
s {$sel:httpStatus:AssociateAddressResponse' :: Int
httpStatus = Int
a} :: AssociateAddressResponse)

instance Prelude.NFData AssociateAddressResponse where
  rnf :: AssociateAddressResponse -> ()
rnf AssociateAddressResponse' {Int
Maybe Text
httpStatus :: Int
associationId :: Maybe Text
$sel:httpStatus:AssociateAddressResponse' :: AssociateAddressResponse -> Int
$sel:associationId:AssociateAddressResponse' :: AssociateAddressResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
associationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus