{-# 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.PinpointEmail.PutDedicatedIpInPool
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Move a dedicated IP address to an existing dedicated IP pool.
--
-- The dedicated IP address that you specify must already exist, and must
-- be associated with your Amazon Pinpoint account.
--
-- The dedicated IP pool you specify must already exist. You can create a
-- new pool by using the @CreateDedicatedIpPool@ operation.
module Amazonka.PinpointEmail.PutDedicatedIpInPool
  ( -- * Creating a Request
    PutDedicatedIpInPool (..),
    newPutDedicatedIpInPool,

    -- * Request Lenses
    putDedicatedIpInPool_ip,
    putDedicatedIpInPool_destinationPoolName,

    -- * Destructuring the Response
    PutDedicatedIpInPoolResponse (..),
    newPutDedicatedIpInPoolResponse,

    -- * Response Lenses
    putDedicatedIpInPoolResponse_httpStatus,
  )
where

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

-- | A request to move a dedicated IP address to a dedicated IP pool.
--
-- /See:/ 'newPutDedicatedIpInPool' smart constructor.
data PutDedicatedIpInPool = PutDedicatedIpInPool'
  { -- | The IP address that you want to move to the dedicated IP pool. The value
    -- you specify has to be a dedicated IP address that\'s associated with
    -- your Amazon Pinpoint account.
    PutDedicatedIpInPool -> Text
ip :: Prelude.Text,
    -- | The name of the IP pool that you want to add the dedicated IP address
    -- to. You have to specify an IP pool that already exists.
    PutDedicatedIpInPool -> Text
destinationPoolName :: Prelude.Text
  }
  deriving (PutDedicatedIpInPool -> PutDedicatedIpInPool -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutDedicatedIpInPool -> PutDedicatedIpInPool -> Bool
$c/= :: PutDedicatedIpInPool -> PutDedicatedIpInPool -> Bool
== :: PutDedicatedIpInPool -> PutDedicatedIpInPool -> Bool
$c== :: PutDedicatedIpInPool -> PutDedicatedIpInPool -> Bool
Prelude.Eq, ReadPrec [PutDedicatedIpInPool]
ReadPrec PutDedicatedIpInPool
Int -> ReadS PutDedicatedIpInPool
ReadS [PutDedicatedIpInPool]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutDedicatedIpInPool]
$creadListPrec :: ReadPrec [PutDedicatedIpInPool]
readPrec :: ReadPrec PutDedicatedIpInPool
$creadPrec :: ReadPrec PutDedicatedIpInPool
readList :: ReadS [PutDedicatedIpInPool]
$creadList :: ReadS [PutDedicatedIpInPool]
readsPrec :: Int -> ReadS PutDedicatedIpInPool
$creadsPrec :: Int -> ReadS PutDedicatedIpInPool
Prelude.Read, Int -> PutDedicatedIpInPool -> ShowS
[PutDedicatedIpInPool] -> ShowS
PutDedicatedIpInPool -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutDedicatedIpInPool] -> ShowS
$cshowList :: [PutDedicatedIpInPool] -> ShowS
show :: PutDedicatedIpInPool -> String
$cshow :: PutDedicatedIpInPool -> String
showsPrec :: Int -> PutDedicatedIpInPool -> ShowS
$cshowsPrec :: Int -> PutDedicatedIpInPool -> ShowS
Prelude.Show, forall x. Rep PutDedicatedIpInPool x -> PutDedicatedIpInPool
forall x. PutDedicatedIpInPool -> Rep PutDedicatedIpInPool x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutDedicatedIpInPool x -> PutDedicatedIpInPool
$cfrom :: forall x. PutDedicatedIpInPool -> Rep PutDedicatedIpInPool x
Prelude.Generic)

-- |
-- Create a value of 'PutDedicatedIpInPool' 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:
--
-- 'ip', 'putDedicatedIpInPool_ip' - The IP address that you want to move to the dedicated IP pool. The value
-- you specify has to be a dedicated IP address that\'s associated with
-- your Amazon Pinpoint account.
--
-- 'destinationPoolName', 'putDedicatedIpInPool_destinationPoolName' - The name of the IP pool that you want to add the dedicated IP address
-- to. You have to specify an IP pool that already exists.
newPutDedicatedIpInPool ::
  -- | 'ip'
  Prelude.Text ->
  -- | 'destinationPoolName'
  Prelude.Text ->
  PutDedicatedIpInPool
