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

import Amazonka.ComputeOptimizer.Types.ProjectedMetric
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.
--
-- 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:/ 'newRecommendedOptionProjectedMetric' smart constructor.
data RecommendedOptionProjectedMetric = RecommendedOptionProjectedMetric'
  { -- | The recommended instance type.
    RecommendedOptionProjectedMetric -> Maybe Text
recommendedInstanceType :: Prelude.Maybe Prelude.Text,
    -- | An array of objects that describe a projected utilization metric.
    RecommendedOptionProjectedMetric -> Maybe [ProjectedMetric]
projectedMetrics :: Prelude.Maybe [ProjectedMetric],
    -- | The rank of the recommendation option projected metric.
    --
    -- The top recommendation option is ranked as @1@.
    --
    -- The projected metric rank correlates to the recommendation option rank.
    -- For example, the projected metric ranked as @1@ is related to the
    -- recommendation option that is also ranked as @1@ in the same response.
    RecommendedOptionProjectedMetric -> Maybe Int
rank :: Prelude.Maybe Prelude.Int
  }
  deriving (RecommendedOptionProjectedMetric
-> RecommendedOptionProjectedMetric -> Bool
(RecommendedOptionProjectedMetric
 -> RecommendedOptionProjectedMetric -> Bool)
-> (RecommendedOptionProjectedMetric
    -> RecommendedOptionProjectedMetric -> Bool)
-> Eq RecommendedOptionProjectedMetric
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RecommendedOptionProjectedMetric
-> RecommendedOptionProjectedMetric -> Bool
$c/= :: RecommendedOptionProjectedMetric
-> RecommendedOptionProjectedMetric -> Bool
== :: RecommendedOptionProjectedMetric
-> RecommendedOptionProjectedMetric -> Bool
$c== :: RecommendedOptionProjectedMetric
-> RecommendedOptionProjectedMetric -> Bool
Prelude.Eq, ReadPrec [RecommendedOptionProjectedMetric]
ReadPrec RecommendedOptionProjectedMetric
Int -> ReadS RecommendedOptionProjectedMetric
ReadS [RecommendedOptionProjectedMetric]
(Int -> ReadS RecommendedOptionProjectedMetric)
-> ReadS [RecommendedOptionProjectedMetric]
-> ReadPrec RecommendedOptionProjectedMetric
-> ReadPrec [RecommendedOptionProjectedMetric]
-> Read RecommendedOptionProjectedMetric
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RecommendedOptionProjectedMetric]
$creadListPrec :: ReadPrec [RecommendedOptionProjectedMetric]
readPrec :: ReadPrec RecommendedOptionProjectedMetric
$creadPrec :: ReadPrec RecommendedOptionProjectedMetric
readList :: ReadS [RecommendedOptionProjectedMetric]
$creadList :: ReadS [RecommendedOptionProjectedMetric]
readsPrec :: Int -> ReadS RecommendedOptionProjectedMetric
$creadsPrec :: Int -> ReadS RecommendedOptionProjectedMetric
Prelude.Read, Int -> RecommendedOptionProjectedMetric -> ShowS
[RecommendedOptionProjectedMetric] -> ShowS
RecommendedOptionProjectedMetric -> String
(Int -> RecommendedOptionProjectedMetric -> ShowS)
-> (RecommendedOptionProjectedMetric -> String)
-> ([RecommendedOptionProjectedMetric] -> ShowS)
-> Show RecommendedOptionProjectedMetric
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RecommendedOptionProjectedMetric] -> ShowS
$cshowList :: [RecommendedOptionProjectedMetric] -> ShowS
show :: RecommendedOptionProjectedMetric -> String
$cshow :: RecommendedOptionProjectedMetric -> String
showsPrec :: Int -> RecommendedOptionProjectedMetric -> ShowS
$cshowsPrec :: Int -> RecommendedOptionProjectedMetric -> ShowS
Prelude.Show, (forall x.
 RecommendedOptionProjectedMetric
 -> Rep RecommendedOptionProjectedMetric x)
-> (forall x.
    Rep RecommendedOptionProjectedMetric x
    -> RecommendedOptionProjectedMetric)
-> Generic RecommendedOptionProjectedMetric
forall x.
Rep RecommendedOptionProjectedMetric x
-> RecommendedOptionProjectedMetric
forall x.
RecommendedOptionProjectedMetric
-> Rep RecommendedOptionProjectedMetric x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RecommendedOptionProjectedMetric x
-> RecommendedOptionProjectedMetric
$cfrom :: forall x.
RecommendedOptionProjectedMetric
-> Rep RecommendedOptionProjectedMetric x
Prelude.Generic)

