{-# 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.CreateDedicatedIpPool
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Create a new pool of dedicated IP addresses. A pool can include one or
-- more dedicated IP addresses that are associated with your Amazon Web
-- Services account. You can associate a pool with a configuration set.
-- When you send an email that uses that configuration set, the message is
-- sent from one of the addresses in the associated pool.
module Amazonka.SESV2.CreateDedicatedIpPool
  ( -- * Creating a Request
    CreateDedicatedIpPool (..),
    newCreateDedicatedIpPool,

    -- * Request Lenses
    createDedicatedIpPool_scalingMode,
    createDedicatedIpPool_tags,
    createDedicatedIpPool_poolName,

    -- * Destructuring the Response
    CreateDedicatedIpPoolResponse (..),
    newCreateDedicatedIpPoolResponse,

    -- * Response Lenses
    createDedicatedIpPoolResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 create a new dedicated IP pool.
--
-- /See:/ 'newCreateDedicatedIpPool' smart constructor.
data CreateDedicatedIpPool = CreateDedicatedIpPool'
  { -- | The type of scaling mode.
    CreateDedicatedIpPool -> Maybe ScalingMode
scalingMode :: Prelude.Maybe ScalingMode,
    -- | An object that defines the tags (keys and values) that you want to
    -- associate with the pool.
    CreateDedicatedIpPool -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The name of the dedicated IP pool.
    CreateDedicatedIpPool -> Text
poolName :: Prelude.Text
  }
  deriving (CreateDedicatedIpPool -> CreateDedicatedIpPool -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDedicatedIpPool -> CreateDedicatedIpPool -> Bool
$c/= :: CreateDedicatedIpPool -> CreateDedicatedIpPool -> Bool
== :: CreateDedicatedIpPool -> CreateDedicatedIpPool -> Bool
$c== :: CreateDedicatedIpPool -> CreateDedicatedIpPool -> Bool
Prelude.Eq, ReadPrec [CreateDedicatedIpPool]
ReadPrec CreateDedicatedIpPool
Int -> ReadS CreateDedicatedIpPool
ReadS [CreateDedicatedIpPool]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDedicatedIpPool]
$creadListPrec :: ReadPrec [CreateDedicatedIpPool]
readPrec :: ReadPrec CreateDedicatedIpPool
$creadPrec :: ReadPrec CreateDedicatedIpPool
readList :: ReadS [CreateDedicatedIpPool]
$creadList :: ReadS [CreateDedicatedIpPool]
readsPrec :: Int -> ReadS CreateDedicatedIpPool
$creadsPrec :: Int -> ReadS CreateDedicatedIpPool
Prelude.Read, Int -> CreateDedicatedIpPool -> ShowS
[CreateDedicatedIpPool] -> ShowS
CreateDedicatedIpPool -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDedicatedIpPool] -> ShowS
$cshowList :: [CreateDedicatedIpPool] -> ShowS
show :: CreateDedicatedIpPool -> String
$cshow :: CreateDedicatedIpPool -> String
showsPrec :: Int -> CreateDedicatedIpPool -> ShowS
$cshowsPrec :: Int -> CreateDedicatedIpPool -> ShowS
Prelude.Show, forall x. Rep CreateDedicatedIpPool x -> CreateDedicatedIpPool
forall x. CreateDedicatedIpPool -> Rep CreateDedicatedIpPool x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateDedicatedIpPool x -> CreateDedicatedIpPool
$cfrom :: forall x. CreateDedicatedIpPool -> Rep CreateDedicatedIpPool x
Prelude.Generic)

-- |
-- Create a value of 'CreateDedicatedIpPool' 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:
--
-- 'scalingMode', 'createDedicatedIpPool_scalingMode' - The type of scaling mode.
--
-- 'tags', 'createDedicatedIpPool_tags' - An object that defines the tags (keys and values) that you want to
-- associate with the pool.
--
-- 'poolName', 'createDedicatedIpPool_poolName' - The name of the dedicated IP pool.
newCreateDedicatedIpPool ::
  -- | 'poolName'
  Prelude.Text ->
  CreateDedicatedIpPool
