{-# 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.Recommendation
-- 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.Recommendation where

import qualified Amazonka.Core as Core
import Amazonka.DevOpsGuru.Types.RecommendationRelatedAnomaly
import Amazonka.DevOpsGuru.Types.RecommendationRelatedEvent
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Recommendation information to help you remediate detected anomalous
-- behavior that generated an insight.
--
-- /See:/ 'newRecommendation' smart constructor.
data Recommendation = Recommendation'
  { -- | A hyperlink to information to help you address the problem.
    Recommendation -> Maybe Text
link :: Prelude.Maybe Prelude.Text,
    -- | Anomalies that are related to the problem. Use these Anomalies to learn
    -- more about what\'s happening and to help address the issue.
    Recommendation -> Maybe [RecommendationRelatedAnomaly]
relatedAnomalies :: Prelude.Maybe [RecommendationRelatedAnomaly],
    -- | The reason DevOps Guru flagged the anomalous behavior as a problem.
    Recommendation -> Maybe Text
reason :: Prelude.Maybe Prelude.Text,
    -- | The name of the recommendation.
    Recommendation -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | Events that are related to the problem. Use these events to learn more
    -- about what\'s happening and to help address the issue.
    Recommendation -> Maybe [RecommendationRelatedEvent]
relatedEvents :: Prelude.Maybe [RecommendationRelatedEvent],
    -- | A description of the problem.
    Recommendation -> Maybe Text
description :: Prelude.Maybe Prelude.Text
  }
  deriving (Recommendation -> Recommendation -> Bool
(Recommendation -> Recommendation -> Bool)
-> (Recommendation -> Recommendation -> Bool) -> Eq Recommendation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Recommendation -> Recommendation -> Bool
$c/= :: Recommendation -> Recommendation -> Bool
== :: Recommendation -> Recommendation -> Bool
$c== :: Recommendation -> Recommendation -> Bool
Prelude.Eq, ReadPrec [Recommendation]
ReadPrec Recommendation
Int -> ReadS Recommendation
ReadS [Recommendation]
(Int -> ReadS Recommendation)
-> ReadS [Recommendation]
-> ReadPrec Recommendation
-> ReadPrec [Recommendation]
-> Read Recommendation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Recommendation]
$creadListPrec :: ReadPrec [Recommendation]
readPrec :: ReadPrec Recommendation
$creadPrec :: ReadPrec Recommendation
readList :: ReadS [Recommendation]
$creadList :: ReadS [Recommendation]
readsPrec :: Int -> ReadS Recommendation
$creadsPrec :: Int -> ReadS Recommendation
Prelude.Read, Int -> Recommendation -> ShowS
[Recommendation] -> ShowS
Recommendation -> String
(Int -> Recommendation -> ShowS)
-> (Recommendation -> String)
-> ([Recommendation] -> ShowS)
-> Show Recommendation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Recommendation] -> ShowS
$cshowList :: [Recommendation] -> ShowS
show :: Recommendation -> String
$cshow :: Recommendation -> String
showsPrec :: Int -> Recommendation -> ShowS
$cshowsPrec :: Int -> Recommendation -> ShowS
Prelude.Show, (forall x. Recommendation -> Rep Recommendation x)
-> (forall x. Rep Recommendation x -> Recommendation)
-> Generic Recommendation
forall x. Rep Recommendation x -> Recommendation
forall x. Recommendation -> Rep Recommendation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Recommendation x -> Recommendation
$cfrom :: forall x. Recommendation -> Rep Recommendation x
Prelude.Generic)

-- |
-- Create a value of 'Recommendation' 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:
--
-- 'link', 'recommendation_link' - A hyperlink to information to help you address the problem.
--
-- 'relatedAnomalies', 'recommendation_relatedAnomalies' - Anomalies that are related to the problem. Use these Anomalies to learn
-- more about what\'s happening and to help address the issue.
--
-- 'reason', 'recommendation_reason' - The reason DevOps Guru flagged the anomalous behavior as a problem.
--
-- 'name', 'recommendation_name' - The name of the recommendation.
--
-- 'relatedEvents', 'recommendation_relatedEvents' - Events that are related to the problem. Use these events to learn more
-- about what\'s happening and to help address the issue.
--
-- 'description', 'recommendation_description' - A description of the problem.
newRecommendation ::
  Recommendation
