{-# 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.GetDedicatedIp
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Get information about a dedicated IP address, including the name of the
-- dedicated IP pool that it\'s associated with, as well information about
-- the automatic warm-up process for the address.
module Amazonka.PinpointEmail.GetDedicatedIp
  ( -- * Creating a Request
    GetDedicatedIp (..),
    newGetDedicatedIp,

    -- * Request Lenses
    getDedicatedIp_ip,

    -- * Destructuring the Response
    GetDedicatedIpResponse (..),
    newGetDedicatedIpResponse,

    -- * Response Lenses
    getDedicatedIpResponse_dedicatedIp,
    getDedicatedIpResponse_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 obtain more information about a dedicated IP address.
--
-- /See:/ 'newGetDedicatedIp' smart constructor.
data GetDedicatedIp = GetDedicatedIp'
  { -- | The IP address that you want to obtain more information about. The value
    -- you specify has to be a dedicated IP address that\'s assocaited with
    -- your Amazon Pinpoint account.
    GetDedicatedIp -> Text
ip :: Prelude.Text
  }
  deriving (GetDedicatedIp -> GetDedicatedIp -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDedicatedIp -> GetDedicatedIp -> Bool
$c/= :: GetDedicatedIp -> GetDedicatedIp -> Bool
== :: GetDedicatedIp -> GetDedicatedIp -> Bool
$c== :: GetDedicatedIp -> GetDedicatedIp -> Bool
Prelude.Eq, ReadPrec [GetDedicatedIp]
ReadPrec GetDedicatedIp
Int -> ReadS GetDedicatedIp
ReadS [GetDedicatedIp]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDedicatedIp]
$creadListPrec :: ReadPrec [GetDedicatedIp]
readPrec :: ReadPrec GetDedicatedIp
$creadPrec :: ReadPrec GetDedicatedIp
readList :: ReadS [GetDedicatedIp]
$creadList :: ReadS [GetDedicatedIp]
readsPrec :: Int -> ReadS GetDedicatedIp
$creadsPrec :: Int -> ReadS GetDedicatedIp
Prelude.Read, Int -> GetDedicatedIp -> ShowS
[GetDedicatedIp] -> ShowS
GetDedicatedIp -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDedicatedIp] -> ShowS
$cshowList :: [GetDedicatedIp] -> ShowS
show :: GetDedicatedIp -> String
$cshow :: GetDedicatedIp -> String
showsPrec :: Int -> GetDedicatedIp -> ShowS
$cshowsPrec :: Int -> GetDedicatedIp -> ShowS
Prelude.Show, forall x. Rep GetDedicatedIp x -> GetDedicatedIp
forall x. GetDedicatedIp -> Rep GetDedicatedIp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDedicatedIp x -> GetDedicatedIp
$cfrom :: forall x. GetDedicatedIp -> Rep GetDedicatedIp x
Prelude.Generic)

-- |
-- Create a value of 'GetDedicatedIp' 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', 'getDedicatedIp_ip' - The IP address that you want to obtain more information about. The value
-- you specify has to be a dedicated IP address that\'s assocaited with
-- your Amazon Pinpoint account.
newGetDedicatedIp ::
  -- | 'ip'
  Prelude.Text ->
  GetDedicatedIp
newGetDedicatedIp :: Text -> GetDedicatedIp
newGetDedicatedIp Text
pIp_ = GetDedicatedIp' {$sel:ip:GetDedicatedIp' :: Text
ip = Text
pIp_}

-- | The IP address that you want to obtain more information about. The value
-- you specify has to be a dedicated IP address that\'s assocaited with
-- your Amazon Pinpoint account.
getDedicatedIp_ip :: Lens.Lens' GetDedicatedIp Prelude.Text
getDedicatedIp_ip :: Lens' GetDedicatedIp Text
getDedicatedIp_ip = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDedicatedIp' {Text
ip :: Text
$sel:ip:GetDedicatedIp' :: GetDedicatedIp -> Text
ip} -> Text
ip) (\s :: GetDedicatedIp
s@GetDedicatedIp' {} Text
a -> GetDedicatedIp
s {$sel:ip:GetDedicatedIp' :: Text
ip = Text
a} :: GetDedicatedIp)

instance Core.AWSRequest GetDedicatedIp where
  type
    AWSResponse GetDedicatedIp =
      GetDedicatedIpResponse
  request :: (Service -> Service) -> GetDedicatedIp -> Request GetDedicatedIp
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetDedicatedIp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDedicatedIp)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe DedicatedIp -> Int -> GetDedicatedIpResponse
GetDedicatedIpResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"DedicatedIp")
            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 GetDedicatedIp where
  hashWithSalt :: Int -> GetDedicatedIp -> Int
hashWithSalt Int
_salt GetDedicatedIp' {Text
ip :: Text
$sel:ip:GetDedicatedIp' :: GetDedicatedIp -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
ip