newCreateDedicatedIpPool :: Text -> CreateDedicatedIpPool
newCreateDedicatedIpPool Text
pPoolName_ =
  CreateDedicatedIpPool'
    { $sel:scalingMode:CreateDedicatedIpPool' :: Maybe ScalingMode
scalingMode =
        forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateDedicatedIpPool' :: Maybe [Tag]
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:poolName:CreateDedicatedIpPool' :: Text
poolName = Text
pPoolName_
    }

-- | The type of scaling mode.
createDedicatedIpPool_scalingMode :: Lens.Lens' CreateDedicatedIpPool (Prelude.Maybe ScalingMode)
createDedicatedIpPool_scalingMode :: Lens' CreateDedicatedIpPool (Maybe ScalingMode)
createDedicatedIpPool_scalingMode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDedicatedIpPool' {Maybe ScalingMode
scalingMode :: Maybe ScalingMode
$sel:scalingMode:CreateDedicatedIpPool' :: CreateDedicatedIpPool -> Maybe ScalingMode
scalingMode} -> Maybe ScalingMode
scalingMode) (\s :: CreateDedicatedIpPool
s@CreateDedicatedIpPool' {} Maybe ScalingMode
a -> CreateDedicatedIpPool
s {$sel:scalingMode:CreateDedicatedIpPool' :: Maybe ScalingMode
scalingMode = Maybe ScalingMode
a} :: CreateDedicatedIpPool)

-- | An object that defines the tags (keys and values) that you want to
-- associate with the pool.
createDedicatedIpPool_tags :: Lens.Lens' CreateDedicatedIpPool (Prelude.Maybe [Tag])
createDedicatedIpPool_tags :: Lens' CreateDedicatedIpPool (Maybe [Tag])
createDedicatedIpPool_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDedicatedIpPool' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateDedicatedIpPool' :: CreateDedicatedIpPool -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateDedicatedIpPool
s@CreateDedicatedIpPool' {} Maybe [Tag]
a -> CreateDedicatedIpPool
s {$sel:tags:CreateDedicatedIpPool' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateDedicatedIpPool) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the dedicated IP pool.
createDedicatedIpPool_poolName :: Lens.Lens' CreateDedicatedIpPool Prelude.Text
createDedicatedIpPool_poolName :: Lens' CreateDedicatedIpPool Text
createDedicatedIpPool_poolName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDedicatedIpPool' {Text
poolName :: Text
$sel:poolName:CreateDedicatedIpPool' :: CreateDedicatedIpPool -> Text
poolName} -> Text
poolName) (\s :: CreateDedicatedIpPool
s@CreateDedicatedIpPool' {} Text
a -> CreateDedicatedIpPool
s {$sel:poolName:CreateDedicatedIpPool' :: Text
poolName = Text
a} :: CreateDedicatedIpPool)

instance Core.AWSRequest CreateDedicatedIpPool where
  type
    AWSResponse CreateDedicatedIpPool =
      CreateDedicatedIpPoolResponse
  request :: (Service -> Service)
-> CreateDedicatedIpPool -> Request CreateDedicatedIpPool
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateDedicatedIpPool
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateDedicatedIpPool)))
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 -> CreateDedicatedIpPoolResponse
CreateDedicatedIpPoolResponse'
            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 CreateDedicatedIpPool where
  hashWithSalt :: Int -> CreateDedicatedIpPool -> Int
hashWithSalt Int
_salt CreateDedicatedIpPool' {Maybe [Tag]
Maybe ScalingMode
Text
poolName :: Text
tags :: Maybe [Tag]
scalingMode :: Maybe ScalingMode
$sel:poolName:CreateDedicatedIpPool' :: CreateDedicatedIpPool -> Text
$sel:tags:CreateDedicatedIpPool' :: CreateDedicatedIpPool -> Maybe [Tag]
$sel:scalingMode:CreateDedicatedIpPool' :: CreateDedicatedIpPool -> Maybe ScalingMode
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ScalingMode
scalingMode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
poolName

instance Prelude.NFData CreateDedicatedIpPool where
  rnf :: CreateDedicatedIpPool -> ()
rnf CreateDedicatedIpPool' {Maybe [Tag]
Maybe ScalingMode
Text
poolName :: Text
tags :: Maybe [Tag]
scalingMode :: Maybe ScalingMode
$sel:poolName:CreateDedicatedIpPool' :: CreateDedicatedIpPool -> Text
$sel:tags:CreateDedicatedIpPool' :: CreateDedicatedIpPool -> Maybe [Tag]
$sel:scalingMode:CreateDedicatedIpPool' :: CreateDedicatedIpPool -> Maybe ScalingMode
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ScalingMode
scalingMode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
poolName

