{-# 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.RedshiftServerLess.GetEndpointAccess
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns information, such as the name, about a VPC endpoint.
module Amazonka.RedshiftServerLess.GetEndpointAccess
  ( -- * Creating a Request
    GetEndpointAccess (..),
    newGetEndpointAccess,

    -- * Request Lenses
    getEndpointAccess_endpointName,

    -- * Destructuring the Response
    GetEndpointAccessResponse (..),
    newGetEndpointAccessResponse,

    -- * Response Lenses
    getEndpointAccessResponse_endpoint,
    getEndpointAccessResponse_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 Amazonka.RedshiftServerLess.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetEndpointAccess' smart constructor.
data GetEndpointAccess = GetEndpointAccess'
  { -- | The name of the VPC endpoint to return information for.
    GetEndpointAccess -> Text
endpointName :: Prelude.Text
  }
  deriving (GetEndpointAccess -> GetEndpointAccess -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetEndpointAccess -> GetEndpointAccess -> Bool
$c/= :: GetEndpointAccess -> GetEndpointAccess -> Bool
== :: GetEndpointAccess -> GetEndpointAccess -> Bool
$c== :: GetEndpointAccess -> GetEndpointAccess -> Bool
Prelude.Eq, ReadPrec [GetEndpointAccess]
ReadPrec GetEndpointAccess
Int -> ReadS GetEndpointAccess
ReadS [GetEndpointAccess]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetEndpointAccess]
$creadListPrec :: ReadPrec [GetEndpointAccess]
readPrec :: ReadPrec GetEndpointAccess
$creadPrec :: ReadPrec GetEndpointAccess
readList :: ReadS [GetEndpointAccess]
$creadList :: ReadS [GetEndpointAccess]
readsPrec :: Int -> ReadS GetEndpointAccess
$creadsPrec :: Int -> ReadS GetEndpointAccess
Prelude.Read, Int -> GetEndpointAccess -> ShowS
[GetEndpointAccess] -> ShowS
GetEndpointAccess -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetEndpointAccess] -> ShowS
$cshowList :: [GetEndpointAccess] -> ShowS
show :: GetEndpointAccess -> String
$cshow :: GetEndpointAccess -> String
showsPrec :: Int -> GetEndpointAccess -> ShowS
$cshowsPrec :: Int -> GetEndpointAccess -> ShowS
Prelude.Show, forall x. Rep GetEndpointAccess x -> GetEndpointAccess
forall x. GetEndpointAccess -> Rep GetEndpointAccess x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetEndpointAccess x -> GetEndpointAccess
$cfrom :: forall x. GetEndpointAccess -> Rep GetEndpointAccess x
Prelude.Generic)

-- |
-- Create a value of 'GetEndpointAccess' 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:
--
-- 'endpointName', 'getEndpointAccess_endpointName' - The name of the VPC endpoint to return information for.
newGetEndpointAccess ::
  -- | 'endpointName'
  Prelude.Text ->
  GetEndpointAccess
newGetEndpointAccess :: Text -> GetEndpointAccess
newGetEndpointAccess Text
pEndpointName_ =
  GetEndpointAccess' {$sel:endpointName:GetEndpointAccess' :: Text
endpointName = Text
pEndpointName_}

-- | The name of the VPC endpoint to return information for.
getEndpointAccess_endpointName :: Lens.Lens' GetEndpointAccess Prelude.Text
getEndpointAccess_endpointName :: Lens' GetEndpointAccess Text
getEndpointAccess_endpointName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEndpointAccess' {Text
endpointName :: Text
$sel:endpointName:GetEndpointAccess' :: GetEndpointAccess -> Text
endpointName} -> Text
endpointName) (\s :: GetEndpointAccess
s@GetEndpointAccess' {} Text
a -> GetEndpointAccess
s {$sel:endpointName:GetEndpointAccess' :: Text
endpointName = Text
a} :: GetEndpointAccess)

instance Core.AWSRequest GetEndpointAccess where
  type
    AWSResponse GetEndpointAccess =
      GetEndpointAccessResponse
  request :: (Service -> Service)
-> GetEndpointAccess -> Request GetEndpointAccess
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 GetEndpointAccess
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetEndpointAccess)))
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 EndpointAccess -> Int -> GetEndpointAccessResponse
GetEndpointAccessResponse'
            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
"endpoint")
            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 GetEndpointAccess where
  hashWithSalt :: Int -> GetEndpointAccess -> Int
hashWithSalt Int
_salt GetEndpointAccess' {Text
endpointName :: Text
$sel:endpointName:GetEndpointAccess' :: GetEndpointAccess -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
endpointName

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

