{-# 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.GetAssessmentFramework
-- 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 a framework from Audit Manager.
module Amazonka.AuditManager.GetAssessmentFramework
  ( -- * Creating a Request
    GetAssessmentFramework (..),
    newGetAssessmentFramework,

    -- * Request Lenses
    getAssessmentFramework_frameworkId,

    -- * Destructuring the Response
    GetAssessmentFrameworkResponse (..),
    newGetAssessmentFrameworkResponse,

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

-- |
-- Create a value of 'GetAssessmentFramework' 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:
--
-- 'frameworkId', 'getAssessmentFramework_frameworkId' - The identifier for the specified framework.
newGetAssessmentFramework ::
  -- | 'frameworkId'
  Prelude.Text ->
  GetAssessmentFramework
newGetAssessmentFramework :: Text -> GetAssessmentFramework
newGetAssessmentFramework Text
pFrameworkId_ =
  GetAssessmentFramework' :: Text -> GetAssessmentFramework
GetAssessmentFramework'
    { $sel:frameworkId:GetAssessmentFramework' :: Text
frameworkId =
        Text
pFrameworkId_
    }

-- | The identifier for the specified framework.
getAssessmentFramework_frameworkId :: Lens.Lens' GetAssessmentFramework Prelude.Text
getAssessmentFramework_frameworkId :: (Text -> f Text)
-> GetAssessmentFramework -> f GetAssessmentFramework
getAssessmentFramework_frameworkId = (GetAssessmentFramework -> Text)
-> (GetAssessmentFramework -> Text -> GetAssessmentFramework)
-> Lens GetAssessmentFramework GetAssessmentFramework Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAssessmentFramework' {Text
frameworkId :: Text
$sel:frameworkId:GetAssessmentFramework' :: GetAssessmentFramework -> Text
frameworkId} -> Text
frameworkId) (\s :: GetAssessmentFramework
s@GetAssessmentFramework' {} Text
a -> GetAssessmentFramework
s {$sel:frameworkId:GetAssessmentFramework' :: Text
frameworkId = Text
a} :: GetAssessmentFramework)

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

instance Prelude.NFData GetAssessmentFramework

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

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

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

-- |
-- Create a value of 'GetAssessmentFrameworkResponse' 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:
--
-- 'framework', 'getAssessmentFrameworkResponse_framework' - The framework returned by the @GetAssessmentFramework@ API.
--
-- 'httpStatus', 'getAssessmentFrameworkResponse_httpStatus' - The response's http status code.
newGetAssessmentFrameworkResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetAssessmentFrameworkResponse
newGetAssessmentFrameworkResponse :: Int -> GetAssessmentFrameworkResponse
newGetAssessmentFrameworkResponse Int
pHttpStatus_ =
  GetAssessmentFrameworkResponse' :: Maybe Framework -> Int -> GetAssessmentFrameworkResponse
GetAssessmentFrameworkResponse'
    { $sel:framework:GetAssessmentFrameworkResponse' :: Maybe Framework
framework =
        Maybe Framework
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetAssessmentFrameworkResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The framework returned by the @GetAssessmentFramework@ API.
getAssessmentFrameworkResponse_framework :: Lens.Lens' GetAssessmentFrameworkResponse (Prelude.Maybe Framework)
getAssessmentFrameworkResponse_framework :: (Maybe Framework -> f (Maybe Framework))
-> GetAssessmentFrameworkResponse
-> f GetAssessmentFrameworkResponse
getAssessmentFrameworkResponse_framework = (GetAssessmentFrameworkResponse -> Maybe Framework)
-> (GetAssessmentFrameworkResponse
    -> Maybe Framework -> GetAssessmentFrameworkResponse)
-> Lens
     GetAssessmentFrameworkResponse
     GetAssessmentFrameworkResponse
     (Maybe Framework)
     (Maybe Framework)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAssessmentFrameworkResponse' {Maybe Framework
framework :: Maybe Framework
$sel:framework:GetAssessmentFrameworkResponse' :: GetAssessmentFrameworkResponse -> Maybe Framework
framework} -> Maybe Framework
framework) (\s :: GetAssessmentFrameworkResponse
s@GetAssessmentFrameworkResponse' {} Maybe Framework
a -> GetAssessmentFrameworkResponse
s {$sel:framework:GetAssessmentFrameworkResponse' :: Maybe Framework
framework = Maybe Framework
a} :: GetAssessmentFrameworkResponse)

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

instance
  Prelude.NFData
    GetAssessmentFrameworkResponse