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

import Amazonka.ComputeOptimizer.Types.LambdaFunctionMetricName
import Amazonka.ComputeOptimizer.Types.LambdaFunctionMetricStatistic
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes a utilization metric of an Lambda function.
--
-- /See:/ 'newLambdaFunctionUtilizationMetric' smart constructor.
data LambdaFunctionUtilizationMetric = LambdaFunctionUtilizationMetric'
  { -- | The value of the utilization metric.
    LambdaFunctionUtilizationMetric -> Maybe Double
value :: Prelude.Maybe Prelude.Double,
    -- | The name of the utilization metric.
    --
    -- The following utilization metrics are available:
    --
    -- -   @Duration@ - The amount of time that your function code spends
    --     processing an event.
    --
    -- -   @Memory@ - The amount of memory used per invocation.
    LambdaFunctionUtilizationMetric -> Maybe LambdaFunctionMetricName
name :: Prelude.Maybe LambdaFunctionMetricName,
    -- | The statistic of the utilization metric.
    --
    -- The Compute Optimizer API, Command Line Interface (CLI), and SDKs return
    -- utilization metrics using only the @Maximum@ statistic, which is the
    -- highest value observed during the specified period.
    --
    -- The Compute Optimizer console displays graphs for some utilization
    -- metrics using the @Average@ statistic, which is the value of @Sum@ \/
    -- @SampleCount@ during the specified period. For more information, see
    -- <https://docs.aws.amazon.com/compute-optimizer/latest/ug/viewing-recommendations.html Viewing resource recommendations>
    -- in the /Compute Optimizer User Guide/. You can also get averaged
    -- utilization metric data for your resources using Amazon CloudWatch. For
    -- more information, see the
    -- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/WhatIsCloudWatch.html Amazon CloudWatch User Guide>.
    LambdaFunctionUtilizationMetric
-> Maybe LambdaFunctionMetricStatistic
statistic :: Prelude.Maybe LambdaFunctionMetricStatistic
  }
  deriving (LambdaFunctionUtilizationMetric
-> LambdaFunctionUtilizationMetric -> Bool
(LambdaFunctionUtilizationMetric
 -> LambdaFunctionUtilizationMetric -> Bool)
-> (LambdaFunctionUtilizationMetric
    -> LambdaFunctionUtilizationMetric -> Bool)
-> Eq LambdaFunctionUtilizationMetric
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LambdaFunctionUtilizationMetric
-> LambdaFunctionUtilizationMetric -> Bool
$c/= :: LambdaFunctionUtilizationMetric
-> LambdaFunctionUtilizationMetric -> Bool
== :: LambdaFunctionUtilizationMetric
-> LambdaFunctionUtilizationMetric -> Bool
$c== :: LambdaFunctionUtilizationMetric
-> LambdaFunctionUtilizationMetric -> Bool
Prelude.Eq, ReadPrec [LambdaFunctionUtilizationMetric]
ReadPrec LambdaFunctionUtilizationMetric
Int -> ReadS LambdaFunctionUtilizationMetric
ReadS [LambdaFunctionUtilizationMetric]
(Int -> ReadS LambdaFunctionUtilizationMetric)
-> ReadS [LambdaFunctionUtilizationMetric]
-> ReadPrec LambdaFunctionUtilizationMetric
-> ReadPrec [LambdaFunctionUtilizationMetric]
-> Read LambdaFunctionUtilizationMetric
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LambdaFunctionUtilizationMetric]
$creadListPrec :: ReadPrec [LambdaFunctionUtilizationMetric]
readPrec :: ReadPrec LambdaFunctionUtilizationMetric
$creadPrec :: ReadPrec LambdaFunctionUtilizationMetric
readList :: ReadS [LambdaFunctionUtilizationMetric]
$creadList :: ReadS [LambdaFunctionUtilizationMetric]
readsPrec :: Int -> ReadS LambdaFunctionUtilizationMetric
$creadsPrec :: Int -> ReadS LambdaFunctionUtilizationMetric
Prelude.Read, Int -> LambdaFunctionUtilizationMetric -> ShowS
[LambdaFunctionUtilizationMetric] -> ShowS
LambdaFunctionUtilizationMetric -> String
(Int -> LambdaFunctionUtilizationMetric -> ShowS)
-> (LambdaFunctionUtilizationMetric -> String)
-> ([LambdaFunctionUtilizationMetric] -> ShowS)
-> Show LambdaFunctionUtilizationMetric
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LambdaFunctionUtilizationMetric] -> ShowS
$cshowList :: [LambdaFunctionUtilizationMetric] -> ShowS
show :: LambdaFunctionUtilizationMetric -> String
$cshow :: LambdaFunctionUtilizationMetric -> String
showsPrec :: Int -> LambdaFunctionUtilizationMetric -> ShowS
$cshowsPrec :: Int -> LambdaFunctionUtilizationMetric -> ShowS
Prelude.Show, (forall x.
 LambdaFunctionUtilizationMetric
 -> Rep LambdaFunctionUtilizationMetric x)
