{-# 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.GetMetricStatistics
-- 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)
--
-- Gets statistics for the specified metric.
--
-- The maximum number of data points returned from a single call is 1,440.
-- If you request more than 1,440 data points, CloudWatch returns an error.
-- To reduce the number of data points, you can narrow the specified time
-- range and make multiple requests across adjacent time ranges, or you can
-- increase the specified period. Data points are not returned in
-- chronological order.
--
-- CloudWatch aggregates data points based on the length of the period that
-- you specify. For example, if you request statistics with a one-hour
-- period, CloudWatch aggregates all data points with time stamps that fall
-- within each one-hour period. Therefore, the number of values aggregated
-- by CloudWatch is larger than the number of data points returned.
--
-- CloudWatch needs raw data points to calculate percentile statistics. If
-- you publish data using a statistic set instead, you can only retrieve
-- percentile statistics for this data if one of the following conditions
-- is true:
--
-- -   The SampleCount value of the statistic set is 1.
--
-- -   The Min and the Max values of the statistic set are equal.
--
-- Percentile statistics are not available for metrics when any of the
-- metric values are negative numbers.
--
-- 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.
--
-- CloudWatch started retaining 5-minute and 1-hour metric data as of July
-- 9, 2016.
--
-- For information about metrics and dimensions supported by Amazon Web
-- Services services, see the
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CW_Support_For_AWS.html Amazon CloudWatch Metrics and Dimensions Reference>
-- in the /Amazon CloudWatch User Guide/.
module Amazonka.CloudWatch.GetMetricStatistics
  ( -- * Creating a Request
    GetMetricStatistics (..),
    newGetMetricStatistics,

    -- * Request Lenses
    getMetricStatistics_extendedStatistics,
    getMetricStatistics_statistics,
    getMetricStatistics_dimensions,
    getMetricStatistics_unit,
    getMetricStatistics_namespace,
    getMetricStatistics_metricName,
    getMetricStatistics_startTime,
    getMetricStatistics_endTime,
    getMetricStatistics_period,

    -- * Destructuring the Response
    GetMetricStatisticsResponse (..),
    newGetMetricStatisticsResponse,

    -- * Response Lenses
    getMetricStatisticsResponse_datapoints,
    getMetricStatisticsResponse_label,
    getMetricStatisticsResponse_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:/ 'newGetMetricStatistics' smart constructor.
data GetMetricStatistics = GetMetricStatistics'
  { -- | The percentile statistics. Specify values between p0.0 and p100. When
    -- calling @GetMetricStatistics@, you must specify either @Statistics@ or
    -- @ExtendedStatistics@, but not both. Percentile statistics are not
    -- available for metrics when any of the metric values are negative
    -- numbers.
    GetMetricStatistics -> Maybe (NonEmpty Text)
extendedStatistics :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The metric statistics, other than percentile. For percentile statistics,
    -- use @ExtendedStatistics@. When calling @GetMetricStatistics@, you must
    -- specify either @Statistics@ or @ExtendedStatistics@, but not both.
    GetMetricStatistics -> Maybe (NonEmpty Statistic)
statistics :: Prelude.Maybe (Prelude.NonEmpty Statistic),
    -- | The dimensions. If the metric contains multiple dimensions, you must
    -- include a value for each dimension. CloudWatch treats each unique
    -- combination of dimensions as a separate metric. If a specific
    -- combination of dimensions was not published, you can\'t retrieve
    -- statistics for it. You must specify the same dimensions that were used
    -- when the metrics were created. For an example, see
    -- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#dimension-combinations Dimension Combinations>
    -- in the /Amazon CloudWatch User Guide/. For more information about
    -- specifying dimensions, see
    -- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/publishingMetrics.html Publishing Metrics>
    -- in the /Amazon CloudWatch User Guide/.
    GetMetricStatistics -> Maybe [Dimension]
dimensions :: Prelude.Maybe [Dimension],
    -- | The unit for a given metric. If you omit @Unit@, 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.
    GetMetricStatistics -> Maybe StandardUnit
unit :: Prelude.Maybe StandardUnit,
    -- | The namespace of the metric, with or without spaces.
    GetMetricStatistics -> Text
namespace :: Prelude.Text,
    -- | The name of the metric, with or without spaces.
    GetMetricStatistics -> Text
metricName :: Prelude.Text,
    -- | The time stamp that determines the first data point to return. Start
    -- times are evaluated relative to the time that CloudWatch receives the
    -- request.
    --
    -- The value specified is inclusive; results include data points with the
    -- specified time stamp. In a raw HTTP query, the time stamp must be in ISO
    -- 8601 UTC format (for example, 2016-10-03T23:00:00Z).
    --
    -- 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.
    GetMetricStatistics -> ISO8601
startTime :: Core.ISO8601,
    -- | The time stamp that determines the last data point to return.
    --
    -- The value specified is exclusive; results include data points up to the
    -- specified time stamp. In a raw HTTP query, the time stamp must be in ISO
    -- 8601 UTC format (for example, 2016-10-10T23:00:00Z).
    GetMetricStatistics -> ISO8601
endTime :: Core.ISO8601,
    -- | The granularity, in seconds, of the returned data points. For metrics
    -- with regular resolution, a period can be as short as one minute (60
    -- seconds) and must be a multiple of 60. For high-resolution metrics that
    -- are collected at intervals of less than one minute, the period can be 1,
    -- 5, 10, 30, 60, or any multiple of 60. High-resolution metrics are those
    -- metrics stored by a @PutMetricData@ call that includes a
    -- @StorageResolution@ of 1 second.
    --
    -- If the @StartTime@ parameter specifies a time stamp that is greater than
    -- 3 hours ago, you must specify the period as follows or no data points in
    -- that time range is returned:
    --
    -- -   Start time between 3 hours and 15 days ago - Use a multiple of 60
    --     seconds (1 minute).
    --
    -- -   Start time between 15 and 63 days ago - Use a multiple of 300
    --     seconds (5 minutes).
    --
    -- -   Start time greater than 63 days ago - Use a multiple of 3600 seconds
    --     (1 hour).
    GetMetricStatistics -> Natural
period :: Prelude.Natural
  }
  deriving (GetMetricStatistics -> GetMetricStatistics -> Bool
(GetMetricStatistics -> GetMetricStatistics -> Bool)
-> (GetMetricStatistics -> GetMetricStatistics -> Bool)
-> Eq GetMetricStatistics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetMetricStatistics -> GetMetricStatistics -> Bool
$c/= :: GetMetricStatistics -> GetMetricStatistics -> Bool
== :: GetMetricStatistics -> GetMetricStatistics -> Bool
$c== :: GetMetricStatistics -> GetMetricStatistics -> Bool
Prelude.Eq, ReadPrec [GetMetricStatistics]
ReadPrec GetMetricStatistics
Int -> ReadS GetMetricStatistics
ReadS [GetMetricStatistics]
(Int -> ReadS GetMetricStatistics)
-> ReadS [GetMetricStatistics]
-> ReadPrec GetMetricStatistics
-> ReadPrec [GetMetricStatistics]
-> Read GetMetricStatistics
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetMetricStatistics]
$creadListPrec :: ReadPrec [GetMetricStatistics]
readPrec :: ReadPrec GetMetricStatistics
$creadPrec :: ReadPrec GetMetricStatistics
readList :: ReadS [GetMetricStatistics]
$creadList :: ReadS [GetMetricStatistics]
readsPrec :: Int -> ReadS GetMetricStatistics
$creadsPrec :: Int -> ReadS GetMetricStatistics
Prelude.Read, Int -> GetMetricStatistics -> ShowS
[GetMetricStatistics] -> ShowS
GetMetricStatistics -> String
(Int -> GetMetricStatistics -> ShowS)
-> (GetMetricStatistics -> String)
-> ([GetMetricStatistics] -> ShowS)
-> Show GetMetricStatistics
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetMetricStatistics] -> ShowS
$cshowList :: [GetMetricStatistics] -> ShowS
show :: GetMetricStatistics -> String
$cshow :: GetMetricStatistics -> String
showsPrec :: Int -> GetMetricStatistics -> ShowS
$cshowsPrec :: Int -> GetMetricStatistics -> ShowS
Prelude.Show, (forall x. GetMetricStatistics -> Rep GetMetricStatistics x)
-> (forall x. Rep GetMetricStatistics x -> GetMetricStatistics)
-> Generic GetMetricStatistics
forall x. Rep GetMetricStatistics x -> GetMetricStatistics
forall x. GetMetricStatistics -> Rep GetMetricStatistics x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetMetricStatistics x -> GetMetricStatistics
$cfrom :: forall x. GetMetricStatistics -> Rep GetMetricStatistics x
Prelude.Generic)

