{-# 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.ListMetrics
-- 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)
--
-- List the specified metrics. You can use the returned metrics with
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricData.html GetMetricData>
-- or
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricStatistics.html GetMetricStatistics>
-- to obtain statistical data.
--
-- Up to 500 results are returned for any one call. To retrieve additional
-- results, use the returned token with subsequent calls.
--
-- After you create a metric, allow up to 15 minutes before the metric
-- appears. You can see statistics about the metric sooner by using
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricData.html GetMetricData>
-- or
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricStatistics.html GetMetricStatistics>.
--
-- @ListMetrics@ doesn\'t return information about metrics if those metrics
-- haven\'t reported data in the past two weeks. To retrieve those metrics,
-- use
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricData.html GetMetricData>
-- or
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricStatistics.html GetMetricStatistics>.
--
-- This operation returns paginated results.
module Amazonka.CloudWatch.ListMetrics
  ( -- * Creating a Request
    ListMetrics (..),
    newListMetrics,

    -- * Request Lenses
    listMetrics_metricName,
    listMetrics_namespace,
    listMetrics_nextToken,
    listMetrics_recentlyActive,
    listMetrics_dimensions,

    -- * Destructuring the Response
    ListMetricsResponse (..),
    newListMetricsResponse,

    -- * Response Lenses
    listMetricsResponse_metrics,
    listMetricsResponse_nextToken,
    listMetricsResponse_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:/ 'newListMetrics' smart constructor.
data ListMetrics = ListMetrics'
  { -- | The name of the metric to filter against. Only the metrics with names
    -- that match exactly will be returned.
    ListMetrics -> Maybe Text
metricName :: Prelude.Maybe Prelude.Text,
    -- | The metric namespace to filter against. Only the namespace that matches
    -- exactly will be returned.
    ListMetrics -> Maybe Text
namespace :: Prelude.Maybe Prelude.Text,
    -- | The token returned by a previous call to indicate that there is more
    -- data available.
    ListMetrics -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | To filter the results to show only metrics that have had data points
    -- published in the past three hours, specify this parameter with a value
    -- of @PT3H@. This is the only valid value for this parameter.
    --
    -- The results that are returned are an approximation of the value you
    -- specify. There is a low probability that the returned results include
    -- metrics with last published data as much as 40 minutes more than the
    -- specified time interval.
    ListMetrics -> Maybe RecentlyActive
recentlyActive :: Prelude.Maybe RecentlyActive,
    -- | The dimensions to filter against. Only the dimensions that match exactly
    -- will be returned.
    ListMetrics -> Maybe [DimensionFilter]
dimensions :: Prelude.Maybe [DimensionFilter]
  }
  deriving (ListMetrics -> ListMetrics -> Bool
(ListMetrics -> ListMetrics -> Bool)
-> (ListMetrics -> ListMetrics -> Bool) -> Eq ListMetrics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListMetrics -> ListMetrics -> Bool
$c/= :: ListMetrics -> ListMetrics -> Bool
== :: ListMetrics -> ListMetrics -> Bool
$c== :: ListMetrics -> ListMetrics -> Bool
Prelude.Eq, ReadPrec [ListMetrics]
ReadPrec ListMetrics
Int -> ReadS ListMetrics
ReadS [ListMetrics]
(Int -> ReadS ListMetrics)
-> ReadS [ListMetrics]
-> ReadPrec ListMetrics
-> ReadPrec [ListMetrics]
-> Read ListMetrics
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListMetrics]
$creadListPrec :: ReadPrec [ListMetrics]
readPrec :: ReadPrec ListMetrics
$creadPrec :: ReadPrec ListMetrics
readList :: ReadS [ListMetrics]
$creadList :: ReadS [ListMetrics]
readsPrec :: Int -> ReadS ListMetrics
$creadsPrec :: Int -> ReadS ListMetrics
Prelude.Read, Int -> ListMetrics -> ShowS
[ListMetrics] -> ShowS
ListMetrics -> String
(Int -> ListMetrics -> ShowS)
-> (ListMetrics -> String)
-> ([ListMetrics] -> ShowS)
-> Show ListMetrics
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListMetrics] -> ShowS
$cshowList :: [ListMetrics] -> ShowS
show :: ListMetrics -> String
$cshow :: ListMetrics -> String
showsPrec :: Int -> ListMetrics -> ShowS
$cshowsPrec :: Int -> ListMetrics -> ShowS
Prelude.Show, (forall x. ListMetrics -> Rep ListMetrics x)
-> (forall x. Rep ListMetrics x -> ListMetrics)
-> Generic ListMetrics
forall x. Rep ListMetrics x -> ListMetrics
forall x. ListMetrics -> Rep ListMetrics x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListMetrics x -> ListMetrics
$cfrom :: forall x. ListMetrics -> Rep ListMetrics x
Prelude.Generic)