-- |
-- Create a value of 'RecommendedOptionProjectedMetric' 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:
--
-- 'recommendedInstanceType', 'recommendedOptionProjectedMetric_recommendedInstanceType' - The recommended instance type.
--
-- 'projectedMetrics', 'recommendedOptionProjectedMetric_projectedMetrics' - An array of objects that describe a projected utilization metric.
--
-- 'rank', 'recommendedOptionProjectedMetric_rank' - The rank of the recommendation option projected metric.
--
-- The top recommendation option is ranked as @1@.
--
-- The projected metric rank correlates to the recommendation option rank.
-- For example, the projected metric ranked as @1@ is related to the
-- recommendation option that is also ranked as @1@ in the same response.
newRecommendedOptionProjectedMetric ::
  RecommendedOptionProjectedMetric
newRecommendedOptionProjectedMetric :: RecommendedOptionProjectedMetric
newRecommendedOptionProjectedMetric =
  RecommendedOptionProjectedMetric' :: Maybe Text
-> Maybe [ProjectedMetric]
-> Maybe Int
-> RecommendedOptionProjectedMetric
RecommendedOptionProjectedMetric'
    { $sel:recommendedInstanceType:RecommendedOptionProjectedMetric' :: Maybe Text
recommendedInstanceType =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:projectedMetrics:RecommendedOptionProjectedMetric' :: Maybe [ProjectedMetric]
projectedMetrics = Maybe [ProjectedMetric]
forall a. Maybe a
Prelude.Nothing,
      $sel:rank:RecommendedOptionProjectedMetric' :: Maybe Int
rank = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The recommended instance type.
recommendedOptionProjectedMetric_recommendedInstanceType :: Lens.Lens' RecommendedOptionProjectedMetric (Prelude.Maybe Prelude.Text)
recommendedOptionProjectedMetric_recommendedInstanceType :: (Maybe Text -> f (Maybe Text))
-> RecommendedOptionProjectedMetric
-> f RecommendedOptionProjectedMetric
recommendedOptionProjectedMetric_recommendedInstanceType = (RecommendedOptionProjectedMetric -> Maybe Text)
-> (RecommendedOptionProjectedMetric
    -> Maybe Text -> RecommendedOptionProjectedMetric)
-> Lens
     RecommendedOptionProjectedMetric
     RecommendedOptionProjectedMetric
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecommendedOptionProjectedMetric' {Maybe Text
recommendedInstanceType :: Maybe Text
$sel:recommendedInstanceType:RecommendedOptionProjectedMetric' :: RecommendedOptionProjectedMetric -> Maybe Text
recommendedInstanceType} -> Maybe Text
recommendedInstanceType) (\s :: RecommendedOptionProjectedMetric
s@RecommendedOptionProjectedMetric' {} Maybe Text
a -> RecommendedOptionProjectedMetric
s {$sel:recommendedInstanceType:RecommendedOptionProjectedMetric' :: Maybe Text
recommendedInstanceType = Maybe Text
a} :: RecommendedOptionProjectedMetric)

-- | An array of objects that describe a projected utilization metric.
recommendedOptionProjectedMetric_projectedMetrics :: Lens.Lens' RecommendedOptionProjectedMetric (Prelude.Maybe [ProjectedMetric])
recommendedOptionProjectedMetric_projectedMetrics :: (Maybe [ProjectedMetric] -> f (Maybe [ProjectedMetric]))
-> RecommendedOptionProjectedMetric
-> f RecommendedOptionProjectedMetric
recommendedOptionProjectedMetric_projectedMetrics = (RecommendedOptionProjectedMetric -> Maybe [ProjectedMetric])
-> (RecommendedOptionProjectedMetric
    -> Maybe [ProjectedMetric] -> RecommendedOptionProjectedMetric)
-> Lens
     RecommendedOptionProjectedMetric
     RecommendedOptionProjectedMetric
     (Maybe [ProjectedMetric])
     (Maybe [ProjectedMetric])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecommendedOptionProjectedMetric' {Maybe [ProjectedMetric]
