{-# 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.WellArchitected.UpdateAnswer
-- 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)
--
-- Update the answer to a specific question in a workload review.
module Amazonka.WellArchitected.UpdateAnswer
  ( -- * Creating a Request
    UpdateAnswer (..),
    newUpdateAnswer,

    -- * Request Lenses
    updateAnswer_isApplicable,
    updateAnswer_selectedChoices,
    updateAnswer_reason,
    updateAnswer_notes,
    updateAnswer_choiceUpdates,
    updateAnswer_workloadId,
    updateAnswer_lensAlias,
    updateAnswer_questionId,

    -- * Destructuring the Response
    UpdateAnswerResponse (..),
    newUpdateAnswerResponse,

    -- * Response Lenses
    updateAnswerResponse_lensAlias,
    updateAnswerResponse_answer,
    updateAnswerResponse_workloadId,
    updateAnswerResponse_httpStatus,
  )
where

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
import Amazonka.WellArchitected.Types

-- | Input to update answer.
--
-- /See:/ 'newUpdateAnswer' smart constructor.
data UpdateAnswer = UpdateAnswer'
  { UpdateAnswer -> Maybe Bool
isApplicable :: Prelude.Maybe Prelude.Bool,
    UpdateAnswer -> Maybe [Text]
selectedChoices :: Prelude.Maybe [Prelude.Text],
    -- | The reason why a question is not applicable to your workload.
    UpdateAnswer -> Maybe AnswerReason
reason :: Prelude.Maybe AnswerReason,
    UpdateAnswer -> Maybe Text
notes :: Prelude.Maybe Prelude.Text,
    -- | A list of choices to update on a question in your workload. The String
    -- key corresponds to the choice ID to be updated.
    UpdateAnswer -> Maybe (HashMap Text ChoiceUpdate)
choiceUpdates :: Prelude.Maybe (Prelude.HashMap Prelude.Text ChoiceUpdate),
    UpdateAnswer -> Text
workloadId :: Prelude.Text,
    UpdateAnswer -> Text
lensAlias :: Prelude.Text,
    UpdateAnswer -> Text
questionId :: Prelude.Text
  }
  deriving (UpdateAnswer -> UpdateAnswer -> Bool
(UpdateAnswer -> UpdateAnswer -> Bool)
-> (UpdateAnswer -> UpdateAnswer -> Bool) -> Eq UpdateAnswer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateAnswer -> UpdateAnswer -> Bool
$c/= :: UpdateAnswer -> UpdateAnswer -> Bool
== :: UpdateAnswer -> UpdateAnswer -> Bool
$c== :: UpdateAnswer -> UpdateAnswer -> Bool
Prelude.Eq, ReadPrec [UpdateAnswer]
ReadPrec UpdateAnswer
Int -> ReadS UpdateAnswer
ReadS [UpdateAnswer]
(Int -> ReadS UpdateAnswer)
-> ReadS [UpdateAnswer]
-> ReadPrec UpdateAnswer
-> ReadPrec [UpdateAnswer]
-> Read UpdateAnswer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateAnswer]
$creadListPrec :: ReadPrec [UpdateAnswer]
readPrec :: ReadPrec UpdateAnswer
$creadPrec :: ReadPrec UpdateAnswer
readList :: ReadS [UpdateAnswer]
$creadList :: ReadS [UpdateAnswer]
readsPrec :: Int -> ReadS UpdateAnswer
$creadsPrec :: Int -> ReadS UpdateAnswer
Prelude.Read, Int -> UpdateAnswer -> ShowS
[UpdateAnswer] -> ShowS
UpdateAnswer -> String
(Int -> UpdateAnswer -> ShowS)
-> (UpdateAnswer -> String)
-> ([UpdateAnswer] -> ShowS)
-> Show UpdateAnswer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateAnswer] -> ShowS
$cshowList :: [UpdateAnswer] -> ShowS
show :: UpdateAnswer -> String
$cshow :: UpdateAnswer -> String
showsPrec :: Int -> UpdateAnswer -> ShowS
$cshowsPrec :: Int -> UpdateAnswer -> ShowS
Prelude.Show, (forall x. UpdateAnswer -> Rep UpdateAnswer x)
-> (forall x. Rep UpdateAnswer x -> UpdateAnswer)
-> Generic UpdateAnswer
forall x. Rep UpdateAnswer x -> UpdateAnswer
forall x. UpdateAnswer -> Rep UpdateAnswer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateAnswer x -> UpdateAnswer
$cfrom :: forall x. UpdateAnswer -> Rep UpdateAnswer x
Prelude.Generic)

