{-# 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-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)
--
-- 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.Lens as Lens
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
(GetAnalyzer -> GetAnalyzer -> Bool)
-> (GetAnalyzer -> GetAnalyzer -> Bool) -> Eq GetAnalyzer
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]
(Int -> ReadS GetAnalyzer)
-> ReadS [GetAnalyzer]
-> ReadPrec GetAnalyzer
-> ReadPrec [GetAnalyzer]
-> Read 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
(Int -> GetAnalyzer -> ShowS)
-> (GetAnalyzer -> String)
-> ([GetAnalyzer] -> ShowS)
-> Show GetAnalyzer
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. GetAnalyzer -> Rep GetAnalyzer x)
-> (forall x. Rep GetAnalyzer x -> GetAnalyzer)
-> Generic GetAnalyzer
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' :: Text -> GetAnalyzer
GetAnalyzer' {$sel:analyzerName:GetAnalyzer' :: Text
analyzerName = Text
pAnalyzerName_}

-- | The name of the analyzer retrieved.
getAnalyzer_analyzerName :: Lens.Lens' GetAnalyzer Prelude.Text
getAnalyzer_analyzerName :: (Text -> f Text) -> GetAnalyzer -> f GetAnalyzer
getAnalyzer_analyzerName = (GetAnalyzer -> Text)
-> (GetAnalyzer -> Text -> GetAnalyzer)
-> Lens GetAnalyzer GetAnalyzer Text Text
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 :: GetAnalyzer -> Request GetAnalyzer
request = Service -> GetAnalyzer -> Request GetAnalyzer
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetAnalyzer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetAnalyzer)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetAnalyzer))
-> Logger
-> Service
-> Proxy GetAnalyzer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetAnalyzer)))
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 ->
          Int -> AnalyzerSummary -> GetAnalyzerResponse
GetAnalyzerResponse'
            (Int -> AnalyzerSummary -> GetAnalyzerResponse)
-> Either String Int
-> Either String (AnalyzerSummary -> GetAnalyzerResponse)
forall (f :: * -> *) a b. Functor 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))
            Either String (AnalyzerSummary -> GetAnalyzerResponse)
-> Either String AnalyzerSummary
-> Either String GetAnalyzerResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String AnalyzerSummary
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"analyzer")
      )

instance Prelude.Hashable GetAnalyzer

instance Prelude.NFData GetAnalyzer

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

instance Core.ToQuery GetAnalyzer where
  toQuery :: GetAnalyzer -> QueryString
toQuery = QueryString -> GetAnalyzer -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(GetAnalyzerResponse -> GetAnalyzerResponse -> Bool)
-> (GetAnalyzerResponse -> GetAnalyzerResponse -> Bool)
-> Eq GetAnalyzerResponse
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]
(Int -> ReadS GetAnalyzerResponse)
-> ReadS [GetAnalyzerResponse]
-> ReadPrec GetAnalyzerResponse
-> ReadPrec [GetAnalyzerResponse]
-> Read 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
(Int -> GetAnalyzerResponse -> ShowS)
-> (GetAnalyzerResponse -> String)
-> ([GetAnalyzerResponse] -> ShowS)
-> Show GetAnalyzerResponse
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. GetAnalyzerResponse -> Rep GetAnalyzerResponse x)
-> (forall x. Rep GetAnalyzerResponse x -> GetAnalyzerResponse)
-> Generic GetAnalyzerResponse
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' :: Int -> AnalyzerSummary -> GetAnalyzerResponse
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 :: (Int -> f Int) -> GetAnalyzerResponse -> f GetAnalyzerResponse
getAnalyzerResponse_httpStatus = (GetAnalyzerResponse -> Int)
-> (GetAnalyzerResponse -> Int -> GetAnalyzerResponse)
-> Lens GetAnalyzerResponse GetAnalyzerResponse Int Int
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 :: (AnalyzerSummary -> f AnalyzerSummary)
-> GetAnalyzerResponse -> f GetAnalyzerResponse
getAnalyzerResponse_analyzer = (GetAnalyzerResponse -> AnalyzerSummary)
-> (GetAnalyzerResponse -> AnalyzerSummary -> GetAnalyzerResponse)
-> Lens
     GetAnalyzerResponse
     GetAnalyzerResponse
     AnalyzerSummary
     AnalyzerSummary
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