{-# 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.CloudWatch.GetMetricData
-- 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)
--
-- You can use the @GetMetricData@ API to retrieve as many as 500 different
-- metrics in a single request, with a total of as many as 100,800 data
-- points. You can also optionally perform math expressions on the values
-- of the returned statistics, to create new time series that represent new
-- insights into your data. For example, using Lambda metrics, you could
-- divide the Errors metric by the Invocations metric to get an error rate
-- time series. For more information about metric math expressions, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/using-metric-math.html#metric-math-syntax Metric Math Syntax and Functions>
-- in the /Amazon CloudWatch User Guide/.
--
-- Calls to the @GetMetricData@ API have a different pricing structure than
-- calls to @GetMetricStatistics@. For more information about pricing, see
-- <https://aws.amazon.com/cloudwatch/pricing/ Amazon CloudWatch Pricing>.
--
-- Amazon CloudWatch retains metric data as follows:
--
-- -   Data points with a period of less than 60 seconds are available for
--     3 hours. These data points are high-resolution metrics and are
--     available only for custom metrics that have been defined with a
--     @StorageResolution@ of 1.
--
-- -   Data points with a period of 60 seconds (1-minute) are available for
--     15 days.
--
-- -   Data points with a period of 300 seconds (5-minute) are available
--     for 63 days.
--
-- -   Data points with a period of 3600 seconds (1 hour) are available for
--     455 days (15 months).
--
-- Data points that are initially published with a shorter period are
-- aggregated together for long-term storage. For example, if you collect
-- data using a period of 1 minute, the data remains available for 15 days
-- with 1-minute resolution. After 15 days, this data is still available,
-- but is aggregated and retrievable only with a resolution of 5 minutes.
-- After 63 days, the data is further aggregated and is available with a
-- resolution of 1 hour.
--
-- If you omit @Unit@ in your request, all data that was collected with any
-- unit is returned, along with the corresponding units that were specified
-- when the data was reported to CloudWatch. If you specify a unit, the
-- operation returns only data that was collected with that unit specified.
-- If you specify a unit that does not match the data collected, the
-- results of the operation are null. CloudWatch does not perform unit
-- conversions.
--
-- This operation returns paginated results.
module Amazonka.CloudWatch.GetMetricData
  ( -- * Creating a Request
    GetMetricData (..),
    newGetMetricData,

    -- * Request Lenses
    getMetricData_maxDatapoints,
    getMetricData_labelOptions,
    getMetricData_nextToken,
    getMetricData_scanBy,
    getMetricData_metricDataQueries,
    getMetricData_startTime,
    getMetricData_endTime,

    -- * Destructuring the Response
    GetMetricDataResponse (..),
    newGetMetricDataResponse,

    -- * Response Lenses
    getMetricDataResponse_metricDataResults,
    getMetricDataResponse_nextToken,
    getMetricDataResponse_messages,
    getMetricDataResponse_httpStatus,
  )
where