-- |
-- Create a value of 'UpdateAnswer' 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:
--
-- 'isApplicable', 'updateAnswer_isApplicable' - Undocumented member.
--
-- 'selectedChoices', 'updateAnswer_selectedChoices' - Undocumented member.
--
-- 'reason', 'updateAnswer_reason' - The reason why a question is not applicable to your workload.
--
-- 'notes', 'updateAnswer_notes' - Undocumented member.
--
-- 'choiceUpdates', 'updateAnswer_choiceUpdates' - A list of choices to update on a question in your workload. The String
-- key corresponds to the choice ID to be updated.
--
-- 'workloadId', 'updateAnswer_workloadId' - Undocumented member.
--
-- 'lensAlias', 'updateAnswer_lensAlias' - Undocumented member.
--
-- 'questionId', 'updateAnswer_questionId' - Undocumented member.
newUpdateAnswer ::
  -- | 'workloadId'
  Prelude.Text ->
  -- | 'lensAlias'
  Prelude.Text ->
  -- | 'questionId'
  Prelude.Text ->
  UpdateAnswer
newUpdateAnswer :: Text -> Text -> Text -> UpdateAnswer
newUpdateAnswer Text
pWorkloadId_ Text
pLensAlias_ Text
pQuestionId_ =
  UpdateAnswer' :: Maybe Bool
-> Maybe [Text]
-> Maybe AnswerReason
-> Maybe Text
-> Maybe (HashMap Text ChoiceUpdate)
-> Text
-> Text
-> Text
-> UpdateAnswer
UpdateAnswer'
    { $sel:isApplicable:UpdateAnswer' :: Maybe Bool
isApplicable = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:selectedChoices:UpdateAnswer' :: Maybe [Text]
selectedChoices = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:reason:UpdateAnswer' :: Maybe AnswerReason
reason = Maybe AnswerReason
forall a. Maybe a
Prelude.Nothing,
      $sel:notes:UpdateAnswer' :: Maybe Text
notes = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:choiceUpdates:UpdateAnswer' :: Maybe (HashMap Text ChoiceUpdate)
choiceUpdates = Maybe (HashMap Text ChoiceUpdate)
forall a. Maybe a
Prelude.Nothing,
      $sel:workloadId:UpdateAnswer' :: Text
workloadId = Text
pWorkloadId_,
      $sel:lensAlias:UpdateAnswer' :: Text
lensAlias = Text
pLensAlias_,
      $sel:questionId:UpdateAnswer' :: Text
questionId = Text
pQuestionId_
    }

-- | Undocumented member.
updateAnswer_isApplicable :: Lens.Lens' UpdateAnswer (Prelude.Maybe Prelude.Bool)
updateAnswer_isApplicable :: (Maybe Bool -> f (Maybe Bool)) -> UpdateAnswer -> f UpdateAnswer
updateAnswer_isApplicable = (UpdateAnswer -> Maybe Bool)
-> (UpdateAnswer -> Maybe Bool -> UpdateAnswer)
-> Lens UpdateAnswer UpdateAnswer (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAnswer' {Maybe Bool
isApplicable :: Maybe Bool
$sel:isApplicable:UpdateAnswer' :: UpdateAnswer -> Maybe Bool
isApplicable} -> Maybe Bool
isApplicable) (\s :: UpdateAnswer
s@UpdateAnswer' {} Maybe Bool
a -> UpdateAnswer
s {$sel:isApplicable:UpdateAnswer' :: Maybe Bool
isApplicable = Maybe Bool
a} :: UpdateAnswer)

