{-# 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.UpdateAssessmentStatus
-- 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)
--
-- Updates the status of an assessment in Audit Manager.
module Amazonka.AuditManager.UpdateAssessmentStatus
  ( -- * Creating a Request
    UpdateAssessmentStatus (..),
    newUpdateAssessmentStatus,

    -- * Request Lenses
    updateAssessmentStatus_assessmentId,
    updateAssessmentStatus_status,

    -- * Destructuring the Response
    UpdateAssessmentStatusResponse (..),
    newUpdateAssessmentStatusResponse,

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

-- |
-- Create a value of 'UpdateAssessmentStatus' 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', 'updateAssessmentStatus_assessmentId' - The identifier for the specified assessment.
--
-- 'status', 'updateAssessmentStatus_status' - The current status of the specified assessment.
newUpdateAssessmentStatus ::
  -- | 'assessmentId'
  Prelude.Text ->
  -- | 'status'
  AssessmentStatus ->
  UpdateAssessmentStatus
newUpdateAssessmentStatus :: Text -> AssessmentStatus -> UpdateAssessmentStatus
newUpdateAssessmentStatus Text
pAssessmentId_ AssessmentStatus
pStatus_ =
  UpdateAssessmentStatus' :: Text -> AssessmentStatus -> UpdateAssessmentStatus
UpdateAssessmentStatus'
    { $sel:assessmentId:UpdateAssessmentStatus' :: Text
assessmentId =
        Text
pAssessmentId_,
      $sel:status:UpdateAssessmentStatus' :: AssessmentStatus
status = AssessmentStatus
pStatus_
    }

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

-- | The current status of the specified assessment.
updateAssessmentStatus_status :: Lens.Lens' UpdateAssessmentStatus AssessmentStatus
updateAssessmentStatus_status :: (AssessmentStatus -> f AssessmentStatus)
-> UpdateAssessmentStatus -> f UpdateAssessmentStatus
updateAssessmentStatus_status = (UpdateAssessmentStatus -> AssessmentStatus)
-> (UpdateAssessmentStatus
    -> AssessmentStatus -> UpdateAssessmentStatus)
-> Lens
     UpdateAssessmentStatus
     UpdateAssessmentStatus
     AssessmentStatus
     AssessmentStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAssessmentStatus' {AssessmentStatus
status :: AssessmentStatus
$sel:status:UpdateAssessmentStatus' :: UpdateAssessmentStatus -> AssessmentStatus
status} -> AssessmentStatus
status) (\s :: UpdateAssessmentStatus
s@UpdateAssessmentStatus' {} AssessmentStatus
a -> UpdateAssessmentStatus
s {$sel:status:UpdateAssessmentStatus' :: AssessmentStatus
status = AssessmentStatus
a} :: UpdateAssessmentStatus)

instance Core.AWSRequest UpdateAssessmentStatus where
  type
    AWSResponse UpdateAssessmentStatus =
      UpdateAssessmentStatusResponse
  request :: UpdateAssessmentStatus -> Request UpdateAssessmentStatus
request = Service -> UpdateAssessmentStatus -> Request UpdateAssessmentStatus
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateAssessmentStatus
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateAssessmentStatus)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateAssessmentStatus))
-> Logger
-> Service
-> Proxy UpdateAssessmentStatus
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateAssessmentStatus)))
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 Assessment -> Int -> UpdateAssessmentStatusResponse
UpdateAssessmentStatusResponse'
            (Maybe Assessment -> Int -> UpdateAssessmentStatusResponse)
-> Either String (Maybe Assessment)
-> Either String (Int -> UpdateAssessmentStatusResponse)
forall (f :: * -> *) a b. Functor 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 -> UpdateAssessmentStatusResponse)
-> Either String Int
-> Either String UpdateAssessmentStatusResponse
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 UpdateAssessmentStatus

instance Prelude.NFData UpdateAssessmentStatus

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

instance Core.ToPath UpdateAssessmentStatus where
  toPath :: UpdateAssessmentStatus -> ByteString
toPath UpdateAssessmentStatus' {Text
AssessmentStatus
status :: AssessmentStatus
assessmentId :: Text
$sel:status:UpdateAssessmentStatus' :: UpdateAssessmentStatus -> AssessmentStatus
$sel:assessmentId:UpdateAssessmentStatus' :: UpdateAssessmentStatus -> 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
"/status"]

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

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

-- |
-- Create a value of 'UpdateAssessmentStatusResponse' 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:
--
-- 'assessment', 'updateAssessmentStatusResponse_assessment' - The name of the updated assessment returned by the
-- @UpdateAssessmentStatus@ API.
--
-- 'httpStatus', 'updateAssessmentStatusResponse_httpStatus' - The response's http status code.
newUpdateAssessmentStatusResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateAssessmentStatusResponse
newUpdateAssessmentStatusResponse :: Int -> UpdateAssessmentStatusResponse
newUpdateAssessmentStatusResponse Int
pHttpStatus_ =
  UpdateAssessmentStatusResponse' :: Maybe Assessment -> Int -> UpdateAssessmentStatusResponse
UpdateAssessmentStatusResponse'
    { $sel:assessment:UpdateAssessmentStatusResponse' :: Maybe Assessment
assessment =
        Maybe Assessment
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateAssessmentStatusResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The name of the updated assessment returned by the
-- @UpdateAssessmentStatus@ API.
updateAssessmentStatusResponse_assessment :: Lens.Lens' UpdateAssessmentStatusResponse (Prelude.Maybe Assessment)
updateAssessmentStatusResponse_assessment :: (Maybe Assessment -> f (Maybe Assessment))
-> UpdateAssessmentStatusResponse
-> f UpdateAssessmentStatusResponse
updateAssessmentStatusResponse_assessment = (UpdateAssessmentStatusResponse -> Maybe Assessment)
-> (UpdateAssessmentStatusResponse
    -> Maybe Assessment -> UpdateAssessmentStatusResponse)
-> Lens
     UpdateAssessmentStatusResponse
     UpdateAssessmentStatusResponse
     (Maybe Assessment)
     (Maybe Assessment)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAssessmentStatusResponse' {Maybe Assessment
assessment :: Maybe Assessment
$sel:assessment:UpdateAssessmentStatusResponse' :: UpdateAssessmentStatusResponse -> Maybe Assessment
assessment} -> Maybe Assessment
assessment) (\s :: UpdateAssessmentStatusResponse
s@UpdateAssessmentStatusResponse' {} Maybe Assessment
a -> UpdateAssessmentStatusResponse
s {$sel:assessment:UpdateAssessmentStatusResponse' :: Maybe Assessment
assessment = Maybe Assessment
a} :: UpdateAssessmentStatusResponse)

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

instance
  Prelude.NFData
    UpdateAssessmentStatusResponse