instance Data.ToHeaders GetEndpointAccess where
  toHeaders :: GetEndpointAccess -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"RedshiftServerless.GetEndpointAccess" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON GetEndpointAccess where
  toJSON :: GetEndpointAccess -> Value
toJSON GetEndpointAccess' {Text
endpointName :: Text
$sel:endpointName:GetEndpointAccess' :: GetEndpointAccess -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"endpointName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
endpointName)]
      )

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

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

-- | /See:/ 'newGetEndpointAccessResponse' smart constructor.
data GetEndpointAccessResponse = GetEndpointAccessResponse'
  { -- | The returned VPC endpoint.
    GetEndpointAccessResponse -> Maybe EndpointAccess
endpoint :: Prelude.Maybe EndpointAccess,
    -- | The response's http status code.
    GetEndpointAccessResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetEndpointAccessResponse -> GetEndpointAccessResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetEndpointAccessResponse -> GetEndpointAccessResponse -> Bool
$c/= :: GetEndpointAccessResponse -> GetEndpointAccessResponse -> Bool
== :: GetEndpointAccessResponse -> GetEndpointAccessResponse -> Bool
$c== :: GetEndpointAccessResponse -> GetEndpointAccessResponse -> Bool
Prelude.Eq, ReadPrec [GetEndpointAccessResponse]
ReadPrec GetEndpointAccessResponse
Int -> ReadS GetEndpointAccessResponse
ReadS [GetEndpointAccessResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetEndpointAccessResponse]
$creadListPrec :: ReadPrec [GetEndpointAccessResponse]
readPrec :: ReadPrec GetEndpointAccessResponse
$creadPrec :: ReadPrec GetEndpointAccessResponse
readList :: ReadS [GetEndpointAccessResponse]
$creadList :: ReadS [GetEndpointAccessResponse]
readsPrec :: Int -> ReadS GetEndpointAccessResponse
$creadsPrec :: Int -> ReadS GetEndpointAccessResponse
Prelude.Read, Int -> GetEndpointAccessResponse -> ShowS
[GetEndpointAccessResponse] -> ShowS
GetEndpointAccessResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetEndpointAccessResponse] -> ShowS
$cshowList :: [GetEndpointAccessResponse] -> ShowS
show :: GetEndpointAccessResponse -> String
$cshow :: GetEndpointAccessResponse -> String
showsPrec :: Int -> GetEndpointAccessResponse -> ShowS
$cshowsPrec :: Int -> GetEndpointAccessResponse -> ShowS
Prelude.Show, forall x.
Rep GetEndpointAccessResponse x -> GetEndpointAccessResponse
forall x.
GetEndpointAccessResponse -> Rep GetEndpointAccessResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetEndpointAccessResponse x -> GetEndpointAccessResponse
$cfrom :: forall x.
GetEndpointAccessResponse -> Rep GetEndpointAccessResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetEndpointAccessResponse' 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:
--
-- 'endpoint', 'getEndpointAccessResponse_endpoint' - The returned VPC endpoint.
--
-- 'httpStatus', 'getEndpointAccessResponse_httpStatus' - The response's http status code.
newGetEndpointAccessResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetEndpointAccessResponse
newGetEndpointAccessResponse :: Int -> GetEndpointAccessResponse
newGetEndpointAccessResponse Int
pHttpStatus_ =
  GetEndpointAccessResponse'
    { $sel:endpoint:GetEndpointAccessResponse' :: Maybe EndpointAccess
endpoint =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetEndpointAccessResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The returned VPC endpoint.
getEndpointAccessResponse_endpoint :: Lens.Lens' GetEndpointAccessResponse (Prelude.Maybe EndpointAccess)
getEndpointAccessResponse_endpoint :: Lens' GetEndpointAccessResponse (Maybe EndpointAccess)
getEndpointAccessResponse_endpoint = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEndpointAccessResponse' {Maybe EndpointAccess
endpoint :: Maybe EndpointAccess
$sel:endpoint:GetEndpointAccessResponse' :: GetEndpointAccessResponse -> Maybe EndpointAccess
endpoint} -> Maybe EndpointAccess
endpoint) (\s :: GetEndpointAccessResponse
s@GetEndpointAccessResponse' {} Maybe EndpointAccess
a -> GetEndpointAccessResponse
s {$sel:endpoint:GetEndpointAccessResponse' :: Maybe EndpointAccess
endpoint = Maybe EndpointAccess
a} :: GetEndpointAccessResponse)

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

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