-- |
-- Create a value of 'ListMetrics' 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:
--
-- 'metricName', 'listMetrics_metricName' - The name of the metric to filter against. Only the metrics with names
-- that match exactly will be returned.
--
-- 'namespace', 'listMetrics_namespace' - The metric namespace to filter against. Only the namespace that matches
-- exactly will be returned.
--
-- 'nextToken', 'listMetrics_nextToken' - The token returned by a previous call to indicate that there is more
-- data available.
--
-- 'recentlyActive', 'listMetrics_recentlyActive' - To filter the results to show only metrics that have had data points
-- published in the past three hours, specify this parameter with a value
-- of @PT3H@. This is the only valid value for this parameter.
--
-- The results that are returned are an approximation of the value you
-- specify. There is a low probability that the returned results include
-- metrics with last published data as much as 40 minutes more than the
-- specified time interval.
--
-- 'dimensions', 'listMetrics_dimensions' - The dimensions to filter against. Only the dimensions that match exactly
-- will be returned.
newListMetrics ::
  ListMetrics
newListMetrics :: ListMetrics
newListMetrics =
  ListMetrics' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe RecentlyActive
-> Maybe [DimensionFilter]
-> ListMetrics
ListMetrics'
    { $sel:metricName:ListMetrics' :: Maybe Text
metricName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:namespace:ListMetrics' :: Maybe Text
namespace = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListMetrics' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:recentlyActive:ListMetrics' :: Maybe RecentlyActive
recentlyActive = Maybe RecentlyActive
forall a. Maybe a
Prelude.Nothing,
      $sel:dimensions:ListMetrics' :: Maybe [DimensionFilter]
dimensions = Maybe [DimensionFilter]
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the metric to filter against. Only the metrics with names
-- that match exactly will be returned.
listMetrics_metricName :: Lens.Lens' ListMetrics (Prelude.Maybe Prelude.Text)
listMetrics_metricName :: (Maybe Text -> f (Maybe Text)) -> ListMetrics -> f ListMetrics
listMetrics_metricName = (ListMetrics -> Maybe Text)
-> (ListMetrics -> Maybe Text -> ListMetrics)
-> Lens ListMetrics ListMetrics (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListMetrics' {Maybe Text
metricName :: Maybe Text
$sel:metricName:ListMetrics' :: ListMetrics -> Maybe Text
metricName} -> Maybe Text
metricName) (\s :: ListMetrics
s@ListMetrics' {} Maybe Text
a -> ListMetrics
s {$sel:metricName:ListMetrics' :: Maybe Text
metricName = Maybe Text
a} :: ListMetrics)

-- | The metric namespace to filter against. Only the namespace that matches
-- exactly will be returned.
listMetrics_namespace :: Lens.Lens' ListMetrics (Prelude.Maybe Prelude.Text)
listMetrics_namespace :: (Maybe Text -> f (Maybe Text)) -> ListMetrics -> f ListMetrics
listMetrics_namespace = (ListMetrics -> Maybe Text)
-> (ListMetrics -> Maybe Text -> ListMetrics)
-> Lens ListMetrics ListMetrics (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListMetrics' {Maybe Text
namespace :: Maybe Text
$sel:namespace:ListMetrics' :: ListMetrics -> Maybe Text
namespace} -> Maybe Text
namespace) (\s :: ListMetrics
s@ListMetrics' {} Maybe Text
a -> ListMetrics
s {$sel:namespace:ListMetrics' :: Maybe Text
namespace = Maybe Text
a} :: ListMetrics)

-- | The token returned by a previous call to indicate that there is more
-- data available.
listMetrics_nextToken :: Lens.Lens' ListMetrics (Prelude.Maybe Prelude.Text)
listMetrics_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListMetrics -> f ListMetrics
listMetrics_nextToken = (ListMetrics -> Maybe Text)
-> (ListMetrics -> Maybe Text -> ListMetrics)
-> Lens ListMetrics ListMetrics (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListMetrics' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListMetrics' :: ListMetrics -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListMetrics
s@ListMetrics' {} Maybe Text
a -> ListMetrics
s {$sel:nextToken:ListMetrics' :: Maybe Text
nextToken = Maybe Text
a} :: ListMetrics)

