{-# 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.ResilienceHub.Types.ComponentRecommendation
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ResilienceHub.Types.ComponentRecommendation where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.ResilienceHub.Types.ConfigRecommendation
import Amazonka.ResilienceHub.Types.RecommendationComplianceStatus

-- | Defines recommendations for a Resilience Hub application component,
-- returned as an object. This object contains component names,
-- configuration recommendations, and recommendation statuses.
--
-- /See:/ 'newComponentRecommendation' smart constructor.
data ComponentRecommendation = ComponentRecommendation'
  { -- | The name of the application component.
    ComponentRecommendation -> Text
appComponentName :: Prelude.Text,
    -- | The list of recommendations.
    ComponentRecommendation -> [ConfigRecommendation]
configRecommendations :: [ConfigRecommendation],
    -- | The recommendation status.
    ComponentRecommendation -> RecommendationComplianceStatus
recommendationStatus :: RecommendationComplianceStatus
  }
  deriving (ComponentRecommendation -> ComponentRecommendation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ComponentRecommendation -> ComponentRecommendation -> Bool
$c/= :: ComponentRecommendation -> ComponentRecommendation -> Bool
== :: ComponentRecommendation -> ComponentRecommendation -> Bool
$c== :: ComponentRecommendation -> ComponentRecommendation -> Bool
Prelude.Eq, ReadPrec [ComponentRecommendation]
ReadPrec ComponentRecommendation
Int -> ReadS ComponentRecommendation
ReadS [ComponentRecommendation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ComponentRecommendation]
$creadListPrec :: ReadPrec [ComponentRecommendation]
readPrec :: ReadPrec ComponentRecommendation
$creadPrec :: ReadPrec ComponentRecommendation
readList :: ReadS [ComponentRecommendation]
$creadList :: ReadS [ComponentRecommendation]
readsPrec :: Int -> ReadS ComponentRecommendation
$creadsPrec :: Int -> ReadS ComponentRecommendation
Prelude.Read, Int -> ComponentRecommendation -> ShowS
[ComponentRecommendation] -> ShowS
ComponentRecommendation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ComponentRecommendation] -> ShowS
$cshowList :: [ComponentRecommendation] -> ShowS
show :: ComponentRecommendation -> String
$cshow :: ComponentRecommendation -> String
showsPrec :: Int -> ComponentRecommendation -> ShowS
$cshowsPrec :: Int -> ComponentRecommendation -> ShowS
Prelude.Show, forall x. Rep ComponentRecommendation x -> ComponentRecommendation
forall x. ComponentRecommendation -> Rep ComponentRecommendation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ComponentRecommendation x -> ComponentRecommendation
$cfrom :: forall x. ComponentRecommendation -> Rep ComponentRecommendation x
Prelude.Generic)

-- |
-- Create a value of 'ComponentRecommendation' 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:
--
-- 'appComponentName', 'componentRecommendation_appComponentName' - The name of the application component.
--
-- 'configRecommendations', 'componentRecommendation_configRecommendations' - The list of recommendations.
--
-- 'recommendationStatus', 'componentRecommendation_recommendationStatus' - The recommendation status.
newComponentRecommendation ::
  -- | 'appComponentName'
  Prelude.Text ->
  -- | 'recommendationStatus'
  RecommendationComplianceStatus ->
  ComponentRecommendation
newComponentRecommendation :: Text -> RecommendationComplianceStatus -> ComponentRecommendation
newComponentRecommendation
  Text
pAppComponentName_
  RecommendationComplianceStatus
pRecommendationStatus_ =
    ComponentRecommendation'
      { $sel:appComponentName:ComponentRecommendation' :: Text
appComponentName =
          Text
pAppComponentName_,
        $sel:configRecommendations:ComponentRecommendation' :: [ConfigRecommendation]
configRecommendations = forall a. Monoid a => a
Prelude.mempty,
        $sel:recommendationStatus:ComponentRecommendation' :: RecommendationComplianceStatus
recommendationStatus = RecommendationComplianceStatus
pRecommendationStatus_
      }

