{-# 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.AccessAnalyzer.GetAnalyzer
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves information about the specified analyzer.
module Amazonka.AccessAnalyzer.GetAnalyzer
  ( -- * Creating a Request
    GetAnalyzer (..),
    newGetAnalyzer,

    -- * Request Lenses
    getAnalyzer_analyzerName,

    -- * Destructuring the Response
    GetAnalyzerResponse (..),
    newGetAnalyzerResponse,

    -- * Response Lenses
    getAnalyzerResponse_httpStatus,
    getAnalyzerResponse_analyzer,
  )
where

import Amazonka.AccessAnalyzer.Types
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 qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Retrieves an analyzer.
--
-- /See:/ 'newGetAnalyzer' smart constructor.
data GetAnalyzer = GetAnalyzer'
  { -- | The name of the analyzer retrieved.
    GetAnalyzer -> Text
analyzerName :: Prelude.Text
  }
  deriving (GetAnalyzer -> GetAnalyzer -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAnalyzer -> GetAnalyzer -> Bool
$c/= :: GetAnalyzer -> GetAnalyzer -> Bool
== :: GetAnalyzer -> GetAnalyzer -> Bool
$c== :: GetAnalyzer -> GetAnalyzer -> Bool
Prelude.Eq, ReadPrec [GetAnalyzer]
ReadPrec GetAnalyzer
Int -> ReadS GetAnalyzer
ReadS [GetAnalyzer]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAnalyzer]
$creadListPrec :: ReadPrec [GetAnalyzer]
readPrec :: ReadPrec GetAnalyzer
$creadPrec :: ReadPrec GetAnalyzer
readList :: ReadS [GetAnalyzer]
$creadList :: ReadS [GetAnalyzer]
readsPrec :: Int -> ReadS GetAnalyzer
$creadsPrec :: Int -> ReadS GetAnalyzer
Prelude.Read, Int -> GetAnalyzer -> ShowS
[GetAnalyzer] -> ShowS
GetAnalyzer -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAnalyzer] -> ShowS
$cshowList :: [GetAnalyzer] -> ShowS
show :: GetAnalyzer -> String
$cshow :: GetAnalyzer -> String
showsPrec :: Int -> GetAnalyzer -> ShowS
$cshowsPrec :: Int -> GetAnalyzer -> ShowS
Prelude.Show, forall x. Rep GetAnalyzer x -> GetAnalyzer
forall x. GetAnalyzer -> Rep GetAnalyzer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetAnalyzer x -> GetAnalyzer
$cfrom :: forall x. GetAnalyzer -> Rep GetAnalyzer x
Prelude.Generic)

-- |
-- Create a value of 'GetAnalyzer' 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:
--
-- 'analyzerName', 'getAnalyzer_analyzerName' - The name of the analyzer retrieved.
newGetAnalyzer ::
  -- | 'analyzerName'
  Prelude.Text ->
  GetAnalyzer
newGetAnalyzer :: Text -> GetAnalyzer
newGetAnalyzer Text
pAnalyzerName_ =
  GetAnalyzer' {$sel:analyzerName:GetAnalyzer' :: Text
analyzerName = Text
pAnalyzerName_}

-- | The name of the analyzer retrieved.
getAnalyzer_analyzerName :: Lens.Lens' GetAnalyzer Prelude.Text
getAnalyzer_analyzerName :: Lens' GetAnalyzer Text
getAnalyzer_analyzerName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAnalyzer' {Text
analyzerName :: Text
$sel:analyzerName:GetAnalyzer' :: GetAnalyzer -> Text
analyzerName} -> Text
analyzerName) (\s :: GetAnalyzer
s@GetAnalyzer' {} Text
a -> GetAnalyzer
s {$sel:analyzerName:GetAnalyzer' :: Text
analyzerName = Text
a} :: GetAnalyzer)

instance Core.AWSRequest GetAnalyzer where
  type AWSResponse GetAnalyzer = GetAnalyzerResponse
  request :: (Service -> Service) -> GetAnalyzer -> Request GetAnalyzer
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 GetAnalyzer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetAnalyzer)))
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 ->
          Int -> AnalyzerSummary -> GetAnalyzerResponse
GetAnalyzerResponse'
            forall (f :: * -> *) a b. Functor 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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"analyzer")
      )

instance Prelude.Hashable GetAnalyzer where
  hashWithSalt :: Int -> GetAnalyzer -> Int
hashWithSalt Int
_salt GetAnalyzer' {Text
analyzerName :: Text
$sel:analyzerName:GetAnalyzer' :: GetAnalyzer -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
analyzerName

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

instance Data.ToHeaders GetAnalyzer where
  toHeaders :: GetAnalyzer -> 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 GetAnalyzer where
  toPath :: GetAnalyzer -> ByteString