-- | Undocumented member.
updateAnswer_selectedChoices :: Lens.Lens' UpdateAnswer (Prelude.Maybe [Prelude.Text])
updateAnswer_selectedChoices :: (Maybe [Text] -> f (Maybe [Text]))
-> UpdateAnswer -> f UpdateAnswer
updateAnswer_selectedChoices = (UpdateAnswer -> Maybe [Text])
-> (UpdateAnswer -> Maybe [Text] -> UpdateAnswer)
-> Lens UpdateAnswer UpdateAnswer (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAnswer' {Maybe [Text]
selectedChoices :: Maybe [Text]
$sel:selectedChoices:UpdateAnswer' :: UpdateAnswer -> Maybe [Text]
selectedChoices} -> Maybe [Text]
selectedChoices) (\s :: UpdateAnswer
s@UpdateAnswer' {} Maybe [Text]
a -> UpdateAnswer
s {$sel:selectedChoices:UpdateAnswer' :: Maybe [Text]
selectedChoices = Maybe [Text]
a} :: UpdateAnswer) ((Maybe [Text] -> f (Maybe [Text]))
 -> UpdateAnswer -> f UpdateAnswer)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> UpdateAnswer
-> f UpdateAnswer
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The reason why a question is not applicable to your workload.
updateAnswer_reason :: Lens.Lens' UpdateAnswer (Prelude.Maybe AnswerReason)
updateAnswer_reason :: (Maybe AnswerReason -> f (Maybe AnswerReason))
-> UpdateAnswer -> f UpdateAnswer
updateAnswer_reason = (UpdateAnswer -> Maybe AnswerReason)
-> (UpdateAnswer -> Maybe AnswerReason -> UpdateAnswer)
-> Lens
     UpdateAnswer UpdateAnswer (Maybe AnswerReason) (Maybe AnswerReason)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAnswer' {Maybe AnswerReason
reason :: Maybe AnswerReason
$sel:reason:UpdateAnswer' :: UpdateAnswer -> Maybe AnswerReason
reason} -> Maybe AnswerReason
reason) (\s :: UpdateAnswer
s@UpdateAnswer' {} Maybe AnswerReason
a -> UpdateAnswer
s {$sel:reason:UpdateAnswer' :: Maybe AnswerReason
reason = Maybe AnswerReason
a} :: UpdateAnswer)

-- | Undocumented member.
updateAnswer_notes :: Lens.Lens' UpdateAnswer (Prelude.Maybe Prelude.Text)
updateAnswer_notes :: (Maybe Text -> f (Maybe Text)) -> UpdateAnswer -> f UpdateAnswer
updateAnswer_notes = (UpdateAnswer -> Maybe Text)
-> (UpdateAnswer -> Maybe Text -> UpdateAnswer)
-> Lens UpdateAnswer UpdateAnswer (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAnswer' {Maybe Text
notes :: Maybe Text
$sel:notes:UpdateAnswer' :: UpdateAnswer -> Maybe Text
notes} -> Maybe Text
notes) (\s :: UpdateAnswer
s@UpdateAnswer' {} Maybe Text
a -> UpdateAnswer
s {$sel:notes:UpdateAnswer' :: Maybe Text
notes = Maybe Text
a} :: UpdateAnswer)

-- | A list of choices to update on a question in your workload. The String
-- key corresponds to the choice ID to be updated.
updateAnswer_choiceUpdates :: Lens.Lens' UpdateAnswer (Prelude.Maybe (Prelude.HashMap Prelude.Text ChoiceUpdate))
updateAnswer_choiceUpdates :: (Maybe (HashMap Text ChoiceUpdate)
 -> f (Maybe (HashMap Text ChoiceUpdate)))
-> UpdateAnswer -> f UpdateAnswer
updateAnswer_choiceUpdates = (UpdateAnswer -> Maybe (HashMap Text ChoiceUpdate))
-> (UpdateAnswer
    -> Maybe (HashMap Text ChoiceUpdate) -> UpdateAnswer)
