{-# 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.SESV2.PutDedicatedIpInPool
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- 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 Web Services account.
--
-- The dedicated IP pool you specify must already exist. You can create a
-- new pool by using the @CreateDedicatedIpPool@ operation.
module Amazonka.SESV2.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.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SESV2.Types

-- | 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 Web Services 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
(PutDedicatedIpInPool -> PutDedicatedIpInPool -> Bool)
-> (PutDedicatedIpInPool -> PutDedicatedIpInPool -> Bool)
-> Eq PutDedicatedIpInPool
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]
(Int -> ReadS PutDedicatedIpInPool)
-> ReadS [PutDedicatedIpInPool]
-> ReadPrec PutDedicatedIpInPool
-> ReadPrec [PutDedicatedIpInPool]
-> Read 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
(Int -> PutDedicatedIpInPool -> ShowS)
-> (PutDedicatedIpInPool -> String)
-> ([PutDedicatedIpInPool] -> ShowS)
-> Show PutDedicatedIpInPool
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. PutDedicatedIpInPool -> Rep PutDedicatedIpInPool x)
-> (forall x. Rep PutDedicatedIpInPool x -> PutDedicatedIpInPool)
-> Generic PutDedicatedIpInPool
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 Web Services 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' :: Text -> Text -> PutDedicatedIpInPool
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 Web Services account.
putDedicatedIpInPool_ip :: Lens.Lens' PutDedicatedIpInPool Prelude.Text
putDedicatedIpInPool_ip :: (Text -> f Text) -> PutDedicatedIpInPool -> f PutDedicatedIpInPool
putDedicatedIpInPool_ip = (PutDedicatedIpInPool -> Text)
-> (PutDedicatedIpInPool -> Text -> PutDedicatedIpInPool)
-> Lens PutDedicatedIpInPool PutDedicatedIpInPool Text Text
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 :: (Text -> f Text) -> PutDedicatedIpInPool -> f PutDedicatedIpInPool
putDedicatedIpInPool_destinationPoolName = (PutDedicatedIpInPool -> Text)
-> (PutDedicatedIpInPool -> Text -> PutDedicatedIpInPool)
-> Lens PutDedicatedIpInPool PutDedicatedIpInPool Text Text
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 :: PutDedicatedIpInPool -> Request PutDedicatedIpInPool
request = Service -> PutDedicatedIpInPool -> Request PutDedicatedIpInPool
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutDedicatedIpInPool
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutDedicatedIpInPool)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse PutDedicatedIpInPool))
-> Logger
-> Service
-> Proxy PutDedicatedIpInPool
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutDedicatedIpInPool)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> PutDedicatedIpInPoolResponse
PutDedicatedIpInPoolResponse'
            (Int -> PutDedicatedIpInPoolResponse)
-> Either String Int -> Either String PutDedicatedIpInPoolResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable PutDedicatedIpInPool

instance Prelude.NFData PutDedicatedIpInPool

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

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"DestinationPoolName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
destinationPoolName)
          ]
      )

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

instance Core.ToQuery PutDedicatedIpInPool where
  toQuery :: PutDedicatedIpInPool -> QueryString
toQuery = QueryString -> PutDedicatedIpInPool -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(PutDedicatedIpInPoolResponse
 -> PutDedicatedIpInPoolResponse -> Bool)
-> (PutDedicatedIpInPoolResponse
    -> PutDedicatedIpInPoolResponse -> Bool)
-> Eq PutDedicatedIpInPoolResponse
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]
(Int -> ReadS PutDedicatedIpInPoolResponse)
-> ReadS [PutDedicatedIpInPoolResponse]
-> ReadPrec PutDedicatedIpInPoolResponse
-> ReadPrec [PutDedicatedIpInPoolResponse]
-> Read 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
(Int -> PutDedicatedIpInPoolResponse -> ShowS)
-> (PutDedicatedIpInPoolResponse -> String)
-> ([PutDedicatedIpInPoolResponse] -> ShowS)
-> Show PutDedicatedIpInPoolResponse
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.
 PutDedicatedIpInPoolResponse -> Rep PutDedicatedIpInPoolResponse x)
-> (forall x.
    Rep PutDedicatedIpInPoolResponse x -> PutDedicatedIpInPoolResponse)
-> Generic PutDedicatedIpInPoolResponse
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' :: Int -> PutDedicatedIpInPoolResponse
PutDedicatedIpInPoolResponse'
    { $sel:httpStatus:PutDedicatedIpInPoolResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
putDedicatedIpInPoolResponse_httpStatus :: Lens.Lens' PutDedicatedIpInPoolResponse Prelude.Int
putDedicatedIpInPoolResponse_httpStatus :: (Int -> f Int)
-> PutDedicatedIpInPoolResponse -> f PutDedicatedIpInPoolResponse
putDedicatedIpInPoolResponse_httpStatus = (PutDedicatedIpInPoolResponse -> Int)
-> (PutDedicatedIpInPoolResponse
    -> Int -> PutDedicatedIpInPoolResponse)
-> Lens
     PutDedicatedIpInPoolResponse PutDedicatedIpInPoolResponse Int Int
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