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

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

-- | Describes a projected utilization metric of a recommendation option,
-- such as an Amazon EC2 instance. This represents the projected
-- utilization of a recommendation option had you used that resource during
-- the analyzed period.
--
-- Compare the utilization metric data of your resource against its
-- projected utilization metric data to determine the performance
-- difference between your current resource and the recommended option.
--
-- The @Cpu@ and @Memory@ metrics are the only projected utilization
-- metrics returned when you run the GetEC2RecommendationProjectedMetrics
-- action. Additionally, the @Memory@ metric is returned only for resources
-- that have the unified CloudWatch agent installed on them. For more
-- information, see
-- <https://docs.aws.amazon.com/compute-optimizer/latest/ug/metrics.html#cw-agent Enabling Memory Utilization with the CloudWatch Agent>.
--
-- /See:/ 'newProjectedMetric' smart constructor.
data ProjectedMetric = ProjectedMetric'
  { -- | The values of the projected utilization metrics.
    ProjectedMetric -> Maybe [Double]
values :: Prelude.Maybe [Prelude.Double],
    -- | The name of the projected utilization metric.
    --
    -- The following projected utilization metrics are returned:
    --
    -- -   @Cpu@ - The projected percentage of allocated EC2 compute units that
    --     would be in use on the recommendation option had you used that
    --     resource during the analyzed period. This metric identifies the
    --     processing power required to run an application on the
    --     recommendation option.
    --
    --     Depending on the instance type, tools in your operating system can
    --     show a lower percentage than CloudWatch when the instance is not
    --     allocated a full processor core.
    --
    --     Units: Percent
    --
    -- -   @Memory@ - The percentage of memory that would be in use on the
    --     recommendation option had you used that resource during the analyzed
    --     period. This metric identifies the amount of memory required to run
    --     an application on the recommendation option.
    --
    --     Units: Percent
    --
    --     The @Memory@ metric is returned only for resources that have the
    --     unified CloudWatch agent installed on them. For more information,
    --     see
    --     <https://docs.aws.amazon.com/compute-optimizer/latest/ug/metrics.html#cw-agent Enabling Memory Utilization with the CloudWatch Agent>.
    ProjectedMetric -> Maybe MetricName
name :: Prelude.Maybe MetricName,
    -- | The timestamps of the projected utilization metric.
    ProjectedMetric -> Maybe [POSIX]
timestamps :: Prelude.Maybe [Core.POSIX]
  }
  deriving (ProjectedMetric -> ProjectedMetric -> Bool
(ProjectedMetric -> ProjectedMetric -> Bool)
-> (ProjectedMetric -> ProjectedMetric -> Bool)
-> Eq ProjectedMetric
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProjectedMetric -> ProjectedMetric -> Bool
$c/= :: ProjectedMetric -> ProjectedMetric -> Bool
== :: ProjectedMetric -> ProjectedMetric -> Bool
$c== :: ProjectedMetric -> ProjectedMetric -> Bool
Prelude.Eq, ReadPrec [ProjectedMetric]
ReadPrec ProjectedMetric
Int -> ReadS ProjectedMetric
ReadS [ProjectedMetric]
(Int -> ReadS ProjectedMetric)
-> ReadS [ProjectedMetric]
-> ReadPrec ProjectedMetric
-> ReadPrec [ProjectedMetric]
-> Read ProjectedMetric
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProjectedMetric]
$creadListPrec :: ReadPrec [ProjectedMetric]
readPrec :: ReadPrec ProjectedMetric
$creadPrec :: ReadPrec ProjectedMetric
readList :: ReadS [ProjectedMetric]
$creadList :: ReadS [ProjectedMetric]
readsPrec :: Int -> ReadS ProjectedMetric
$creadsPrec :: Int -> ReadS ProjectedMetric
Prelude.Read, Int -> ProjectedMetric -> ShowS
[ProjectedMetric] -> ShowS
ProjectedMetric -> String
(Int -> ProjectedMetric -> ShowS)
-> (ProjectedMetric -> String)
-> ([ProjectedMetric] -> ShowS)
-> Show ProjectedMetric
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProjectedMetric] -> ShowS
$cshowList :: [ProjectedMetric] -> ShowS
show :: ProjectedMetric -> String
$cshow :: ProjectedMetric -> String
showsPrec :: Int -> ProjectedMetric -> ShowS
$cshowsPrec :: Int -> ProjectedMetric -> ShowS
Prelude.Show, (forall x. ProjectedMetric -> Rep ProjectedMetric x)
-> (forall x. Rep ProjectedMetric x -> ProjectedMetric)
-> Generic ProjectedMetric
forall x. Rep ProjectedMetric x -> ProjectedMetric
forall x. ProjectedMetric -> Rep ProjectedMetric x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProjectedMetric x -> ProjectedMetric
$cfrom :: forall x. ProjectedMetric -> Rep ProjectedMetric x
Prelude.Generic)

