{-# 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.IoT.DescribeAuditFinding
-- 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 single audit finding. Properties include the
-- reason for noncompliance, the severity of the issue, and the start time
-- when the audit that returned the finding.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions DescribeAuditFinding>
-- action.
module Amazonka.IoT.DescribeAuditFinding
  ( -- * Creating a Request
    DescribeAuditFinding (..),
    newDescribeAuditFinding,

    -- * Request Lenses
    describeAuditFinding_findingId,

    -- * Destructuring the Response
    DescribeAuditFindingResponse (..),
    newDescribeAuditFindingResponse,

    -- * Response Lenses
    describeAuditFindingResponse_finding,
    describeAuditFindingResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoT.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDescribeAuditFinding' smart constructor.
data DescribeAuditFinding = DescribeAuditFinding'
  { -- | A unique identifier for a single audit finding. You can use this
    -- identifier to apply mitigation actions to the finding.
    DescribeAuditFinding -> Text
findingId :: Prelude.Text
  }
  deriving (DescribeAuditFinding -> DescribeAuditFinding -> Bool
(DescribeAuditFinding -> DescribeAuditFinding -> Bool)
-> (DescribeAuditFinding -> DescribeAuditFinding -> Bool)
-> Eq DescribeAuditFinding
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAuditFinding -> DescribeAuditFinding -> Bool
$c/= :: DescribeAuditFinding -> DescribeAuditFinding -> Bool
== :: DescribeAuditFinding -> DescribeAuditFinding -> Bool
$c== :: DescribeAuditFinding -> DescribeAuditFinding -> Bool
Prelude.Eq, ReadPrec [DescribeAuditFinding]
ReadPrec DescribeAuditFinding
Int -> ReadS DescribeAuditFinding
ReadS [DescribeAuditFinding]
(Int -> ReadS DescribeAuditFinding)
-> ReadS [DescribeAuditFinding]
-> ReadPrec DescribeAuditFinding
-> ReadPrec [DescribeAuditFinding]
-> Read DescribeAuditFinding
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAuditFinding]
$creadListPrec :: ReadPrec [DescribeAuditFinding]
readPrec :: ReadPrec DescribeAuditFinding
$creadPrec :: ReadPrec DescribeAuditFinding
readList :: ReadS [DescribeAuditFinding]
$creadList :: ReadS [DescribeAuditFinding]
readsPrec :: Int -> ReadS DescribeAuditFinding
$creadsPrec :: Int -> ReadS DescribeAuditFinding
Prelude.Read, Int -> DescribeAuditFinding -> ShowS
[DescribeAuditFinding] -> ShowS
DescribeAuditFinding -> String
(Int -> DescribeAuditFinding -> ShowS)
-> (DescribeAuditFinding -> String)
-> ([DescribeAuditFinding] -> ShowS)
-> Show DescribeAuditFinding
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAuditFinding] -> ShowS
$cshowList :: [DescribeAuditFinding] -> ShowS
show :: DescribeAuditFinding -> String
$cshow :: DescribeAuditFinding -> String
showsPrec :: Int -> DescribeAuditFinding -> ShowS
$cshowsPrec :: Int -> DescribeAuditFinding -> ShowS
Prelude.Show, (forall x. DescribeAuditFinding -> Rep DescribeAuditFinding x)
-> (forall x. Rep DescribeAuditFinding x -> DescribeAuditFinding)
-> Generic DescribeAuditFinding
forall x. Rep DescribeAuditFinding x -> DescribeAuditFinding
forall x. DescribeAuditFinding -> Rep DescribeAuditFinding x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeAuditFinding x -> DescribeAuditFinding
$cfrom :: forall x. DescribeAuditFinding -> Rep DescribeAuditFinding x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAuditFinding' 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:
--
-- 'findingId', 'describeAuditFinding_findingId' - A unique identifier for a single audit finding. You can use this
-- identifier to apply mitigation actions to the finding.
newDescribeAuditFinding ::
  -- | 'findingId'
  Prelude.Text ->
  DescribeAuditFinding
newDescribeAuditFinding :: Text -> DescribeAuditFinding
newDescribeAuditFinding Text
pFindingId_ =
  DescribeAuditFinding' :: Text -> DescribeAuditFinding
DescribeAuditFinding' {$sel:findingId:DescribeAuditFinding' :: Text
findingId = Text
pFindingId_}