newRecommendation :: Recommendation
newRecommendation =
  Recommendation' :: Maybe Text
-> Maybe [RecommendationRelatedAnomaly]
-> Maybe Text
-> Maybe Text
-> Maybe [RecommendationRelatedEvent]
-> Maybe Text
-> Recommendation
Recommendation'
    { $sel:link:Recommendation' :: Maybe Text
link = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:relatedAnomalies:Recommendation' :: Maybe [RecommendationRelatedAnomaly]
relatedAnomalies = Maybe [RecommendationRelatedAnomaly]
forall a. Maybe a
Prelude.Nothing,
      $sel:reason:Recommendation' :: Maybe Text
reason = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Recommendation' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:relatedEvents:Recommendation' :: Maybe [RecommendationRelatedEvent]
relatedEvents = Maybe [RecommendationRelatedEvent]
forall a. Maybe a
Prelude.Nothing,
      $sel:description:Recommendation' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A hyperlink to information to help you address the problem.
recommendation_link :: Lens.Lens' Recommendation (Prelude.Maybe Prelude.Text)
recommendation_link :: (Maybe Text -> f (Maybe Text))
-> Recommendation -> f Recommendation
recommendation_link = (Recommendation -> Maybe Text)
-> (Recommendation -> Maybe Text -> Recommendation)
-> Lens Recommendation Recommendation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Recommendation' {Maybe Text
link :: Maybe Text
$sel:link:Recommendation' :: Recommendation -> Maybe Text
link} -> Maybe Text
link) (\s :: Recommendation
s@Recommendation' {} Maybe Text
a -> Recommendation
s {$sel:link:Recommendation' :: Maybe Text
link = Maybe Text
a} :: Recommendation)

-- | Anomalies that are related to the problem. Use these Anomalies to learn
-- more about what\'s happening and to help address the issue.
recommendation_relatedAnomalies :: Lens.Lens' Recommendation (Prelude.Maybe [RecommendationRelatedAnomaly])
recommendation_relatedAnomalies :: (Maybe [RecommendationRelatedAnomaly]
 -> f (Maybe [RecommendationRelatedAnomaly]))
-> Recommendation -> f Recommendation
recommendation_relatedAnomalies = (Recommendation -> Maybe [RecommendationRelatedAnomaly])
-> (Recommendation
    -> Maybe [RecommendationRelatedAnomaly] -> Recommendation)
-> Lens
     Recommendation
     Recommendation
     (Maybe [RecommendationRelatedAnomaly])
     (Maybe [RecommendationRelatedAnomaly])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Recommendation' {Maybe [RecommendationRelatedAnomaly]
relatedAnomalies :: Maybe [RecommendationRelatedAnomaly]
$sel:relatedAnomalies:Recommendation' :: Recommendation -> Maybe [RecommendationRelatedAnomaly]
relatedAnomalies} -> Maybe [RecommendationRelatedAnomaly]
relatedAnomalies) (\s :: Recommendation
s@Recommendation' {} Maybe [RecommendationRelatedAnomaly]
a -> Recommendation
s {$sel:relatedAnomalies:Recommendation' :: Maybe [RecommendationRelatedAnomaly]
relatedAnomalies = Maybe [RecommendationRelatedAnomaly]
a} :: Recommendation) ((Maybe [RecommendationRelatedAnomaly]
  -> f (Maybe [RecommendationRelatedAnomaly]))
 -> Recommendation -> f Recommendation)
-> ((Maybe [RecommendationRelatedAnomaly]
     -> f (Maybe [RecommendationRelatedAnomaly]))
    -> Maybe [RecommendationRelatedAnomaly]
    -> f (Maybe [RecommendationRelatedAnomaly]))
-> (Maybe [RecommendationRelatedAnomaly]
    -> f (Maybe [RecommendationRelatedAnomaly]))
-> Recommendation
-> f Recommendation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [RecommendationRelatedAnomaly]
  [RecommendationRelatedAnomaly]
  [RecommendationRelatedAnomaly]
  [RecommendationRelatedAnomaly]