-- |
-- Create a value of 'GetMetricStatistics' 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:
--
-- 'extendedStatistics', 'getMetricStatistics_extendedStatistics' - The percentile statistics. Specify values between p0.0 and p100. When
-- calling @GetMetricStatistics@, you must specify either @Statistics@ or
-- @ExtendedStatistics@, but not both. Percentile statistics are not
-- available for metrics when any of the metric values are negative
-- numbers.
--
-- 'statistics', 'getMetricStatistics_statistics' - The metric statistics, other than percentile. For percentile statistics,
-- use @ExtendedStatistics@. When calling @GetMetricStatistics@, you must
-- specify either @Statistics@ or @ExtendedStatistics@, but not both.
--
-- 'dimensions', 'getMetricStatistics_dimensions' - The dimensions. If the metric contains multiple dimensions, you must
-- include a value for each dimension. CloudWatch treats each unique
-- combination of dimensions as a separate metric. If a specific
-- combination of dimensions was not published, you can\'t retrieve
-- statistics for it. You must specify the same dimensions that were used
-- when the metrics were created. For an example, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#dimension-combinations Dimension Combinations>
-- in the /Amazon CloudWatch User Guide/. For more information about
-- specifying dimensions, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/publishingMetrics.html Publishing Metrics>
-- in the /Amazon CloudWatch User Guide/.
--
-- 'unit', 'getMetricStatistics_unit' - The unit for a given metric. If you omit @Unit@, 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.
--
-- 'namespace', 'getMetricStatistics_namespace' - The namespace of the metric, with or without spaces.
--
-- 'metricName', 'getMetricStatistics_metricName' - The name of the metric, with or without spaces.
--
-- 'startTime', 'getMetricStatistics_startTime' - The time stamp that determines the first data point to return. Start
-- times are evaluated relative to the time that CloudWatch receives the
-- request.
--
-- The value specified is inclusive; results include data points with the
-- specified time stamp. In a raw HTTP query, the time stamp must be in ISO
-- 8601 UTC format (for example, 2016-10-03T23:00:00Z).
--
-- 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.
--
-- 'endTime', 'getMetricStatistics_endTime' - The time stamp that determines the last data point to return.
--
-- The value specified is exclusive; results include data points up to the
-- specified time stamp. In a raw HTTP query, the time stamp must be in ISO
-- 8601 UTC format (for example, 2016-10-10T23:00:00Z).
--
-- 'period', 'getMetricStatistics_period' - The granularity, in seconds, of the returned data points. For metrics
-- with regular resolution, a period can be as short as one minute (60
-- seconds) and must be a multiple of 60. For high-resolution metrics that
-- are collected at intervals of less than one minute, the period can be 1,
-- 5, 10, 30, 60, or any multiple of 60. High-resolution metrics are those
-- metrics stored by a @PutMetricData@ call that includes a
-- @StorageResolution@ of 1 second.
--
-- If the @StartTime@ parameter specifies a time stamp that is greater than
-- 3 hours ago, you must specify the period as follows or no data points in
-- that time range is returned:
--
-- -   Start time between 3 hours and 15 days ago - Use a multiple of 60
--     seconds (1 minute).
--
-- -   Start time between 15 and 63 days ago - Use a multiple of 300
--     seconds (5 minutes).
--
-- -   Start time greater than 63 days ago - Use a multiple of 3600 seconds
--     (1 hour).
newGetMetricStatistics ::
  -- | 'namespace'
  Prelude.Text ->
  -- | 'metricName'
  Prelude.Text ->
  -- | 'startTime'
  Prelude.UTCTime ->
  -- | 'endTime'
  Prelude.UTCTime ->
  -- | 'period'
  Prelude.Natural ->
  GetMetricStatistics