import Amazonka.CloudWatch.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:/ 'newGetMetricData' smart constructor.
data GetMetricData = GetMetricData'
  { -- | The maximum number of data points the request should return before
    -- paginating. If you omit this, the default of 100,800 is used.
    GetMetricData -> Maybe Int
maxDatapoints :: Prelude.Maybe Prelude.Int,
    -- | This structure includes the @Timezone@ parameter, which you can use to
    -- specify your time zone so that the labels of returned data display the
    -- correct time for your time zone.
    GetMetricData -> Maybe LabelOptions
labelOptions :: Prelude.Maybe LabelOptions,
    -- | Include this value, if it was returned by the previous @GetMetricData@
    -- operation, to get the next set of data points.
    GetMetricData -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The order in which data points should be returned. @TimestampDescending@
    -- returns the newest data first and paginates when the @MaxDatapoints@
    -- limit is reached. @TimestampAscending@ returns the oldest data first and
    -- paginates when the @MaxDatapoints@ limit is reached.
    GetMetricData -> Maybe ScanBy
scanBy :: Prelude.Maybe ScanBy,
    -- | The metric queries to be returned. A single @GetMetricData@ call can
    -- include as many as 500 @MetricDataQuery@ structures. Each of these
    -- structures can specify either a metric to retrieve, or a math expression
    -- to perform on retrieved data.
    GetMetricData -> [MetricDataQuery]
metricDataQueries :: [MetricDataQuery],
    -- | The time stamp indicating the earliest data to be returned.
    --
    -- The value specified is inclusive; results include data points with the
    -- specified time stamp.
    --
    -- CloudWatch rounds the specified time stamp as follows:
    --
    -- -   Start time less than 15 days ago - Round down to the nearest whole
    --     minute. For example, 12:32:34 is rounded down to 12:32:00.
    --
    -- -   Start time between 15 and 63 days ago - Round down to the nearest
    --     5-minute clock interval. For example, 12:32:34 is rounded down to
    --     12:30:00.
    --
    -- -   Start time greater than 63 days ago - Round down to the nearest
    --     1-hour clock interval. For example, 12:32:34 is rounded down to
    --     12:00:00.
    --
    -- If you set @Period@ to 5, 10, or 30, the start time of your request is
    -- rounded down to the nearest time that corresponds to even 5-, 10-, or
    -- 30-second divisions of a minute. For example, if you make a query at
    -- (HH:mm:ss) 01:05:23 for the previous 10-second period, the start time of
    -- your request is rounded down and you receive data from 01:05:10 to
    -- 01:05:20. If you make a query at 15:07:17 for the previous 5 minutes of
    -- data, using a period of 5 seconds, you receive data timestamped between
    -- 15:02:15 and 15:07:15.
    --
    -- For better performance, specify @StartTime@ and @EndTime@ values that
    -- align with the value of the metric\'s @Period@ and sync up with the
    -- beginning and end of an hour. For example, if the @Period@ of a metric
    -- is 5 minutes, specifying 12:05 or 12:30 as @StartTime@ can get a faster
    -- response from CloudWatch than setting 12:07 or 12:29 as the @StartTime@.
    GetMetricData -> ISO8601
startTime :: Core.ISO8601,
    -- | The time stamp indicating the latest data to be returned.
    --
    -- The value specified is exclusive; results include data points up to the
    -- specified time stamp.
    --
    -- For better performance, specify @StartTime@ and @EndTime@ values that
    -- align with the value of the metric\'s @Period@ and sync up with the
    -- beginning and end of an hour. For example, if the @Period@ of a metric
    -- is 5 minutes, specifying 12:05 or 12:30 as @EndTime@ can get a faster
    -- response from CloudWatch than setting 12:07 or 12:29 as the @EndTime@.
    GetMetricData -> ISO8601
endTime :: Core.ISO8601
  }
  deriving (GetMetricData -> GetMetricData -> Bool
(GetMetricData -> GetMetricData -> Bool)
-> (GetMetricData -> GetMetricData -> Bool) -> Eq GetMetricData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetMetricData -> GetMetricData -> Bool
$c/= :: GetMetricData -> GetMetricData -> Bool
== :: GetMetricData -> GetMetricData -> Bool
$c== :: GetMetricData -> GetMetricData -> Bool
Prelude.Eq, ReadPrec [GetMetricData]
ReadPrec GetMetricData
Int -> ReadS GetMetricData
ReadS [GetMetricData]
(Int -> ReadS GetMetricData)
-> ReadS [GetMetricData]
-> ReadPrec GetMetricData
-> ReadPrec [GetMetricData]
-> Read GetMetricData
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetMetricData]
$creadListPrec :: ReadPrec [GetMetricData]
readPrec :: ReadPrec GetMetricData
$creadPrec :: ReadPrec GetMetricData
readList :: ReadS [GetMetricData]
$creadList :: ReadS [GetMetricData]
readsPrec :: Int -> ReadS GetMetricData
$creadsPrec :: Int -> ReadS GetMetricData
Prelude.Read, Int -> GetMetricData -> ShowS
[GetMetricData] -> ShowS
GetMetricData -> String
(Int -> GetMetricData -> ShowS)
-> (GetMetricData -> String)
-> ([GetMetricData] -> ShowS)
-> Show GetMetricData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetMetricData] -> ShowS
$cshowList :: [GetMetricData] -> ShowS
show :: GetMetricData -> String
$cshow :: GetMetricData -> String
showsPrec :: Int -> GetMetricData -> ShowS
$cshowsPrec :: Int -> GetMetricData -> ShowS
Prelude.Show, (forall x. GetMetricData -> Rep GetMetricData x)
-> (forall x. Rep GetMetricData x -> GetMetricData)
-> Generic GetMetricData
forall x. Rep GetMetricData x -> GetMetricData
forall x. GetMetricData -> Rep GetMetricData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetMetricData x -> GetMetricData
$cfrom :: forall x. GetMetricData -> Rep GetMetricData x
Prelude.Generic)

-- |
-- Create a value of 'GetMetricData' 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:
--
-- 'maxDatapoints', 'getMetricData_maxDatapoints' - The maximum number of data points the request should return before
-- paginating. If you omit this, the default of 100,800 is used.
--
-- 'labelOptions', 'getMetricData_labelOptions' - This structure includes the @Timezone@ parameter, which you can use to
-- specify your time zone so that the labels of returned data display the
-- correct time for your time zone.
--
-- 'nextToken', 'getMetricData_nextToken' - Include this value, if it was returned by the previous @GetMetricData@
-- operation, to get the next set of data points.
--
-- 'scanBy', 'getMetricData_scanBy' - The order in which data points should be returned. @TimestampDescending@
-- returns the newest data first and paginates when the @MaxDatapoints@
-- limit is reached. @TimestampAscending@ returns the oldest data first and
-- paginates when the @MaxDatapoints@ limit is reached.
--
-- 'metricDataQueries', 'getMetricData_metricDataQueries' - The metric queries to be returned. A single @GetMetricData@ call can
-- include as many as 500 @MetricDataQuery@ structures. Each of these
-- structures can specify either a metric to retrieve, or a math expression
-- to perform on retrieved data.
--
-- 'startTime', 'getMetricData_startTime' - The time stamp indicating the earliest data to be returned.
--
-- The value specified is inclusive; results include data points with the
-- specified time stamp.
--
-- CloudWatch rounds the specified time stamp as follows:
--
-- -   Start time less than 15 days ago - Round down to the nearest whole
--     minute. For example, 12:32:34 is rounded down to 12:32:00.
--
-- -   Start time between 15 and 63 days ago - Round down to the nearest
--     5-minute clock interval. For example, 12:32:34 is rounded down to
--     12:30:00.
--
-- -   Start time greater than 63 days ago - Round down to the nearest
--     1-hour clock interval. For example, 12:32:34 is rounded down to
--     12:00:00.
--
-- If you set @Period@ to 5, 10, or 30, the start time of your request is
-- rounded down to the nearest time that corresponds to even 5-, 10-, or
-- 30-second divisions of a minute. For example, if you make a query at
-- (HH:mm:ss) 01:05:23 for the previous 10-second period, the start time of
-- your request is rounded down and you receive data from 01:05:10 to
-- 01:05:20. If you make a query at 15:07:17 for the previous 5 minutes of
-- data, using a period of 5 seconds, you receive data timestamped between
-- 15:02:15 and 15:07:15.
--
-- For better performance, specify @StartTime@ and @EndTime@ values that
-- align with the value of the metric\'s @Period@ and sync up with the
-- beginning and end of an hour. For example, if the @Period@ of a metric
-- is 5 minutes, specifying 12:05 or 12:30 as @StartTime@ can get a faster
-- response from CloudWatch than setting 12:07 or 12:29 as the @StartTime@.
--
-- 'endTime', 'getMetricData_endTime' - The time stamp indicating the latest data to be returned.
--
-- The value specified is exclusive; results include data points up to the
-- specified time stamp.
--
-- For better performance, specify @StartTime@ and @EndTime@ values that
-- align with the value of the metric\'s @Period@ and sync up with the
-- beginning and end of an hour. For example, if the @Period@ of a metric
-- is 5 minutes, specifying 12:05 or 12:30 as @EndTime@ can get a faster
-- response from CloudWatch than setting 12:07 or 12:29 as the @EndTime@.
newGetMetricData ::
  -- | 'startTime'
  Prelude.UTCTime ->
  -- | 'endTime'
  Prelude.UTCTime ->
  GetMetricData