-> Iso
     (Maybe [RecommendationRelatedAnomaly])
     (Maybe [RecommendationRelatedAnomaly])
     (Maybe [RecommendationRelatedAnomaly])
     (Maybe [RecommendationRelatedAnomaly])
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
  [RecommendationRelatedAnomaly]
  [RecommendationRelatedAnomaly]
  [RecommendationRelatedAnomaly]
  [RecommendationRelatedAnomaly]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The reason DevOps Guru flagged the anomalous behavior as a problem.
recommendation_reason :: Lens.Lens' Recommendation (Prelude.Maybe Prelude.Text)
recommendation_reason :: (Maybe Text -> f (Maybe Text))
-> Recommendation -> f Recommendation
recommendation_reason = (Recommendation -> Maybe Text)
-> (Recommendation -> Maybe Text -> Recommendation)
-> Lens Recommendation Recommendation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Recommendation' {Maybe Text
reason :: Maybe Text
$sel:reason:Recommendation' :: Recommendation -> Maybe Text
reason} -> Maybe Text
reason) (\s :: Recommendation
s@Recommendation' {} Maybe Text
a -> Recommendation
s {$sel:reason:Recommendation' :: Maybe Text
reason = Maybe Text
a} :: Recommendation)

-- | The name of the recommendation.
recommendation_name :: Lens.Lens' Recommendation (Prelude.Maybe Prelude.Text)
recommendation_name :: (Maybe Text -> f (Maybe Text))
-> Recommendation -> f Recommendation
recommendation_name = (Recommendation -> Maybe Text)
-> (Recommendation -> Maybe Text -> Recommendation)
-> Lens Recommendation Recommendation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Recommendation' {Maybe Text
name :: Maybe Text
$sel:name:Recommendation' :: Recommendation -> Maybe Text
name} -> Maybe Text
name) (\s :: Recommendation
s@Recommendation' {} Maybe Text
a -> Recommendation
s {$sel:name:Recommendation' :: Maybe Text
name = Maybe Text
a} :: Recommendation)

-- | Events that are related to the problem. Use these events to learn more
-- about what\'s happening and to help address the issue.
recommendation_relatedEvents :: Lens.Lens' Recommendation (Prelude.Maybe [RecommendationRelatedEvent])
recommendation_relatedEvents :: (Maybe [RecommendationRelatedEvent]
 -> f (Maybe [RecommendationRelatedEvent]))
-> Recommendation -> f Recommendation
recommendation_relatedEvents = (Recommendation -> Maybe [RecommendationRelatedEvent])
-> (Recommendation
    -> Maybe [RecommendationRelatedEvent] -> Recommendation)
-> Lens
     Recommendation
     Recommendation
     (Maybe [RecommendationRelatedEvent])
     (Maybe [RecommendationRelatedEvent])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Recommendation' {Maybe [RecommendationRelatedEvent]
relatedEvents :: Maybe [RecommendationRelatedEvent]
$sel:relatedEvents:Recommendation' :: Recommendation -> Maybe [RecommendationRelatedEvent]
relatedEvents} -> Maybe [RecommendationRelatedEvent]
relatedEvents) (\s :: Recommendation
s@Recommendation' {} Maybe [RecommendationRelatedEvent]
a -> Recommendation
s {$sel:relatedEvents:Recommendation' :: Maybe [RecommendationRelatedEvent]
relatedEvents = Maybe [RecommendationRelatedEvent]
a} :: Recommendation) ((Maybe [RecommendationRelatedEvent]
  -> f (Maybe [RecommendationRelatedEvent]))
 -> Recommendation -> f Recommendation)
-> ((Maybe [RecommendationRelatedEvent]
     -> f (Maybe [RecommendationRelatedEvent]))
    -> Maybe [RecommendationRelatedEvent]
    -> f (Maybe [RecommendationRelatedEvent]))
-> (Maybe [RecommendationRelatedEvent]
    -> f (Maybe [RecommendationRelatedEvent]))
-> Recommendation
-> f Recommendation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [RecommendationRelatedEvent]
  [RecommendationRelatedEvent]
  [RecommendationRelatedEvent]
  [RecommendationRelatedEvent]