newGetMetricStatistics :: Text
-> Text -> UTCTime -> UTCTime -> Natural -> GetMetricStatistics
newGetMetricStatistics
  Text
pNamespace_
  Text
pMetricName_
  UTCTime
pStartTime_
  UTCTime
pEndTime_
  Natural
pPeriod_ =
    GetMetricStatistics' :: Maybe (NonEmpty Text)
-> Maybe (NonEmpty Statistic)
-> Maybe [Dimension]
-> Maybe StandardUnit
-> Text
-> Text
-> ISO8601
-> ISO8601
-> Natural
-> GetMetricStatistics
GetMetricStatistics'
      { $sel:extendedStatistics:GetMetricStatistics' :: Maybe (NonEmpty Text)
extendedStatistics =
          Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
        $sel:statistics:GetMetricStatistics' :: Maybe (NonEmpty Statistic)
statistics = Maybe (NonEmpty Statistic)
forall a. Maybe a
Prelude.Nothing,
        $sel:dimensions:GetMetricStatistics' :: Maybe [Dimension]
dimensions = Maybe [Dimension]
forall a. Maybe a
Prelude.Nothing,
        $sel:unit:GetMetricStatistics' :: Maybe StandardUnit
unit = Maybe StandardUnit
forall a. Maybe a
Prelude.Nothing,
        $sel:namespace:GetMetricStatistics' :: Text
namespace = Text
pNamespace_,
        $sel:metricName:GetMetricStatistics' :: Text
metricName = Text
pMetricName_,
        $sel:startTime:GetMetricStatistics' :: 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:GetMetricStatistics' :: 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_,
        $sel:period:GetMetricStatistics' :: Natural
period = Natural
pPeriod_
      }

-- | The percentile statistics. Specify values between p0.0 and p100. When
-- calling @GetMetricStatistics@, you must specify either @Statistics@ or
-- @ExtendedStatistics@, but not both. Percentile statistics are not
-- available for metrics when any of the metric values are negative
-- numbers.
getMetricStatistics_extendedStatistics :: Lens.Lens' GetMetricStatistics (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
getMetricStatistics_extendedStatistics :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> GetMetricStatistics -> f GetMetricStatistics
getMetricStatistics_extendedStatistics = (GetMetricStatistics -> Maybe (NonEmpty Text))
-> (GetMetricStatistics
    -> Maybe (NonEmpty Text) -> GetMetricStatistics)
