{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.GetEC2RecommendationProjectedMetrics
-- 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)
--
-- Returns the projected utilization metrics of Amazon EC2 instance
-- recommendations.
--
-- The @Cpu@ and @Memory@ metrics are the only projected utilization
-- metrics returned when you run this 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>.
module Amazonka.ComputeOptimizer.GetEC2RecommendationProjectedMetrics
  ( -- * Creating a Request
    GetEC2RecommendationProjectedMetrics (..),
    newGetEC2RecommendationProjectedMetrics,

    -- * Request Lenses
    getEC2RecommendationProjectedMetrics_recommendationPreferences,
    getEC2RecommendationProjectedMetrics_instanceArn,
    getEC2RecommendationProjectedMetrics_stat,
    getEC2RecommendationProjectedMetrics_period,
    getEC2RecommendationProjectedMetrics_startTime,
    getEC2RecommendationProjectedMetrics_endTime,

    -- * Destructuring the Response
    GetEC2RecommendationProjectedMetricsResponse (..),
    newGetEC2RecommendationProjectedMetricsResponse,

    -- * Response Lenses
    getEC2RecommendationProjectedMetricsResponse_recommendedOptionProjectedMetrics,
    getEC2RecommendationProjectedMetricsResponse_httpStatus,
  )
where

import Amazonka.ComputeOptimizer.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetEC2RecommendationProjectedMetrics' smart constructor.
data GetEC2RecommendationProjectedMetrics = GetEC2RecommendationProjectedMetrics'
  { -- | An object to specify the preferences for the Amazon EC2 recommendation
    -- projected metrics to return in the response.
    GetEC2RecommendationProjectedMetrics
-> Maybe RecommendationPreferences
recommendationPreferences :: Prelude.Maybe RecommendationPreferences,
    -- | The Amazon Resource Name (ARN) of the instances for which to return
    -- recommendation projected metrics.
    GetEC2RecommendationProjectedMetrics -> Text
instanceArn :: Prelude.Text,
    -- | The statistic of the projected metrics.
    GetEC2RecommendationProjectedMetrics -> MetricStatistic
stat :: MetricStatistic,
    -- | The granularity, in seconds, of the projected metrics data points.
    GetEC2RecommendationProjectedMetrics -> Int
period :: Prelude.Int,
    -- | The timestamp of the first projected metrics data point to return.
    GetEC2RecommendationProjectedMetrics -> POSIX
startTime :: Core.POSIX,
    -- | The timestamp of the last projected metrics data point to return.
    GetEC2RecommendationProjectedMetrics -> POSIX
endTime :: Core.POSIX
  }
  deriving (GetEC2RecommendationProjectedMetrics
-> GetEC2RecommendationProjectedMetrics -> Bool
(GetEC2RecommendationProjectedMetrics
 -> GetEC2RecommendationProjectedMetrics -> Bool)
-> (GetEC2RecommendationProjectedMetrics
    -> GetEC2RecommendationProjectedMetrics -> Bool)
-> Eq GetEC2RecommendationProjectedMetrics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetEC2RecommendationProjectedMetrics
-> GetEC2RecommendationProjectedMetrics -> Bool
$c/= :: GetEC2RecommendationProjectedMetrics
-> GetEC2RecommendationProjectedMetrics -> Bool
== :: GetEC2RecommendationProjectedMetrics
-> GetEC2RecommendationProjectedMetrics -> Bool
$c== :: GetEC2RecommendationProjectedMetrics
-> GetEC2RecommendationProjectedMetrics -> Bool
Prelude.Eq, ReadPrec [GetEC2RecommendationProjectedMetrics]
ReadPrec GetEC2RecommendationProjectedMetrics
Int -> ReadS GetEC2RecommendationProjectedMetrics
ReadS [GetEC2RecommendationProjectedMetrics]
(Int -> ReadS GetEC2RecommendationProjectedMetrics)
-> ReadS [GetEC2RecommendationProjectedMetrics]
-> ReadPrec GetEC2RecommendationProjectedMetrics
-> ReadPrec [GetEC2RecommendationProjectedMetrics]
-> Read GetEC2RecommendationProjectedMetrics
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetEC2RecommendationProjectedMetrics]
$creadListPrec :: ReadPrec [GetEC2RecommendationProjectedMetrics]
readPrec :: ReadPrec GetEC2RecommendationProjectedMetrics
$creadPrec :: ReadPrec GetEC2RecommendationProjectedMetrics
readList :: ReadS [GetEC2RecommendationProjectedMetrics]
$creadList :: ReadS [GetEC2RecommendationProjectedMetrics]
readsPrec :: Int -> ReadS GetEC2RecommendationProjectedMetrics
$creadsPrec :: Int -> ReadS GetEC2RecommendationProjectedMetrics
Prelude.Read, Int -> GetEC2RecommendationProjectedMetrics -> ShowS
[GetEC2RecommendationProjectedMetrics] -> ShowS
GetEC2RecommendationProjectedMetrics -> String
(Int -> GetEC2RecommendationProjectedMetrics -> ShowS)
-> (GetEC2RecommendationProjectedMetrics -> String)
-> ([GetEC2RecommendationProjectedMetrics] -> ShowS)
-> Show GetEC2RecommendationProjectedMetrics
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetEC2RecommendationProjectedMetrics] -> ShowS
$cshowList :: [GetEC2RecommendationProjectedMetrics] -> ShowS
show :: GetEC2RecommendationProjectedMetrics -> String
$cshow :: GetEC2RecommendationProjectedMetrics -> String
showsPrec :: Int -> GetEC2RecommendationProjectedMetrics -> ShowS
$cshowsPrec :: Int -> GetEC2RecommendationProjectedMetrics -> ShowS
Prelude.Show, (forall x.
 GetEC2RecommendationProjectedMetrics
 -> Rep GetEC2RecommendationProjectedMetrics x)