-> Iso
     (Maybe [RecommendationRelatedEvent])
     (Maybe [RecommendationRelatedEvent])
     (Maybe [RecommendationRelatedEvent])
     (Maybe [RecommendationRelatedEvent])
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
  [RecommendationRelatedEvent]
  [RecommendationRelatedEvent]
  [RecommendationRelatedEvent]
  [RecommendationRelatedEvent]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A description of the problem.
recommendation_description :: Lens.Lens' Recommendation (Prelude.Maybe Prelude.Text)
recommendation_description :: (Maybe Text -> f (Maybe Text))
-> Recommendation -> f Recommendation
recommendation_description = (Recommendation -> Maybe Text)
-> (Recommendation -> Maybe Text -> Recommendation)
-> Lens Recommendation Recommendation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Recommendation' {Maybe Text
description :: Maybe Text
$sel:description:Recommendation' :: Recommendation -> Maybe Text
description} -> Maybe Text
description) (\s :: Recommendation
s@Recommendation' {} Maybe Text
a -> Recommendation
s {$sel:description:Recommendation' :: Maybe Text
description = Maybe Text
a} :: Recommendation)

instance Core.FromJSON Recommendation where
  parseJSON :: Value -> Parser Recommendation
parseJSON =
    String
-> (Object -> Parser Recommendation)
-> Value
-> Parser Recommendation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Recommendation"
      ( \Object
x ->
          Maybe Text
-> Maybe [RecommendationRelatedAnomaly]
-> Maybe Text
-> Maybe Text
-> Maybe [RecommendationRelatedEvent]
-> Maybe Text
-> Recommendation
Recommendation'
            (Maybe Text
 -> Maybe [RecommendationRelatedAnomaly]
 -> Maybe Text
 -> Maybe Text
 -> Maybe [RecommendationRelatedEvent]
 -> Maybe Text
 -> Recommendation)
-> Parser (Maybe Text)
-> Parser
     (Maybe [RecommendationRelatedAnomaly]
      -> Maybe Text
      -> Maybe Text
      -> Maybe [RecommendationRelatedEvent]
      -> Maybe Text
      -> Recommendation)
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
"Link")
            Parser
  (Maybe [RecommendationRelatedAnomaly]
   -> Maybe Text
   -> Maybe Text
   -> Maybe [RecommendationRelatedEvent]
   -> Maybe Text
   -> Recommendation)
-> Parser (Maybe [RecommendationRelatedAnomaly])
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe [RecommendationRelatedEvent]
      -> Maybe Text
      -> Recommendation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text -> Parser (Maybe (Maybe [RecommendationRelatedAnomaly]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RelatedAnomalies"
                            Parser (Maybe (Maybe [RecommendationRelatedAnomaly]))
-> Maybe [RecommendationRelatedAnomaly]
-> Parser (Maybe [RecommendationRelatedAnomaly])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [RecommendationRelatedAnomaly]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe [RecommendationRelatedEvent]
   -> Maybe Text
   -> Recommendation)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe [RecommendationRelatedEvent]
      -> Maybe Text
      -> Recommendation)
forall (f :: * -> *) a b. Applicative f => 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
"Reason")
            Parser
  (Maybe Text
   -> Maybe [RecommendationRelatedEvent]
   -> Maybe Text
   -> Recommendation)
-> Parser (Maybe Text)
-> Parser
     (Maybe [RecommendationRelatedEvent]
      -> Maybe Text -> Recommendation)
forall (f :: * -> *) a b. Applicative f => 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
"Name")
            Parser
  (Maybe [RecommendationRelatedEvent]
   -> Maybe Text -> Recommendation)
-> Parser (Maybe [RecommendationRelatedEvent])
-> Parser (Maybe Text -> Recommendation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Parser (Maybe (Maybe [RecommendationRelatedEvent]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RelatedEvents" Parser (Maybe (Maybe [RecommendationRelatedEvent]))
-> Maybe [RecommendationRelatedEvent]
-> Parser (Maybe [RecommendationRelatedEvent])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [RecommendationRelatedEvent]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> Recommendation)
-> Parser (Maybe Text) -> Parser Recommendation
forall (f :: * -> *) a b. Applicative f => 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
"Description")
      )

instance Prelude.Hashable Recommendation

instance Prelude.NFData Recommendation