-> Lens
     GetMetricStatistics
     GetMetricStatistics
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMetricStatistics' {Maybe (NonEmpty Text)
extendedStatistics :: Maybe (NonEmpty Text)
$sel:extendedStatistics:GetMetricStatistics' :: GetMetricStatistics -> Maybe (NonEmpty Text)
extendedStatistics} -> Maybe (NonEmpty Text)
extendedStatistics) (\s :: GetMetricStatistics
s@GetMetricStatistics' {} Maybe (NonEmpty Text)
a -> GetMetricStatistics
s {$sel:extendedStatistics:GetMetricStatistics' :: Maybe (NonEmpty Text)
extendedStatistics = Maybe (NonEmpty Text)
a} :: GetMetricStatistics) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> GetMetricStatistics -> f GetMetricStatistics)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> GetMetricStatistics
-> f GetMetricStatistics
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The metric statistics, other than percentile. For percentile statistics,
-- use @ExtendedStatistics@. When calling @GetMetricStatistics@, you must
-- specify either @Statistics@ or @ExtendedStatistics@, but not both.
getMetricStatistics_statistics :: Lens.Lens' GetMetricStatistics (Prelude.Maybe (Prelude.NonEmpty Statistic))
getMetricStatistics_statistics :: (Maybe (NonEmpty Statistic) -> f (Maybe (NonEmpty Statistic)))
-> GetMetricStatistics -> f GetMetricStatistics
getMetricStatistics_statistics = (GetMetricStatistics -> Maybe (NonEmpty Statistic))
-> (GetMetricStatistics
    -> Maybe (NonEmpty Statistic) -> GetMetricStatistics)
-> Lens
     GetMetricStatistics
     GetMetricStatistics
     (Maybe (NonEmpty Statistic))
     (Maybe (NonEmpty Statistic))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMetricStatistics' {Maybe (NonEmpty Statistic)
statistics :: Maybe (NonEmpty Statistic)
$sel:statistics:GetMetricStatistics' :: GetMetricStatistics -> Maybe (NonEmpty Statistic)
statistics} -> Maybe (NonEmpty Statistic)
statistics) (\s :: GetMetricStatistics
s@GetMetricStatistics' {} Maybe (NonEmpty Statistic)
a -> GetMetricStatistics
s {$sel:statistics:GetMetricStatistics' :: Maybe (NonEmpty Statistic)
statistics = Maybe (NonEmpty Statistic)
a} :: GetMetricStatistics) ((Maybe (NonEmpty Statistic) -> f (Maybe (NonEmpty Statistic)))
 -> GetMetricStatistics -> f GetMetricStatistics)
-> ((Maybe (NonEmpty Statistic) -> f (Maybe (NonEmpty Statistic)))
    -> Maybe (NonEmpty Statistic) -> f (Maybe (NonEmpty Statistic)))
-> (Maybe (NonEmpty Statistic) -> f (Maybe (NonEmpty Statistic)))
-> GetMetricStatistics
-> f GetMetricStatistics
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Statistic)
  (NonEmpty Statistic)
  (NonEmpty Statistic)
  (NonEmpty Statistic)
-> Iso
     (Maybe (NonEmpty Statistic))
     (Maybe (NonEmpty Statistic))
     (Maybe (NonEmpty Statistic))
     (Maybe (NonEmpty Statistic))
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
  (NonEmpty Statistic)
  (NonEmpty Statistic)
  (NonEmpty Statistic)
  (NonEmpty Statistic)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The dimensions. If the metric contains multiple dimensions, you must
-- include a value for each dimension. CloudWatch treats each unique
-- combination of dimensions as a separate metric. If a specific
-- combination of dimensions was not published, you can\'t retrieve
-- statistics for it. You must specify the same dimensions that were used
-- when the metrics were created. For an example, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#dimension-combinations Dimension Combinations>
-- in the /Amazon CloudWatch User Guide/. For more information about
-- specifying dimensions, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/publishingMetrics.html Publishing Metrics>
-- in the /Amazon CloudWatch User Guide/.
getMetricStatistics_dimensions :: Lens.Lens' GetMetricStatistics (Prelude.Maybe [Dimension])
getMetricStatistics_dimensions :: (Maybe [Dimension] -> f (Maybe [Dimension]))
-> GetMetricStatistics -> f GetMetricStatistics
getMetricStatistics_dimensions = (GetMetricStatistics -> Maybe [Dimension])
-> (GetMetricStatistics
    -> Maybe [Dimension] -> GetMetricStatistics)
-> Lens
     GetMetricStatistics
     GetMetricStatistics
     (Maybe [Dimension])
     (Maybe [Dimension])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMetricStatistics' {Maybe [Dimension]
dimensions :: Maybe [Dimension]
$sel:dimensions:GetMetricStatistics' :: GetMetricStatistics -> Maybe [Dimension]
dimensions} -> Maybe [Dimension]
dimensions) (\s :: GetMetricStatistics
s@GetMetricStatistics' {} Maybe [Dimension]
a -> GetMetricStatistics
s {$sel:dimensions:GetMetricStatistics' :: Maybe [Dimension]
dimensions = Maybe [Dimension]
a} :: GetMetricStatistics) ((Maybe [Dimension] -> f (Maybe [Dimension]))
 -> GetMetricStatistics -> f GetMetricStatistics)