-> (forall x.
    Rep LambdaFunctionUtilizationMetric x
    -> LambdaFunctionUtilizationMetric)
-> Generic LambdaFunctionUtilizationMetric
forall x.
Rep LambdaFunctionUtilizationMetric x
-> LambdaFunctionUtilizationMetric
forall x.
LambdaFunctionUtilizationMetric
-> Rep LambdaFunctionUtilizationMetric x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep LambdaFunctionUtilizationMetric x
-> LambdaFunctionUtilizationMetric
$cfrom :: forall x.
LambdaFunctionUtilizationMetric
-> Rep LambdaFunctionUtilizationMetric x
Prelude.Generic)

-- |
-- Create a value of 'LambdaFunctionUtilizationMetric' 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', 'lambdaFunctionUtilizationMetric_value' - The value of the utilization metric.
--
-- 'name', 'lambdaFunctionUtilizationMetric_name' - The name of the utilization metric.
--
-- The following utilization metrics are available:
--
-- -   @Duration@ - The amount of time that your function code spends
--     processing an event.
--
-- -   @Memory@ - The amount of memory used per invocation.
--
-- 'statistic', 'lambdaFunctionUtilizationMetric_statistic' - The statistic of the utilization metric.
--
-- The Compute Optimizer API, Command Line Interface (CLI), and SDKs return
-- utilization metrics using only the @Maximum@ statistic, which is the
-- highest value observed during the specified period.
--
-- The Compute Optimizer console displays graphs for some utilization
-- metrics using the @Average@ statistic, which is the value of @Sum@ \/
-- @SampleCount@ during the specified period. For more information, see
-- <https://docs.aws.amazon.com/compute-optimizer/latest/ug/viewing-recommendations.html Viewing resource recommendations>
-- in the /Compute Optimizer User Guide/. You can also get averaged
-- utilization metric data for your resources using Amazon CloudWatch. For
-- more information, see the
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/WhatIsCloudWatch.html Amazon CloudWatch User Guide>.
newLambdaFunctionUtilizationMetric ::
  LambdaFunctionUtilizationMetric
newLambdaFunctionUtilizationMetric :: LambdaFunctionUtilizationMetric
newLambdaFunctionUtilizationMetric =
  LambdaFunctionUtilizationMetric' :: Maybe Double
-> Maybe LambdaFunctionMetricName
-> Maybe LambdaFunctionMetricStatistic
-> LambdaFunctionUtilizationMetric
LambdaFunctionUtilizationMetric'
    { $sel:value:LambdaFunctionUtilizationMetric' :: Maybe Double
value =
        Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:name:LambdaFunctionUtilizationMetric' :: Maybe LambdaFunctionMetricName
name = Maybe LambdaFunctionMetricName
forall a. Maybe a
Prelude.Nothing,
      $sel:statistic:LambdaFunctionUtilizationMetric' :: Maybe LambdaFunctionMetricStatistic
statistic = Maybe LambdaFunctionMetricStatistic
forall a. Maybe a
Prelude.Nothing
    }

