{-# 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.GetAssessment
-- 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 an assessment from Audit Manager.
module Amazonka.AuditManager.GetAssessment
  ( -- * Creating a Request
    GetAssessment (..),
    newGetAssessment,

    -- * Request Lenses
    getAssessment_assessmentId,

    -- * Destructuring the Response
    GetAssessmentResponse (..),
    newGetAssessmentResponse,

    -- * Response Lenses
    getAssessmentResponse_userRole,
    getAssessmentResponse_assessment,
    getAssessmentResponse_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:/ 'newGetAssessment' smart constructor.
data GetAssessment = GetAssessment'
  { -- | The identifier for the specified assessment.
    GetAssessment -> Text
assessmentId :: Prelude.Text
  }
  deriving (GetAssessment -> GetAssessment -> Bool
(GetAssessment -> GetAssessment -> Bool)
-> (GetAssessment -> GetAssessment -> Bool) -> Eq GetAssessment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAssessment -> GetAssessment -> Bool
$c/= :: GetAssessment -> GetAssessment -> Bool
== :: GetAssessment -> GetAssessment -> Bool
$c== :: GetAssessment -> GetAssessment -> Bool
Prelude.Eq, ReadPrec [GetAssessment]
ReadPrec GetAssessment
Int -> ReadS GetAssessment
ReadS [GetAssessment]
(Int -> ReadS GetAssessment)
-> ReadS [GetAssessment]
-> ReadPrec GetAssessment
-> ReadPrec [GetAssessment]
-> Read GetAssessment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAssessment]
$creadListPrec :: ReadPrec [GetAssessment]
readPrec :: ReadPrec GetAssessment
$creadPrec :: ReadPrec GetAssessment
readList :: ReadS [GetAssessment]
$creadList :: ReadS [GetAssessment]
readsPrec :: Int -> ReadS GetAssessment
$creadsPrec :: Int -> ReadS GetAssessment
Prelude.Read, Int -> GetAssessment -> ShowS
[GetAssessment] -> ShowS
GetAssessment -> String
(Int -> GetAssessment -> ShowS)
-> (GetAssessment -> String)
-> ([GetAssessment] -> ShowS)
-> Show GetAssessment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAssessment] -> ShowS
$cshowList :: [GetAssessment] -> ShowS
show :: GetAssessment -> String
$cshow :: GetAssessment -> String
showsPrec :: Int -> GetAssessment -> ShowS
$cshowsPrec :: Int -> GetAssessment -> ShowS
Prelude.Show, (forall x. GetAssessment -> Rep GetAssessment x)
-> (forall x. Rep GetAssessment x -> GetAssessment)
-> Generic GetAssessment
forall x. Rep GetAssessment x -> GetAssessment
forall x. GetAssessment -> Rep GetAssessment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetAssessment x -> GetAssessment
$cfrom :: forall x. GetAssessment -> Rep GetAssessment x
Prelude.Generic)

-- |
-- Create a value of 'GetAssessment' 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', 'getAssessment_assessmentId' - The identifier for the specified assessment.
newGetAssessment ::
  -- | 'assessmentId'
  Prelude.Text ->
  GetAssessment
newGetAssessment :: Text -> GetAssessment
newGetAssessment Text
pAssessmentId_ =
  GetAssessment' :: Text -> GetAssessment
GetAssessment' {$sel:assessmentId:GetAssessment' :: Text
assessmentId = Text
pAssessmentId_}

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

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

instance Prelude.NFData GetAssessment

instance Core.ToHeaders GetAssessment where
  toHeaders :: GetAssessment -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetAssessment -> 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 GetAssessment where
  toPath :: GetAssessment -> ByteString
toPath GetAssessment' {Text
assessmentId :: Text
$sel:assessmentId:GetAssessment' :: GetAssessment -> 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]

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

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

-- |
-- Create a value of 'GetAssessmentResponse' 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:
--
-- 'userRole', 'getAssessmentResponse_userRole' - Undocumented member.
--
-- 'assessment', 'getAssessmentResponse_assessment' - Undocumented member.
--
-- 'httpStatus', 'getAssessmentResponse_httpStatus' - The response's http status code.
newGetAssessmentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetAssessmentResponse
newGetAssessmentResponse :: Int -> GetAssessmentResponse
newGetAssessmentResponse Int
pHttpStatus_ =
  GetAssessmentResponse' :: Maybe Role -> Maybe Assessment -> Int -> GetAssessmentResponse
GetAssessmentResponse'
    { $sel:userRole:GetAssessmentResponse' :: Maybe Role
userRole = Maybe Role
forall a. Maybe a
Prelude.Nothing,
      $sel:assessment:GetAssessmentResponse' :: Maybe Assessment
assessment = Maybe Assessment
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetAssessmentResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
getAssessmentResponse_userRole :: Lens.Lens' GetAssessmentResponse (Prelude.Maybe Role)
getAssessmentResponse_userRole :: (Maybe Role -> f (Maybe Role))
-> GetAssessmentResponse -> f GetAssessmentResponse
getAssessmentResponse_userRole = (GetAssessmentResponse -> Maybe Role)
-> (GetAssessmentResponse -> Maybe Role -> GetAssessmentResponse)
-> Lens
     GetAssessmentResponse
     GetAssessmentResponse
     (Maybe Role)
     (Maybe Role)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAssessmentResponse' {Maybe Role
userRole :: Maybe Role
$sel:userRole:GetAssessmentResponse' :: GetAssessmentResponse -> Maybe Role
userRole} -> Maybe Role
userRole) (\s :: GetAssessmentResponse
s@GetAssessmentResponse' {} Maybe Role
a -> GetAssessmentResponse
s {$sel:userRole:GetAssessmentResponse' :: Maybe Role
userRole = Maybe Role
a} :: GetAssessmentResponse)

-- | Undocumented member.
getAssessmentResponse_assessment :: Lens.Lens' GetAssessmentResponse (Prelude.Maybe Assessment)
getAssessmentResponse_assessment :: (Maybe Assessment -> f (Maybe Assessment))
-> GetAssessmentResponse -> f GetAssessmentResponse
getAssessmentResponse_assessment = (GetAssessmentResponse -> Maybe Assessment)
-> (GetAssessmentResponse
    -> Maybe Assessment -> GetAssessmentResponse)
-> Lens
     GetAssessmentResponse
     GetAssessmentResponse
     (Maybe Assessment)
     (Maybe Assessment)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAssessmentResponse' {Maybe Assessment
assessment :: Maybe Assessment
$sel:assessment:GetAssessmentResponse' :: GetAssessmentResponse -> Maybe Assessment
assessment} -> Maybe Assessment
assessment) (\s :: GetAssessmentResponse
s@GetAssessmentResponse' {} Maybe Assessment
a -> GetAssessmentResponse
s {$sel:assessment:GetAssessmentResponse' :: Maybe Assessment
assessment = Maybe Assessment
a} :: GetAssessmentResponse)

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

instance Prelude.NFData GetAssessmentResponse