-> (forall x.
    Rep GetEC2RecommendationProjectedMetrics x
    -> GetEC2RecommendationProjectedMetrics)
-> Generic GetEC2RecommendationProjectedMetrics
forall x.
Rep GetEC2RecommendationProjectedMetrics x
-> GetEC2RecommendationProjectedMetrics
forall x.
GetEC2RecommendationProjectedMetrics
-> Rep GetEC2RecommendationProjectedMetrics x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetEC2RecommendationProjectedMetrics x
-> GetEC2RecommendationProjectedMetrics
$cfrom :: forall x.
GetEC2RecommendationProjectedMetrics
-> Rep GetEC2RecommendationProjectedMetrics x
Prelude.Generic)

-- |
-- Create a value of 'GetEC2RecommendationProjectedMetrics' 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:
--
-- 'recommendationPreferences', 'getEC2RecommendationProjectedMetrics_recommendationPreferences' - An object to specify the preferences for the Amazon EC2 recommendation
-- projected metrics to return in the response.
--
-- 'instanceArn', 'getEC2RecommendationProjectedMetrics_instanceArn' - The Amazon Resource Name (ARN) of the instances for which to return
-- recommendation projected metrics.
--
-- 'stat', 'getEC2RecommendationProjectedMetrics_stat' - The statistic of the projected metrics.
--
-- 'period', 'getEC2RecommendationProjectedMetrics_period' - The granularity, in seconds, of the projected metrics data points.
--
-- 'startTime', 'getEC2RecommendationProjectedMetrics_startTime' - The timestamp of the first projected metrics data point to return.
--
-- 'endTime', 'getEC2RecommendationProjectedMetrics_endTime' - The timestamp of the last projected metrics data point to return.
newGetEC2RecommendationProjectedMetrics ::
  -- | 'instanceArn'
  Prelude.Text ->
  -- | 'stat'
  MetricStatistic ->
  -- | 'period'
  Prelude.Int ->
  -- | 'startTime'
  Prelude.UTCTime ->
  -- | 'endTime'
  Prelude.UTCTime ->
  GetEC2RecommendationProjectedMetrics