newGetMetricData :: UTCTime -> UTCTime -> GetMetricData
newGetMetricData UTCTime
pStartTime_ UTCTime
pEndTime_ =
  GetMetricData' :: Maybe Int
-> Maybe LabelOptions
-> Maybe Text
-> Maybe ScanBy
-> [MetricDataQuery]
-> ISO8601
-> ISO8601
-> GetMetricData
GetMetricData'
    { $sel:maxDatapoints:GetMetricData' :: Maybe Int
maxDatapoints = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:labelOptions:GetMetricData' :: Maybe LabelOptions
labelOptions = Maybe LabelOptions
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetMetricData' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:scanBy:GetMetricData' :: Maybe ScanBy
scanBy = Maybe ScanBy
forall a. Maybe a
Prelude.Nothing,
      $sel:metricDataQueries:GetMetricData' :: [MetricDataQuery]
metricDataQueries = [MetricDataQuery]
forall a. Monoid a => a
Prelude.mempty,
      $sel:startTime:GetMetricData' :: ISO8601
startTime = Tagged UTCTime (Identity UTCTime)
-> Tagged ISO8601 (Identity ISO8601)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged ISO8601 (Identity ISO8601))
-> UTCTime -> ISO8601
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pStartTime_,
      $sel:endTime:GetMetricData' :: ISO8601
endTime = Tagged UTCTime (Identity UTCTime)
-> Tagged ISO8601 (Identity ISO8601)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged ISO8601 (Identity ISO8601))
-> UTCTime -> ISO8601
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pEndTime_
    }

-- | The maximum number of data points the request should return before
-- paginating. If you omit this, the default of 100,800 is used.
getMetricData_maxDatapoints :: Lens.Lens' GetMetricData (Prelude.Maybe Prelude.Int)
getMetricData_maxDatapoints :: (Maybe Int -> f (Maybe Int)) -> GetMetricData -> f GetMetricData
getMetricData_maxDatapoints = (GetMetricData -> Maybe Int)
-> (GetMetricData -> Maybe Int -> GetMetricData)
-> Lens GetMetricData GetMetricData (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMetricData' {Maybe Int
maxDatapoints :: Maybe Int
$sel:maxDatapoints:GetMetricData' :: GetMetricData -> Maybe Int
maxDatapoints} -> Maybe Int
maxDatapoints) (\s :: GetMetricData
s@GetMetricData' {} Maybe Int
a -> GetMetricData
s {$sel:maxDatapoints:GetMetricData' :: Maybe Int
maxDatapoints = Maybe Int
a} :: GetMetricData)

-- | This structure includes the @Timezone@ parameter, which you can use to
-- specify your time zone so that the labels of returned data display the
-- correct time for your time zone.
getMetricData_labelOptions :: Lens.Lens' GetMetricData (Prelude.Maybe LabelOptions)
getMetricData_labelOptions :: (Maybe LabelOptions -> f (Maybe LabelOptions))
-> GetMetricData -> f GetMetricData
getMetricData_labelOptions = (GetMetricData -> Maybe LabelOptions)
-> (GetMetricData -> Maybe LabelOptions -> GetMetricData)
-> Lens
     GetMetricData
     GetMetricData
     (Maybe LabelOptions)
     (Maybe LabelOptions)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMetricData' {Maybe LabelOptions
labelOptions :: Maybe LabelOptions
$sel:labelOptions:GetMetricData' :: GetMetricData -> Maybe LabelOptions
labelOptions} -> Maybe LabelOptions
labelOptions) (\s :: GetMetricData
s@GetMetricData' {} Maybe LabelOptions
a -> GetMetricData
s {$sel:labelOptions:GetMetricData' :: Maybe LabelOptions
labelOptions = Maybe LabelOptions
a} :: GetMetricData)