-- | The value of the utilization metric.
lambdaFunctionUtilizationMetric_value :: Lens.Lens' LambdaFunctionUtilizationMetric (Prelude.Maybe Prelude.Double)
lambdaFunctionUtilizationMetric_value :: (Maybe Double -> f (Maybe Double))
-> LambdaFunctionUtilizationMetric
-> f LambdaFunctionUtilizationMetric
lambdaFunctionUtilizationMetric_value = (LambdaFunctionUtilizationMetric -> Maybe Double)
-> (LambdaFunctionUtilizationMetric
    -> Maybe Double -> LambdaFunctionUtilizationMetric)
-> Lens
     LambdaFunctionUtilizationMetric
     LambdaFunctionUtilizationMetric
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaFunctionUtilizationMetric' {Maybe Double
value :: Maybe Double
$sel:value:LambdaFunctionUtilizationMetric' :: LambdaFunctionUtilizationMetric -> Maybe Double
value} -> Maybe Double
value) (\s :: LambdaFunctionUtilizationMetric
s@LambdaFunctionUtilizationMetric' {} Maybe Double
a -> LambdaFunctionUtilizationMetric
s {$sel:value:LambdaFunctionUtilizationMetric' :: Maybe Double
value = Maybe Double
a} :: LambdaFunctionUtilizationMetric)

-- | The name of the utilization metric.
--
-- The following utilization metrics are available:
--
-- -   @Duration@ - The amount of time that your function code spends
--     processing an event.
--
-- -   @Memory@ - The amount of memory used per invocation.
lambdaFunctionUtilizationMetric_name :: Lens.Lens' LambdaFunctionUtilizationMetric (Prelude.Maybe LambdaFunctionMetricName)
lambdaFunctionUtilizationMetric_name :: (Maybe LambdaFunctionMetricName
 -> f (Maybe LambdaFunctionMetricName))
-> LambdaFunctionUtilizationMetric
-> f LambdaFunctionUtilizationMetric
lambdaFunctionUtilizationMetric_name = (LambdaFunctionUtilizationMetric -> Maybe LambdaFunctionMetricName)
-> (LambdaFunctionUtilizationMetric
    -> Maybe LambdaFunctionMetricName
    -> LambdaFunctionUtilizationMetric)
-> Lens
     LambdaFunctionUtilizationMetric
     LambdaFunctionUtilizationMetric
     (Maybe LambdaFunctionMetricName)
     (Maybe LambdaFunctionMetricName)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaFunctionUtilizationMetric' {Maybe LambdaFunctionMetricName
name :: Maybe LambdaFunctionMetricName
$sel:name:LambdaFunctionUtilizationMetric' :: LambdaFunctionUtilizationMetric -> Maybe LambdaFunctionMetricName
name} -> Maybe LambdaFunctionMetricName
name) (\s :: LambdaFunctionUtilizationMetric
s@LambdaFunctionUtilizationMetric' {} Maybe LambdaFunctionMetricName
a -> LambdaFunctionUtilizationMetric
s {$sel:name:LambdaFunctionUtilizationMetric' :: Maybe LambdaFunctionMetricName
name = Maybe LambdaFunctionMetricName
a} :: LambdaFunctionUtilizationMetric)