newGetEC2RecommendationProjectedMetrics :: Text
-> MetricStatistic
-> Int
-> UTCTime
-> UTCTime
-> GetEC2RecommendationProjectedMetrics
newGetEC2RecommendationProjectedMetrics
  Text
pInstanceArn_
  MetricStatistic
pStat_
  Int
pPeriod_
  UTCTime
pStartTime_
  UTCTime
pEndTime_ =
    GetEC2RecommendationProjectedMetrics' :: Maybe RecommendationPreferences
-> Text
-> MetricStatistic
-> Int
-> POSIX
-> POSIX
-> GetEC2RecommendationProjectedMetrics
GetEC2RecommendationProjectedMetrics'
      { $sel:recommendationPreferences:GetEC2RecommendationProjectedMetrics' :: Maybe RecommendationPreferences
recommendationPreferences =
          Maybe RecommendationPreferences
forall a. Maybe a
Prelude.Nothing,
        $sel:instanceArn:GetEC2RecommendationProjectedMetrics' :: Text
instanceArn = Text
pInstanceArn_,
        $sel:stat:GetEC2RecommendationProjectedMetrics' :: MetricStatistic
stat = MetricStatistic
pStat_,
        $sel:period:GetEC2RecommendationProjectedMetrics' :: Int
period = Int
pPeriod_,
        $sel:startTime:GetEC2RecommendationProjectedMetrics' :: POSIX
startTime =
          Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pStartTime_,
        $sel:endTime:GetEC2RecommendationProjectedMetrics' :: POSIX
endTime = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pEndTime_
      }

-- | An object to specify the preferences for the Amazon EC2 recommendation
-- projected metrics to return in the response.
getEC2RecommendationProjectedMetrics_recommendationPreferences :: Lens.Lens' GetEC2RecommendationProjectedMetrics (Prelude.Maybe RecommendationPreferences)
getEC2RecommendationProjectedMetrics_recommendationPreferences :: (Maybe RecommendationPreferences
 -> f (Maybe RecommendationPreferences))
-> GetEC2RecommendationProjectedMetrics
-> f GetEC2RecommendationProjectedMetrics
getEC2RecommendationProjectedMetrics_recommendationPreferences = (GetEC2RecommendationProjectedMetrics
 -> Maybe RecommendationPreferences)
-> (GetEC2RecommendationProjectedMetrics
    -> Maybe RecommendationPreferences
    -> GetEC2RecommendationProjectedMetrics)
-> Lens
     GetEC2RecommendationProjectedMetrics
     GetEC2RecommendationProjectedMetrics
     (Maybe RecommendationPreferences)
     (Maybe RecommendationPreferences)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEC2RecommendationProjectedMetrics' {Maybe RecommendationPreferences
recommendationPreferences :: Maybe RecommendationPreferences
$sel:recommendationPreferences:GetEC2RecommendationProjectedMetrics' :: GetEC2RecommendationProjectedMetrics
-> Maybe RecommendationPreferences
recommendationPreferences} -> Maybe RecommendationPreferences
recommendationPreferences) (\s :: GetEC2RecommendationProjectedMetrics
s@GetEC2RecommendationProjectedMetrics' {} Maybe RecommendationPreferences
a -> GetEC2RecommendationProjectedMetrics
s {$sel:recommendationPreferences:GetEC2RecommendationProjectedMetrics' :: Maybe RecommendationPreferences
recommendationPreferences = Maybe RecommendationPreferences
a} :: GetEC2RecommendationProjectedMetrics)