-> ((Maybe [Dimension] -> f (Maybe [Dimension]))
    -> Maybe [Dimension] -> f (Maybe [Dimension]))
-> (Maybe [Dimension] -> f (Maybe [Dimension]))
-> GetMetricStatistics
-> f GetMetricStatistics
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Dimension] [Dimension] [Dimension] [Dimension]
-> Iso
     (Maybe [Dimension])
     (Maybe [Dimension])
     (Maybe [Dimension])
     (Maybe [Dimension])
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 [Dimension] [Dimension] [Dimension] [Dimension]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The unit for a given metric. If you omit @Unit@, 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.
getMetricStatistics_unit :: Lens.Lens' GetMetricStatistics (Prelude.Maybe StandardUnit)
getMetricStatistics_unit :: (Maybe StandardUnit -> f (Maybe StandardUnit))
-> GetMetricStatistics -> f GetMetricStatistics
getMetricStatistics_unit = (GetMetricStatistics -> Maybe StandardUnit)
-> (GetMetricStatistics
    -> Maybe StandardUnit -> GetMetricStatistics)
-> Lens
     GetMetricStatistics
     GetMetricStatistics
     (Maybe StandardUnit)
     (Maybe StandardUnit)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMetricStatistics' {Maybe StandardUnit
unit :: Maybe StandardUnit
$sel:unit:GetMetricStatistics' :: GetMetricStatistics -> Maybe StandardUnit
unit} -> Maybe StandardUnit
unit) (\s :: GetMetricStatistics
s@GetMetricStatistics' {} Maybe StandardUnit
a -> GetMetricStatistics
s {$sel:unit:GetMetricStatistics' :: Maybe StandardUnit
unit = Maybe StandardUnit
a} :: GetMetricStatistics)

-- | The namespace of the metric, with or without spaces.
getMetricStatistics_namespace :: Lens.Lens' GetMetricStatistics Prelude.Text
getMetricStatistics_namespace :: (Text -> f Text) -> GetMetricStatistics -> f GetMetricStatistics
getMetricStatistics_namespace = (GetMetricStatistics -> Text)
-> (GetMetricStatistics -> Text -> GetMetricStatistics)
-> Lens GetMetricStatistics GetMetricStatistics Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMetricStatistics' {Text
namespace :: Text
$sel:namespace:GetMetricStatistics' :: GetMetricStatistics -> Text
namespace} -> Text
namespace) (\s :: GetMetricStatistics
s@GetMetricStatistics' {} Text
a -> GetMetricStatistics
s {$sel:namespace:GetMetricStatistics' :: Text
namespace = Text
a} :: GetMetricStatistics)

-- | The name of the metric, with or without spaces.
getMetricStatistics_metricName :: Lens.Lens' GetMetricStatistics Prelude.Text
getMetricStatistics_metricName :: (Text -> f Text) -> GetMetricStatistics -> f GetMetricStatistics
getMetricStatistics_metricName = (GetMetricStatistics -> Text)
-> (GetMetricStatistics -> Text -> GetMetricStatistics)
-> Lens GetMetricStatistics GetMetricStatistics Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMetricStatistics' {Text
metricName :: Text
$sel:metricName:GetMetricStatistics' :: GetMetricStatistics -> Text
metricName} -> Text
metricName) (\s :: GetMetricStatistics
s@GetMetricStatistics' {} Text
a -> GetMetricStatistics
s {$sel:metricName:GetMetricStatistics' :: Text
metricName = Text
a} :: GetMetricStatistics)

-- | The time stamp that determines the first data point to return. Start
-- times are evaluated relative to the time that CloudWatch receives the
-- request.
--
-- The value specified is inclusive; results include data points with the
-- specified time stamp. In a raw HTTP query, the time stamp must be in ISO
-- 8601 UTC format (for example, 2016-10-03T23:00:00Z).
--
-- 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.
getMetricStatistics_startTime :: Lens.Lens' GetMetricStatistics Prelude.UTCTime
getMetricStatistics_startTime :: (UTCTime -> f UTCTime)
-> GetMetricStatistics -> f GetMetricStatistics
getMetricStatistics_startTime = (GetMetricStatistics -> ISO8601)
-> (GetMetricStatistics -> ISO8601 -> GetMetricStatistics)
-> Lens GetMetricStatistics GetMetricStatistics ISO8601 ISO8601
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMetricStatistics' {ISO8601
startTime :: ISO8601
$sel:startTime:GetMetricStatistics' :: GetMetricStatistics -> ISO8601
startTime} -> ISO8601
startTime) (\s :: GetMetricStatistics
s@GetMetricStatistics' {} ISO8601
a -> GetMetricStatistics
s {$sel:startTime:GetMetricStatistics' :: ISO8601
startTime = ISO8601
a} :: GetMetricStatistics) ((ISO8601 -> f ISO8601)
 -> GetMetricStatistics -> f GetMetricStatistics)
