{-# 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-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)
--
-- 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.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 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
(GetDedicatedIp -> GetDedicatedIp -> Bool)
-> (GetDedicatedIp -> GetDedicatedIp -> Bool) -> Eq GetDedicatedIp
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]
(Int -> ReadS GetDedicatedIp)
-> ReadS [GetDedicatedIp]
-> ReadPrec GetDedicatedIp
-> ReadPrec [GetDedicatedIp]
-> Read 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
(Int -> GetDedicatedIp -> ShowS)
-> (GetDedicatedIp -> String)
-> ([GetDedicatedIp] -> ShowS)
-> Show GetDedicatedIp
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. GetDedicatedIp -> Rep GetDedicatedIp x)
-> (forall x. Rep GetDedicatedIp x -> GetDedicatedIp)
-> Generic GetDedicatedIp
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' :: Text -> GetDedicatedIp
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 :: (Text -> f Text) -> GetDedicatedIp -> f GetDedicatedIp
getDedicatedIp_ip = (GetDedicatedIp -> Text)
-> (GetDedicatedIp -> Text -> GetDedicatedIp)
-> Lens GetDedicatedIp GetDedicatedIp Text Text
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 :: GetDedicatedIp -> Request GetDedicatedIp
request = Service -> GetDedicatedIp -> Request GetDedicatedIp
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetDedicatedIp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDedicatedIp)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetDedicatedIp))
-> Logger
-> Service
-> Proxy GetDedicatedIp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDedicatedIp)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe DedicatedIp -> Int -> GetDedicatedIpResponse
GetDedicatedIpResponse'
            (Maybe DedicatedIp -> Int -> GetDedicatedIpResponse)
-> Either String (Maybe DedicatedIp)
-> Either String (Int -> GetDedicatedIpResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe DedicatedIp)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"DedicatedIp")
            Either String (Int -> GetDedicatedIpResponse)
-> Either String Int -> Either String GetDedicatedIpResponse
forall (f :: * -> *) a b. Applicative f => 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 GetDedicatedIp

instance Prelude.NFData GetDedicatedIp

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

instance Core.ToQuery GetDedicatedIp where
  toQuery :: GetDedicatedIp -> QueryString
toQuery = QueryString -> GetDedicatedIp -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(GetDedicatedIpResponse -> GetDedicatedIpResponse -> Bool)
-> (GetDedicatedIpResponse -> GetDedicatedIpResponse -> Bool)
-> Eq GetDedicatedIpResponse
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]
(Int -> ReadS GetDedicatedIpResponse)
-> ReadS [GetDedicatedIpResponse]
-> ReadPrec GetDedicatedIpResponse
-> ReadPrec [GetDedicatedIpResponse]
-> Read 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
(Int -> GetDedicatedIpResponse -> ShowS)
-> (GetDedicatedIpResponse -> String)
-> ([GetDedicatedIpResponse] -> ShowS)
-> Show GetDedicatedIpResponse
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. GetDedicatedIpResponse -> Rep GetDedicatedIpResponse x)
-> (forall x.
    Rep GetDedicatedIpResponse x -> GetDedicatedIpResponse)
-> Generic GetDedicatedIpResponse
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' :: Maybe DedicatedIp -> Int -> GetDedicatedIpResponse
GetDedicatedIpResponse'
    { $sel:dedicatedIp:GetDedicatedIpResponse' :: Maybe DedicatedIp
dedicatedIp =
        Maybe 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 :: (Maybe DedicatedIp -> f (Maybe DedicatedIp))
-> GetDedicatedIpResponse -> f GetDedicatedIpResponse
getDedicatedIpResponse_dedicatedIp = (GetDedicatedIpResponse -> Maybe DedicatedIp)
-> (GetDedicatedIpResponse
    -> Maybe DedicatedIp -> GetDedicatedIpResponse)
-> Lens
     GetDedicatedIpResponse
     GetDedicatedIpResponse
     (Maybe DedicatedIp)
     (Maybe 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 :: (Int -> f Int)
-> GetDedicatedIpResponse -> f GetDedicatedIpResponse
getDedicatedIpResponse_httpStatus = (GetDedicatedIpResponse -> Int)
-> (GetDedicatedIpResponse -> Int -> GetDedicatedIpResponse)
-> Lens GetDedicatedIpResponse GetDedicatedIpResponse Int Int
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