{-# 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.CreateAssessmentReport
-- 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)
--
-- Creates an assessment report for the specified assessment.
module Amazonka.AuditManager.CreateAssessmentReport
  ( -- * Creating a Request
    CreateAssessmentReport (..),
    newCreateAssessmentReport,

    -- * Request Lenses
    createAssessmentReport_description,
    createAssessmentReport_name,
    createAssessmentReport_assessmentId,

    -- * Destructuring the Response
    CreateAssessmentReportResponse (..),
    newCreateAssessmentReportResponse,

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

-- |
-- Create a value of 'CreateAssessmentReport' 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:
--
-- 'description', 'createAssessmentReport_description' - The description of the assessment report.
--
-- 'name', 'createAssessmentReport_name' - The name of the new assessment report.
--
-- 'assessmentId', 'createAssessmentReport_assessmentId' - The identifier for the specified assessment.
newCreateAssessmentReport ::
  -- | 'name'
  Prelude.Text ->
  -- | 'assessmentId'
  Prelude.Text ->
  CreateAssessmentReport
newCreateAssessmentReport :: Text -> Text -> CreateAssessmentReport
newCreateAssessmentReport Text
pName_ Text
pAssessmentId_ =
  CreateAssessmentReport' :: Maybe Text -> Text -> Text -> CreateAssessmentReport
CreateAssessmentReport'
    { $sel:description:CreateAssessmentReport' :: Maybe Text
description =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CreateAssessmentReport' :: Text
name = Text
pName_,
      $sel:assessmentId:CreateAssessmentReport' :: Text
assessmentId = Text
pAssessmentId_
    }

-- | The description of the assessment report.
createAssessmentReport_description :: Lens.Lens' CreateAssessmentReport (Prelude.Maybe Prelude.Text)
createAssessmentReport_description :: (Maybe Text -> f (Maybe Text))
-> CreateAssessmentReport -> f CreateAssessmentReport
createAssessmentReport_description = (CreateAssessmentReport -> Maybe Text)
-> (CreateAssessmentReport -> Maybe Text -> CreateAssessmentReport)
-> Lens
     CreateAssessmentReport
     CreateAssessmentReport
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAssessmentReport' {Maybe Text
description :: Maybe Text
$sel:description:CreateAssessmentReport' :: CreateAssessmentReport -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateAssessmentReport
s@CreateAssessmentReport' {} Maybe Text
a -> CreateAssessmentReport
s {$sel:description:CreateAssessmentReport' :: Maybe Text
description = Maybe Text
a} :: CreateAssessmentReport)

-- | The name of the new assessment report.
createAssessmentReport_name :: Lens.Lens' CreateAssessmentReport Prelude.Text
createAssessmentReport_name :: (Text -> f Text)
-> CreateAssessmentReport -> f CreateAssessmentReport
createAssessmentReport_name = (CreateAssessmentReport -> Text)
-> (CreateAssessmentReport -> Text -> CreateAssessmentReport)
-> Lens CreateAssessmentReport CreateAssessmentReport Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAssessmentReport' {Text
name :: Text
$sel:name:CreateAssessmentReport' :: CreateAssessmentReport -> Text
name} -> Text
name) (\s :: CreateAssessmentReport
s@CreateAssessmentReport' {} Text
a -> CreateAssessmentReport
s {$sel:name:CreateAssessmentReport' :: Text
name = Text
a} :: CreateAssessmentReport)

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

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

instance Prelude.NFData CreateAssessmentReport

instance Core.ToHeaders CreateAssessmentReport where
  toHeaders :: CreateAssessmentReport -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateAssessmentReport -> 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.ToJSON CreateAssessmentReport where
  toJSON :: CreateAssessmentReport -> Value
toJSON CreateAssessmentReport' {Maybe Text
Text
assessmentId :: Text
name :: Text
description :: Maybe Text
$sel:assessmentId:CreateAssessmentReport' :: CreateAssessmentReport -> Text
$sel:name:CreateAssessmentReport' :: CreateAssessmentReport -> Text
$sel:description:CreateAssessmentReport' :: CreateAssessmentReport -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)
          ]
      )

instance Core.ToPath CreateAssessmentReport where
  toPath :: CreateAssessmentReport -> ByteString
toPath CreateAssessmentReport' {Maybe Text
Text
assessmentId :: Text
name :: Text
description :: Maybe Text
$sel:assessmentId:CreateAssessmentReport' :: CreateAssessmentReport -> Text
$sel:name:CreateAssessmentReport' :: CreateAssessmentReport -> Text
$sel:description:CreateAssessmentReport' :: CreateAssessmentReport -> Maybe 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
"/reports"]

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

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

-- |
-- Create a value of 'CreateAssessmentReportResponse' 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:
--
-- 'assessmentReport', 'createAssessmentReportResponse_assessmentReport' - The new assessment report returned by the @CreateAssessmentReport@ API.
--
-- 'httpStatus', 'createAssessmentReportResponse_httpStatus' - The response's http status code.
newCreateAssessmentReportResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateAssessmentReportResponse
newCreateAssessmentReportResponse :: Int -> CreateAssessmentReportResponse
newCreateAssessmentReportResponse Int
pHttpStatus_ =
  CreateAssessmentReportResponse' :: Maybe AssessmentReport -> Int -> CreateAssessmentReportResponse
CreateAssessmentReportResponse'
    { $sel:assessmentReport:CreateAssessmentReportResponse' :: Maybe AssessmentReport
assessmentReport =
        Maybe AssessmentReport
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateAssessmentReportResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The new assessment report returned by the @CreateAssessmentReport@ API.
createAssessmentReportResponse_assessmentReport :: Lens.Lens' CreateAssessmentReportResponse (Prelude.Maybe AssessmentReport)
createAssessmentReportResponse_assessmentReport :: (Maybe AssessmentReport -> f (Maybe AssessmentReport))
-> CreateAssessmentReportResponse
-> f CreateAssessmentReportResponse
createAssessmentReportResponse_assessmentReport = (CreateAssessmentReportResponse -> Maybe AssessmentReport)
-> (CreateAssessmentReportResponse
    -> Maybe AssessmentReport -> CreateAssessmentReportResponse)
-> Lens
     CreateAssessmentReportResponse
     CreateAssessmentReportResponse
     (Maybe AssessmentReport)
     (Maybe AssessmentReport)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAssessmentReportResponse' {Maybe AssessmentReport
assessmentReport :: Maybe AssessmentReport
$sel:assessmentReport:CreateAssessmentReportResponse' :: CreateAssessmentReportResponse -> Maybe AssessmentReport
assessmentReport} -> Maybe AssessmentReport
assessmentReport) (\s :: CreateAssessmentReportResponse
s@CreateAssessmentReportResponse' {} Maybe AssessmentReport
a -> CreateAssessmentReportResponse
s {$sel:assessmentReport:CreateAssessmentReportResponse' :: Maybe AssessmentReport
assessmentReport = Maybe AssessmentReport
a} :: CreateAssessmentReportResponse)

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

instance
  Prelude.NFData
    CreateAssessmentReportResponse