{-# 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.GetAnalyzedResource
-- 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 a resource that was analyzed.
module Amazonka.AccessAnalyzer.GetAnalyzedResource
  ( -- * Creating a Request
    GetAnalyzedResource (..),
    newGetAnalyzedResource,

    -- * Request Lenses
    getAnalyzedResource_analyzerArn,
    getAnalyzedResource_resourceArn,

    -- * Destructuring the Response
    GetAnalyzedResourceResponse (..),
    newGetAnalyzedResourceResponse,

    -- * Response Lenses
    getAnalyzedResourceResponse_resource,
    getAnalyzedResourceResponse_httpStatus,
  )
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 analyzed resource.
--
-- /See:/ 'newGetAnalyzedResource' smart constructor.
data GetAnalyzedResource = GetAnalyzedResource'
  { -- | The
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-getting-started.html#permission-resources ARN of the analyzer>
    -- to retrieve information from.
    GetAnalyzedResource -> Text
analyzerArn :: Prelude.Text,
    -- | The ARN of the resource to retrieve information about.
    GetAnalyzedResource -> Text
resourceArn :: Prelude.Text
  }
  deriving (GetAnalyzedResource -> GetAnalyzedResource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAnalyzedResource -> GetAnalyzedResource -> Bool
$c/= :: GetAnalyzedResource -> GetAnalyzedResource -> Bool
== :: GetAnalyzedResource -> GetAnalyzedResource -> Bool
$c== :: GetAnalyzedResource -> GetAnalyzedResource -> Bool
Prelude.Eq, ReadPrec [GetAnalyzedResource]
ReadPrec GetAnalyzedResource
Int -> ReadS GetAnalyzedResource
ReadS [GetAnalyzedResource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAnalyzedResource]
$creadListPrec :: ReadPrec [GetAnalyzedResource]
readPrec :: ReadPrec GetAnalyzedResource
$creadPrec :: ReadPrec GetAnalyzedResource
readList :: ReadS [GetAnalyzedResource]
$creadList :: ReadS [GetAnalyzedResource]
readsPrec :: Int -> ReadS GetAnalyzedResource
$creadsPrec :: Int -> ReadS GetAnalyzedResource
Prelude.Read, Int -> GetAnalyzedResource -> ShowS
[GetAnalyzedResource] -> ShowS
GetAnalyzedResource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAnalyzedResource] -> ShowS
$cshowList :: [GetAnalyzedResource] -> ShowS
show :: GetAnalyzedResource -> String
$cshow :: GetAnalyzedResource -> String
showsPrec :: Int -> GetAnalyzedResource -> ShowS
$cshowsPrec :: Int -> GetAnalyzedResource -> ShowS
Prelude.Show, forall x. Rep GetAnalyzedResource x -> GetAnalyzedResource
forall x. GetAnalyzedResource -> Rep GetAnalyzedResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetAnalyzedResource x -> GetAnalyzedResource
$cfrom :: forall x. GetAnalyzedResource -> Rep GetAnalyzedResource x
Prelude.Generic)

-- |
-- Create a value of 'GetAnalyzedResource' 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:
--
-- 'analyzerArn', 'getAnalyzedResource_analyzerArn' - The
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-getting-started.html#permission-resources ARN of the analyzer>
-- to retrieve information from.
--
-- 'resourceArn', 'getAnalyzedResource_resourceArn' - The ARN of the resource to retrieve information about.
newGetAnalyzedResource ::
  -- | 'analyzerArn'
  Prelude.Text ->
  -- | 'resourceArn'
  Prelude.Text ->
  GetAnalyzedResource
newGetAnalyzedResource :: Text -> Text -> GetAnalyzedResource
newGetAnalyzedResource Text
pAnalyzerArn_ Text
pResourceArn_ =
  GetAnalyzedResource'
    { $sel:analyzerArn:GetAnalyzedResource' :: Text
analyzerArn = Text
pAnalyzerArn_,
      $sel:resourceArn:GetAnalyzedResource' :: Text
resourceArn = Text
pResourceArn_
    }

-- | The
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-getting-started.html#permission-resources ARN of the analyzer>
-- to retrieve information from.
getAnalyzedResource_analyzerArn :: Lens.Lens' GetAnalyzedResource Prelude.Text
getAnalyzedResource_analyzerArn :: Lens' GetAnalyzedResource Text
getAnalyzedResource_analyzerArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAnalyzedResource' {Text
analyzerArn :: Text
$sel:analyzerArn:GetAnalyzedResource' :: GetAnalyzedResource -> Text
analyzerArn} -> Text
analyzerArn) (\s :: GetAnalyzedResource
s@GetAnalyzedResource' {} Text
a -> GetAnalyzedResource
s {$sel:analyzerArn:GetAnalyzedResource' :: Text
analyzerArn = Text
a} :: GetAnalyzedResource)