-- |
-- Create a value of 'ProjectedMetric' 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:
--
-- 'values', 'projectedMetric_values' - The values of the projected utilization metrics.
--
-- 'name', 'projectedMetric_name' - The name of the projected utilization metric.
--
-- The following projected utilization metrics are returned:
--
-- -   @Cpu@ - The projected percentage of allocated EC2 compute units that
--     would be in use on the recommendation option had you used that
--     resource during the analyzed period. This metric identifies the
--     processing power required to run an application on the
--     recommendation option.
--
--     Depending on the instance type, tools in your operating system can
--     show a lower percentage than CloudWatch when the instance is not
--     allocated a full processor core.
--
--     Units: Percent
--
-- -   @Memory@ - The percentage of memory that would be in use on the
--     recommendation option had you used that resource during the analyzed
--     period. This metric identifies the amount of memory required to run
--     an application on the recommendation option.
--
--     Units: Percent
--
--     The @Memory@ metric is returned only for resources that have the
--     unified CloudWatch agent installed on them. For more information,
--     see
--     <https://docs.aws.amazon.com/compute-optimizer/latest/ug/metrics.html#cw-agent Enabling Memory Utilization with the CloudWatch Agent>.
--
-- 'timestamps', 'projectedMetric_timestamps' - The timestamps of the projected utilization metric.
newProjectedMetric ::
  ProjectedMetric
newProjectedMetric :: ProjectedMetric
newProjectedMetric =
  ProjectedMetric' :: Maybe [Double]
-> Maybe MetricName -> Maybe [POSIX] -> ProjectedMetric
ProjectedMetric'
    { $sel:values:ProjectedMetric' :: Maybe [Double]
values = Maybe [Double]
forall a. Maybe a
Prelude.Nothing,
      $sel:name:ProjectedMetric' :: Maybe MetricName
name = Maybe MetricName
forall a. Maybe a
Prelude.Nothing,
      $sel:timestamps:ProjectedMetric' :: Maybe [POSIX]
timestamps = Maybe [POSIX]
forall a. Maybe a
Prelude.Nothing
    }

-- | The values of the projected utilization metrics.
projectedMetric_values :: Lens.Lens' ProjectedMetric (Prelude.Maybe [Prelude.Double])
projectedMetric_values :: (Maybe [Double] -> f (Maybe [Double]))
-> ProjectedMetric -> f ProjectedMetric
projectedMetric_values = (ProjectedMetric -> Maybe [Double])
-> (ProjectedMetric -> Maybe [Double] -> ProjectedMetric)
-> Lens
     ProjectedMetric ProjectedMetric (Maybe [Double]) (Maybe [Double])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProjectedMetric' {Maybe [Double]
values :: Maybe [Double]
$sel:values:ProjectedMetric' :: ProjectedMetric -> Maybe [Double]
values} -> Maybe [Double]
values) (\s :: ProjectedMetric
s@ProjectedMetric' {} Maybe [Double]
a -> ProjectedMetric
s {$sel:values:ProjectedMetric' :: Maybe [Double]
values = Maybe [Double]
a} :: ProjectedMetric) ((Maybe [Double] -> f (Maybe [Double]))
 -> ProjectedMetric -> f ProjectedMetric)
-> ((Maybe [Double] -> f (Maybe [Double]))
    -> Maybe [Double] -> f (Maybe [Double]))
-> (Maybe [Double] -> f (Maybe [Double]))
-> ProjectedMetric
-> f ProjectedMetric
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Double] [Double] [Double] [Double]
-> Iso
     (Maybe [Double]) (Maybe [Double]) (Maybe [Double]) (Maybe [Double])
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 AnIso [Double] [Double] [Double] [Double]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the projected utilization metric.
--
-- The following projected utilization metrics are returned:
--
-- -   @Cpu@ - The projected percentage of allocated EC2 compute units that
--     would be in use on the recommendation option had you used that
--     resource during the analyzed period. This metric identifies the
--     processing power required to run an application on the
--     recommendation option.
--
--     Depending on the instance type, tools in your operating system can
--     show a lower percentage than CloudWatch when the instance is not
--     allocated a full processor core.
--
--     Units: Percent
--
-- -   @Memory@ - The percentage of memory that would be in use on the
--     recommendation option had you used that resource during the analyzed
--     period. This metric identifies the amount of memory required to run
--     an application on the recommendation option.
--
--     Units: Percent
--
--     The @Memory@ metric is returned only for resources that have the
--     unified CloudWatch agent installed on them. For more information,
--     see
--     <https://docs.aws.amazon.com/compute-optimizer/latest/ug/metrics.html#cw-agent Enabling Memory Utilization with the CloudWatch Agent>.
projectedMetric_name :: Lens.Lens' ProjectedMetric (Prelude.Maybe MetricName)
projectedMetric_name :: (Maybe MetricName -> f (Maybe MetricName))
-> ProjectedMetric -> f ProjectedMetric
projectedMetric_name = (ProjectedMetric -> Maybe MetricName)
-> (ProjectedMetric -> Maybe MetricName -> ProjectedMetric)
-> Lens
     ProjectedMetric
     ProjectedMetric
     (Maybe MetricName)
     (Maybe MetricName)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProjectedMetric' {Maybe MetricName
