{-# 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.AuditManager.GetEvidence
-- 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)
--
-- Returns evidence from Audit Manager.
module Amazonka.AuditManager.GetEvidence
  ( -- * Creating a Request
    GetEvidence (..),
    newGetEvidence,

    -- * Request Lenses
    getEvidence_assessmentId,
    getEvidence_controlSetId,
    getEvidence_evidenceFolderId,
    getEvidence_evidenceId,

    -- * Destructuring the Response
    GetEvidenceResponse (..),
    newGetEvidenceResponse,

    -- * Response Lenses
    getEvidenceResponse_evidence,
    getEvidenceResponse_httpStatus,
  )
where

import Amazonka.AuditManager.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

-- | /See:/ 'newGetEvidence' smart constructor.
data GetEvidence = GetEvidence'
  { -- | The identifier for the specified assessment.
    GetEvidence -> Text
assessmentId :: Prelude.Text,
    -- | The identifier for the specified control set.
    GetEvidence -> Text
controlSetId :: Prelude.Text,
    -- | The identifier for the folder in which the evidence is stored.
    GetEvidence -> Text
evidenceFolderId :: Prelude.Text,
    -- | The identifier for the evidence.
    GetEvidence -> Text
evidenceId :: Prelude.Text
  }
  deriving (GetEvidence -> GetEvidence -> Bool
(GetEvidence -> GetEvidence -> Bool)
-> (GetEvidence -> GetEvidence -> Bool) -> Eq GetEvidence
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetEvidence -> GetEvidence -> Bool
$c/= :: GetEvidence -> GetEvidence -> Bool
== :: GetEvidence -> GetEvidence -> Bool
$c== :: GetEvidence -> GetEvidence -> Bool
Prelude.Eq, ReadPrec [GetEvidence]
ReadPrec GetEvidence
Int -> ReadS GetEvidence
ReadS [GetEvidence]
(Int -> ReadS GetEvidence)
-> ReadS [GetEvidence]
-> ReadPrec GetEvidence
-> ReadPrec [GetEvidence]
-> Read GetEvidence
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetEvidence]
$creadListPrec :: ReadPrec [GetEvidence]
readPrec :: ReadPrec GetEvidence
$creadPrec :: ReadPrec GetEvidence
readList :: ReadS [GetEvidence]
$creadList :: ReadS [GetEvidence]
readsPrec :: Int -> ReadS GetEvidence
$creadsPrec :: Int -> ReadS GetEvidence
Prelude.Read, Int -> GetEvidence -> ShowS
[GetEvidence] -> ShowS
GetEvidence -> String
(Int -> GetEvidence -> ShowS)
-> (GetEvidence -> String)
-> ([GetEvidence] -> ShowS)
-> Show GetEvidence
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetEvidence] -> ShowS
$cshowList :: [GetEvidence] -> ShowS
show :: GetEvidence -> String
$cshow :: GetEvidence -> String
showsPrec :: Int -> GetEvidence -> ShowS
$cshowsPrec :: Int -> GetEvidence -> ShowS
Prelude.Show, (forall x. GetEvidence -> Rep GetEvidence x)
-> (forall x. Rep GetEvidence x -> GetEvidence)
-> Generic GetEvidence
forall x. Rep GetEvidence x -> GetEvidence
forall x. GetEvidence -> Rep GetEvidence x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetEvidence x -> GetEvidence
$cfrom :: forall x. GetEvidence -> Rep GetEvidence x
Prelude.Generic)

-- |
-- Create a value of 'GetEvidence' 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:
--
-- 'assessmentId', 'getEvidence_assessmentId' - The identifier for the specified assessment.
--
-- 'controlSetId', 'getEvidence_controlSetId' - The identifier for the specified control set.
--
-- 'evidenceFolderId', 'getEvidence_evidenceFolderId' - The identifier for the folder in which the evidence is stored.
--
-- 'evidenceId', 'getEvidence_evidenceId' - The identifier for the evidence.
newGetEvidence ::
  -- | 'assessmentId'
  Prelude.Text ->
  -- | 'controlSetId'
  Prelude.Text ->
  -- | 'evidenceFolderId'
  Prelude.Text ->
  -- | 'evidenceId'
  Prelude.Text ->
  GetEvidence
newGetEvidence :: Text -> Text -> Text -> Text -> GetEvidence
newGetEvidence
  Text
pAssessmentId_
  Text
pControlSetId_
  Text
pEvidenceFolderId_
  Text
pEvidenceId_ =
    GetEvidence' :: Text -> Text -> Text -> Text -> GetEvidence
GetEvidence'
      { $sel:assessmentId:GetEvidence' :: Text
assessmentId = Text
pAssessmentId_,
        $sel:controlSetId:GetEvidence' :: Text
controlSetId = Text
pControlSetId_,
        $sel:evidenceFolderId:GetEvidence' :: Text
evidenceFolderId = Text
pEvidenceFolderId_,
        $sel:evidenceId:GetEvidence' :: Text
evidenceId = Text
pEvidenceId_
      }

-- | The identifier for the specified assessment.
getEvidence_assessmentId :: Lens.Lens' GetEvidence Prelude.Text
getEvidence_assessmentId :: (Text -> f Text) -> GetEvidence -> f GetEvidence
getEvidence_assessmentId = (GetEvidence -> Text)
-> (GetEvidence -> Text -> GetEvidence)
-> Lens GetEvidence GetEvidence Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEvidence' {Text
assessmentId :: Text
$sel:assessmentId:GetEvidence' :: GetEvidence -> Text
assessmentId} -> Text
assessmentId) (\s :: GetEvidence
s@GetEvidence' {} Text
a -> GetEvidence
s {$sel:assessmentId:GetEvidence' :: Text
assessmentId = Text
a} :: GetEvidence)