-- | The ARN of the resource to retrieve information about.
getAnalyzedResource_resourceArn :: Lens.Lens' GetAnalyzedResource Prelude.Text
getAnalyzedResource_resourceArn :: Lens' GetAnalyzedResource Text
getAnalyzedResource_resourceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAnalyzedResource' {Text
resourceArn :: Text
$sel:resourceArn:GetAnalyzedResource' :: GetAnalyzedResource -> Text
resourceArn} -> Text
resourceArn) (\s :: GetAnalyzedResource
s@GetAnalyzedResource' {} Text
a -> GetAnalyzedResource
s {$sel:resourceArn:GetAnalyzedResource' :: Text
resourceArn = Text
a} :: GetAnalyzedResource)

instance Core.AWSRequest GetAnalyzedResource where
  type
    AWSResponse GetAnalyzedResource =
      GetAnalyzedResourceResponse
  request :: (Service -> Service)
-> GetAnalyzedResource -> Request GetAnalyzedResource
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 GetAnalyzedResource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetAnalyzedResource)))
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 AnalyzedResource -> Int -> GetAnalyzedResourceResponse
GetAnalyzedResourceResponse'
            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
"resource")
            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 GetAnalyzedResource where
  hashWithSalt :: Int -> GetAnalyzedResource -> Int
hashWithSalt Int
_salt GetAnalyzedResource' {Text
resourceArn :: Text
analyzerArn :: Text
$sel:resourceArn:GetAnalyzedResource' :: GetAnalyzedResource -> Text
$sel:analyzerArn:GetAnalyzedResource' :: GetAnalyzedResource -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
analyzerArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceArn

instance Prelude.NFData GetAnalyzedResource where
  rnf :: GetAnalyzedResource -> ()
rnf GetAnalyzedResource' {Text
resourceArn :: Text
analyzerArn :: Text
$sel:resourceArn:GetAnalyzedResource' :: GetAnalyzedResource -> Text
$sel:analyzerArn:GetAnalyzedResource' :: GetAnalyzedResource -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
analyzerArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
resourceArn

instance Data.ToHeaders GetAnalyzedResource where
  toHeaders :: GetAnalyzedResource -> 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 GetAnalyzedResource where
  toPath :: GetAnalyzedResource -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/analyzed-resource"

instance Data.ToQuery GetAnalyzedResource where
  toQuery :: GetAnalyzedResource -> QueryString
toQuery GetAnalyzedResource' {Text
resourceArn :: Text
analyzerArn :: Text
$sel:resourceArn:GetAnalyzedResource' :: GetAnalyzedResource -> Text
$sel:analyzerArn:GetAnalyzedResource' :: GetAnalyzedResource -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"analyzerArn" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
analyzerArn,
        ByteString
"resourceArn" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
resourceArn
      ]

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

-- |
-- Create a value of 'GetAnalyzedResourceResponse' 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:
--
-- 'resource', 'getAnalyzedResourceResponse_resource' - An @AnalyzedResource@ object that contains information that IAM Access
-- Analyzer found when it analyzed the resource.
--
-- 'httpStatus', 'getAnalyzedResourceResponse_httpStatus' - The response's http status code.
newGetAnalyzedResourceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetAnalyzedResourceResponse
newGetAnalyzedResourceResponse :: Int -> GetAnalyzedResourceResponse
newGetAnalyzedResourceResponse Int
pHttpStatus_ =
  GetAnalyzedResourceResponse'
    { $sel:resource:GetAnalyzedResourceResponse' :: Maybe AnalyzedResource
resource =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetAnalyzedResourceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An @AnalyzedResource@ object that contains information that IAM Access
-- Analyzer found when it analyzed the resource.
getAnalyzedResourceResponse_resource :: Lens.Lens' GetAnalyzedResourceResponse (Prelude.Maybe AnalyzedResource)
getAnalyzedResourceResponse_resource :: Lens' GetAnalyzedResourceResponse (Maybe AnalyzedResource)
getAnalyzedResourceResponse_resource = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAnalyzedResourceResponse' {Maybe AnalyzedResource
resource :: Maybe AnalyzedResource
$sel:resource:GetAnalyzedResourceResponse' :: GetAnalyzedResourceResponse -> Maybe AnalyzedResource
resource} -> Maybe AnalyzedResource
resource) (\s :: GetAnalyzedResourceResponse
s@GetAnalyzedResourceResponse' {} Maybe AnalyzedResource
a -> GetAnalyzedResourceResponse
s {$sel:resource:GetAnalyzedResourceResponse' :: Maybe AnalyzedResource
resource = Maybe AnalyzedResource
a} :: GetAnalyzedResourceResponse)

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

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