-> Lens
     UpdateAnswer
     UpdateAnswer
     (Maybe (HashMap Text ChoiceUpdate))
     (Maybe (HashMap Text ChoiceUpdate))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAnswer' {Maybe (HashMap Text ChoiceUpdate)
choiceUpdates :: Maybe (HashMap Text ChoiceUpdate)
$sel:choiceUpdates:UpdateAnswer' :: UpdateAnswer -> Maybe (HashMap Text ChoiceUpdate)
choiceUpdates} -> Maybe (HashMap Text ChoiceUpdate)
choiceUpdates) (\s :: UpdateAnswer
s@UpdateAnswer' {} Maybe (HashMap Text ChoiceUpdate)
a -> UpdateAnswer
s {$sel:choiceUpdates:UpdateAnswer' :: Maybe (HashMap Text ChoiceUpdate)
choiceUpdates = Maybe (HashMap Text ChoiceUpdate)
a} :: UpdateAnswer) ((Maybe (HashMap Text ChoiceUpdate)
  -> f (Maybe (HashMap Text ChoiceUpdate)))
 -> UpdateAnswer -> f UpdateAnswer)
-> ((Maybe (HashMap Text ChoiceUpdate)
     -> f (Maybe (HashMap Text ChoiceUpdate)))
    -> Maybe (HashMap Text ChoiceUpdate)
    -> f (Maybe (HashMap Text ChoiceUpdate)))
-> (Maybe (HashMap Text ChoiceUpdate)
    -> f (Maybe (HashMap Text ChoiceUpdate)))
-> UpdateAnswer
-> f UpdateAnswer
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text ChoiceUpdate)
  (HashMap Text ChoiceUpdate)
  (HashMap Text ChoiceUpdate)
  (HashMap Text ChoiceUpdate)
-> Iso
     (Maybe (HashMap Text ChoiceUpdate))
     (Maybe (HashMap Text ChoiceUpdate))
     (Maybe (HashMap Text ChoiceUpdate))
     (Maybe (HashMap Text ChoiceUpdate))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap Text ChoiceUpdate)
  (HashMap Text ChoiceUpdate)
  (HashMap Text ChoiceUpdate)
  (HashMap Text ChoiceUpdate)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Undocumented member.
updateAnswer_workloadId :: Lens.Lens' UpdateAnswer Prelude.Text
updateAnswer_workloadId :: (Text -> f Text) -> UpdateAnswer -> f UpdateAnswer
updateAnswer_workloadId = (UpdateAnswer -> Text)
-> (UpdateAnswer -> Text -> UpdateAnswer)
-> Lens UpdateAnswer UpdateAnswer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAnswer' {Text
workloadId :: Text
$sel:workloadId:UpdateAnswer' :: UpdateAnswer -> Text
workloadId} -> Text
workloadId) (\s :: UpdateAnswer
s@UpdateAnswer' {} Text
a -> UpdateAnswer
s {$sel:workloadId:UpdateAnswer' :: Text
workloadId = Text
a} :: UpdateAnswer)

-- | Undocumented member.
updateAnswer_lensAlias :: Lens.Lens' UpdateAnswer Prelude.Text
updateAnswer_lensAlias :: (Text -> f Text) -> UpdateAnswer -> f UpdateAnswer
updateAnswer_lensAlias = (UpdateAnswer -> Text)
-> (UpdateAnswer -> Text -> UpdateAnswer)
-> Lens UpdateAnswer UpdateAnswer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAnswer' {Text
lensAlias :: Text
$sel:lensAlias:UpdateAnswer' :: UpdateAnswer -> Text
lensAlias} -> Text
lensAlias) (\s :: UpdateAnswer
s@UpdateAnswer' {} Text
a -> UpdateAnswer
s {$sel:lensAlias:UpdateAnswer' :: Text
lensAlias = Text
a} :: UpdateAnswer)