newPutDedicatedIpInPool :: Text -> Text -> PutDedicatedIpInPool
newPutDedicatedIpInPool Text
pIp_ Text
pDestinationPoolName_ =
  PutDedicatedIpInPool'
    { $sel:ip:PutDedicatedIpInPool' :: Text
ip = Text
pIp_,
      $sel:destinationPoolName:PutDedicatedIpInPool' :: Text
destinationPoolName = Text
pDestinationPoolName_
    }

-- | The IP address that you want to move to the dedicated IP pool. The value
-- you specify has to be a dedicated IP address that\'s associated with
-- your Amazon Pinpoint account.
putDedicatedIpInPool_ip :: Lens.Lens' PutDedicatedIpInPool Prelude.Text
putDedicatedIpInPool_ip :: Lens' PutDedicatedIpInPool Text
putDedicatedIpInPool_ip = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutDedicatedIpInPool' {Text
ip :: Text
$sel:ip:PutDedicatedIpInPool' :: PutDedicatedIpInPool -> Text
ip} -> Text
ip) (\s :: PutDedicatedIpInPool
s@PutDedicatedIpInPool' {} Text
a -> PutDedicatedIpInPool
s {$sel:ip:PutDedicatedIpInPool' :: Text
ip = Text
a} :: PutDedicatedIpInPool)

-- | The name of the IP pool that you want to add the dedicated IP address
-- to. You have to specify an IP pool that already exists.
putDedicatedIpInPool_destinationPoolName :: Lens.Lens' PutDedicatedIpInPool Prelude.Text
putDedicatedIpInPool_destinationPoolName :: Lens' PutDedicatedIpInPool Text
putDedicatedIpInPool_destinationPoolName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutDedicatedIpInPool' {Text
destinationPoolName :: Text
$sel:destinationPoolName:PutDedicatedIpInPool' :: PutDedicatedIpInPool -> Text
destinationPoolName} -> Text
destinationPoolName) (\s :: PutDedicatedIpInPool
s@PutDedicatedIpInPool' {} Text
a -> PutDedicatedIpInPool
s {$sel:destinationPoolName:PutDedicatedIpInPool' :: Text
destinationPoolName = Text
a} :: PutDedicatedIpInPool)

instance Core.AWSRequest PutDedicatedIpInPool where
  type
    AWSResponse PutDedicatedIpInPool =
      PutDedicatedIpInPoolResponse
  request :: (Service -> Service)
-> PutDedicatedIpInPool -> Request PutDedicatedIpInPool
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy PutDedicatedIpInPool
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutDedicatedIpInPool)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> PutDedicatedIpInPoolResponse
PutDedicatedIpInPoolResponse'
            forall (f :: * -> *) a b. Functor 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 PutDedicatedIpInPool where
  hashWithSalt :: Int -> PutDedicatedIpInPool -> Int
hashWithSalt Int
_salt PutDedicatedIpInPool' {Text
destinationPoolName :: Text
ip :: Text
$sel:destinationPoolName:PutDedicatedIpInPool' :: PutDedicatedIpInPool -> Text
$sel:ip:PutDedicatedIpInPool' :: PutDedicatedIpInPool -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
ip
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
destinationPoolName

instance Prelude.NFData PutDedicatedIpInPool where
  rnf :: PutDedicatedIpInPool -> ()
rnf PutDedicatedIpInPool' {Text
destinationPoolName :: Text
ip :: Text
$sel:destinationPoolName:PutDedicatedIpInPool' :: PutDedicatedIpInPool -> Text
$sel:ip:PutDedicatedIpInPool' :: PutDedicatedIpInPool -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
ip
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
destinationPoolName

instance Data.ToHeaders PutDedicatedIpInPool where
  toHeaders :: PutDedicatedIpInPool -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON PutDedicatedIpInPool where
  toJSON :: PutDedicatedIpInPool -> Value
toJSON PutDedicatedIpInPool' {Text
destinationPoolName :: Text
ip :: Text
$sel:destinationPoolName:PutDedicatedIpInPool' :: PutDedicatedIpInPool -> Text
$sel:ip:PutDedicatedIpInPool' :: PutDedicatedIpInPool -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"DestinationPoolName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
destinationPoolName)
          ]
      )

