{-# 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.Route53Resolver.GetResolverEndpoint
-- 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)
--
-- Gets information about a specified Resolver endpoint, such as whether
-- it\'s an inbound or an outbound Resolver endpoint, and the current
-- status of the endpoint.
module Amazonka.Route53Resolver.GetResolverEndpoint
  ( -- * Creating a Request
    GetResolverEndpoint (..),
    newGetResolverEndpoint,

    -- * Request Lenses
    getResolverEndpoint_resolverEndpointId,

    -- * Destructuring the Response
    GetResolverEndpointResponse (..),
    newGetResolverEndpointResponse,

    -- * Response Lenses
    getResolverEndpointResponse_resolverEndpoint,
    getResolverEndpointResponse_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.Route53Resolver.Types

-- | /See:/ 'newGetResolverEndpoint' smart constructor.
data GetResolverEndpoint = GetResolverEndpoint'
  { -- | The ID of the Resolver endpoint that you want to get information about.
    GetResolverEndpoint -> Text
resolverEndpointId :: Prelude.Text
  }
  deriving (GetResolverEndpoint -> GetResolverEndpoint -> Bool
(GetResolverEndpoint -> GetResolverEndpoint -> Bool)
-> (GetResolverEndpoint -> GetResolverEndpoint -> Bool)
-> Eq GetResolverEndpoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetResolverEndpoint -> GetResolverEndpoint -> Bool
$c/= :: GetResolverEndpoint -> GetResolverEndpoint -> Bool
== :: GetResolverEndpoint -> GetResolverEndpoint -> Bool
$c== :: GetResolverEndpoint -> GetResolverEndpoint -> Bool
Prelude.Eq, ReadPrec [GetResolverEndpoint]
ReadPrec GetResolverEndpoint
Int -> ReadS GetResolverEndpoint
ReadS [GetResolverEndpoint]
(Int -> ReadS GetResolverEndpoint)
-> ReadS [GetResolverEndpoint]
-> ReadPrec GetResolverEndpoint
-> ReadPrec [GetResolverEndpoint]
-> Read GetResolverEndpoint
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetResolverEndpoint]
$creadListPrec :: ReadPrec [GetResolverEndpoint]
readPrec :: ReadPrec GetResolverEndpoint
$creadPrec :: ReadPrec GetResolverEndpoint
readList :: ReadS [GetResolverEndpoint]
$creadList :: ReadS [GetResolverEndpoint]
readsPrec :: Int -> ReadS GetResolverEndpoint
$creadsPrec :: Int -> ReadS GetResolverEndpoint
Prelude.Read, Int -> GetResolverEndpoint -> ShowS
[GetResolverEndpoint] -> ShowS
GetResolverEndpoint -> String
(Int -> GetResolverEndpoint -> ShowS)
-> (GetResolverEndpoint -> String)
-> ([GetResolverEndpoint] -> ShowS)
-> Show GetResolverEndpoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetResolverEndpoint] -> ShowS
$cshowList :: [GetResolverEndpoint] -> ShowS
show :: GetResolverEndpoint -> String
$cshow :: GetResolverEndpoint -> String
showsPrec :: Int -> GetResolverEndpoint -> ShowS
$cshowsPrec :: Int -> GetResolverEndpoint -> ShowS
Prelude.Show, (forall x. GetResolverEndpoint -> Rep GetResolverEndpoint x)
-> (forall x. Rep GetResolverEndpoint x -> GetResolverEndpoint)
-> Generic GetResolverEndpoint
forall x. Rep GetResolverEndpoint x -> GetResolverEndpoint
forall x. GetResolverEndpoint -> Rep GetResolverEndpoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetResolverEndpoint x -> GetResolverEndpoint
$cfrom :: forall x. GetResolverEndpoint -> Rep GetResolverEndpoint x
Prelude.Generic)

-- |
-- Create a value of 'GetResolverEndpoint' 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:
--
-- 'resolverEndpointId', 'getResolverEndpoint_resolverEndpointId' - The ID of the Resolver endpoint that you want to get information about.
newGetResolverEndpoint ::
  -- | 'resolverEndpointId'
  Prelude.Text ->
  GetResolverEndpoint
newGetResolverEndpoint :: Text -> GetResolverEndpoint
newGetResolverEndpoint Text
pResolverEndpointId_ =
  GetResolverEndpoint' :: Text -> GetResolverEndpoint
GetResolverEndpoint'
    { $sel:resolverEndpointId:GetResolverEndpoint' :: Text
resolverEndpointId =
        Text
pResolverEndpointId_
    }