-- | The Amazon Resource Name (ARN) of the instances for which to return
-- recommendation projected metrics.
getEC2RecommendationProjectedMetrics_instanceArn :: Lens.Lens' GetEC2RecommendationProjectedMetrics Prelude.Text
getEC2RecommendationProjectedMetrics_instanceArn :: (Text -> f Text)
-> GetEC2RecommendationProjectedMetrics
-> f GetEC2RecommendationProjectedMetrics
getEC2RecommendationProjectedMetrics_instanceArn = (GetEC2RecommendationProjectedMetrics -> Text)
-> (GetEC2RecommendationProjectedMetrics
    -> Text -> GetEC2RecommendationProjectedMetrics)
-> Lens
     GetEC2RecommendationProjectedMetrics
     GetEC2RecommendationProjectedMetrics
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEC2RecommendationProjectedMetrics' {Text
instanceArn :: Text
$sel:instanceArn:GetEC2RecommendationProjectedMetrics' :: GetEC2RecommendationProjectedMetrics -> Text
instanceArn} -> Text
instanceArn) (\s :: GetEC2RecommendationProjectedMetrics
s@GetEC2RecommendationProjectedMetrics' {} Text
a -> GetEC2RecommendationProjectedMetrics
s {$sel:instanceArn:GetEC2RecommendationProjectedMetrics' :: Text
instanceArn = Text
a} :: GetEC2RecommendationProjectedMetrics)

-- | The statistic of the projected metrics.
getEC2RecommendationProjectedMetrics_stat :: Lens.Lens' GetEC2RecommendationProjectedMetrics MetricStatistic
getEC2RecommendationProjectedMetrics_stat :: (MetricStatistic -> f MetricStatistic)
-> GetEC2RecommendationProjectedMetrics
-> f GetEC2RecommendationProjectedMetrics
getEC2RecommendationProjectedMetrics_stat = (GetEC2RecommendationProjectedMetrics -> MetricStatistic)
-> (GetEC2RecommendationProjectedMetrics
    -> MetricStatistic -> GetEC2RecommendationProjectedMetrics)
-> Lens
     GetEC2RecommendationProjectedMetrics
     GetEC2RecommendationProjectedMetrics
     MetricStatistic
     MetricStatistic
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEC2RecommendationProjectedMetrics' {MetricStatistic
stat :: MetricStatistic
$sel:stat:GetEC2RecommendationProjectedMetrics' :: GetEC2RecommendationProjectedMetrics -> MetricStatistic
stat} -> MetricStatistic
stat) (\s :: GetEC2RecommendationProjectedMetrics
s@GetEC2RecommendationProjectedMetrics' {} MetricStatistic
a -> GetEC2RecommendationProjectedMetrics
s {$sel:stat:GetEC2RecommendationProjectedMetrics' :: MetricStatistic
stat = MetricStatistic
a} :: GetEC2RecommendationProjectedMetrics)

-- | The granularity, in seconds, of the projected metrics data points.
getEC2RecommendationProjectedMetrics_period :: Lens.Lens' GetEC2RecommendationProjectedMetrics Prelude.Int
getEC2RecommendationProjectedMetrics_period :: (Int -> f Int)
-> GetEC2RecommendationProjectedMetrics
-> f GetEC2RecommendationProjectedMetrics
getEC2RecommendationProjectedMetrics_period = (GetEC2RecommendationProjectedMetrics -> Int)
-> (GetEC2RecommendationProjectedMetrics
    -> Int -> GetEC2RecommendationProjectedMetrics)
-> Lens
     GetEC2RecommendationProjectedMetrics
     GetEC2RecommendationProjectedMetrics
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEC2RecommendationProjectedMetrics' {Int
period :: Int
$sel:period:GetEC2RecommendationProjectedMetrics' :: GetEC2RecommendationProjectedMetrics -> Int
period} -> Int
period) (\s :: GetEC2RecommendationProjectedMetrics
s@GetEC2RecommendationProjectedMetrics' {} Int
a -> GetEC2RecommendationProjectedMetrics
s {$sel:period:GetEC2RecommendationProjectedMetrics' :: Int
period = Int
a} :: GetEC2RecommendationProjectedMetrics)