instance Data.ToPath PutDedicatedIpInPool where
  toPath :: PutDedicatedIpInPool -> ByteString
toPath PutDedicatedIpInPool' {Text
destinationPoolName :: Text
ip :: Text
$sel:destinationPoolName:PutDedicatedIpInPool' :: PutDedicatedIpInPool -> Text
$sel:ip:PutDedicatedIpInPool' :: PutDedicatedIpInPool -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/email/dedicated-ips/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
ip, ByteString
"/pool"]

instance Data.ToQuery PutDedicatedIpInPool where
  toQuery :: PutDedicatedIpInPool -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | An HTTP 200 response if the request succeeds, or an error message if the
-- request fails.
--
-- /See:/ 'newPutDedicatedIpInPoolResponse' smart constructor.
data PutDedicatedIpInPoolResponse = PutDedicatedIpInPoolResponse'
  { -- | The response's http status code.
    PutDedicatedIpInPoolResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutDedicatedIpInPoolResponse
-> PutDedicatedIpInPoolResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutDedicatedIpInPoolResponse
-> PutDedicatedIpInPoolResponse -> Bool
$c/= :: PutDedicatedIpInPoolResponse
-> PutDedicatedIpInPoolResponse -> Bool
== :: PutDedicatedIpInPoolResponse
-> PutDedicatedIpInPoolResponse -> Bool
$c== :: PutDedicatedIpInPoolResponse
-> PutDedicatedIpInPoolResponse -> Bool
Prelude.Eq, ReadPrec [PutDedicatedIpInPoolResponse]
ReadPrec PutDedicatedIpInPoolResponse
Int -> ReadS PutDedicatedIpInPoolResponse
ReadS [PutDedicatedIpInPoolResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutDedicatedIpInPoolResponse]
$creadListPrec :: ReadPrec [PutDedicatedIpInPoolResponse]
readPrec :: ReadPrec PutDedicatedIpInPoolResponse
$creadPrec :: ReadPrec PutDedicatedIpInPoolResponse
readList :: ReadS [PutDedicatedIpInPoolResponse]
$creadList :: ReadS [PutDedicatedIpInPoolResponse]
readsPrec :: Int -> ReadS PutDedicatedIpInPoolResponse
$creadsPrec :: Int -> ReadS PutDedicatedIpInPoolResponse
Prelude.Read, Int -> PutDedicatedIpInPoolResponse -> ShowS
[PutDedicatedIpInPoolResponse] -> ShowS
PutDedicatedIpInPoolResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutDedicatedIpInPoolResponse] -> ShowS
$cshowList :: [PutDedicatedIpInPoolResponse] -> ShowS
show :: PutDedicatedIpInPoolResponse -> String
$cshow :: PutDedicatedIpInPoolResponse -> String
showsPrec :: Int -> PutDedicatedIpInPoolResponse -> ShowS
$cshowsPrec :: Int -> PutDedicatedIpInPoolResponse -> ShowS
Prelude.Show, forall x.
Rep PutDedicatedIpInPoolResponse x -> PutDedicatedIpInPoolResponse
forall x.
PutDedicatedIpInPoolResponse -> Rep PutDedicatedIpInPoolResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutDedicatedIpInPoolResponse x -> PutDedicatedIpInPoolResponse
$cfrom :: forall x.
PutDedicatedIpInPoolResponse -> Rep PutDedicatedIpInPoolResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutDedicatedIpInPoolResponse' 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:
--
-- 'httpStatus', 'putDedicatedIpInPoolResponse_httpStatus' - The response's http status code.
newPutDedicatedIpInPoolResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutDedicatedIpInPoolResponse
newPutDedicatedIpInPoolResponse :: Int -> PutDedicatedIpInPoolResponse
newPutDedicatedIpInPoolResponse Int
pHttpStatus_ =
  PutDedicatedIpInPoolResponse'
    { $sel:httpStatus:PutDedicatedIpInPoolResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData PutDedicatedIpInPoolResponse where
  rnf :: PutDedicatedIpInPoolResponse -> ()
rnf PutDedicatedIpInPoolResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutDedicatedIpInPoolResponse' :: PutDedicatedIpInPoolResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus