{-# 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.ComputeOptimizer.Types.Summary
-- 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.ComputeOptimizer.Types.Summary where

import Amazonka.ComputeOptimizer.Types.Finding
import Amazonka.ComputeOptimizer.Types.ReasonCodeSummary
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

-- | The summary of a recommendation.
--
-- /See:/ 'newSummary' smart constructor.
data Summary = Summary'
  { -- | The finding classification of the recommendation.
    Summary -> Maybe Finding
name :: Prelude.Maybe Finding,
    -- | An array of objects that summarize a finding reason code.
    Summary -> Maybe [ReasonCodeSummary]
reasonCodeSummaries :: Prelude.Maybe [ReasonCodeSummary],
    -- | The value of the recommendation summary.
    Summary -> Maybe Double
value :: Prelude.Maybe Prelude.Double
  }
  deriving (Summary -> Summary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Summary -> Summary -> Bool
$c/= :: Summary -> Summary -> Bool
== :: Summary -> Summary -> Bool
$c== :: Summary -> Summary -> Bool
Prelude.Eq, ReadPrec [Summary]
ReadPrec Summary
Int -> ReadS Summary
ReadS [Summary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Summary]
$creadListPrec :: ReadPrec [Summary]
readPrec :: ReadPrec Summary
$creadPrec :: ReadPrec Summary
readList :: ReadS [Summary]
$creadList :: ReadS [Summary]
readsPrec :: Int -> ReadS Summary
$creadsPrec :: Int -> ReadS Summary
Prelude.Read, Int -> Summary -> ShowS
[Summary] -> ShowS
Summary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Summary] -> ShowS
$cshowList :: [Summary] -> ShowS
show :: Summary -> String
$cshow :: Summary -> String
showsPrec :: Int -> Summary -> ShowS
$cshowsPrec :: Int -> Summary -> ShowS
Prelude.Show, forall x. Rep Summary x -> Summary
forall x. Summary -> Rep Summary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Summary x -> Summary
$cfrom :: forall x. Summary -> Rep Summary x
Prelude.Generic)

-- |
-- Create a value of 'Summary' 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:
--
-- 'name', 'summary_name' - The finding classification of the recommendation.
--
-- 'reasonCodeSummaries', 'summary_reasonCodeSummaries' - An array of objects that summarize a finding reason code.
--
-- 'value', 'summary_value' - The value of the recommendation summary.
newSummary ::
  Summary
newSummary :: Summary
newSummary =
  Summary'
    { $sel:name:Summary' :: Maybe Finding
name = forall a. Maybe a
Prelude.Nothing,
      $sel:reasonCodeSummaries:Summary' :: Maybe [ReasonCodeSummary]
reasonCodeSummaries = forall a. Maybe a
Prelude.Nothing,
      $sel:value:Summary' :: Maybe Double
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The finding classification of the recommendation.
summary_name :: Lens.Lens' Summary (Prelude.Maybe Finding)
summary_name :: Lens' Summary (Maybe Finding)
summary_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Summary' {Maybe Finding
name :: Maybe Finding
$sel:name:Summary' :: Summary -> Maybe Finding
name} -> Maybe Finding
name) (\s :: Summary
s@Summary' {} Maybe Finding
a -> Summary
s {$sel:name:Summary' :: Maybe Finding
name = Maybe Finding
a} :: Summary)

-- | An array of objects that summarize a finding reason code.
summary_reasonCodeSummaries :: Lens.Lens' Summary (Prelude.Maybe [ReasonCodeSummary])
summary_reasonCodeSummaries :: Lens' Summary (Maybe [ReasonCodeSummary])
summary_reasonCodeSummaries = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Summary' {Maybe [ReasonCodeSummary]
reasonCodeSummaries :: Maybe [ReasonCodeSummary]
$sel:reasonCodeSummaries:Summary' :: Summary -> Maybe [ReasonCodeSummary]
reasonCodeSummaries} -> Maybe [ReasonCodeSummary]
reasonCodeSummaries) (\s :: Summary
s@Summary' {} Maybe [ReasonCodeSummary]
a -> Summary
s {$sel:reasonCodeSummaries:Summary' :: Maybe [ReasonCodeSummary]
reasonCodeSummaries = Maybe [ReasonCodeSummary]
a} :: Summary) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The value of the recommendation summary.
summary_value :: Lens.Lens' Summary (Prelude.Maybe Prelude.Double)
summary_value :: Lens' Summary (Maybe Double)
summary_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Summary' {Maybe Double
value :: Maybe Double
$sel:value:Summary' :: Summary -> Maybe Double
value} -> Maybe Double
value) (\s :: Summary
s@Summary' {} Maybe Double
a -> Summary
s {$sel:value:Summary' :: Maybe Double
value = Maybe Double
a} :: Summary)

instance Data.FromJSON Summary where
  parseJSON :: Value -> Parser Summary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Summary"
      ( \Object
x ->
          Maybe Finding
-> Maybe [ReasonCodeSummary] -> Maybe Double -> Summary
Summary'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"name")
            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
"reasonCodeSummaries"
                            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 (Maybe a)
Data..:? Key
"value")
      )

instance Prelude.Hashable Summary where
  hashWithSalt :: Int -> Summary -> Int
hashWithSalt Int
_salt Summary' {Maybe Double
Maybe [ReasonCodeSummary]
Maybe Finding
value :: Maybe Double
reasonCodeSummaries :: Maybe [ReasonCodeSummary]
name :: Maybe Finding
$sel:value:Summary' :: Summary -> Maybe Double
$sel:reasonCodeSummaries:Summary' :: Summary -> Maybe [ReasonCodeSummary]
$sel:name:Summary' :: Summary -> Maybe Finding
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Finding
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ReasonCodeSummary]
reasonCodeSummaries
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
value

instance Prelude.NFData Summary where
  rnf :: Summary -> ()
rnf Summary' {Maybe Double
Maybe [ReasonCodeSummary]
Maybe Finding
value :: Maybe Double
reasonCodeSummaries :: Maybe [ReasonCodeSummary]
name :: Maybe Finding
$sel:value:Summary' :: Summary -> Maybe Double
$sel:reasonCodeSummaries:Summary' :: Summary -> Maybe [ReasonCodeSummary]
$sel:name:Summary' :: Summary -> Maybe Finding
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Finding
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [ReasonCodeSummary]
reasonCodeSummaries
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
value