{-# 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.CreateDedicatedIpPool
-- 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)
--
-- Create a new pool of dedicated IP addresses. A pool can include one or
-- more dedicated IP addresses that are associated with your Amazon
-- Pinpoint account. You can associate a pool with a configuration set.
-- When you send an email that uses that configuration set, Amazon Pinpoint
-- sends it using only the IP addresses in the associated pool.
module Amazonka.PinpointEmail.CreateDedicatedIpPool
  ( -- * Creating a Request
    CreateDedicatedIpPool (..),
    newCreateDedicatedIpPool,

    -- * Request Lenses
    createDedicatedIpPool_tags,
    createDedicatedIpPool_poolName,

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

    -- * Response Lenses
    createDedicatedIpPoolResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 create a new dedicated IP pool.
--
-- /See:/ 'newCreateDedicatedIpPool' smart constructor.
data CreateDedicatedIpPool = CreateDedicatedIpPool'
  { -- | 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
(CreateDedicatedIpPool -> CreateDedicatedIpPool -> Bool)
-> (CreateDedicatedIpPool -> CreateDedicatedIpPool -> Bool)
-> Eq CreateDedicatedIpPool
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]
(Int -> ReadS CreateDedicatedIpPool)
-> ReadS [CreateDedicatedIpPool]
-> ReadPrec CreateDedicatedIpPool
-> ReadPrec [CreateDedicatedIpPool]
-> Read 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
(Int -> CreateDedicatedIpPool -> ShowS)
-> (CreateDedicatedIpPool -> String)
-> ([CreateDedicatedIpPool] -> ShowS)
-> Show CreateDedicatedIpPool
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. CreateDedicatedIpPool -> Rep CreateDedicatedIpPool x)
-> (forall x. Rep CreateDedicatedIpPool x -> CreateDedicatedIpPool)
-> Generic CreateDedicatedIpPool
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:
--
-- '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' :: Maybe [Tag] -> Text -> CreateDedicatedIpPool
CreateDedicatedIpPool'
    { $sel:tags:CreateDedicatedIpPool' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:poolName:CreateDedicatedIpPool' :: Text
poolName = Text
pPoolName_
    }

-- | 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 :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateDedicatedIpPool -> f CreateDedicatedIpPool
createDedicatedIpPool_tags = (CreateDedicatedIpPool -> Maybe [Tag])
-> (CreateDedicatedIpPool -> Maybe [Tag] -> CreateDedicatedIpPool)
-> Lens
     CreateDedicatedIpPool
     CreateDedicatedIpPool
     (Maybe [Tag])
     (Maybe [Tag])
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) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> CreateDedicatedIpPool -> f CreateDedicatedIpPool)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateDedicatedIpPool
-> f CreateDedicatedIpPool
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 AnIso [Tag] [Tag] [Tag] [Tag]
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 :: (Text -> f Text)
-> CreateDedicatedIpPool -> f CreateDedicatedIpPool
createDedicatedIpPool_poolName = (CreateDedicatedIpPool -> Text)
-> (CreateDedicatedIpPool -> Text -> CreateDedicatedIpPool)
-> Lens CreateDedicatedIpPool CreateDedicatedIpPool Text Text
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 :: CreateDedicatedIpPool -> Request CreateDedicatedIpPool
request = Service -> CreateDedicatedIpPool -> Request CreateDedicatedIpPool
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateDedicatedIpPool
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateDedicatedIpPool)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse CreateDedicatedIpPool))
-> Logger
-> Service
-> Proxy CreateDedicatedIpPool
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateDedicatedIpPool)))
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 -> CreateDedicatedIpPoolResponse
CreateDedicatedIpPoolResponse'
            (Int -> CreateDedicatedIpPoolResponse)
-> Either String Int -> Either String CreateDedicatedIpPoolResponse
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 CreateDedicatedIpPool

instance Prelude.NFData CreateDedicatedIpPool

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

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

instance Core.ToQuery CreateDedicatedIpPool where
  toQuery :: CreateDedicatedIpPool -> QueryString
toQuery = QueryString -> CreateDedicatedIpPool -> 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:/ 'newCreateDedicatedIpPoolResponse' smart constructor.
data CreateDedicatedIpPoolResponse = CreateDedicatedIpPoolResponse'
  { -- | The response's http status code.
    CreateDedicatedIpPoolResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateDedicatedIpPoolResponse
-> CreateDedicatedIpPoolResponse -> Bool
(CreateDedicatedIpPoolResponse
 -> CreateDedicatedIpPoolResponse -> Bool)
-> (CreateDedicatedIpPoolResponse
    -> CreateDedicatedIpPoolResponse -> Bool)
-> Eq CreateDedicatedIpPoolResponse
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]
(Int -> ReadS CreateDedicatedIpPoolResponse)
-> ReadS [CreateDedicatedIpPoolResponse]
-> ReadPrec CreateDedicatedIpPoolResponse
-> ReadPrec [CreateDedicatedIpPoolResponse]
-> Read 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
(Int -> CreateDedicatedIpPoolResponse -> ShowS)
-> (CreateDedicatedIpPoolResponse -> String)
-> ([CreateDedicatedIpPoolResponse] -> ShowS)
-> Show CreateDedicatedIpPoolResponse
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.
 CreateDedicatedIpPoolResponse
 -> Rep CreateDedicatedIpPoolResponse x)
-> (forall x.
    Rep CreateDedicatedIpPoolResponse x
    -> CreateDedicatedIpPoolResponse)
-> Generic CreateDedicatedIpPoolResponse
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' :: Int -> CreateDedicatedIpPoolResponse
CreateDedicatedIpPoolResponse'
    { $sel:httpStatus:CreateDedicatedIpPoolResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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