-- | Undocumented member.
updateAnswer_questionId :: Lens.Lens' UpdateAnswer Prelude.Text
updateAnswer_questionId :: (Text -> f Text) -> UpdateAnswer -> f UpdateAnswer
updateAnswer_questionId = (UpdateAnswer -> Text)
-> (UpdateAnswer -> Text -> UpdateAnswer)
-> Lens UpdateAnswer UpdateAnswer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAnswer' {Text
questionId :: Text
$sel:questionId:UpdateAnswer' :: UpdateAnswer -> Text
questionId} -> Text
questionId) (\s :: UpdateAnswer
s@UpdateAnswer' {} Text
a -> UpdateAnswer
s {$sel:questionId:UpdateAnswer' :: Text
questionId = Text
a} :: UpdateAnswer)

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

instance Prelude.NFData UpdateAnswer

instance Core.ToHeaders UpdateAnswer where
  toHeaders :: UpdateAnswer -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateAnswer -> 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 UpdateAnswer where
  toJSON :: UpdateAnswer -> Value
toJSON UpdateAnswer' {Maybe Bool
Maybe [Text]
Maybe Text
Maybe (HashMap Text ChoiceUpdate)
Maybe AnswerReason
Text
questionId :: Text
lensAlias :: Text
workloadId :: Text
choiceUpdates :: Maybe (HashMap Text ChoiceUpdate)
notes :: Maybe Text
reason :: Maybe AnswerReason
selectedChoices :: Maybe [Text]
isApplicable :: Maybe Bool
$sel:questionId:UpdateAnswer' :: UpdateAnswer -> Text
$sel:lensAlias:UpdateAnswer' :: UpdateAnswer -> Text
$sel:workloadId:UpdateAnswer' :: UpdateAnswer -> Text
$sel:choiceUpdates:UpdateAnswer' :: UpdateAnswer -> Maybe (HashMap Text ChoiceUpdate)
$sel:notes:UpdateAnswer' :: UpdateAnswer -> Maybe Text
$sel:reason:UpdateAnswer' :: UpdateAnswer -> Maybe AnswerReason
$sel:selectedChoices:UpdateAnswer' :: UpdateAnswer -> Maybe [Text]
$sel:isApplicable:UpdateAnswer' :: UpdateAnswer -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"IsApplicable" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
isApplicable,
            (Text
"SelectedChoices" 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]
selectedChoices,
            (Text
"Reason" Text -> AnswerReason -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (AnswerReason -> Pair) -> Maybe AnswerReason -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AnswerReason
reason,
            (Text
"Notes" 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
notes,
            (Text
"ChoiceUpdates" Text -> HashMap Text ChoiceUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text ChoiceUpdate -> Pair)
-> Maybe (HashMap Text ChoiceUpdate) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text ChoiceUpdate)
choiceUpdates
          ]
      )

instance Core.ToPath UpdateAnswer where
  toPath :: UpdateAnswer -> ByteString
toPath UpdateAnswer' {Maybe Bool
Maybe [Text]
Maybe Text
Maybe (HashMap Text ChoiceUpdate)
Maybe AnswerReason
Text
questionId :: Text
lensAlias :: Text
workloadId :: Text
choiceUpdates :: Maybe (HashMap Text ChoiceUpdate)
notes :: Maybe Text
reason :: Maybe AnswerReason
selectedChoices :: Maybe [Text]
isApplicable :: Maybe Bool
$sel:questionId:UpdateAnswer' :: UpdateAnswer -> Text
$sel:lensAlias:UpdateAnswer' :: UpdateAnswer -> Text
$sel:workloadId:UpdateAnswer' :: UpdateAnswer -> Text
$sel:choiceUpdates:UpdateAnswer' :: UpdateAnswer -> Maybe (HashMap Text ChoiceUpdate)
$sel:notes:UpdateAnswer' :: UpdateAnswer -> Maybe Text
$sel:reason:UpdateAnswer' :: UpdateAnswer -> Maybe AnswerReason
$sel:selectedChoices:UpdateAnswer' :: UpdateAnswer -> Maybe [Text]
$sel:isApplicable:UpdateAnswer' :: UpdateAnswer -> Maybe Bool
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/workloads/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
workloadId,
        ByteString