-- | Include this value, if it was returned by the previous @GetMetricData@
-- operation, to get the next set of data points.
getMetricData_nextToken :: Lens.Lens' GetMetricData (Prelude.Maybe Prelude.Text)
getMetricData_nextToken :: (Maybe Text -> f (Maybe Text)) -> GetMetricData -> f GetMetricData
getMetricData_nextToken = (GetMetricData -> Maybe Text)
-> (GetMetricData -> Maybe Text -> GetMetricData)
-> Lens GetMetricData GetMetricData (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMetricData' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetMetricData' :: GetMetricData -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetMetricData
s@GetMetricData' {} Maybe Text
a -> GetMetricData
s {$sel:nextToken:GetMetricData' :: Maybe Text
nextToken = Maybe Text
a} :: GetMetricData)

-- | The order in which data points should be returned. @TimestampDescending@
-- returns the newest data first and paginates when the @MaxDatapoints@
-- limit is reached. @TimestampAscending@ returns the oldest data first and
-- paginates when the @MaxDatapoints@ limit is reached.
getMetricData_scanBy :: Lens.Lens' GetMetricData (Prelude.Maybe ScanBy)
getMetricData_scanBy :: (Maybe ScanBy -> f (Maybe ScanBy))
-> GetMetricData -> f GetMetricData
getMetricData_scanBy = (GetMetricData -> Maybe ScanBy)
-> (GetMetricData -> Maybe ScanBy -> GetMetricData)
-> Lens GetMetricData GetMetricData (Maybe ScanBy) (Maybe ScanBy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMetricData' {Maybe ScanBy
scanBy :: Maybe ScanBy
$sel:scanBy:GetMetricData' :: GetMetricData -> Maybe ScanBy
scanBy} -> Maybe ScanBy
scanBy) (\s :: GetMetricData
s@GetMetricData' {} Maybe ScanBy
a -> GetMetricData
s {$sel:scanBy:GetMetricData' :: Maybe ScanBy
scanBy = Maybe ScanBy
a} :: GetMetricData)

-- | The metric queries to be returned. A single @GetMetricData@ call can
-- include as many as 500 @MetricDataQuery@ structures. Each of these
-- structures can specify either a metric to retrieve, or a math expression
-- to perform on retrieved data.
getMetricData_metricDataQueries :: Lens.Lens' GetMetricData [MetricDataQuery]
getMetricData_metricDataQueries :: ([MetricDataQuery] -> f [MetricDataQuery])
-> GetMetricData -> f GetMetricData
getMetricData_metricDataQueries = (GetMetricData -> [MetricDataQuery])
-> (GetMetricData -> [MetricDataQuery] -> GetMetricData)
-> Lens
     GetMetricData GetMetricData [MetricDataQuery] [MetricDataQuery]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMetricData' {[MetricDataQuery]
metricDataQueries :: [MetricDataQuery]
$sel:metricDataQueries:GetMetricData' :: GetMetricData -> [MetricDataQuery]
metricDataQueries} -> [MetricDataQuery]
metricDataQueries) (\s :: GetMetricData
s@GetMetricData' {} [MetricDataQuery]
a -> GetMetricData
s {$sel:metricDataQueries:GetMetricData' :: [MetricDataQuery]
metricDataQueries = [MetricDataQuery]
a} :: GetMetricData) (([MetricDataQuery] -> f [MetricDataQuery])
 -> GetMetricData -> f GetMetricData)
-> (([MetricDataQuery] -> f [MetricDataQuery])
    -> [MetricDataQuery] -> f [MetricDataQuery])