-- | To filter the results to show only metrics that have had data points
-- published in the past three hours, specify this parameter with a value
-- of @PT3H@. This is the only valid value for this parameter.
--
-- The results that are returned are an approximation of the value you
-- specify. There is a low probability that the returned results include
-- metrics with last published data as much as 40 minutes more than the
-- specified time interval.
listMetrics_recentlyActive :: Lens.Lens' ListMetrics (Prelude.Maybe RecentlyActive)
listMetrics_recentlyActive :: (Maybe RecentlyActive -> f (Maybe RecentlyActive))
-> ListMetrics -> f ListMetrics
listMetrics_recentlyActive = (ListMetrics -> Maybe RecentlyActive)
-> (ListMetrics -> Maybe RecentlyActive -> ListMetrics)
-> Lens
     ListMetrics
     ListMetrics
     (Maybe RecentlyActive)
     (Maybe RecentlyActive)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListMetrics' {Maybe RecentlyActive
recentlyActive :: Maybe RecentlyActive
$sel:recentlyActive:ListMetrics' :: ListMetrics -> Maybe RecentlyActive
recentlyActive} -> Maybe RecentlyActive
recentlyActive) (\s :: ListMetrics
s@ListMetrics' {} Maybe RecentlyActive
a -> ListMetrics
s {$sel:recentlyActive:ListMetrics' :: Maybe RecentlyActive
recentlyActive = Maybe RecentlyActive
a} :: ListMetrics)

-- | The dimensions to filter against. Only the dimensions that match exactly
-- will be returned.
listMetrics_dimensions :: Lens.Lens' ListMetrics (Prelude.Maybe [DimensionFilter])
listMetrics_dimensions :: (Maybe [DimensionFilter] -> f (Maybe [DimensionFilter]))
-> ListMetrics -> f ListMetrics
listMetrics_dimensions = (ListMetrics -> Maybe [DimensionFilter])
-> (ListMetrics -> Maybe [DimensionFilter] -> ListMetrics)
-> Lens
     ListMetrics
     ListMetrics
     (Maybe [DimensionFilter])
     (Maybe [DimensionFilter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListMetrics' {Maybe [DimensionFilter]
dimensions :: Maybe [DimensionFilter]
$sel:dimensions:ListMetrics' :: ListMetrics -> Maybe [DimensionFilter]
dimensions} -> Maybe [DimensionFilter]
dimensions) (\s :: ListMetrics
s@ListMetrics' {} Maybe [DimensionFilter]
a -> ListMetrics
s {$sel:dimensions:ListMetrics' :: Maybe [DimensionFilter]
dimensions = Maybe [DimensionFilter]
a} :: ListMetrics) ((Maybe [DimensionFilter] -> f (Maybe [DimensionFilter]))
 -> ListMetrics -> f ListMetrics)
-> ((Maybe [DimensionFilter] -> f (Maybe [DimensionFilter]))
    -> Maybe [DimensionFilter] -> f (Maybe [DimensionFilter]))
-> (Maybe [DimensionFilter] -> f (Maybe [DimensionFilter]))
-> ListMetrics
-> f ListMetrics
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [DimensionFilter]
  [DimensionFilter]
  [DimensionFilter]
  [DimensionFilter]
-> Iso
     (Maybe [DimensionFilter])
     (Maybe [DimensionFilter])
     (Maybe [DimensionFilter])
     (Maybe [DimensionFilter])
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
  [DimensionFilter]
  [DimensionFilter]
  [DimensionFilter]
  [DimensionFilter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSPager ListMetrics where
  page :: ListMetrics -> AWSResponse ListMetrics -> Maybe ListMetrics
page ListMetrics
rq AWSResponse ListMetrics
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListMetrics
ListMetricsResponse
rs
            ListMetricsResponse
-> Getting (First Text) ListMetricsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListMetricsResponse -> Const (First Text) ListMetricsResponse
Lens' ListMetricsResponse (Maybe Text)
listMetricsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListMetricsResponse -> Const (First Text) ListMetricsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListMetricsResponse 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 ListMetrics
forall a. Maybe a
Prelude.Nothing
    | Maybe [Metric] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListMetrics
ListMetricsResponse
rs
            ListMetricsResponse
-> Getting (First [Metric]) ListMetricsResponse [Metric]
-> Maybe [Metric]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Metric] -> Const (First [Metric]) (Maybe [Metric]))
-> ListMetricsResponse
-> Const (First [Metric]) ListMetricsResponse
Lens' ListMetricsResponse (Maybe [Metric])
listMetricsResponse_metrics ((Maybe [Metric] -> Const (First [Metric]) (Maybe [Metric]))
 -> ListMetricsResponse
 -> Const (First [Metric]) ListMetricsResponse)