-- | The timestamp of the first projected metrics data point to return.
getEC2RecommendationProjectedMetrics_startTime :: Lens.Lens' GetEC2RecommendationProjectedMetrics Prelude.UTCTime
getEC2RecommendationProjectedMetrics_startTime :: (UTCTime -> f UTCTime)
-> GetEC2RecommendationProjectedMetrics
-> f GetEC2RecommendationProjectedMetrics
getEC2RecommendationProjectedMetrics_startTime = (GetEC2RecommendationProjectedMetrics -> POSIX)
-> (GetEC2RecommendationProjectedMetrics
    -> POSIX -> GetEC2RecommendationProjectedMetrics)
-> Lens
     GetEC2RecommendationProjectedMetrics
     GetEC2RecommendationProjectedMetrics
     POSIX
     POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEC2RecommendationProjectedMetrics' {POSIX
startTime :: POSIX
$sel:startTime:GetEC2RecommendationProjectedMetrics' :: GetEC2RecommendationProjectedMetrics -> POSIX
startTime} -> POSIX
startTime) (\s :: GetEC2RecommendationProjectedMetrics
s@GetEC2RecommendationProjectedMetrics' {} POSIX
a -> GetEC2RecommendationProjectedMetrics
s {$sel:startTime:GetEC2RecommendationProjectedMetrics' :: POSIX
startTime = POSIX
a} :: GetEC2RecommendationProjectedMetrics) ((POSIX -> f POSIX)
 -> GetEC2RecommendationProjectedMetrics
 -> f GetEC2RecommendationProjectedMetrics)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> GetEC2RecommendationProjectedMetrics
-> f GetEC2RecommendationProjectedMetrics
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The timestamp of the last projected metrics data point to return.
getEC2RecommendationProjectedMetrics_endTime :: Lens.Lens' GetEC2RecommendationProjectedMetrics Prelude.UTCTime
getEC2RecommendationProjectedMetrics_endTime :: (UTCTime -> f UTCTime)
-> GetEC2RecommendationProjectedMetrics
-> f GetEC2RecommendationProjectedMetrics
getEC2RecommendationProjectedMetrics_endTime = (GetEC2RecommendationProjectedMetrics -> POSIX)
-> (GetEC2RecommendationProjectedMetrics
    -> POSIX -> GetEC2RecommendationProjectedMetrics)
-> Lens
     GetEC2RecommendationProjectedMetrics
     GetEC2RecommendationProjectedMetrics
     POSIX
     POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEC2RecommendationProjectedMetrics' {POSIX
endTime :: POSIX
$sel:endTime:GetEC2RecommendationProjectedMetrics' :: GetEC2RecommendationProjectedMetrics -> POSIX
endTime} -> POSIX
endTime) (\s :: GetEC2RecommendationProjectedMetrics
s@GetEC2RecommendationProjectedMetrics' {} POSIX
a -> GetEC2RecommendationProjectedMetrics
s {$sel:endTime:GetEC2RecommendationProjectedMetrics' :: POSIX
endTime = POSIX
a} :: GetEC2RecommendationProjectedMetrics) ((POSIX -> f POSIX)
 -> GetEC2RecommendationProjectedMetrics
 -> f GetEC2RecommendationProjectedMetrics)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> GetEC2RecommendationProjectedMetrics
-> f GetEC2RecommendationProjectedMetrics
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance
  Core.AWSRequest
    GetEC2RecommendationProjectedMetrics
  where
  type
    AWSResponse GetEC2RecommendationProjectedMetrics =
      GetEC2RecommendationProjectedMetricsResponse
  request :: GetEC2RecommendationProjectedMetrics
-> Request GetEC2RecommendationProjectedMetrics
request = Service
-> GetEC2RecommendationProjectedMetrics
-> Request GetEC2RecommendationProjectedMetrics
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetEC2RecommendationProjectedMetrics
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse
           (AWSResponse GetEC2RecommendationProjectedMetrics)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either
      String (AWSResponse GetEC2RecommendationProjectedMetrics))