-> ([MetricDataQuery] -> f [MetricDataQuery])
-> GetMetricData
-> f GetMetricData
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([MetricDataQuery] -> f [MetricDataQuery])
-> [MetricDataQuery] -> f [MetricDataQuery]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The time stamp indicating the earliest data to be returned.
--
-- The value specified is inclusive; results include data points with the
-- specified time stamp.
--
-- CloudWatch rounds the specified time stamp as follows:
--
-- -   Start time less than 15 days ago - Round down to the nearest whole
--     minute. For example, 12:32:34 is rounded down to 12:32:00.
--
-- -   Start time between 15 and 63 days ago - Round down to the nearest
--     5-minute clock interval. For example, 12:32:34 is rounded down to
--     12:30:00.
--
-- -   Start time greater than 63 days ago - Round down to the nearest
--     1-hour clock interval. For example, 12:32:34 is rounded down to
--     12:00:00.
--
-- If you set @Period@ to 5, 10, or 30, the start time of your request is
-- rounded down to the nearest time that corresponds to even 5-, 10-, or
-- 30-second divisions of a minute. For example, if you make a query at
-- (HH:mm:ss) 01:05:23 for the previous 10-second period, the start time of
-- your request is rounded down and you receive data from 01:05:10 to
-- 01:05:20. If you make a query at 15:07:17 for the previous 5 minutes of
-- data, using a period of 5 seconds, you receive data timestamped between
-- 15:02:15 and 15:07:15.
--
-- For better performance, specify @StartTime@ and @EndTime@ values that
-- align with the value of the metric\'s @Period@ and sync up with the
-- beginning and end of an hour. For example, if the @Period@ of a metric
-- is 5 minutes, specifying 12:05 or 12:30 as @StartTime@ can get a faster
-- response from CloudWatch than setting 12:07 or 12:29 as the @StartTime@.
getMetricData_startTime :: Lens.Lens' GetMetricData Prelude.UTCTime
getMetricData_startTime :: (UTCTime -> f UTCTime) -> GetMetricData -> f GetMetricData
getMetricData_startTime = (GetMetricData -> ISO8601)
-> (GetMetricData -> ISO8601 -> GetMetricData)
-> Lens GetMetricData GetMetricData ISO8601 ISO8601
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMetricData' {ISO8601
startTime :: ISO8601
$sel:startTime:GetMetricData' :: GetMetricData -> ISO8601
startTime} -> ISO8601
startTime) (\s :: GetMetricData
s@GetMetricData' {} ISO8601
a -> GetMetricData
s {$sel:startTime:GetMetricData' :: ISO8601
startTime = ISO8601
a} :: GetMetricData) ((ISO8601 -> f ISO8601) -> GetMetricData -> f GetMetricData)
-> ((UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601)
-> (UTCTime -> f UTCTime)
-> GetMetricData
-> f GetMetricData
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The time stamp indicating the latest data to be returned.
--
-- The value specified is exclusive; results include data points up to the
-- specified time stamp.
--
-- For better performance, specify @StartTime@ and @EndTime@ values that
-- align with the value of the metric\'s @Period@ and sync up with the
-- beginning and end of an hour. For example, if the @Period@ of a metric
-- is 5 minutes, specifying 12:05 or 12:30 as @EndTime@ can get a faster
-- response from CloudWatch than setting 12:07 or 12:29 as the @EndTime@.
getMetricData_endTime :: Lens.Lens' GetMetricData Prelude.UTCTime
getMetricData_endTime :: (UTCTime -> f UTCTime) -> GetMetricData -> f GetMetricData
getMetricData_endTime = (GetMetricData -> ISO8601)
-> (GetMetricData -> ISO8601 -> GetMetricData)
-> Lens GetMetricData GetMetricData ISO8601 ISO8601
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMetricData' {ISO8601
endTime :: ISO8601
$sel:endTime:GetMetricData' :: GetMetricData -> ISO8601
endTime} -> ISO8601
endTime) (\s :: GetMetricData
s@GetMetricData' {} ISO8601
a -> GetMetricData
s {$sel:endTime:GetMetricData' :: ISO8601
endTime = ISO8601
a} :: GetMetricData) ((ISO8601 -> f ISO8601) -> GetMetricData -> f GetMetricData)
-> ((UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601)
-> (UTCTime -> f UTCTime)
-> GetMetricData
-> f GetMetricData
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.AWSPager GetMetricData where
  page :: GetMetricData -> AWSResponse GetMetricData -> Maybe GetMetricData
page GetMetricData
rq AWSResponse GetMetricData
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetMetricData
GetMetricDataResponse
rs
            GetMetricDataResponse
-> Getting (First Text) GetMetricDataResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetMetricDataResponse
-> Const (First Text) GetMetricDataResponse
Lens' GetMetricDataResponse (Maybe Text)
getMetricDataResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetMetricDataResponse
 -> Const (First Text) GetMetricDataResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetMetricDataResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe GetMetricData
forall a. Maybe a
Prelude.Nothing
    | Maybe [MetricDataResult] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetMetricData
GetMetricDataResponse
rs
            GetMetricDataResponse
-> Getting
     (First [MetricDataResult]) GetMetricDataResponse [MetricDataResult]
-> Maybe [MetricDataResult]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [MetricDataResult]
 -> Const (First [MetricDataResult]) (Maybe [MetricDataResult]))
-> GetMetricDataResponse
-> Const (First [MetricDataResult]) GetMetricDataResponse
Lens' GetMetricDataResponse (Maybe [MetricDataResult])
getMetricDataResponse_metricDataResults
              ((Maybe [MetricDataResult]
  -> Const (First [MetricDataResult]) (Maybe [MetricDataResult]))
 -> GetMetricDataResponse
 -> Const (First [MetricDataResult]) GetMetricDataResponse)
-> (([MetricDataResult]
     -> Const (First [MetricDataResult]) [MetricDataResult])
    -> Maybe [MetricDataResult]
    -> Const (First [MetricDataResult]) (Maybe [MetricDataResult]))
-> Getting
     (First [MetricDataResult]) GetMetricDataResponse [MetricDataResult]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([MetricDataResult]
 -> Const (First [MetricDataResult]) [MetricDataResult])
-> Maybe [MetricDataResult]
-> Const (First [MetricDataResult]) (Maybe [MetricDataResult])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe GetMetricData
forall a. Maybe a
Prelude.Nothing
    | Maybe [MessageData] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetMetricData
GetMetricDataResponse
rs
            GetMetricDataResponse
-> Getting
     (First [MessageData]) GetMetricDataResponse [MessageData]
-> Maybe [MessageData]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [MessageData]
 -> Const (First [MessageData]) (Maybe [MessageData]))
-> GetMetricDataResponse
-> Const (First [MessageData]) GetMetricDataResponse
Lens' GetMetricDataResponse (Maybe [MessageData])
getMetricDataResponse_messages ((Maybe [MessageData]
  -> Const (First [MessageData]) (Maybe [MessageData]))
 -> GetMetricDataResponse
 -> Const (First [MessageData]) GetMetricDataResponse)