toPath GetAnalyzer' {Text
analyzerName :: Text
$sel:analyzerName:GetAnalyzer' :: GetAnalyzer -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/analyzer/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
analyzerName]

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

-- | The response to the request.
--
-- /See:/ 'newGetAnalyzerResponse' smart constructor.
data GetAnalyzerResponse = GetAnalyzerResponse'
  { -- | The response's http status code.
    GetAnalyzerResponse -> Int
httpStatus :: Prelude.Int,
    -- | An @AnalyzerSummary@ object that contains information about the
    -- analyzer.
    GetAnalyzerResponse -> AnalyzerSummary
analyzer :: AnalyzerSummary
  }
  deriving (GetAnalyzerResponse -> GetAnalyzerResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAnalyzerResponse -> GetAnalyzerResponse -> Bool
$c/= :: GetAnalyzerResponse -> GetAnalyzerResponse -> Bool
== :: GetAnalyzerResponse -> GetAnalyzerResponse -> Bool
$c== :: GetAnalyzerResponse -> GetAnalyzerResponse -> Bool
Prelude.Eq, ReadPrec [GetAnalyzerResponse]
ReadPrec GetAnalyzerResponse
Int -> ReadS GetAnalyzerResponse
ReadS [GetAnalyzerResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAnalyzerResponse]
$creadListPrec :: ReadPrec [GetAnalyzerResponse]
readPrec :: ReadPrec GetAnalyzerResponse
$creadPrec :: ReadPrec GetAnalyzerResponse
readList :: ReadS [GetAnalyzerResponse]
$creadList :: ReadS [GetAnalyzerResponse]
readsPrec :: Int -> ReadS GetAnalyzerResponse
$creadsPrec :: Int -> ReadS GetAnalyzerResponse
Prelude.Read, Int -> GetAnalyzerResponse -> ShowS
[GetAnalyzerResponse] -> ShowS
GetAnalyzerResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAnalyzerResponse] -> ShowS
$cshowList :: [GetAnalyzerResponse] -> ShowS
show :: GetAnalyzerResponse -> String
$cshow :: GetAnalyzerResponse -> String
showsPrec :: Int -> GetAnalyzerResponse -> ShowS
$cshowsPrec :: Int -> GetAnalyzerResponse -> ShowS
Prelude.Show, forall x. Rep GetAnalyzerResponse x -> GetAnalyzerResponse
forall x. GetAnalyzerResponse -> Rep GetAnalyzerResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetAnalyzerResponse x -> GetAnalyzerResponse
$cfrom :: forall x. GetAnalyzerResponse -> Rep GetAnalyzerResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetAnalyzerResponse' 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', 'getAnalyzerResponse_httpStatus' - The response's http status code.
--
-- 'analyzer', 'getAnalyzerResponse_analyzer' - An @AnalyzerSummary@ object that contains information about the
-- analyzer.
newGetAnalyzerResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'analyzer'
  AnalyzerSummary ->
  GetAnalyzerResponse
newGetAnalyzerResponse :: Int -> AnalyzerSummary -> GetAnalyzerResponse
newGetAnalyzerResponse Int
pHttpStatus_ AnalyzerSummary
pAnalyzer_ =
  GetAnalyzerResponse'
    { $sel:httpStatus:GetAnalyzerResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:analyzer:GetAnalyzerResponse' :: AnalyzerSummary
analyzer = AnalyzerSummary
pAnalyzer_
    }

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

-- | An @AnalyzerSummary@ object that contains information about the
-- analyzer.
getAnalyzerResponse_analyzer :: Lens.Lens' GetAnalyzerResponse AnalyzerSummary
getAnalyzerResponse_analyzer :: Lens' GetAnalyzerResponse AnalyzerSummary
getAnalyzerResponse_analyzer = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAnalyzerResponse' {AnalyzerSummary
analyzer :: AnalyzerSummary
$sel:analyzer:GetAnalyzerResponse' :: GetAnalyzerResponse -> AnalyzerSummary
analyzer} -> AnalyzerSummary
analyzer) (\s :: GetAnalyzerResponse
s@GetAnalyzerResponse' {} AnalyzerSummary
a -> GetAnalyzerResponse
s {$sel:analyzer:GetAnalyzerResponse' :: AnalyzerSummary
analyzer = AnalyzerSummary
a} :: GetAnalyzerResponse)

instance Prelude.NFData GetAnalyzerResponse where
  rnf :: GetAnalyzerResponse -> ()
rnf GetAnalyzerResponse' {Int
AnalyzerSummary
analyzer :: AnalyzerSummary
httpStatus :: Int
$sel:analyzer:GetAnalyzerResponse' :: GetAnalyzerResponse -> AnalyzerSummary
$sel:httpStatus:GetAnalyzerResponse' :: GetAnalyzerResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf AnalyzerSummary
analyzer