-> Logger
-> Service
-> Proxy GetEC2RecommendationProjectedMetrics
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse
           (AWSResponse GetEC2RecommendationProjectedMetrics)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [RecommendedOptionProjectedMetric]
-> Int -> GetEC2RecommendationProjectedMetricsResponse
GetEC2RecommendationProjectedMetricsResponse'
            (Maybe [RecommendedOptionProjectedMetric]
 -> Int -> GetEC2RecommendationProjectedMetricsResponse)
-> Either String (Maybe [RecommendedOptionProjectedMetric])
-> Either
     String (Int -> GetEC2RecommendationProjectedMetricsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object
-> Text
-> Either String (Maybe (Maybe [RecommendedOptionProjectedMetric]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"recommendedOptionProjectedMetrics"
                            Either String (Maybe (Maybe [RecommendedOptionProjectedMetric]))
-> Maybe [RecommendedOptionProjectedMetric]
-> Either String (Maybe [RecommendedOptionProjectedMetric])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [RecommendedOptionProjectedMetric]
forall a. Monoid a => a
Prelude.mempty
                        )
              Either String (Int -> GetEC2RecommendationProjectedMetricsResponse)
-> Either String Int
-> Either String GetEC2RecommendationProjectedMetricsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance
  Prelude.Hashable
    GetEC2RecommendationProjectedMetrics

instance
  Prelude.NFData
    GetEC2RecommendationProjectedMetrics

instance
  Core.ToHeaders
    GetEC2RecommendationProjectedMetrics
  where
  toHeaders :: GetEC2RecommendationProjectedMetrics -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> GetEC2RecommendationProjectedMetrics -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"ComputeOptimizerService.GetEC2RecommendationProjectedMetrics" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance
  Core.ToJSON
    GetEC2RecommendationProjectedMetrics
  where
  toJSON :: GetEC2RecommendationProjectedMetrics -> Value
toJSON GetEC2RecommendationProjectedMetrics' {Int
Maybe RecommendationPreferences
Text
POSIX
MetricStatistic
endTime :: POSIX
startTime :: POSIX
period :: Int
stat :: MetricStatistic
instanceArn :: Text
recommendationPreferences :: Maybe RecommendationPreferences
$sel:endTime:GetEC2RecommendationProjectedMetrics' :: GetEC2RecommendationProjectedMetrics -> POSIX
$sel:startTime:GetEC2RecommendationProjectedMetrics' :: GetEC2RecommendationProjectedMetrics -> POSIX
$sel:period:GetEC2RecommendationProjectedMetrics' :: GetEC2RecommendationProjectedMetrics -> Int
$sel:stat:GetEC2RecommendationProjectedMetrics' :: GetEC2RecommendationProjectedMetrics -> MetricStatistic
$sel:instanceArn:GetEC2RecommendationProjectedMetrics' :: GetEC2RecommendationProjectedMetrics -> Text
$sel:recommendationPreferences:GetEC2RecommendationProjectedMetrics' :: GetEC2RecommendationProjectedMetrics
-> Maybe RecommendationPreferences
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"recommendationPreferences" Text -> RecommendationPreferences -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (RecommendationPreferences -> Pair)
-> Maybe RecommendationPreferences -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RecommendationPreferences
recommendationPreferences,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"instanceArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
instanceArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"stat" Text -> MetricStatistic -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= MetricStatistic
stat),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"period" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Int
period),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"startTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= POSIX
startTime),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"endTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= POSIX
endTime)
          ]
      )

instance
  Core.ToPath
    GetEC2RecommendationProjectedMetrics
  where
  toPath :: GetEC2RecommendationProjectedMetrics -> ByteString