-- | A unique identifier for a single audit finding. You can use this
-- identifier to apply mitigation actions to the finding.
describeAuditFinding_findingId :: Lens.Lens' DescribeAuditFinding Prelude.Text
describeAuditFinding_findingId :: (Text -> f Text) -> DescribeAuditFinding -> f DescribeAuditFinding
describeAuditFinding_findingId = (DescribeAuditFinding -> Text)
-> (DescribeAuditFinding -> Text -> DescribeAuditFinding)
-> Lens DescribeAuditFinding DescribeAuditFinding Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAuditFinding' {Text
findingId :: Text
$sel:findingId:DescribeAuditFinding' :: DescribeAuditFinding -> Text
findingId} -> Text
findingId) (\s :: DescribeAuditFinding
s@DescribeAuditFinding' {} Text
a -> DescribeAuditFinding
s {$sel:findingId:DescribeAuditFinding' :: Text
findingId = Text
a} :: DescribeAuditFinding)

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

instance Prelude.NFData DescribeAuditFinding

instance Core.ToHeaders DescribeAuditFinding where
  toHeaders :: DescribeAuditFinding -> ResponseHeaders
toHeaders = ResponseHeaders -> DescribeAuditFinding -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath DescribeAuditFinding where
  toPath :: DescribeAuditFinding -> ByteString
toPath DescribeAuditFinding' {Text
findingId :: Text
$sel:findingId:DescribeAuditFinding' :: DescribeAuditFinding -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/audit/findings/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
findingId]

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

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

-- |
-- Create a value of 'DescribeAuditFindingResponse' 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:
--
-- 'finding', 'describeAuditFindingResponse_finding' - Undocumented member.
--
-- 'httpStatus', 'describeAuditFindingResponse_httpStatus' - The response's http status code.
newDescribeAuditFindingResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeAuditFindingResponse
newDescribeAuditFindingResponse :: Int -> DescribeAuditFindingResponse
newDescribeAuditFindingResponse Int
pHttpStatus_ =
  DescribeAuditFindingResponse' :: Maybe AuditFinding -> Int -> DescribeAuditFindingResponse
DescribeAuditFindingResponse'
    { $sel:finding:DescribeAuditFindingResponse' :: Maybe AuditFinding
finding =
        Maybe AuditFinding
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeAuditFindingResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
describeAuditFindingResponse_finding :: Lens.Lens' DescribeAuditFindingResponse (Prelude.Maybe AuditFinding)
describeAuditFindingResponse_finding :: (Maybe AuditFinding -> f (Maybe AuditFinding))
-> DescribeAuditFindingResponse -> f DescribeAuditFindingResponse
describeAuditFindingResponse_finding = (DescribeAuditFindingResponse -> Maybe AuditFinding)
-> (DescribeAuditFindingResponse
    -> Maybe AuditFinding -> DescribeAuditFindingResponse)
-> Lens
     DescribeAuditFindingResponse
     DescribeAuditFindingResponse
     (Maybe AuditFinding)
     (Maybe AuditFinding)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAuditFindingResponse' {Maybe AuditFinding
finding :: Maybe AuditFinding
$sel:finding:DescribeAuditFindingResponse' :: DescribeAuditFindingResponse -> Maybe AuditFinding
finding} -> Maybe AuditFinding
finding) (\s :: DescribeAuditFindingResponse
s@DescribeAuditFindingResponse' {} Maybe AuditFinding
a -> DescribeAuditFindingResponse
s {$sel:finding:DescribeAuditFindingResponse' :: Maybe AuditFinding
finding = Maybe AuditFinding
a} :: DescribeAuditFindingResponse)

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

instance Prelude.NFData DescribeAuditFindingResponse