-- | The ID of the Resolver endpoint that you want to get information about.
getResolverEndpoint_resolverEndpointId :: Lens.Lens' GetResolverEndpoint Prelude.Text
getResolverEndpoint_resolverEndpointId :: (Text -> f Text) -> GetResolverEndpoint -> f GetResolverEndpoint
getResolverEndpoint_resolverEndpointId = (GetResolverEndpoint -> Text)
-> (GetResolverEndpoint -> Text -> GetResolverEndpoint)
-> Lens GetResolverEndpoint GetResolverEndpoint Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResolverEndpoint' {Text
resolverEndpointId :: Text
$sel:resolverEndpointId:GetResolverEndpoint' :: GetResolverEndpoint -> Text
resolverEndpointId} -> Text
resolverEndpointId) (\s :: GetResolverEndpoint
s@GetResolverEndpoint' {} Text
a -> GetResolverEndpoint
s {$sel:resolverEndpointId:GetResolverEndpoint' :: Text
resolverEndpointId = Text
a} :: GetResolverEndpoint)

instance Core.AWSRequest GetResolverEndpoint where
  type
    AWSResponse GetResolverEndpoint =
      GetResolverEndpointResponse
  request :: GetResolverEndpoint -> Request GetResolverEndpoint
request = Service -> GetResolverEndpoint -> Request GetResolverEndpoint
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetResolverEndpoint
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetResolverEndpoint)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetResolverEndpoint))
-> Logger
-> Service
-> Proxy GetResolverEndpoint
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetResolverEndpoint)))
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 ResolverEndpoint -> Int -> GetResolverEndpointResponse
GetResolverEndpointResponse'
            (Maybe ResolverEndpoint -> Int -> GetResolverEndpointResponse)
-> Either String (Maybe ResolverEndpoint)
-> Either String (Int -> GetResolverEndpointResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ResolverEndpoint)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ResolverEndpoint")
            Either String (Int -> GetResolverEndpointResponse)
-> Either String Int -> Either String GetResolverEndpointResponse
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 GetResolverEndpoint

instance Prelude.NFData GetResolverEndpoint

instance Core.ToHeaders GetResolverEndpoint where
  toHeaders :: GetResolverEndpoint -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetResolverEndpoint -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"Route53Resolver.GetResolverEndpoint" ::
                          Prelude.ByteString
                      ),
            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 GetResolverEndpoint where
  toJSON :: GetResolverEndpoint -> Value
toJSON GetResolverEndpoint' {Text
resolverEndpointId :: Text
$sel:resolverEndpointId:GetResolverEndpoint' :: GetResolverEndpoint -> 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
"ResolverEndpointId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
resolverEndpointId)
          ]
      )

instance Core.ToPath GetResolverEndpoint where
  toPath :: GetResolverEndpoint -> ByteString
toPath = ByteString -> GetResolverEndpoint -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newGetResolverEndpointResponse' smart constructor.
data GetResolverEndpointResponse = GetResolverEndpointResponse'
  { -- | Information about the Resolver endpoint that you specified in a
    -- @GetResolverEndpoint@ request.
    GetResolverEndpointResponse -> Maybe ResolverEndpoint
resolverEndpoint :: Prelude.Maybe ResolverEndpoint,
    -- | The response's http status code.
    GetResolverEndpointResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetResolverEndpointResponse -> GetResolverEndpointResponse -> Bool
(GetResolverEndpointResponse
 -> GetResolverEndpointResponse -> Bool)
-> (GetResolverEndpointResponse
    -> GetResolverEndpointResponse -> Bool)
-> Eq GetResolverEndpointResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetResolverEndpointResponse -> GetResolverEndpointResponse -> Bool
$c/= :: GetResolverEndpointResponse -> GetResolverEndpointResponse -> Bool
== :: GetResolverEndpointResponse -> GetResolverEndpointResponse -> Bool
$c== :: GetResolverEndpointResponse -> GetResolverEndpointResponse -> Bool
Prelude.Eq, ReadPrec [GetResolverEndpointResponse]
ReadPrec GetResolverEndpointResponse
Int -> ReadS GetResolverEndpointResponse
ReadS [GetResolverEndpointResponse]
(Int -> ReadS GetResolverEndpointResponse)
-> ReadS [GetResolverEndpointResponse]
-> ReadPrec GetResolverEndpointResponse
-> ReadPrec [GetResolverEndpointResponse]
-> Read GetResolverEndpointResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetResolverEndpointResponse]
$creadListPrec :: ReadPrec [GetResolverEndpointResponse]
readPrec :: ReadPrec GetResolverEndpointResponse
$creadPrec :: ReadPrec GetResolverEndpointResponse
readList :: ReadS [GetResolverEndpointResponse]
$creadList :: ReadS [GetResolverEndpointResponse]
readsPrec :: Int -> ReadS GetResolverEndpointResponse
$creadsPrec :: Int -> ReadS GetResolverEndpointResponse
Prelude.Read, Int -> GetResolverEndpointResponse -> ShowS
[GetResolverEndpointResponse] -> ShowS
GetResolverEndpointResponse -> String
(Int -> GetResolverEndpointResponse -> ShowS)
-> (GetResolverEndpointResponse -> String)
-> ([GetResolverEndpointResponse] -> ShowS)
-> Show GetResolverEndpointResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetResolverEndpointResponse] -> ShowS
$cshowList :: [GetResolverEndpointResponse] -> ShowS
show :: GetResolverEndpointResponse -> String
$cshow :: GetResolverEndpointResponse -> String
showsPrec :: Int -> GetResolverEndpointResponse -> ShowS
$cshowsPrec :: Int -> GetResolverEndpointResponse -> ShowS
Prelude.Show, (forall x.
 GetResolverEndpointResponse -> Rep GetResolverEndpointResponse x)