-> ((UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601)
-> (UTCTime -> f UTCTime)
-> GetMetricStatistics
-> f GetMetricStatistics
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 that determines the last data point to return.
--
-- The value specified is exclusive; results include data points up to the
-- specified time stamp. In a raw HTTP query, the time stamp must be in ISO
-- 8601 UTC format (for example, 2016-10-10T23:00:00Z).
getMetricStatistics_endTime :: Lens.Lens' GetMetricStatistics Prelude.UTCTime
getMetricStatistics_endTime :: (UTCTime -> f UTCTime)
-> GetMetricStatistics -> f GetMetricStatistics
getMetricStatistics_endTime = (GetMetricStatistics -> ISO8601)
-> (GetMetricStatistics -> ISO8601 -> GetMetricStatistics)
-> Lens GetMetricStatistics GetMetricStatistics ISO8601 ISO8601
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMetricStatistics' {ISO8601
endTime :: ISO8601
$sel:endTime:GetMetricStatistics' :: GetMetricStatistics -> ISO8601
endTime} -> ISO8601
endTime) (\s :: GetMetricStatistics
s@GetMetricStatistics' {} ISO8601
a -> GetMetricStatistics
s {$sel:endTime:GetMetricStatistics' :: ISO8601
endTime = ISO8601
a} :: GetMetricStatistics) ((ISO8601 -> f ISO8601)
 -> GetMetricStatistics -> f GetMetricStatistics)
-> ((UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601)
-> (UTCTime -> f UTCTime)
-> GetMetricStatistics
-> f GetMetricStatistics
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 granularity, in seconds, of the returned data points. For metrics
-- with regular resolution, a period can be as short as one minute (60
-- seconds) and must be a multiple of 60. For high-resolution metrics that
-- are collected at intervals of less than one minute, the period can be 1,
-- 5, 10, 30, 60, or any multiple of 60. High-resolution metrics are those
-- metrics stored by a @PutMetricData@ call that includes a
-- @StorageResolution@ of 1 second.
--
-- If the @StartTime@ parameter specifies a time stamp that is greater than
-- 3 hours ago, you must specify the period as follows or no data points in
-- that time range is returned:
--
-- -   Start time between 3 hours and 15 days ago - Use a multiple of 60
--     seconds (1 minute).
--
-- -   Start time between 15 and 63 days ago - Use a multiple of 300
--     seconds (5 minutes).
--
-- -   Start time greater than 63 days ago - Use a multiple of 3600 seconds
--     (1 hour).
getMetricStatistics_period :: Lens.Lens' GetMetricStatistics Prelude.Natural
getMetricStatistics_period :: (Natural -> f Natural)
-> GetMetricStatistics -> f GetMetricStatistics
getMetricStatistics_period = (GetMetricStatistics -> Natural)
-> (GetMetricStatistics -> Natural -> GetMetricStatistics)
-> Lens GetMetricStatistics GetMetricStatistics Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMetricStatistics' {Natural
period :: Natural
$sel:period:GetMetricStatistics' :: GetMetricStatistics -> Natural
period} -> Natural
period) (\s :: GetMetricStatistics
s@GetMetricStatistics' {} Natural
a -> GetMetricStatistics
s {$sel:period:GetMetricStatistics' :: Natural
period = Natural
a} :: GetMetricStatistics)

instance Core.AWSRequest GetMetricStatistics where
  type
    AWSResponse GetMetricStatistics =
      GetMetricStatisticsResponse
  request :: GetMetricStatistics -> Request GetMetricStatistics
request = Service -> GetMetricStatistics -> Request GetMetricStatistics
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy GetMetricStatistics
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetMetricStatistics)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse GetMetricStatistics))
-> Logger
-> Service
-> Proxy GetMetricStatistics
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetMetricStatistics)))
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
"GetMetricStatisticsResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe [Datapoint]
-> Maybe Text -> Int -> GetMetricStatisticsResponse
GetMetricStatisticsResponse'
            (Maybe [Datapoint]
 -> Maybe Text -> Int -> GetMetricStatisticsResponse)
-> Either String (Maybe [Datapoint])
-> Either String (Maybe Text -> Int -> GetMetricStatisticsResponse)
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
"Datapoints" 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 [Datapoint]))
-> Either String (Maybe [Datapoint])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Datapoint])
-> [Node] -> Either String (Maybe [Datapoint])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Datapoint]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                        )
            Either String (Maybe Text -> Int -> GetMetricStatisticsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GetMetricStatisticsResponse)
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
"Label")
            Either String (Int -> GetMetricStatisticsResponse)
-> Either String Int -> Either String GetMetricStatisticsResponse
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 GetMetricStatistics

instance Prelude.NFData GetMetricStatistics

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

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

instance Core.ToQuery GetMetricStatistics where
  toQuery :: GetMetricStatistics -> QueryString