instance Prelude.NFData GetDedicatedIp where
  rnf :: GetDedicatedIp -> ()
rnf GetDedicatedIp' {Text
ip :: Text
$sel:ip:GetDedicatedIp' :: GetDedicatedIp -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
ip

instance Data.ToHeaders GetDedicatedIp where
  toHeaders :: GetDedicatedIp -> 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.ToPath GetDedicatedIp where
  toPath :: GetDedicatedIp -> ByteString
toPath GetDedicatedIp' {Text
ip :: Text
$sel:ip:GetDedicatedIp' :: GetDedicatedIp -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/email/dedicated-ips/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
ip]

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

-- | Information about a dedicated IP address.
--
-- /See:/ 'newGetDedicatedIpResponse' smart constructor.
data GetDedicatedIpResponse = GetDedicatedIpResponse'
  { -- | An object that contains information about a dedicated IP address.
    GetDedicatedIpResponse -> Maybe DedicatedIp
dedicatedIp :: Prelude.Maybe DedicatedIp,
    -- | The response's http status code.
    GetDedicatedIpResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetDedicatedIpResponse -> GetDedicatedIpResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDedicatedIpResponse -> GetDedicatedIpResponse -> Bool
$c/= :: GetDedicatedIpResponse -> GetDedicatedIpResponse -> Bool
== :: GetDedicatedIpResponse -> GetDedicatedIpResponse -> Bool
$c== :: GetDedicatedIpResponse -> GetDedicatedIpResponse -> Bool
Prelude.Eq, ReadPrec [GetDedicatedIpResponse]
ReadPrec GetDedicatedIpResponse
Int -> ReadS GetDedicatedIpResponse
ReadS [GetDedicatedIpResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDedicatedIpResponse]
$creadListPrec :: ReadPrec [GetDedicatedIpResponse]
readPrec :: ReadPrec GetDedicatedIpResponse
$creadPrec :: ReadPrec GetDedicatedIpResponse
readList :: ReadS [GetDedicatedIpResponse]
$creadList :: ReadS [GetDedicatedIpResponse]
readsPrec :: Int -> ReadS GetDedicatedIpResponse
$creadsPrec :: Int -> ReadS GetDedicatedIpResponse
Prelude.Read, Int -> GetDedicatedIpResponse -> ShowS
[GetDedicatedIpResponse] -> ShowS
GetDedicatedIpResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDedicatedIpResponse] -> ShowS
$cshowList :: [GetDedicatedIpResponse] -> ShowS
show :: GetDedicatedIpResponse -> String
$cshow :: GetDedicatedIpResponse -> String
showsPrec :: Int -> GetDedicatedIpResponse -> ShowS
$cshowsPrec :: Int -> GetDedicatedIpResponse -> ShowS
Prelude.Show, forall x. Rep GetDedicatedIpResponse x -> GetDedicatedIpResponse
forall x. GetDedicatedIpResponse -> Rep GetDedicatedIpResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDedicatedIpResponse x -> GetDedicatedIpResponse
$cfrom :: forall x. GetDedicatedIpResponse -> Rep GetDedicatedIpResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDedicatedIpResponse' 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:
--
-- 'dedicatedIp', 'getDedicatedIpResponse_dedicatedIp' - An object that contains information about a dedicated IP address.
--
-- 'httpStatus', 'getDedicatedIpResponse_httpStatus' - The response's http status code.
newGetDedicatedIpResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDedicatedIpResponse
newGetDedicatedIpResponse :: Int -> GetDedicatedIpResponse
newGetDedicatedIpResponse Int
pHttpStatus_ =
  GetDedicatedIpResponse'
    { $sel:dedicatedIp:GetDedicatedIpResponse' :: Maybe DedicatedIp
dedicatedIp =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetDedicatedIpResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An object that contains information about a dedicated IP address.
getDedicatedIpResponse_dedicatedIp :: Lens.Lens' GetDedicatedIpResponse (Prelude.Maybe DedicatedIp)
getDedicatedIpResponse_dedicatedIp :: Lens' GetDedicatedIpResponse (Maybe DedicatedIp)
getDedicatedIpResponse_dedicatedIp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDedicatedIpResponse' {Maybe DedicatedIp
dedicatedIp :: Maybe DedicatedIp
$sel:dedicatedIp:GetDedicatedIpResponse' :: GetDedicatedIpResponse -> Maybe DedicatedIp
dedicatedIp} -> Maybe DedicatedIp
dedicatedIp) (\s :: GetDedicatedIpResponse
s@GetDedicatedIpResponse' {} Maybe DedicatedIp
a -> GetDedicatedIpResponse
s {$sel:dedicatedIp:GetDedicatedIpResponse' :: Maybe DedicatedIp
dedicatedIp = Maybe DedicatedIp
a} :: GetDedicatedIpResponse)

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

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