-> (([MessageData] -> Const (First [MessageData]) [MessageData])
    -> Maybe [MessageData]
    -> Const (First [MessageData]) (Maybe [MessageData]))
-> Getting
     (First [MessageData]) GetMetricDataResponse [MessageData]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([MessageData] -> Const (First [MessageData]) [MessageData])
-> Maybe [MessageData]
-> Const (First [MessageData]) (Maybe [MessageData])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe GetMetricData
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      GetMetricData -> Maybe GetMetricData
forall a. a -> Maybe a
Prelude.Just (GetMetricData -> Maybe GetMetricData)
-> GetMetricData -> Maybe GetMetricData
forall a b. (a -> b) -> a -> b
Prelude.$
        GetMetricData
rq
          GetMetricData -> (GetMetricData -> GetMetricData) -> GetMetricData
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> GetMetricData -> Identity GetMetricData
Lens GetMetricData GetMetricData (Maybe Text) (Maybe Text)
getMetricData_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> GetMetricData -> Identity GetMetricData)
-> Maybe Text -> GetMetricData -> GetMetricData
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetMetricData
GetMetricDataResponse
rs
          GetMetricDataResponse
-> Getting (First Text) GetMetricDataResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetMetricDataResponse
-> Const (First Text) GetMetricDataResponse
Lens' GetMetricDataResponse (Maybe Text)
getMetricDataResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetMetricDataResponse
 -> Const (First Text) GetMetricDataResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetMetricDataResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest GetMetricData where
  type
    AWSResponse GetMetricData =
      GetMetricDataResponse
  request :: GetMetricData -> Request GetMetricData
request = Service -> GetMetricData -> Request GetMetricData
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy GetMetricData
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetMetricData)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse GetMetricData))
-> Logger
-> Service
-> Proxy GetMetricData
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetMetricData)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"GetMetricDataResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe [MetricDataResult]
-> Maybe Text
-> Maybe [MessageData]
-> Int
-> GetMetricDataResponse
GetMetricDataResponse'
            (Maybe [MetricDataResult]
 -> Maybe Text
 -> Maybe [MessageData]
 -> Int
 -> GetMetricDataResponse)
-> Either String (Maybe [MetricDataResult])
-> Either
     String
     (Maybe Text -> Maybe [MessageData] -> Int -> GetMetricDataResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"MetricDataResults"
                            Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                            Either String [Node]
-> ([Node] -> Either String (Maybe [MetricDataResult]))
-> Either String (Maybe [MetricDataResult])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [MetricDataResult])
-> [Node] -> Either String (Maybe [MetricDataResult])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [MetricDataResult]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                        )
            Either
  String
  (Maybe Text -> Maybe [MessageData] -> Int -> GetMetricDataResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe [MessageData] -> Int -> GetMetricDataResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"NextToken")
            Either String (Maybe [MessageData] -> Int -> GetMetricDataResponse)
-> Either String (Maybe [MessageData])
-> Either String (Int -> GetMetricDataResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Messages" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                            Either String [Node]
-> ([Node] -> Either String (Maybe [MessageData]))
-> Either String (Maybe [MessageData])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [MessageData])
-> [Node] -> Either String (Maybe [MessageData])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [MessageData]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                        )
            Either String (Int -> GetMetricDataResponse)
-> Either String Int -> Either String GetMetricDataResponse
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 GetMetricData

instance Prelude.NFData GetMetricData

instance Core.ToHeaders GetMetricData where
  toHeaders :: GetMetricData -> ResponseHeaders
toHeaders = ResponseHeaders -> GetMetricData -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

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

instance Core.ToQuery GetMetricData where
  toQuery :: GetMetricData -> QueryString
toQuery GetMetricData' {[MetricDataQuery]
Maybe Int
Maybe Text
Maybe LabelOptions
Maybe ScanBy
ISO8601
endTime :: ISO8601
startTime :: ISO8601
metricDataQueries :: [MetricDataQuery]
scanBy :: Maybe ScanBy
nextToken :: Maybe Text
labelOptions :: Maybe LabelOptions
maxDatapoints :: Maybe Int
$sel:endTime:GetMetricData' :: GetMetricData -> ISO8601
$sel:startTime:GetMetricData' :: GetMetricData -> ISO8601
$sel:metricDataQueries:GetMetricData' :: GetMetricData -> [MetricDataQuery]
$sel:scanBy:GetMetricData' :: GetMetricData -> Maybe ScanBy
$sel:nextToken:GetMetricData' :: GetMetricData -> Maybe Text
$sel:labelOptions:GetMetricData' :: GetMetricData -> Maybe LabelOptions
$sel:maxDatapoints:GetMetricData' :: GetMetricData -> Maybe Int
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"GetMetricData" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-08-01" :: Prelude.ByteString),
        ByteString
"MaxDatapoints" ByteString -> Maybe Int -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Int
maxDatapoints,
        ByteString
"LabelOptions" ByteString -> Maybe LabelOptions -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe LabelOptions
labelOptions,
        ByteString
"NextToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken,
        ByteString
"ScanBy" ByteString -> Maybe ScanBy -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe ScanBy
scanBy,
        ByteString
"MetricDataQueries"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ByteString -> [MetricDataQuery] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" [MetricDataQuery]
metricDataQueries,
        ByteString