toPath = ByteString -> GetEC2RecommendationProjectedMetrics -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance
  Core.ToQuery
    GetEC2RecommendationProjectedMetrics
  where
  toQuery :: GetEC2RecommendationProjectedMetrics -> QueryString
toQuery = QueryString -> GetEC2RecommendationProjectedMetrics -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newGetEC2RecommendationProjectedMetricsResponse' smart constructor.
data GetEC2RecommendationProjectedMetricsResponse = GetEC2RecommendationProjectedMetricsResponse'
  { -- | An array of objects that describes projected metrics.
    GetEC2RecommendationProjectedMetricsResponse
-> Maybe [RecommendedOptionProjectedMetric]
recommendedOptionProjectedMetrics :: Prelude.Maybe [RecommendedOptionProjectedMetric],
    -- | The response's http status code.
    GetEC2RecommendationProjectedMetricsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetEC2RecommendationProjectedMetricsResponse
-> GetEC2RecommendationProjectedMetricsResponse -> Bool
(GetEC2RecommendationProjectedMetricsResponse
 -> GetEC2RecommendationProjectedMetricsResponse -> Bool)
-> (GetEC2RecommendationProjectedMetricsResponse
    -> GetEC2RecommendationProjectedMetricsResponse -> Bool)
-> Eq GetEC2RecommendationProjectedMetricsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetEC2RecommendationProjectedMetricsResponse
-> GetEC2RecommendationProjectedMetricsResponse -> Bool
$c/= :: GetEC2RecommendationProjectedMetricsResponse
-> GetEC2RecommendationProjectedMetricsResponse -> Bool
== :: GetEC2RecommendationProjectedMetricsResponse
-> GetEC2RecommendationProjectedMetricsResponse -> Bool
$c== :: GetEC2RecommendationProjectedMetricsResponse
-> GetEC2RecommendationProjectedMetricsResponse -> Bool
Prelude.Eq, ReadPrec [GetEC2RecommendationProjectedMetricsResponse]
ReadPrec GetEC2RecommendationProjectedMetricsResponse
Int -> ReadS GetEC2RecommendationProjectedMetricsResponse
ReadS [GetEC2RecommendationProjectedMetricsResponse]
(Int -> ReadS GetEC2RecommendationProjectedMetricsResponse)
-> ReadS [GetEC2RecommendationProjectedMetricsResponse]
-> ReadPrec GetEC2RecommendationProjectedMetricsResponse
-> ReadPrec [GetEC2RecommendationProjectedMetricsResponse]
-> Read GetEC2RecommendationProjectedMetricsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetEC2RecommendationProjectedMetricsResponse]
$creadListPrec :: ReadPrec [GetEC2RecommendationProjectedMetricsResponse]
readPrec :: ReadPrec GetEC2RecommendationProjectedMetricsResponse
$creadPrec :: ReadPrec GetEC2RecommendationProjectedMetricsResponse
readList :: ReadS [GetEC2RecommendationProjectedMetricsResponse]
$creadList :: ReadS [GetEC2RecommendationProjectedMetricsResponse]
readsPrec :: Int -> ReadS GetEC2RecommendationProjectedMetricsResponse
$creadsPrec :: Int -> ReadS GetEC2RecommendationProjectedMetricsResponse
Prelude.Read, Int -> GetEC2RecommendationProjectedMetricsResponse -> ShowS
[GetEC2RecommendationProjectedMetricsResponse] -> ShowS
GetEC2RecommendationProjectedMetricsResponse -> String
(Int -> GetEC2RecommendationProjectedMetricsResponse -> ShowS)
-> (GetEC2RecommendationProjectedMetricsResponse -> String)
-> ([GetEC2RecommendationProjectedMetricsResponse] -> ShowS)
-> Show GetEC2RecommendationProjectedMetricsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetEC2RecommendationProjectedMetricsResponse] -> ShowS
$cshowList :: [GetEC2RecommendationProjectedMetricsResponse] -> ShowS
show :: GetEC2RecommendationProjectedMetricsResponse -> String
$cshow :: GetEC2RecommendationProjectedMetricsResponse -> String
showsPrec :: Int -> GetEC2RecommendationProjectedMetricsResponse -> ShowS
$cshowsPrec :: Int -> GetEC2RecommendationProjectedMetricsResponse -> ShowS
Prelude.Show, (forall x.
 GetEC2RecommendationProjectedMetricsResponse
 -> Rep GetEC2RecommendationProjectedMetricsResponse x)