-- | The name of the application component.
componentRecommendation_appComponentName :: Lens.Lens' ComponentRecommendation Prelude.Text
componentRecommendation_appComponentName :: Lens' ComponentRecommendation Text
componentRecommendation_appComponentName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentRecommendation' {Text
appComponentName :: Text
$sel:appComponentName:ComponentRecommendation' :: ComponentRecommendation -> Text
appComponentName} -> Text
appComponentName) (\s :: ComponentRecommendation
s@ComponentRecommendation' {} Text
a -> ComponentRecommendation
s {$sel:appComponentName:ComponentRecommendation' :: Text
appComponentName = Text
a} :: ComponentRecommendation)

-- | The list of recommendations.
componentRecommendation_configRecommendations :: Lens.Lens' ComponentRecommendation [ConfigRecommendation]
componentRecommendation_configRecommendations :: Lens' ComponentRecommendation [ConfigRecommendation]
componentRecommendation_configRecommendations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentRecommendation' {[ConfigRecommendation]
configRecommendations :: [ConfigRecommendation]
$sel:configRecommendations:ComponentRecommendation' :: ComponentRecommendation -> [ConfigRecommendation]
configRecommendations} -> [ConfigRecommendation]
configRecommendations) (\s :: ComponentRecommendation
s@ComponentRecommendation' {} [ConfigRecommendation]
a -> ComponentRecommendation
s {$sel:configRecommendations:ComponentRecommendation' :: [ConfigRecommendation]
configRecommendations = [ConfigRecommendation]
a} :: ComponentRecommendation) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The recommendation status.
componentRecommendation_recommendationStatus :: Lens.Lens' ComponentRecommendation RecommendationComplianceStatus
componentRecommendation_recommendationStatus :: Lens' ComponentRecommendation RecommendationComplianceStatus
componentRecommendation_recommendationStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentRecommendation' {RecommendationComplianceStatus
recommendationStatus :: RecommendationComplianceStatus
$sel:recommendationStatus:ComponentRecommendation' :: ComponentRecommendation -> RecommendationComplianceStatus
recommendationStatus} -> RecommendationComplianceStatus
recommendationStatus) (\s :: ComponentRecommendation
s@ComponentRecommendation' {} RecommendationComplianceStatus
a -> ComponentRecommendation
s {$sel:recommendationStatus:ComponentRecommendation' :: RecommendationComplianceStatus
recommendationStatus = RecommendationComplianceStatus
a} :: ComponentRecommendation)

instance Data.FromJSON ComponentRecommendation where
  parseJSON :: Value -> Parser ComponentRecommendation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ComponentRecommendation"
      ( \Object
x ->
          Text
-> [ConfigRecommendation]
-> RecommendationComplianceStatus
-> ComponentRecommendation
ComponentRecommendation'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"appComponentName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"configRecommendations"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"recommendationStatus")
      )

instance Prelude.Hashable ComponentRecommendation where
  hashWithSalt :: Int -> ComponentRecommendation -> Int
hashWithSalt Int
_salt ComponentRecommendation' {[ConfigRecommendation]
Text
RecommendationComplianceStatus
recommendationStatus :: RecommendationComplianceStatus
configRecommendations :: [ConfigRecommendation]
appComponentName :: Text
$sel:recommendationStatus:ComponentRecommendation' :: ComponentRecommendation -> RecommendationComplianceStatus
$sel:configRecommendations:ComponentRecommendation' :: ComponentRecommendation -> [ConfigRecommendation]
$sel:appComponentName:ComponentRecommendation' :: ComponentRecommendation -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
appComponentName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [ConfigRecommendation]
configRecommendations
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` RecommendationComplianceStatus
recommendationStatus

instance Prelude.NFData ComponentRecommendation where
  rnf :: ComponentRecommendation -> ()
rnf ComponentRecommendation' {[ConfigRecommendation]
Text
RecommendationComplianceStatus
recommendationStatus :: RecommendationComplianceStatus
configRecommendations :: [ConfigRecommendation]
appComponentName :: Text
$sel:recommendationStatus:ComponentRecommendation' :: ComponentRecommendation -> RecommendationComplianceStatus
$sel:configRecommendations:ComponentRecommendation' :: ComponentRecommendation -> [ConfigRecommendation]
$sel:appComponentName:ComponentRecommendation' :: ComponentRecommendation -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
appComponentName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [ConfigRecommendation]
configRecommendations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf RecommendationComplianceStatus
recommendationStatus