projectedMetrics :: Maybe [ProjectedMetric]
$sel:projectedMetrics:RecommendedOptionProjectedMetric' :: RecommendedOptionProjectedMetric -> Maybe [ProjectedMetric]
projectedMetrics} -> Maybe [ProjectedMetric]
projectedMetrics) (\s :: RecommendedOptionProjectedMetric
s@RecommendedOptionProjectedMetric' {} Maybe [ProjectedMetric]
a -> RecommendedOptionProjectedMetric
s {$sel:projectedMetrics:RecommendedOptionProjectedMetric' :: Maybe [ProjectedMetric]
projectedMetrics = Maybe [ProjectedMetric]
a} :: RecommendedOptionProjectedMetric) ((Maybe [ProjectedMetric] -> f (Maybe [ProjectedMetric]))
 -> RecommendedOptionProjectedMetric
 -> f RecommendedOptionProjectedMetric)
-> ((Maybe [ProjectedMetric] -> f (Maybe [ProjectedMetric]))
    -> Maybe [ProjectedMetric] -> f (Maybe [ProjectedMetric]))
-> (Maybe [ProjectedMetric] -> f (Maybe [ProjectedMetric]))
-> RecommendedOptionProjectedMetric
-> f RecommendedOptionProjectedMetric
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ProjectedMetric]
  [ProjectedMetric]
  [ProjectedMetric]
  [ProjectedMetric]
-> Iso
     (Maybe [ProjectedMetric])
     (Maybe [ProjectedMetric])
     (Maybe [ProjectedMetric])
     (Maybe [ProjectedMetric])
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
  [ProjectedMetric]
  [ProjectedMetric]
  [ProjectedMetric]
  [ProjectedMetric]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The rank of the recommendation option projected metric.
--
-- The top recommendation option is ranked as @1@.
--
-- The projected metric rank correlates to the recommendation option rank.
-- For example, the projected metric ranked as @1@ is related to the
-- recommendation option that is also ranked as @1@ in the same response.
recommendedOptionProjectedMetric_rank :: Lens.Lens' RecommendedOptionProjectedMetric (Prelude.Maybe Prelude.Int)
recommendedOptionProjectedMetric_rank :: (Maybe Int -> f (Maybe Int))
-> RecommendedOptionProjectedMetric
-> f RecommendedOptionProjectedMetric
recommendedOptionProjectedMetric_rank = (RecommendedOptionProjectedMetric -> Maybe Int)
-> (RecommendedOptionProjectedMetric
    -> Maybe Int -> RecommendedOptionProjectedMetric)
-> Lens
     RecommendedOptionProjectedMetric
     RecommendedOptionProjectedMetric
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecommendedOptionProjectedMetric' {Maybe Int
rank :: Maybe Int
$sel:rank:RecommendedOptionProjectedMetric' :: RecommendedOptionProjectedMetric -> Maybe Int
rank} -> Maybe Int
rank) (\s :: RecommendedOptionProjectedMetric
s@RecommendedOptionProjectedMetric' {} Maybe Int
a -> RecommendedOptionProjectedMetric
s {$sel:rank:RecommendedOptionProjectedMetric' :: Maybe Int
rank = Maybe Int
a} :: RecommendedOptionProjectedMetric)

instance
  Core.FromJSON
    RecommendedOptionProjectedMetric
  where
  parseJSON :: Value -> Parser RecommendedOptionProjectedMetric
parseJSON =
    String
-> (Object -> Parser RecommendedOptionProjectedMetric)
-> Value
-> Parser RecommendedOptionProjectedMetric
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RecommendedOptionProjectedMetric"
      ( \Object
x ->
          Maybe Text
-> Maybe [ProjectedMetric]
-> Maybe Int
-> RecommendedOptionProjectedMetric
RecommendedOptionProjectedMetric'
            (Maybe Text
 -> Maybe [ProjectedMetric]
 -> Maybe Int
 -> RecommendedOptionProjectedMetric)
-> Parser (Maybe Text)
-> Parser
     (Maybe [ProjectedMetric]
      -> Maybe Int -> RecommendedOptionProjectedMetric)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"recommendedInstanceType")
            Parser
  (Maybe [ProjectedMetric]
   -> Maybe Int -> RecommendedOptionProjectedMetric)
-> Parser (Maybe [ProjectedMetric])
-> Parser (Maybe Int -> RecommendedOptionProjectedMetric)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [ProjectedMetric]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"projectedMetrics"
                            Parser (Maybe (Maybe [ProjectedMetric]))
-> Maybe [ProjectedMetric] -> Parser (Maybe [ProjectedMetric])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ProjectedMetric]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe Int -> RecommendedOptionProjectedMetric)
-> Parser (Maybe Int) -> Parser RecommendedOptionProjectedMetric
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"rank")
      )

instance
  Prelude.Hashable
    RecommendedOptionProjectedMetric

instance
  Prelude.NFData
    RecommendedOptionProjectedMetric