-> (([Metric] -> Const (First [Metric]) [Metric])
    -> Maybe [Metric] -> Const (First [Metric]) (Maybe [Metric]))
-> Getting (First [Metric]) ListMetricsResponse [Metric]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Metric] -> Const (First [Metric]) [Metric])
-> Maybe [Metric] -> Const (First [Metric]) (Maybe [Metric])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListMetrics
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListMetrics -> Maybe ListMetrics
forall a. a -> Maybe a
Prelude.Just (ListMetrics -> Maybe ListMetrics)
-> ListMetrics -> Maybe ListMetrics
forall a b. (a -> b) -> a -> b
Prelude.$
        ListMetrics
rq
          ListMetrics -> (ListMetrics -> ListMetrics) -> ListMetrics
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListMetrics -> Identity ListMetrics
Lens ListMetrics ListMetrics (Maybe Text) (Maybe Text)
listMetrics_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListMetrics -> Identity ListMetrics)
-> Maybe Text -> ListMetrics -> ListMetrics
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListMetrics
ListMetricsResponse
rs
          ListMetricsResponse
-> Getting (First Text) ListMetricsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListMetricsResponse -> Const (First Text) ListMetricsResponse
Lens' ListMetricsResponse (Maybe Text)
listMetricsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListMetricsResponse -> Const (First Text) ListMetricsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListMetricsResponse 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 ListMetrics where
  type AWSResponse ListMetrics = ListMetricsResponse
  request :: ListMetrics -> Request ListMetrics
request = Service -> ListMetrics -> Request ListMetrics
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy ListMetrics
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListMetrics)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse ListMetrics))
-> Logger
-> Service
-> Proxy ListMetrics
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListMetrics)))
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
"ListMetricsResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe [Metric] -> Maybe Text -> Int -> ListMetricsResponse
ListMetricsResponse'
            (Maybe [Metric] -> Maybe Text -> Int -> ListMetricsResponse)
-> Either String (Maybe [Metric])
-> Either String (Maybe Text -> Int -> ListMetricsResponse)
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
"Metrics" 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 [Metric]))
-> Either String (Maybe [Metric])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Metric])
-> [Node] -> Either String (Maybe [Metric])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Metric]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                        )
            Either String (Maybe Text -> Int -> ListMetricsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ListMetricsResponse)
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 (Int -> ListMetricsResponse)
-> Either String Int -> Either String ListMetricsResponse
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 ListMetrics

instance Prelude.NFData ListMetrics

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

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

instance Core.ToQuery ListMetrics where
  toQuery :: ListMetrics -> QueryString
toQuery ListMetrics' {Maybe [DimensionFilter]
Maybe Text
Maybe RecentlyActive
dimensions :: Maybe [DimensionFilter]
recentlyActive :: Maybe RecentlyActive
nextToken :: Maybe Text
namespace :: Maybe Text
metricName :: Maybe Text
$sel:dimensions:ListMetrics' :: ListMetrics -> Maybe [DimensionFilter]
$sel:recentlyActive:ListMetrics' :: ListMetrics -> Maybe RecentlyActive
$sel:nextToken:ListMetrics' :: ListMetrics -> Maybe Text
$sel:namespace:ListMetrics' :: ListMetrics -> Maybe Text
$sel:metricName:ListMetrics' :: ListMetrics -> Maybe 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
"ListMetrics" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-08-01" :: Prelude.ByteString),
        ByteString
"MetricName" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
metricName,
        ByteString
"Namespace" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
namespace,
        ByteString
"NextToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken,
        ByteString
"RecentlyActive" ByteString -> Maybe RecentlyActive -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe RecentlyActive
recentlyActive,
        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 -> [DimensionFilter] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([DimensionFilter] -> QueryString)
-> Maybe [DimensionFilter] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [DimensionFilter]
dimensions)
      ]