toQuery GetMetricStatistics' {Natural
Maybe [Dimension]
Maybe (NonEmpty Text)
Maybe (NonEmpty Statistic)
Maybe StandardUnit
Text
ISO8601
period :: Natural
endTime :: ISO8601
startTime :: ISO8601
metricName :: Text
namespace :: Text
unit :: Maybe StandardUnit
dimensions :: Maybe [Dimension]
statistics :: Maybe (NonEmpty Statistic)
extendedStatistics :: Maybe (NonEmpty Text)
$sel:period:GetMetricStatistics' :: GetMetricStatistics -> Natural
$sel:endTime:GetMetricStatistics' :: GetMetricStatistics -> ISO8601
$sel:startTime:GetMetricStatistics' :: GetMetricStatistics -> ISO8601
$sel:metricName:GetMetricStatistics' :: GetMetricStatistics -> Text
$sel:namespace:GetMetricStatistics' :: GetMetricStatistics -> Text
$sel:unit:GetMetricStatistics' :: GetMetricStatistics -> Maybe StandardUnit
$sel:dimensions:GetMetricStatistics' :: GetMetricStatistics -> Maybe [Dimension]
$sel:statistics:GetMetricStatistics' :: GetMetricStatistics -> Maybe (NonEmpty Statistic)
$sel:extendedStatistics:GetMetricStatistics' :: GetMetricStatistics -> Maybe (NonEmpty Text)
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"GetMetricStatistics" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-08-01" :: Prelude.ByteString),
        ByteString
"ExtendedStatistics"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            ( ByteString -> NonEmpty Text -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member"
                (NonEmpty Text -> QueryString)
-> Maybe (NonEmpty Text) -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
extendedStatistics
            ),
        ByteString
"Statistics"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> NonEmpty Statistic -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" (NonEmpty Statistic -> QueryString)
-> Maybe (NonEmpty Statistic) -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Statistic)
statistics),
        ByteString
"Dimensions"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Dimension] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([Dimension] -> QueryString)
-> Maybe [Dimension] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Dimension]
dimensions),
        ByteString
"Unit" ByteString -> Maybe StandardUnit -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe StandardUnit
unit,
        ByteString
"Namespace" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
namespace,
        ByteString
"MetricName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
metricName,
        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,
        ByteString
"Period" ByteString -> Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Natural
period
      ]

-- | /See:/ 'newGetMetricStatisticsResponse' smart constructor.
data GetMetricStatisticsResponse = GetMetricStatisticsResponse'
  { -- | The data points for the specified metric.
    GetMetricStatisticsResponse -> Maybe [Datapoint]
datapoints :: Prelude.Maybe [Datapoint],
    -- | A label for the specified metric.
    GetMetricStatisticsResponse -> Maybe Text
label :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetMetricStatisticsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetMetricStatisticsResponse -> GetMetricStatisticsResponse -> Bool
(GetMetricStatisticsResponse
 -> GetMetricStatisticsResponse -> Bool)
-> (GetMetricStatisticsResponse
    -> GetMetricStatisticsResponse -> Bool)
-> Eq GetMetricStatisticsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetMetricStatisticsResponse -> GetMetricStatisticsResponse -> Bool
$c/= :: GetMetricStatisticsResponse -> GetMetricStatisticsResponse -> Bool
== :: GetMetricStatisticsResponse -> GetMetricStatisticsResponse -> Bool
$c== :: GetMetricStatisticsResponse -> GetMetricStatisticsResponse -> Bool
Prelude.Eq, ReadPrec [GetMetricStatisticsResponse]
ReadPrec GetMetricStatisticsResponse
Int -> ReadS GetMetricStatisticsResponse
ReadS [GetMetricStatisticsResponse]
(Int -> ReadS GetMetricStatisticsResponse)
-> ReadS [GetMetricStatisticsResponse]
-> ReadPrec GetMetricStatisticsResponse
-> ReadPrec [GetMetricStatisticsResponse]
-> Read GetMetricStatisticsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetMetricStatisticsResponse]
$creadListPrec :: ReadPrec [GetMetricStatisticsResponse]
readPrec :: ReadPrec GetMetricStatisticsResponse
$creadPrec :: ReadPrec GetMetricStatisticsResponse
readList :: ReadS [GetMetricStatisticsResponse]
$creadList :: ReadS [GetMetricStatisticsResponse]
readsPrec :: Int -> ReadS GetMetricStatisticsResponse
$creadsPrec :: Int -> ReadS GetMetricStatisticsResponse
Prelude.Read, Int -> GetMetricStatisticsResponse -> ShowS
[GetMetricStatisticsResponse] -> ShowS
GetMetricStatisticsResponse -> String
(Int -> GetMetricStatisticsResponse -> ShowS)
-> (GetMetricStatisticsResponse -> String)
-> ([GetMetricStatisticsResponse] -> ShowS)
-> Show GetMetricStatisticsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetMetricStatisticsResponse] -> ShowS
$cshowList :: [GetMetricStatisticsResponse] -> ShowS
show :: GetMetricStatisticsResponse -> String
$cshow :: GetMetricStatisticsResponse -> String
showsPrec :: Int -> GetMetricStatisticsResponse -> ShowS
$cshowsPrec :: Int -> GetMetricStatisticsResponse -> ShowS
Prelude.Show, (forall x.
 GetMetricStatisticsResponse -> Rep GetMetricStatisticsResponse x)
