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

import Amazonka.ComputeOptimizer.Types.FindingReasonCode
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A summary of a finding reason code.
--
-- /See:/ 'newReasonCodeSummary' smart constructor.
data ReasonCodeSummary = ReasonCodeSummary'
  { -- | The value of the finding reason code summary.
    ReasonCodeSummary -> Maybe Double
value :: Prelude.Maybe Prelude.Double,
    -- | The name of the finding reason code.
    ReasonCodeSummary -> Maybe FindingReasonCode
name :: Prelude.Maybe FindingReasonCode
  }
  deriving (ReasonCodeSummary -> ReasonCodeSummary -> Bool
(ReasonCodeSummary -> ReasonCodeSummary -> Bool)
-> (ReasonCodeSummary -> ReasonCodeSummary -> Bool)
-> Eq ReasonCodeSummary
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]
(Int -> ReadS ReasonCodeSummary)
-> ReadS [ReasonCodeSummary]
-> ReadPrec ReasonCodeSummary
-> ReadPrec [ReasonCodeSummary]
-> Read 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
(Int -> ReasonCodeSummary -> ShowS)
-> (ReasonCodeSummary -> String)
-> ([ReasonCodeSummary] -> ShowS)
-> Show ReasonCodeSummary
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. ReasonCodeSummary -> Rep ReasonCodeSummary x)
-> (forall x. Rep ReasonCodeSummary x -> ReasonCodeSummary)
-> Generic ReasonCodeSummary
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:
--
-- 'value', 'reasonCodeSummary_value' - The value of the finding reason code summary.
--
-- 'name', 'reasonCodeSummary_name' - The name of the finding reason code.
newReasonCodeSummary ::
  ReasonCodeSummary
newReasonCodeSummary :: ReasonCodeSummary
newReasonCodeSummary =
  ReasonCodeSummary' :: Maybe Double -> Maybe FindingReasonCode -> ReasonCodeSummary
ReasonCodeSummary'
    { $sel:value:ReasonCodeSummary' :: Maybe Double
value = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:name:ReasonCodeSummary' :: Maybe FindingReasonCode
name = Maybe FindingReasonCode
forall a. Maybe a
Prelude.Nothing
    }

-- | The value of the finding reason code summary.
reasonCodeSummary_value :: Lens.Lens' ReasonCodeSummary (Prelude.Maybe Prelude.Double)
reasonCodeSummary_value :: (Maybe Double -> f (Maybe Double))
-> ReasonCodeSummary -> f ReasonCodeSummary
reasonCodeSummary_value = (ReasonCodeSummary -> Maybe Double)
-> (ReasonCodeSummary -> Maybe Double -> ReasonCodeSummary)
-> Lens
     ReasonCodeSummary ReasonCodeSummary (Maybe Double) (Maybe Double)
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)

-- | The name of the finding reason code.
reasonCodeSummary_name :: Lens.Lens' ReasonCodeSummary (Prelude.Maybe FindingReasonCode)
reasonCodeSummary_name :: (Maybe FindingReasonCode -> f (Maybe FindingReasonCode))
-> ReasonCodeSummary -> f ReasonCodeSummary
reasonCodeSummary_name = (ReasonCodeSummary -> Maybe FindingReasonCode)
-> (ReasonCodeSummary
    -> Maybe FindingReasonCode -> ReasonCodeSummary)
-> Lens
     ReasonCodeSummary
     ReasonCodeSummary
     (Maybe FindingReasonCode)
     (Maybe FindingReasonCode)
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)

instance Core.FromJSON ReasonCodeSummary where
  parseJSON :: Value -> Parser ReasonCodeSummary
parseJSON =
    String
-> (Object -> Parser ReasonCodeSummary)
-> Value
-> Parser ReasonCodeSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ReasonCodeSummary"
      ( \Object
x ->
          Maybe Double -> Maybe FindingReasonCode -> ReasonCodeSummary
ReasonCodeSummary'
            (Maybe Double -> Maybe FindingReasonCode -> ReasonCodeSummary)
-> Parser (Maybe Double)
-> Parser (Maybe FindingReasonCode -> ReasonCodeSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"value") Parser (Maybe FindingReasonCode -> ReasonCodeSummary)
-> Parser (Maybe FindingReasonCode) -> Parser ReasonCodeSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe FindingReasonCode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"name")
      )

instance Prelude.Hashable ReasonCodeSummary

instance Prelude.NFData ReasonCodeSummary