-- | The statistic of the utilization metric.
--
-- The Compute Optimizer API, Command Line Interface (CLI), and SDKs return
-- utilization metrics using only the @Maximum@ statistic, which is the
-- highest value observed during the specified period.
--
-- The Compute Optimizer console displays graphs for some utilization
-- metrics using the @Average@ statistic, which is the value of @Sum@ \/
-- @SampleCount@ during the specified period. For more information, see
-- <https://docs.aws.amazon.com/compute-optimizer/latest/ug/viewing-recommendations.html Viewing resource recommendations>
-- in the /Compute Optimizer User Guide/. You can also get averaged
-- utilization metric data for your resources using Amazon CloudWatch. For
-- more information, see the
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/WhatIsCloudWatch.html Amazon CloudWatch User Guide>.
lambdaFunctionUtilizationMetric_statistic :: Lens.Lens' LambdaFunctionUtilizationMetric (Prelude.Maybe LambdaFunctionMetricStatistic)
lambdaFunctionUtilizationMetric_statistic :: (Maybe LambdaFunctionMetricStatistic
 -> f (Maybe LambdaFunctionMetricStatistic))
-> LambdaFunctionUtilizationMetric
-> f LambdaFunctionUtilizationMetric
lambdaFunctionUtilizationMetric_statistic = (LambdaFunctionUtilizationMetric
 -> Maybe LambdaFunctionMetricStatistic)
-> (LambdaFunctionUtilizationMetric
    -> Maybe LambdaFunctionMetricStatistic
    -> LambdaFunctionUtilizationMetric)
-> Lens
     LambdaFunctionUtilizationMetric
     LambdaFunctionUtilizationMetric
     (Maybe LambdaFunctionMetricStatistic)
     (Maybe LambdaFunctionMetricStatistic)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaFunctionUtilizationMetric' {Maybe LambdaFunctionMetricStatistic
statistic :: Maybe LambdaFunctionMetricStatistic
$sel:statistic:LambdaFunctionUtilizationMetric' :: LambdaFunctionUtilizationMetric
-> Maybe LambdaFunctionMetricStatistic
statistic} -> Maybe LambdaFunctionMetricStatistic
statistic) (\s :: LambdaFunctionUtilizationMetric
s@LambdaFunctionUtilizationMetric' {} Maybe LambdaFunctionMetricStatistic
a -> LambdaFunctionUtilizationMetric
s {$sel:statistic:LambdaFunctionUtilizationMetric' :: Maybe LambdaFunctionMetricStatistic
statistic = Maybe LambdaFunctionMetricStatistic
a} :: LambdaFunctionUtilizationMetric)

instance
  Core.FromJSON
    LambdaFunctionUtilizationMetric
  where
  parseJSON :: Value -> Parser LambdaFunctionUtilizationMetric
parseJSON =
    String
-> (Object -> Parser LambdaFunctionUtilizationMetric)
-> Value
-> Parser LambdaFunctionUtilizationMetric
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LambdaFunctionUtilizationMetric"
      ( \Object
x ->
          Maybe Double
-> Maybe LambdaFunctionMetricName
-> Maybe LambdaFunctionMetricStatistic
-> LambdaFunctionUtilizationMetric
LambdaFunctionUtilizationMetric'
            (Maybe Double
 -> Maybe LambdaFunctionMetricName
 -> Maybe LambdaFunctionMetricStatistic
 -> LambdaFunctionUtilizationMetric)
-> Parser (Maybe Double)
-> Parser
     (Maybe LambdaFunctionMetricName
      -> Maybe LambdaFunctionMetricStatistic
      -> LambdaFunctionUtilizationMetric)
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 LambdaFunctionMetricName
   -> Maybe LambdaFunctionMetricStatistic
   -> LambdaFunctionUtilizationMetric)
-> Parser (Maybe LambdaFunctionMetricName)
-> Parser
     (Maybe LambdaFunctionMetricStatistic
      -> LambdaFunctionUtilizationMetric)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe LambdaFunctionMetricName)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"name")
            Parser
  (Maybe LambdaFunctionMetricStatistic
   -> LambdaFunctionUtilizationMetric)
-> Parser (Maybe LambdaFunctionMetricStatistic)
-> Parser LambdaFunctionUtilizationMetric
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe LambdaFunctionMetricStatistic)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"statistic")
      )

instance
  Prelude.Hashable
    LambdaFunctionUtilizationMetric

instance
  Prelude.NFData
    LambdaFunctionUtilizationMetric