-- | The identifier for the specified control set.
getEvidence_controlSetId :: Lens.Lens' GetEvidence Prelude.Text
getEvidence_controlSetId :: (Text -> f Text) -> GetEvidence -> f GetEvidence
getEvidence_controlSetId = (GetEvidence -> Text)
-> (GetEvidence -> Text -> GetEvidence)
-> Lens GetEvidence GetEvidence Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEvidence' {Text
controlSetId :: Text
$sel:controlSetId:GetEvidence' :: GetEvidence -> Text
controlSetId} -> Text
controlSetId) (\s :: GetEvidence
s@GetEvidence' {} Text
a -> GetEvidence
s {$sel:controlSetId:GetEvidence' :: Text
controlSetId = Text
a} :: GetEvidence)

-- | The identifier for the folder in which the evidence is stored.
getEvidence_evidenceFolderId :: Lens.Lens' GetEvidence Prelude.Text
getEvidence_evidenceFolderId :: (Text -> f Text) -> GetEvidence -> f GetEvidence
getEvidence_evidenceFolderId = (GetEvidence -> Text)
-> (GetEvidence -> Text -> GetEvidence)
-> Lens GetEvidence GetEvidence Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEvidence' {Text
evidenceFolderId :: Text
$sel:evidenceFolderId:GetEvidence' :: GetEvidence -> Text
evidenceFolderId} -> Text
evidenceFolderId) (\s :: GetEvidence
s@GetEvidence' {} Text
a -> GetEvidence
s {$sel:evidenceFolderId:GetEvidence' :: Text
evidenceFolderId = Text
a} :: GetEvidence)

-- | The identifier for the evidence.
getEvidence_evidenceId :: Lens.Lens' GetEvidence Prelude.Text
getEvidence_evidenceId :: (Text -> f Text) -> GetEvidence -> f GetEvidence
getEvidence_evidenceId = (GetEvidence -> Text)
-> (GetEvidence -> Text -> GetEvidence)
-> Lens GetEvidence GetEvidence Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEvidence' {Text
evidenceId :: Text
$sel:evidenceId:GetEvidence' :: GetEvidence -> Text
evidenceId} -> Text
evidenceId) (\s :: GetEvidence
s@GetEvidence' {} Text
a -> GetEvidence
s {$sel:evidenceId:GetEvidence' :: Text
evidenceId = Text
a} :: GetEvidence)

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

instance Prelude.NFData GetEvidence

instance Core.ToHeaders GetEvidence where
  toHeaders :: GetEvidence -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetEvidence -> 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 GetEvidence where
  toPath :: GetEvidence -> ByteString
toPath GetEvidence' {Text
evidenceId :: Text
evidenceFolderId :: Text
controlSetId :: Text
assessmentId :: Text
$sel:evidenceId:GetEvidence' :: GetEvidence -> Text
$sel:evidenceFolderId:GetEvidence' :: GetEvidence -> Text
$sel:controlSetId:GetEvidence' :: GetEvidence -> Text
$sel:assessmentId:GetEvidence' :: GetEvidence -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/assessments/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
assessmentId,
        ByteString
"/controlSets/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
controlSetId,
        ByteString
"/evidenceFolders/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
evidenceFolderId,
        ByteString
"/evidence/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
evidenceId
      ]

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

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

-- |
-- Create a value of 'GetEvidenceResponse' 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:
--
-- 'evidence', 'getEvidenceResponse_evidence' - The evidence returned by the @GetEvidenceResponse@ API.
--
-- 'httpStatus', 'getEvidenceResponse_httpStatus' - The response's http status code.
newGetEvidenceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetEvidenceResponse
newGetEvidenceResponse :: Int -> GetEvidenceResponse
newGetEvidenceResponse Int
pHttpStatus_ =
  GetEvidenceResponse' :: Maybe Evidence -> Int -> GetEvidenceResponse
GetEvidenceResponse'
    { $sel:evidence:GetEvidenceResponse' :: Maybe Evidence
evidence = Maybe Evidence
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetEvidenceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The evidence returned by the @GetEvidenceResponse@ API.
getEvidenceResponse_evidence :: Lens.Lens' GetEvidenceResponse (Prelude.Maybe Evidence)
getEvidenceResponse_evidence :: (Maybe Evidence -> f (Maybe Evidence))
-> GetEvidenceResponse -> f GetEvidenceResponse
getEvidenceResponse_evidence = (GetEvidenceResponse -> Maybe Evidence)
-> (GetEvidenceResponse -> Maybe Evidence -> GetEvidenceResponse)
-> Lens
     GetEvidenceResponse
     GetEvidenceResponse
     (Maybe Evidence)
     (Maybe Evidence)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEvidenceResponse' {Maybe Evidence
evidence :: Maybe Evidence
$sel:evidence:GetEvidenceResponse' :: GetEvidenceResponse -> Maybe Evidence
evidence} -> Maybe Evidence
evidence) (\s :: GetEvidenceResponse
s@GetEvidenceResponse' {} Maybe Evidence
a -> GetEvidenceResponse
s {$sel:evidence:GetEvidenceResponse' :: Maybe Evidence
evidence = Maybe Evidence
a} :: GetEvidenceResponse)

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

instance Prelude.NFData GetEvidenceResponse