{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.DevOpsGuru.Types.InsightFeedback
-- 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)
module Amazonka.DevOpsGuru.Types.InsightFeedback where

import qualified Amazonka.Core as Core
import Amazonka.DevOpsGuru.Types.InsightFeedbackOption
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about insight feedback received from a customer.
--
-- /See:/ 'newInsightFeedback' smart constructor.
data InsightFeedback = InsightFeedback'
  { -- | The insight feedback ID.
    InsightFeedback -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The feedback provided by the customer.
    InsightFeedback -> Maybe InsightFeedbackOption
feedback :: Prelude.Maybe InsightFeedbackOption
  }
  deriving (InsightFeedback -> InsightFeedback -> Bool
(InsightFeedback -> InsightFeedback -> Bool)
-> (InsightFeedback -> InsightFeedback -> Bool)
-> Eq InsightFeedback
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InsightFeedback -> InsightFeedback -> Bool
$c/= :: InsightFeedback -> InsightFeedback -> Bool
== :: InsightFeedback -> InsightFeedback -> Bool
$c== :: InsightFeedback -> InsightFeedback -> Bool
Prelude.Eq, ReadPrec [InsightFeedback]
ReadPrec InsightFeedback
Int -> ReadS InsightFeedback
ReadS [InsightFeedback]
(Int -> ReadS InsightFeedback)
-> ReadS [InsightFeedback]
-> ReadPrec InsightFeedback
-> ReadPrec [InsightFeedback]
-> Read InsightFeedback
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InsightFeedback]
$creadListPrec :: ReadPrec [InsightFeedback]
readPrec :: ReadPrec InsightFeedback
$creadPrec :: ReadPrec InsightFeedback
readList :: ReadS [InsightFeedback]
$creadList :: ReadS [InsightFeedback]
readsPrec :: Int -> ReadS InsightFeedback
$creadsPrec :: Int -> ReadS InsightFeedback
Prelude.Read, Int -> InsightFeedback -> ShowS
[InsightFeedback] -> ShowS
InsightFeedback -> String
(Int -> InsightFeedback -> ShowS)
-> (InsightFeedback -> String)
-> ([InsightFeedback] -> ShowS)
-> Show InsightFeedback
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InsightFeedback] -> ShowS
$cshowList :: [InsightFeedback] -> ShowS
show :: InsightFeedback -> String
$cshow :: InsightFeedback -> String
showsPrec :: Int -> InsightFeedback -> ShowS
$cshowsPrec :: Int -> InsightFeedback -> ShowS
Prelude.Show, (forall x. InsightFeedback -> Rep InsightFeedback x)
-> (forall x. Rep InsightFeedback x -> InsightFeedback)
-> Generic InsightFeedback
forall x. Rep InsightFeedback x -> InsightFeedback
forall x. InsightFeedback -> Rep InsightFeedback x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InsightFeedback x -> InsightFeedback
$cfrom :: forall x. InsightFeedback -> Rep InsightFeedback x
Prelude.Generic)

-- |
-- Create a value of 'InsightFeedback' 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:
--
-- 'id', 'insightFeedback_id' - The insight feedback ID.
--
-- 'feedback', 'insightFeedback_feedback' - The feedback provided by the customer.
newInsightFeedback ::
  InsightFeedback
newInsightFeedback :: InsightFeedback
newInsightFeedback =
  InsightFeedback' :: Maybe Text -> Maybe InsightFeedbackOption -> InsightFeedback
InsightFeedback'
    { $sel:id:InsightFeedback' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:feedback:InsightFeedback' :: Maybe InsightFeedbackOption
feedback = Maybe InsightFeedbackOption
forall a. Maybe a
Prelude.Nothing
    }

-- | The insight feedback ID.
insightFeedback_id :: Lens.Lens' InsightFeedback (Prelude.Maybe Prelude.Text)
insightFeedback_id :: (Maybe Text -> f (Maybe Text))
-> InsightFeedback -> f InsightFeedback
insightFeedback_id = (InsightFeedback -> Maybe Text)
-> (InsightFeedback -> Maybe Text -> InsightFeedback)
-> Lens InsightFeedback InsightFeedback (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InsightFeedback' {Maybe Text
id :: Maybe Text
$sel:id:InsightFeedback' :: InsightFeedback -> Maybe Text
id} -> Maybe Text
id) (\s :: InsightFeedback
s@InsightFeedback' {} Maybe Text
a -> InsightFeedback
s {$sel:id:InsightFeedback' :: Maybe Text
id = Maybe Text
a} :: InsightFeedback)

-- | The feedback provided by the customer.
insightFeedback_feedback :: Lens.Lens' InsightFeedback (Prelude.Maybe InsightFeedbackOption)
insightFeedback_feedback :: (Maybe InsightFeedbackOption -> f (Maybe InsightFeedbackOption))
-> InsightFeedback -> f InsightFeedback
insightFeedback_feedback = (InsightFeedback -> Maybe InsightFeedbackOption)
-> (InsightFeedback
    -> Maybe InsightFeedbackOption -> InsightFeedback)
-> Lens
     InsightFeedback
     InsightFeedback
     (Maybe InsightFeedbackOption)
     (Maybe InsightFeedbackOption)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InsightFeedback' {Maybe InsightFeedbackOption
feedback :: Maybe InsightFeedbackOption
$sel:feedback:InsightFeedback' :: InsightFeedback -> Maybe InsightFeedbackOption
feedback} -> Maybe InsightFeedbackOption
feedback) (\s :: InsightFeedback
s@InsightFeedback' {} Maybe InsightFeedbackOption
a -> InsightFeedback
s {$sel:feedback:InsightFeedback' :: Maybe InsightFeedbackOption
feedback = Maybe InsightFeedbackOption
a} :: InsightFeedback)

instance Core.FromJSON InsightFeedback where
  parseJSON :: Value -> Parser InsightFeedback
parseJSON =
    String
-> (Object -> Parser InsightFeedback)
-> Value
-> Parser InsightFeedback
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InsightFeedback"
      ( \Object
x ->
          Maybe Text -> Maybe InsightFeedbackOption -> InsightFeedback
InsightFeedback'
            (Maybe Text -> Maybe InsightFeedbackOption -> InsightFeedback)
-> Parser (Maybe Text)
-> Parser (Maybe InsightFeedbackOption -> InsightFeedback)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Id")
            Parser (Maybe InsightFeedbackOption -> InsightFeedback)
-> Parser (Maybe InsightFeedbackOption) -> Parser InsightFeedback
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe InsightFeedbackOption)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Feedback")
      )

instance Prelude.Hashable InsightFeedback

instance Prelude.NFData InsightFeedback

instance Core.ToJSON InsightFeedback where
  toJSON :: InsightFeedback -> Value
toJSON InsightFeedback' {Maybe Text
Maybe InsightFeedbackOption
feedback :: Maybe InsightFeedbackOption
id :: Maybe Text
$sel:feedback:InsightFeedback' :: InsightFeedback -> Maybe InsightFeedbackOption
$sel:id:InsightFeedback' :: InsightFeedback -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Id" 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
id,
            (Text
"Feedback" Text -> InsightFeedbackOption -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (InsightFeedbackOption -> Pair)
-> Maybe InsightFeedbackOption -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe InsightFeedbackOption
feedback
          ]
      )