-- | /See:/ 'newListMetricsResponse' smart constructor.
data ListMetricsResponse = ListMetricsResponse'
  { -- | The metrics that match your request.
    ListMetricsResponse -> Maybe [Metric]
metrics :: Prelude.Maybe [Metric],
    -- | The token that marks the start of the next batch of returned results.
    ListMetricsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListMetricsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListMetricsResponse -> ListMetricsResponse -> Bool
(ListMetricsResponse -> ListMetricsResponse -> Bool)
-> (ListMetricsResponse -> ListMetricsResponse -> Bool)
-> Eq ListMetricsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListMetricsResponse -> ListMetricsResponse -> Bool
$c/= :: ListMetricsResponse -> ListMetricsResponse -> Bool
== :: ListMetricsResponse -> ListMetricsResponse -> Bool
$c== :: ListMetricsResponse -> ListMetricsResponse -> Bool
Prelude.Eq, ReadPrec [ListMetricsResponse]
ReadPrec ListMetricsResponse
Int -> ReadS ListMetricsResponse
ReadS [ListMetricsResponse]
(Int -> ReadS ListMetricsResponse)
-> ReadS [ListMetricsResponse]
-> ReadPrec ListMetricsResponse
-> ReadPrec [ListMetricsResponse]
-> Read ListMetricsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListMetricsResponse]
$creadListPrec :: ReadPrec [ListMetricsResponse]
readPrec :: ReadPrec ListMetricsResponse
$creadPrec :: ReadPrec ListMetricsResponse
readList :: ReadS [ListMetricsResponse]
$creadList :: ReadS [ListMetricsResponse]
readsPrec :: Int -> ReadS ListMetricsResponse
$creadsPrec :: Int -> ReadS ListMetricsResponse
Prelude.Read, Int -> ListMetricsResponse -> ShowS
[ListMetricsResponse] -> ShowS
ListMetricsResponse -> String
(Int -> ListMetricsResponse -> ShowS)
-> (ListMetricsResponse -> String)
-> ([ListMetricsResponse] -> ShowS)
-> Show ListMetricsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListMetricsResponse] -> ShowS
$cshowList :: [ListMetricsResponse] -> ShowS
show :: ListMetricsResponse -> String
$cshow :: ListMetricsResponse -> String
showsPrec :: Int -> ListMetricsResponse -> ShowS
$cshowsPrec :: Int -> ListMetricsResponse -> ShowS
Prelude.Show, (forall x. ListMetricsResponse -> Rep ListMetricsResponse x)
-> (forall x. Rep ListMetricsResponse x -> ListMetricsResponse)
-> Generic ListMetricsResponse
forall x. Rep ListMetricsResponse x -> ListMetricsResponse
forall x. ListMetricsResponse -> Rep ListMetricsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListMetricsResponse x -> ListMetricsResponse
$cfrom :: forall x. ListMetricsResponse -> Rep ListMetricsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListMetricsResponse' 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:
--
-- 'metrics', 'listMetricsResponse_metrics' - The metrics that match your request.
--
-- 'nextToken', 'listMetricsResponse_nextToken' - The token that marks the start of the next batch of returned results.
--
-- 'httpStatus', 'listMetricsResponse_httpStatus' - The response's http status code.
newListMetricsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListMetricsResponse
newListMetricsResponse :: Int -> ListMetricsResponse
newListMetricsResponse Int
pHttpStatus_ =
  ListMetricsResponse' :: Maybe [Metric] -> Maybe Text -> Int -> ListMetricsResponse
ListMetricsResponse'
    { $sel:metrics:ListMetricsResponse' :: Maybe [Metric]
metrics = Maybe [Metric]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListMetricsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListMetricsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The metrics that match your request.
listMetricsResponse_metrics :: Lens.Lens' ListMetricsResponse (Prelude.Maybe [Metric])
listMetricsResponse_metrics :: (Maybe [Metric] -> f (Maybe [Metric]))
-> ListMetricsResponse -> f ListMetricsResponse
listMetricsResponse_metrics = (ListMetricsResponse -> Maybe [Metric])
-> (ListMetricsResponse -> Maybe [Metric] -> ListMetricsResponse)
-> Lens' ListMetricsResponse (Maybe [Metric])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListMetricsResponse' {Maybe [Metric]
metrics :: Maybe [Metric]
$sel:metrics:ListMetricsResponse' :: ListMetricsResponse -> Maybe [Metric]
metrics} -> Maybe [Metric]
metrics) (\s :: ListMetricsResponse
s@ListMetricsResponse' {} Maybe [Metric]
a -> ListMetricsResponse
s {$sel:metrics:ListMetricsResponse' :: Maybe [Metric]
metrics = Maybe [Metric]
a} :: ListMetricsResponse) ((Maybe [Metric] -> f (Maybe [Metric]))
 -> ListMetricsResponse -> f ListMetricsResponse)
-> ((Maybe [Metric] -> f (Maybe [Metric]))
    -> Maybe [Metric] -> f (Maybe [Metric]))
-> (Maybe [Metric] -> f (Maybe [Metric]))
-> ListMetricsResponse
-> f ListMetricsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Metric] [Metric] [Metric] [Metric]
-> Iso
     (Maybe [Metric]) (Maybe [Metric]) (Maybe [Metric]) (Maybe [Metric])
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 [Metric] [Metric] [Metric] [Metric]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

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

instance Prelude.NFData ListMetricsResponse