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

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

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

-- |
-- Create a value of 'ReasonCodeSummary' 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', 'reasonCodeSummary_name' - The name of the finding reason code.
--
-- 'value', 'reasonCodeSummary_value' - The value of the finding reason code summary.
newReasonCodeSummary ::
  ReasonCodeSummary
newReasonCodeSummary :: ReasonCodeSummary
newReasonCodeSummary =
  ReasonCodeSummary'
    { $sel:name:ReasonCodeSummary' :: Maybe FindingReasonCode
name = forall a. Maybe a
Prelude.Nothing,
      $sel:value:ReasonCodeSummary' :: Maybe Double
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the finding reason code.
reasonCodeSummary_name :: Lens.Lens' ReasonCodeSummary (Prelude.Maybe FindingReasonCode)
reasonCodeSummary_name :: Lens' ReasonCodeSummary (Maybe FindingReasonCode)
reasonCodeSummary_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReasonCodeSummary' {Maybe FindingReasonCode
name :: Maybe FindingReasonCode
$sel:name:ReasonCodeSummary' :: ReasonCodeSummary -> Maybe FindingReasonCode
name} -> Maybe FindingReasonCode
name) (\s :: ReasonCodeSummary
s@ReasonCodeSummary' {} Maybe FindingReasonCode
a -> ReasonCodeSummary
s {$sel:name:ReasonCodeSummary' :: Maybe FindingReasonCode
name = Maybe FindingReasonCode
a} :: ReasonCodeSummary)

-- | The value of the finding reason code summary.
reasonCodeSummary_value :: Lens.Lens' ReasonCodeSummary (Prelude.Maybe Prelude.Double)
reasonCodeSummary_value :: Lens' ReasonCodeSummary (Maybe Double)
reasonCodeSummary_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReasonCodeSummary' {Maybe Double
value :: Maybe Double
$sel:value:ReasonCodeSummary' :: ReasonCodeSummary -> Maybe Double
value} -> Maybe Double
value) (\s :: ReasonCodeSummary
s@ReasonCodeSummary' {} Maybe Double
a -> ReasonCodeSummary
s {$sel:value:ReasonCodeSummary' :: Maybe Double
value = Maybe Double
a} :: ReasonCodeSummary)

instance Data.FromJSON ReasonCodeSummary where
  parseJSON :: Value -> Parser ReasonCodeSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ReasonCodeSummary"
      ( \Object
x ->
          Maybe FindingReasonCode -> Maybe Double -> ReasonCodeSummary
ReasonCodeSummary'
            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
"value")
      )

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

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