name :: Maybe MetricName
$sel:name:ProjectedMetric' :: ProjectedMetric -> Maybe MetricName
name} -> Maybe MetricName
name) (\s :: ProjectedMetric
s@ProjectedMetric' {} Maybe MetricName
a -> ProjectedMetric
s {$sel:name:ProjectedMetric' :: Maybe MetricName
name = Maybe MetricName
a} :: ProjectedMetric)

-- | The timestamps of the projected utilization metric.
projectedMetric_timestamps :: Lens.Lens' ProjectedMetric (Prelude.Maybe [Prelude.UTCTime])
projectedMetric_timestamps :: (Maybe [UTCTime] -> f (Maybe [UTCTime]))
-> ProjectedMetric -> f ProjectedMetric
projectedMetric_timestamps = (ProjectedMetric -> Maybe [POSIX])
-> (ProjectedMetric -> Maybe [POSIX] -> ProjectedMetric)
-> Lens
     ProjectedMetric ProjectedMetric (Maybe [POSIX]) (Maybe [POSIX])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProjectedMetric' {Maybe [POSIX]
timestamps :: Maybe [POSIX]
$sel:timestamps:ProjectedMetric' :: ProjectedMetric -> Maybe [POSIX]
timestamps} -> Maybe [POSIX]
timestamps) (\s :: ProjectedMetric
s@ProjectedMetric' {} Maybe [POSIX]
a -> ProjectedMetric
s {$sel:timestamps:ProjectedMetric' :: Maybe [POSIX]
timestamps = Maybe [POSIX]
a} :: ProjectedMetric) ((Maybe [POSIX] -> f (Maybe [POSIX]))
 -> ProjectedMetric -> f ProjectedMetric)
-> ((Maybe [UTCTime] -> f (Maybe [UTCTime]))
    -> Maybe [POSIX] -> f (Maybe [POSIX]))
-> (Maybe [UTCTime] -> f (Maybe [UTCTime]))
-> ProjectedMetric
-> f ProjectedMetric
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [POSIX] [POSIX] [UTCTime] [UTCTime]
-> Iso
     (Maybe [POSIX]) (Maybe [POSIX]) (Maybe [UTCTime]) (Maybe [UTCTime])
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 AnIso [POSIX] [POSIX] [UTCTime] [UTCTime]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON ProjectedMetric where
  parseJSON :: Value -> Parser ProjectedMetric
parseJSON =
    String
-> (Object -> Parser ProjectedMetric)
-> Value
-> Parser ProjectedMetric
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ProjectedMetric"
      ( \Object
x ->
          Maybe [Double]
-> Maybe MetricName -> Maybe [POSIX] -> ProjectedMetric
ProjectedMetric'
            (Maybe [Double]
 -> Maybe MetricName -> Maybe [POSIX] -> ProjectedMetric)
-> Parser (Maybe [Double])
-> Parser (Maybe MetricName -> Maybe [POSIX] -> ProjectedMetric)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Double]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"values" Parser (Maybe (Maybe [Double]))
-> Maybe [Double] -> Parser (Maybe [Double])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Double]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe MetricName -> Maybe [POSIX] -> ProjectedMetric)
-> Parser (Maybe MetricName)
-> Parser (Maybe [POSIX] -> ProjectedMetric)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe MetricName)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"name")
            Parser (Maybe [POSIX] -> ProjectedMetric)
-> Parser (Maybe [POSIX]) -> Parser ProjectedMetric
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [POSIX]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"timestamps" Parser (Maybe (Maybe [POSIX]))
-> Maybe [POSIX] -> Parser (Maybe [POSIX])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [POSIX]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ProjectedMetric

instance Prelude.NFData ProjectedMetric