-> (forall x.
    Rep GetMetricStatisticsResponse x -> GetMetricStatisticsResponse)
-> Generic GetMetricStatisticsResponse
forall x.
Rep GetMetricStatisticsResponse x -> GetMetricStatisticsResponse
forall x.
GetMetricStatisticsResponse -> Rep GetMetricStatisticsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetMetricStatisticsResponse x -> GetMetricStatisticsResponse
$cfrom :: forall x.
GetMetricStatisticsResponse -> Rep GetMetricStatisticsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetMetricStatisticsResponse' 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:
--
-- 'datapoints', 'getMetricStatisticsResponse_datapoints' - The data points for the specified metric.
--
-- 'label', 'getMetricStatisticsResponse_label' - A label for the specified metric.
--
-- 'httpStatus', 'getMetricStatisticsResponse_httpStatus' - The response's http status code.
newGetMetricStatisticsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetMetricStatisticsResponse
newGetMetricStatisticsResponse :: Int -> GetMetricStatisticsResponse
newGetMetricStatisticsResponse Int
pHttpStatus_ =
  GetMetricStatisticsResponse' :: Maybe [Datapoint]
-> Maybe Text -> Int -> GetMetricStatisticsResponse
GetMetricStatisticsResponse'
    { $sel:datapoints:GetMetricStatisticsResponse' :: Maybe [Datapoint]
datapoints =
        Maybe [Datapoint]
forall a. Maybe a
Prelude.Nothing,
      $sel:label:GetMetricStatisticsResponse' :: Maybe Text
label = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetMetricStatisticsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The data points for the specified metric.
getMetricStatisticsResponse_datapoints :: Lens.Lens' GetMetricStatisticsResponse (Prelude.Maybe [Datapoint])
getMetricStatisticsResponse_datapoints :: (Maybe [Datapoint] -> f (Maybe [Datapoint]))
-> GetMetricStatisticsResponse -> f GetMetricStatisticsResponse
getMetricStatisticsResponse_datapoints = (GetMetricStatisticsResponse -> Maybe [Datapoint])
-> (GetMetricStatisticsResponse
    -> Maybe [Datapoint] -> GetMetricStatisticsResponse)
-> Lens
     GetMetricStatisticsResponse
     GetMetricStatisticsResponse
     (Maybe [Datapoint])
     (Maybe [Datapoint])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMetricStatisticsResponse' {Maybe [Datapoint]
datapoints :: Maybe [Datapoint]
$sel:datapoints:GetMetricStatisticsResponse' :: GetMetricStatisticsResponse -> Maybe [Datapoint]
datapoints} -> Maybe [Datapoint]
datapoints) (\s :: GetMetricStatisticsResponse
s@GetMetricStatisticsResponse' {} Maybe [Datapoint]
a -> GetMetricStatisticsResponse
s {$sel:datapoints:GetMetricStatisticsResponse' :: Maybe [Datapoint]
datapoints = Maybe [Datapoint]
a} :: GetMetricStatisticsResponse) ((Maybe [Datapoint] -> f (Maybe [Datapoint]))
 -> GetMetricStatisticsResponse -> f GetMetricStatisticsResponse)
-> ((Maybe [Datapoint] -> f (Maybe [Datapoint]))
    -> Maybe [Datapoint] -> f (Maybe [Datapoint]))
-> (Maybe [Datapoint] -> f (Maybe [Datapoint]))
-> GetMetricStatisticsResponse
-> f GetMetricStatisticsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Datapoint] [Datapoint] [Datapoint] [Datapoint]
-> Iso
     (Maybe [Datapoint])
     (Maybe [Datapoint])
     (Maybe [Datapoint])
     (Maybe [Datapoint])
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 [Datapoint] [Datapoint] [Datapoint] [Datapoint]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A label for the specified metric.
getMetricStatisticsResponse_label :: Lens.Lens' GetMetricStatisticsResponse (Prelude.Maybe Prelude.Text)
getMetricStatisticsResponse_label :: (Maybe Text -> f (Maybe Text))
-> GetMetricStatisticsResponse -> f GetMetricStatisticsResponse
getMetricStatisticsResponse_label = (GetMetricStatisticsResponse -> Maybe Text)
-> (GetMetricStatisticsResponse
    -> Maybe Text -> GetMetricStatisticsResponse)
-> Lens
     GetMetricStatisticsResponse
     GetMetricStatisticsResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMetricStatisticsResponse' {Maybe Text
label :: Maybe Text
$sel:label:GetMetricStatisticsResponse' :: GetMetricStatisticsResponse -> Maybe Text
label} -> Maybe Text
label) (\s :: GetMetricStatisticsResponse
s@GetMetricStatisticsResponse' {} Maybe Text
a -> GetMetricStatisticsResponse
s {$sel:label:GetMetricStatisticsResponse' :: Maybe Text
label = Maybe Text
a} :: GetMetricStatisticsResponse)

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

instance Prelude.NFData GetMetricStatisticsResponse