"/lensReviews/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
lensAlias,
        ByteString
"/answers/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
questionId
      ]

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

-- | Output of a update answer call.
--
-- /See:/ 'newUpdateAnswerResponse' smart constructor.
data UpdateAnswerResponse = UpdateAnswerResponse'
  { UpdateAnswerResponse -> Maybe Text
lensAlias :: Prelude.Maybe Prelude.Text,
    UpdateAnswerResponse -> Maybe Answer
answer :: Prelude.Maybe Answer,
    UpdateAnswerResponse -> Maybe Text
workloadId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    UpdateAnswerResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateAnswerResponse -> UpdateAnswerResponse -> Bool
(UpdateAnswerResponse -> UpdateAnswerResponse -> Bool)
-> (UpdateAnswerResponse -> UpdateAnswerResponse -> Bool)
-> Eq UpdateAnswerResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateAnswerResponse -> UpdateAnswerResponse -> Bool
$c/= :: UpdateAnswerResponse -> UpdateAnswerResponse -> Bool
== :: UpdateAnswerResponse -> UpdateAnswerResponse -> Bool
$c== :: UpdateAnswerResponse -> UpdateAnswerResponse -> Bool
Prelude.Eq, ReadPrec [UpdateAnswerResponse]
ReadPrec UpdateAnswerResponse
Int -> ReadS UpdateAnswerResponse
ReadS [UpdateAnswerResponse]
(Int -> ReadS UpdateAnswerResponse)
-> ReadS [UpdateAnswerResponse]
-> ReadPrec UpdateAnswerResponse
-> ReadPrec [UpdateAnswerResponse]
-> Read UpdateAnswerResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateAnswerResponse]
$creadListPrec :: ReadPrec [UpdateAnswerResponse]
readPrec :: ReadPrec UpdateAnswerResponse
$creadPrec :: ReadPrec UpdateAnswerResponse
readList :: ReadS [UpdateAnswerResponse]
$creadList :: ReadS [UpdateAnswerResponse]
readsPrec :: Int -> ReadS UpdateAnswerResponse
$creadsPrec :: Int -> ReadS UpdateAnswerResponse
Prelude.Read, Int -> UpdateAnswerResponse -> ShowS
[UpdateAnswerResponse] -> ShowS
UpdateAnswerResponse -> String
(Int -> UpdateAnswerResponse -> ShowS)
-> (UpdateAnswerResponse -> String)
-> ([UpdateAnswerResponse] -> ShowS)
-> Show UpdateAnswerResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateAnswerResponse] -> ShowS
$cshowList :: [UpdateAnswerResponse] -> ShowS
show :: UpdateAnswerResponse -> String
$cshow :: UpdateAnswerResponse -> String
showsPrec :: Int -> UpdateAnswerResponse -> ShowS
$cshowsPrec :: Int -> UpdateAnswerResponse -> ShowS
Prelude.Show, (forall x. UpdateAnswerResponse -> Rep UpdateAnswerResponse x)
-> (forall x. Rep UpdateAnswerResponse x -> UpdateAnswerResponse)
-> Generic UpdateAnswerResponse
forall x. Rep UpdateAnswerResponse x -> UpdateAnswerResponse
forall x. UpdateAnswerResponse -> Rep UpdateAnswerResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateAnswerResponse x -> UpdateAnswerResponse
$cfrom :: forall x. UpdateAnswerResponse -> Rep UpdateAnswerResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateAnswerResponse' 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:
--
-- 'lensAlias', 'updateAnswerResponse_lensAlias' - Undocumented member.
--
-- 'answer', 'updateAnswerResponse_answer' - Undocumented member.
--
-- 'workloadId', 'updateAnswerResponse_workloadId' - Undocumented member.
--
-- 'httpStatus', 'updateAnswerResponse_httpStatus' - The response's http status code.
newUpdateAnswerResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateAnswerResponse
newUpdateAnswerResponse :: Int -> UpdateAnswerResponse
newUpdateAnswerResponse Int
pHttpStatus_ =
  UpdateAnswerResponse' :: Maybe Text