"StartTime" ByteString -> ISO8601 -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ISO8601
startTime,
        ByteString
"EndTime" ByteString -> ISO8601 -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ISO8601
endTime
      ]

-- | /See:/ 'newGetMetricDataResponse' smart constructor.
data GetMetricDataResponse = GetMetricDataResponse'
  { -- | The metrics that are returned, including the metric name, namespace, and
    -- dimensions.
    GetMetricDataResponse -> Maybe [MetricDataResult]
metricDataResults :: Prelude.Maybe [MetricDataResult],
    -- | A token that marks the next batch of returned results.
    GetMetricDataResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Contains a message about this @GetMetricData@ operation, if the
    -- operation results in such a message. An example of a message that might
    -- be returned is @Maximum number of allowed metrics exceeded@. If there is
    -- a message, as much of the operation as possible is still executed.
    --
    -- A message appears here only if it is related to the global
    -- @GetMetricData@ operation. Any message about a specific metric returned
    -- by the operation appears in the @MetricDataResult@ object returned for
    -- that metric.
    GetMetricDataResponse -> Maybe [MessageData]
messages :: Prelude.Maybe [MessageData],
    -- | The response's http status code.
    GetMetricDataResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetMetricDataResponse -> GetMetricDataResponse -> Bool
(GetMetricDataResponse -> GetMetricDataResponse -> Bool)
-> (GetMetricDataResponse -> GetMetricDataResponse -> Bool)
-> Eq GetMetricDataResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetMetricDataResponse -> GetMetricDataResponse -> Bool
$c/= :: GetMetricDataResponse -> GetMetricDataResponse -> Bool
== :: GetMetricDataResponse -> GetMetricDataResponse -> Bool
$c== :: GetMetricDataResponse -> GetMetricDataResponse -> Bool
Prelude.Eq, ReadPrec [GetMetricDataResponse]
ReadPrec GetMetricDataResponse
Int -> ReadS GetMetricDataResponse
ReadS [GetMetricDataResponse]
(Int -> ReadS GetMetricDataResponse)
-> ReadS [GetMetricDataResponse]
-> ReadPrec GetMetricDataResponse
-> ReadPrec [GetMetricDataResponse]
-> Read GetMetricDataResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetMetricDataResponse]
$creadListPrec :: ReadPrec [GetMetricDataResponse]
readPrec :: ReadPrec GetMetricDataResponse
$creadPrec :: ReadPrec GetMetricDataResponse
readList :: ReadS [GetMetricDataResponse]
$creadList :: ReadS [GetMetricDataResponse]
readsPrec :: Int -> ReadS GetMetricDataResponse
$creadsPrec :: Int -> ReadS GetMetricDataResponse
Prelude.Read, Int -> GetMetricDataResponse -> ShowS
[GetMetricDataResponse] -> ShowS
GetMetricDataResponse -> String
(Int -> GetMetricDataResponse -> ShowS)
-> (GetMetricDataResponse -> String)
-> ([GetMetricDataResponse] -> ShowS)
-> Show GetMetricDataResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetMetricDataResponse] -> ShowS
$cshowList :: [GetMetricDataResponse] -> ShowS
show :: GetMetricDataResponse -> String
$cshow :: GetMetricDataResponse -> String
showsPrec :: Int -> GetMetricDataResponse -> ShowS
$cshowsPrec :: Int -> GetMetricDataResponse -> ShowS
Prelude.Show, (forall x. GetMetricDataResponse -> Rep GetMetricDataResponse x)
-> (forall x. Rep GetMetricDataResponse x -> GetMetricDataResponse)
-> Generic GetMetricDataResponse
forall x. Rep GetMetricDataResponse x -> GetMetricDataResponse
forall x. GetMetricDataResponse -> Rep GetMetricDataResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetMetricDataResponse x -> GetMetricDataResponse
$cfrom :: forall x. GetMetricDataResponse -> Rep GetMetricDataResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetMetricDataResponse' 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:
--
-- 'metricDataResults', 'getMetricDataResponse_metricDataResults' - The metrics that are returned, including the metric name, namespace, and
-- dimensions.
--
-- 'nextToken', 'getMetricDataResponse_nextToken' - A token that marks the next batch of returned results.
--
-- 'messages', 'getMetricDataResponse_messages' - Contains a message about this @GetMetricData@ operation, if the
-- operation results in such a message. An example of a message that might
-- be returned is @Maximum number of allowed metrics exceeded@. If there is
-- a message, as much of the operation as possible is still executed.
--
-- A message appears here only if it is related to the global
-- @GetMetricData@ operation. Any message about a specific metric returned
-- by the operation appears in the @MetricDataResult@ object returned for
-- that metric.
--
-- 'httpStatus', 'getMetricDataResponse_httpStatus' - The response's http status code.
newGetMetricDataResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetMetricDataResponse
newGetMetricDataResponse :: Int -> GetMetricDataResponse
newGetMetricDataResponse Int
pHttpStatus_ =
  GetMetricDataResponse' :: Maybe [MetricDataResult]