instance Data.ToHeaders CreateDedicatedIpPool where
  toHeaders :: CreateDedicatedIpPool -> 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 CreateDedicatedIpPool where
  toJSON :: CreateDedicatedIpPool -> Value
toJSON CreateDedicatedIpPool' {Maybe [Tag]
Maybe ScalingMode
Text
poolName :: Text
tags :: Maybe [Tag]
scalingMode :: Maybe ScalingMode
$sel:poolName:CreateDedicatedIpPool' :: CreateDedicatedIpPool -> Text
$sel:tags:CreateDedicatedIpPool' :: CreateDedicatedIpPool -> Maybe [Tag]
$sel:scalingMode:CreateDedicatedIpPool' :: CreateDedicatedIpPool -> Maybe ScalingMode
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ScalingMode" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ScalingMode
scalingMode,
            (Key
"Tags" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
            forall a. a -> Maybe a
Prelude.Just (Key
"PoolName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
poolName)
          ]
      )

instance Data.ToPath CreateDedicatedIpPool where
  toPath :: CreateDedicatedIpPool -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/v2/email/dedicated-ip-pools"

instance Data.ToQuery CreateDedicatedIpPool where
  toQuery :: CreateDedicatedIpPool -> 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:/ 'newCreateDedicatedIpPoolResponse' smart constructor.
data CreateDedicatedIpPoolResponse = CreateDedicatedIpPoolResponse'
  { -- | The response's http status code.
    CreateDedicatedIpPoolResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateDedicatedIpPoolResponse
-> CreateDedicatedIpPoolResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDedicatedIpPoolResponse
-> CreateDedicatedIpPoolResponse -> Bool
$c/= :: CreateDedicatedIpPoolResponse
-> CreateDedicatedIpPoolResponse -> Bool
== :: CreateDedicatedIpPoolResponse
-> CreateDedicatedIpPoolResponse -> Bool
$c== :: CreateDedicatedIpPoolResponse
-> CreateDedicatedIpPoolResponse -> Bool
Prelude.Eq, ReadPrec [CreateDedicatedIpPoolResponse]
ReadPrec CreateDedicatedIpPoolResponse
Int -> ReadS CreateDedicatedIpPoolResponse
ReadS [CreateDedicatedIpPoolResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDedicatedIpPoolResponse]
$creadListPrec :: ReadPrec [CreateDedicatedIpPoolResponse]
readPrec :: ReadPrec CreateDedicatedIpPoolResponse
$creadPrec :: ReadPrec CreateDedicatedIpPoolResponse
readList :: ReadS [CreateDedicatedIpPoolResponse]
$creadList :: ReadS [CreateDedicatedIpPoolResponse]
readsPrec :: Int -> ReadS CreateDedicatedIpPoolResponse
$creadsPrec :: Int -> ReadS CreateDedicatedIpPoolResponse
Prelude.Read, Int -> CreateDedicatedIpPoolResponse -> ShowS
[CreateDedicatedIpPoolResponse] -> ShowS
CreateDedicatedIpPoolResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDedicatedIpPoolResponse] -> ShowS
$cshowList :: [CreateDedicatedIpPoolResponse] -> ShowS
show :: CreateDedicatedIpPoolResponse -> String
$cshow :: CreateDedicatedIpPoolResponse -> String
showsPrec :: Int -> CreateDedicatedIpPoolResponse -> ShowS
$cshowsPrec :: Int -> CreateDedicatedIpPoolResponse -> ShowS
Prelude.Show, forall x.
Rep CreateDedicatedIpPoolResponse x
-> CreateDedicatedIpPoolResponse
forall x.
CreateDedicatedIpPoolResponse
-> Rep CreateDedicatedIpPoolResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateDedicatedIpPoolResponse x
-> CreateDedicatedIpPoolResponse
$cfrom :: forall x.
CreateDedicatedIpPoolResponse
-> Rep CreateDedicatedIpPoolResponse x
Prelude.Generic)

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

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

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