-> (forall x.
    Rep GetResolverEndpointResponse x -> GetResolverEndpointResponse)
-> Generic GetResolverEndpointResponse
forall x.
Rep GetResolverEndpointResponse x -> GetResolverEndpointResponse
forall x.
GetResolverEndpointResponse -> Rep GetResolverEndpointResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetResolverEndpointResponse x -> GetResolverEndpointResponse
$cfrom :: forall x.
GetResolverEndpointResponse -> Rep GetResolverEndpointResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetResolverEndpointResponse' 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:
--
-- 'resolverEndpoint', 'getResolverEndpointResponse_resolverEndpoint' - Information about the Resolver endpoint that you specified in a
-- @GetResolverEndpoint@ request.
--
-- 'httpStatus', 'getResolverEndpointResponse_httpStatus' - The response's http status code.
newGetResolverEndpointResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetResolverEndpointResponse
newGetResolverEndpointResponse :: Int -> GetResolverEndpointResponse
newGetResolverEndpointResponse Int
pHttpStatus_ =
  GetResolverEndpointResponse' :: Maybe ResolverEndpoint -> Int -> GetResolverEndpointResponse
GetResolverEndpointResponse'
    { $sel:resolverEndpoint:GetResolverEndpointResponse' :: Maybe ResolverEndpoint
resolverEndpoint =
        Maybe ResolverEndpoint
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetResolverEndpointResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the Resolver endpoint that you specified in a
-- @GetResolverEndpoint@ request.
getResolverEndpointResponse_resolverEndpoint :: Lens.Lens' GetResolverEndpointResponse (Prelude.Maybe ResolverEndpoint)
getResolverEndpointResponse_resolverEndpoint :: (Maybe ResolverEndpoint -> f (Maybe ResolverEndpoint))
-> GetResolverEndpointResponse -> f GetResolverEndpointResponse
getResolverEndpointResponse_resolverEndpoint = (GetResolverEndpointResponse -> Maybe ResolverEndpoint)
-> (GetResolverEndpointResponse
    -> Maybe ResolverEndpoint -> GetResolverEndpointResponse)
-> Lens
     GetResolverEndpointResponse
     GetResolverEndpointResponse
     (Maybe ResolverEndpoint)
     (Maybe ResolverEndpoint)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResolverEndpointResponse' {Maybe ResolverEndpoint
resolverEndpoint :: Maybe ResolverEndpoint
$sel:resolverEndpoint:GetResolverEndpointResponse' :: GetResolverEndpointResponse -> Maybe ResolverEndpoint
resolverEndpoint} -> Maybe ResolverEndpoint
resolverEndpoint) (\s :: GetResolverEndpointResponse
s@GetResolverEndpointResponse' {} Maybe ResolverEndpoint
a -> GetResolverEndpointResponse
s {$sel:resolverEndpoint:GetResolverEndpointResponse' :: Maybe ResolverEndpoint
resolverEndpoint = Maybe ResolverEndpoint
a} :: GetResolverEndpointResponse)

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

instance Prelude.NFData GetResolverEndpointResponse