-> Maybe Answer -> Maybe Text -> Int -> UpdateAnswerResponse
UpdateAnswerResponse'
    { $sel:lensAlias:UpdateAnswerResponse' :: Maybe Text
lensAlias = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:answer:UpdateAnswerResponse' :: Maybe Answer
answer = Maybe Answer
forall a. Maybe a
Prelude.Nothing,
      $sel:workloadId:UpdateAnswerResponse' :: Maybe Text
workloadId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateAnswerResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
updateAnswerResponse_lensAlias :: Lens.Lens' UpdateAnswerResponse (Prelude.Maybe Prelude.Text)
updateAnswerResponse_lensAlias :: (Maybe Text -> f (Maybe Text))
-> UpdateAnswerResponse -> f UpdateAnswerResponse
updateAnswerResponse_lensAlias = (UpdateAnswerResponse -> Maybe Text)
-> (UpdateAnswerResponse -> Maybe Text -> UpdateAnswerResponse)
-> Lens
     UpdateAnswerResponse UpdateAnswerResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAnswerResponse' {Maybe Text
lensAlias :: Maybe Text
$sel:lensAlias:UpdateAnswerResponse' :: UpdateAnswerResponse -> Maybe Text
lensAlias} -> Maybe Text
lensAlias) (\s :: UpdateAnswerResponse
s@UpdateAnswerResponse' {} Maybe Text
a -> UpdateAnswerResponse
s {$sel:lensAlias:UpdateAnswerResponse' :: Maybe Text
lensAlias = Maybe Text
a} :: UpdateAnswerResponse)

-- | Undocumented member.
updateAnswerResponse_answer :: Lens.Lens' UpdateAnswerResponse (Prelude.Maybe Answer)
updateAnswerResponse_answer :: (Maybe Answer -> f (Maybe Answer))
-> UpdateAnswerResponse -> f UpdateAnswerResponse
updateAnswerResponse_answer = (UpdateAnswerResponse -> Maybe Answer)
-> (UpdateAnswerResponse -> Maybe Answer -> UpdateAnswerResponse)
-> Lens
     UpdateAnswerResponse
     UpdateAnswerResponse
     (Maybe Answer)
     (Maybe Answer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAnswerResponse' {Maybe Answer
answer :: Maybe Answer
$sel:answer:UpdateAnswerResponse' :: UpdateAnswerResponse -> Maybe Answer
answer} -> Maybe Answer
answer) (\s :: UpdateAnswerResponse
s@UpdateAnswerResponse' {} Maybe Answer
a -> UpdateAnswerResponse
s {$sel:answer:UpdateAnswerResponse' :: Maybe Answer
answer = Maybe Answer
a} :: UpdateAnswerResponse)

-- | Undocumented member.
updateAnswerResponse_workloadId :: Lens.Lens' UpdateAnswerResponse (Prelude.Maybe Prelude.Text)
updateAnswerResponse_workloadId :: (Maybe Text -> f (Maybe Text))
-> UpdateAnswerResponse -> f UpdateAnswerResponse
updateAnswerResponse_workloadId = (UpdateAnswerResponse -> Maybe Text)
-> (UpdateAnswerResponse -> Maybe Text -> UpdateAnswerResponse)
-> Lens
     UpdateAnswerResponse UpdateAnswerResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAnswerResponse' {Maybe Text
workloadId :: Maybe Text
$sel:workloadId:UpdateAnswerResponse' :: UpdateAnswerResponse -> Maybe Text
workloadId} -> Maybe Text
workloadId) (\s :: UpdateAnswerResponse
s@UpdateAnswerResponse' {} Maybe Text
a -> UpdateAnswerResponse
s {$sel:workloadId:UpdateAnswerResponse' :: Maybe Text
workloadId = Maybe Text
a} :: UpdateAnswerResponse)

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

instance Prelude.NFData UpdateAnswerResponse