-> (forall x.
    Rep GetEC2RecommendationProjectedMetricsResponse x
    -> GetEC2RecommendationProjectedMetricsResponse)
-> Generic GetEC2RecommendationProjectedMetricsResponse
forall x.
Rep GetEC2RecommendationProjectedMetricsResponse x
-> GetEC2RecommendationProjectedMetricsResponse
forall x.
GetEC2RecommendationProjectedMetricsResponse
-> Rep GetEC2RecommendationProjectedMetricsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetEC2RecommendationProjectedMetricsResponse x
-> GetEC2RecommendationProjectedMetricsResponse
$cfrom :: forall x.
GetEC2RecommendationProjectedMetricsResponse
-> Rep GetEC2RecommendationProjectedMetricsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetEC2RecommendationProjectedMetricsResponse' 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:
--
-- 'recommendedOptionProjectedMetrics', 'getEC2RecommendationProjectedMetricsResponse_recommendedOptionProjectedMetrics' - An array of objects that describes projected metrics.
--
-- 'httpStatus', 'getEC2RecommendationProjectedMetricsResponse_httpStatus' - The response's http status code.
newGetEC2RecommendationProjectedMetricsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetEC2RecommendationProjectedMetricsResponse
newGetEC2RecommendationProjectedMetricsResponse :: Int -> GetEC2RecommendationProjectedMetricsResponse
newGetEC2RecommendationProjectedMetricsResponse
  Int
pHttpStatus_ =
    GetEC2RecommendationProjectedMetricsResponse' :: Maybe [RecommendedOptionProjectedMetric]
-> Int -> GetEC2RecommendationProjectedMetricsResponse
GetEC2RecommendationProjectedMetricsResponse'
      { $sel:recommendedOptionProjectedMetrics:GetEC2RecommendationProjectedMetricsResponse' :: Maybe [RecommendedOptionProjectedMetric]
recommendedOptionProjectedMetrics =
          Maybe [RecommendedOptionProjectedMetric]
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:GetEC2RecommendationProjectedMetricsResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

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

-- | The response's http status code.
getEC2RecommendationProjectedMetricsResponse_httpStatus :: Lens.Lens' GetEC2RecommendationProjectedMetricsResponse Prelude.Int
getEC2RecommendationProjectedMetricsResponse_httpStatus :: (Int -> f Int)
-> GetEC2RecommendationProjectedMetricsResponse
-> f GetEC2RecommendationProjectedMetricsResponse
getEC2RecommendationProjectedMetricsResponse_httpStatus = (GetEC2RecommendationProjectedMetricsResponse -> Int)
-> (GetEC2RecommendationProjectedMetricsResponse
    -> Int -> GetEC2RecommendationProjectedMetricsResponse)
-> Lens
     GetEC2RecommendationProjectedMetricsResponse
     GetEC2RecommendationProjectedMetricsResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEC2RecommendationProjectedMetricsResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetEC2RecommendationProjectedMetricsResponse' :: GetEC2RecommendationProjectedMetricsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetEC2RecommendationProjectedMetricsResponse
s@GetEC2RecommendationProjectedMetricsResponse' {} Int
a -> GetEC2RecommendationProjectedMetricsResponse
s {$sel:httpStatus:GetEC2RecommendationProjectedMetricsResponse' :: Int
httpStatus = Int
a} :: GetEC2RecommendationProjectedMetricsResponse)

instance
  Prelude.NFData
    GetEC2RecommendationProjectedMetricsResponse