-> Maybe Text
-> Maybe [MessageData]
-> Int
-> GetMetricDataResponse
GetMetricDataResponse'
    { $sel:metricDataResults:GetMetricDataResponse' :: Maybe [MetricDataResult]
metricDataResults =
        Maybe [MetricDataResult]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetMetricDataResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:messages:GetMetricDataResponse' :: Maybe [MessageData]
messages = Maybe [MessageData]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetMetricDataResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The metrics that are returned, including the metric name, namespace, and
-- dimensions.
getMetricDataResponse_metricDataResults :: Lens.Lens' GetMetricDataResponse (Prelude.Maybe [MetricDataResult])
getMetricDataResponse_metricDataResults :: (Maybe [MetricDataResult] -> f (Maybe [MetricDataResult]))
-> GetMetricDataResponse -> f GetMetricDataResponse
getMetricDataResponse_metricDataResults = (GetMetricDataResponse -> Maybe [MetricDataResult])
-> (GetMetricDataResponse
    -> Maybe [MetricDataResult] -> GetMetricDataResponse)
-> Lens' GetMetricDataResponse (Maybe [MetricDataResult])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMetricDataResponse' {Maybe [MetricDataResult]
metricDataResults :: Maybe [MetricDataResult]
$sel:metricDataResults:GetMetricDataResponse' :: GetMetricDataResponse -> Maybe [MetricDataResult]
metricDataResults} -> Maybe [MetricDataResult]
metricDataResults) (\s :: GetMetricDataResponse
s@GetMetricDataResponse' {} Maybe [MetricDataResult]
a -> GetMetricDataResponse
s {$sel:metricDataResults:GetMetricDataResponse' :: Maybe [MetricDataResult]
metricDataResults = Maybe [MetricDataResult]
a} :: GetMetricDataResponse) ((Maybe [MetricDataResult] -> f (Maybe [MetricDataResult]))
 -> GetMetricDataResponse -> f GetMetricDataResponse)
-> ((Maybe [MetricDataResult] -> f (Maybe [MetricDataResult]))
    -> Maybe [MetricDataResult] -> f (Maybe [MetricDataResult]))
-> (Maybe [MetricDataResult] -> f (Maybe [MetricDataResult]))
-> GetMetricDataResponse
-> f GetMetricDataResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [MetricDataResult]
  [MetricDataResult]
  [MetricDataResult]
  [MetricDataResult]
-> Iso
     (Maybe [MetricDataResult])
     (Maybe [MetricDataResult])
     (Maybe [MetricDataResult])
     (Maybe [MetricDataResult])
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
  [MetricDataResult]
  [MetricDataResult]
  [MetricDataResult]
  [MetricDataResult]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A token that marks the next batch of returned results.
getMetricDataResponse_nextToken :: Lens.Lens' GetMetricDataResponse (Prelude.Maybe Prelude.Text)
getMetricDataResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetMetricDataResponse -> f GetMetricDataResponse
getMetricDataResponse_nextToken = (GetMetricDataResponse -> Maybe Text)
-> (GetMetricDataResponse -> Maybe Text -> GetMetricDataResponse)
-> Lens' GetMetricDataResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMetricDataResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetMetricDataResponse' :: GetMetricDataResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetMetricDataResponse
s@GetMetricDataResponse' {} Maybe Text
a -> GetMetricDataResponse
s {$sel:nextToken:GetMetricDataResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetMetricDataResponse)

-- | Contains a message about this @GetMetricData@ operation, if the
-- operation results in such a message. An example of a message that might
-- be returned is @Maximum number of allowed metrics exceeded@. If there is
-- a message, as much of the operation as possible is still executed.
--
-- A message appears here only if it is related to the global
-- @GetMetricData@ operation. Any message about a specific metric returned
-- by the operation appears in the @MetricDataResult@ object returned for
-- that metric.
getMetricDataResponse_messages :: Lens.Lens' GetMetricDataResponse (Prelude.Maybe [MessageData])
getMetricDataResponse_messages :: (Maybe [MessageData] -> f (Maybe [MessageData]))
-> GetMetricDataResponse -> f GetMetricDataResponse
getMetricDataResponse_messages = (GetMetricDataResponse -> Maybe [MessageData])
-> (GetMetricDataResponse
    -> Maybe [MessageData] -> GetMetricDataResponse)
-> Lens' GetMetricDataResponse (Maybe [MessageData])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMetricDataResponse' {Maybe [MessageData]
messages :: Maybe [MessageData]
$sel:messages:GetMetricDataResponse' :: GetMetricDataResponse -> Maybe [MessageData]
messages} -> Maybe [MessageData]
messages) (\s :: GetMetricDataResponse
s@GetMetricDataResponse' {} Maybe [MessageData]
a -> GetMetricDataResponse
s {$sel:messages:GetMetricDataResponse' :: Maybe [MessageData]
messages = Maybe [MessageData]
a} :: GetMetricDataResponse) ((Maybe [MessageData] -> f (Maybe [MessageData]))
 -> GetMetricDataResponse -> f GetMetricDataResponse)
-> ((Maybe [MessageData] -> f (Maybe [MessageData]))
    -> Maybe [MessageData] -> f (Maybe [MessageData]))
-> (Maybe [MessageData] -> f (Maybe [MessageData]))
-> GetMetricDataResponse
-> f GetMetricDataResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [MessageData] [MessageData] [MessageData] [MessageData]
-> Iso
     (Maybe [MessageData])
     (Maybe [MessageData])
     (Maybe [MessageData])
     (Maybe [MessageData])
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 [MessageData] [MessageData] [MessageData] [MessageData]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData GetMetricDataResponse