{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Pi.Types.MetricKeyDataPoints
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Pi.Types.MetricKeyDataPoints where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pi.Types.DataPoint
import Amazonka.Pi.Types.ResponseResourceMetricKey
import qualified Amazonka.Prelude as Prelude

-- | A time-ordered series of data points, corresponding to a dimension of a
-- Performance Insights metric.
--
-- /See:/ 'newMetricKeyDataPoints' smart constructor.
data MetricKeyDataPoints = MetricKeyDataPoints'
  { -- | An array of timestamp-value pairs, representing measurements over a
    -- period of time.
    MetricKeyDataPoints -> Maybe [DataPoint]
dataPoints :: Prelude.Maybe [DataPoint],
    -- | The dimension(s) to which the data points apply.
    MetricKeyDataPoints -> Maybe ResponseResourceMetricKey
key :: Prelude.Maybe ResponseResourceMetricKey
  }
  deriving (MetricKeyDataPoints -> MetricKeyDataPoints -> Bool
(MetricKeyDataPoints -> MetricKeyDataPoints -> Bool)
-> (MetricKeyDataPoints -> MetricKeyDataPoints -> Bool)
-> Eq MetricKeyDataPoints
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetricKeyDataPoints -> MetricKeyDataPoints -> Bool
$c/= :: MetricKeyDataPoints -> MetricKeyDataPoints -> Bool
== :: MetricKeyDataPoints -> MetricKeyDataPoints -> Bool
$c== :: MetricKeyDataPoints -> MetricKeyDataPoints -> Bool
Prelude.Eq, ReadPrec [MetricKeyDataPoints]
ReadPrec MetricKeyDataPoints
Int -> ReadS MetricKeyDataPoints
ReadS [MetricKeyDataPoints]
(Int -> ReadS MetricKeyDataPoints)
-> ReadS [MetricKeyDataPoints]
-> ReadPrec MetricKeyDataPoints
-> ReadPrec [MetricKeyDataPoints]
-> Read MetricKeyDataPoints
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetricKeyDataPoints]
$creadListPrec :: ReadPrec [MetricKeyDataPoints]
readPrec :: ReadPrec MetricKeyDataPoints
$creadPrec :: ReadPrec MetricKeyDataPoints
readList :: ReadS [MetricKeyDataPoints]
$creadList :: ReadS [MetricKeyDataPoints]
readsPrec :: Int -> ReadS MetricKeyDataPoints
$creadsPrec :: Int -> ReadS MetricKeyDataPoints
Prelude.Read, Int -> MetricKeyDataPoints -> ShowS
[MetricKeyDataPoints] -> ShowS
MetricKeyDataPoints -> String
(Int -> MetricKeyDataPoints -> ShowS)
-> (MetricKeyDataPoints -> String)
-> ([MetricKeyDataPoints] -> ShowS)
-> Show MetricKeyDataPoints
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetricKeyDataPoints] -> ShowS
$cshowList :: [MetricKeyDataPoints] -> ShowS
show :: MetricKeyDataPoints -> String
$cshow :: MetricKeyDataPoints -> String
showsPrec :: Int -> MetricKeyDataPoints -> ShowS
$cshowsPrec :: Int -> MetricKeyDataPoints -> ShowS
Prelude.Show, (forall x. MetricKeyDataPoints -> Rep MetricKeyDataPoints x)
-> (forall x. Rep MetricKeyDataPoints x -> MetricKeyDataPoints)
-> Generic MetricKeyDataPoints
forall x. Rep MetricKeyDataPoints x -> MetricKeyDataPoints
forall x. MetricKeyDataPoints -> Rep MetricKeyDataPoints x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetricKeyDataPoints x -> MetricKeyDataPoints
$cfrom :: forall x. MetricKeyDataPoints -> Rep MetricKeyDataPoints x
Prelude.Generic)

-- |
-- Create a value of 'MetricKeyDataPoints' 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', 'metricKeyDataPoints_dataPoints' - An array of timestamp-value pairs, representing measurements over a
-- period of time.
--
-- 'key', 'metricKeyDataPoints_key' - The dimension(s) to which the data points apply.
newMetricKeyDataPoints ::
  MetricKeyDataPoints
newMetricKeyDataPoints :: MetricKeyDataPoints
newMetricKeyDataPoints =
  MetricKeyDataPoints' :: Maybe [DataPoint]
-> Maybe ResponseResourceMetricKey -> MetricKeyDataPoints
MetricKeyDataPoints'
    { $sel:dataPoints:MetricKeyDataPoints' :: Maybe [DataPoint]
dataPoints = Maybe [DataPoint]
forall a. Maybe a
Prelude.Nothing,
      $sel:key:MetricKeyDataPoints' :: Maybe ResponseResourceMetricKey
key = Maybe ResponseResourceMetricKey
forall a. Maybe a
Prelude.Nothing
    }

-- | An array of timestamp-value pairs, representing measurements over a
-- period of time.
metricKeyDataPoints_dataPoints :: Lens.Lens' MetricKeyDataPoints (Prelude.Maybe [DataPoint])
metricKeyDataPoints_dataPoints :: (Maybe [DataPoint] -> f (Maybe [DataPoint]))
-> MetricKeyDataPoints -> f MetricKeyDataPoints
metricKeyDataPoints_dataPoints = (MetricKeyDataPoints -> Maybe [DataPoint])
-> (MetricKeyDataPoints
    -> Maybe [DataPoint] -> MetricKeyDataPoints)
-> Lens
     MetricKeyDataPoints
     MetricKeyDataPoints
     (Maybe [DataPoint])
     (Maybe [DataPoint])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricKeyDataPoints' {Maybe [DataPoint]
dataPoints :: Maybe [DataPoint]
$sel:dataPoints:MetricKeyDataPoints' :: MetricKeyDataPoints -> Maybe [DataPoint]
dataPoints} -> Maybe [DataPoint]
dataPoints) (\s :: MetricKeyDataPoints
s@MetricKeyDataPoints' {} Maybe [DataPoint]
a -> MetricKeyDataPoints
s {$sel:dataPoints:MetricKeyDataPoints' :: Maybe [DataPoint]
dataPoints = Maybe [DataPoint]
a} :: MetricKeyDataPoints) ((Maybe [DataPoint] -> f (Maybe [DataPoint]))
 -> MetricKeyDataPoints -> f MetricKeyDataPoints)
-> ((Maybe [DataPoint] -> f (Maybe [DataPoint]))
    -> Maybe [DataPoint] -> f (Maybe [DataPoint]))
-> (Maybe [DataPoint] -> f (Maybe [DataPoint]))
-> MetricKeyDataPoints
-> f MetricKeyDataPoints
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

-- | The dimension(s) to which the data points apply.
metricKeyDataPoints_key :: Lens.Lens' MetricKeyDataPoints (Prelude.Maybe ResponseResourceMetricKey)
metricKeyDataPoints_key :: (Maybe ResponseResourceMetricKey
 -> f (Maybe ResponseResourceMetricKey))
-> MetricKeyDataPoints -> f MetricKeyDataPoints
metricKeyDataPoints_key = (MetricKeyDataPoints -> Maybe ResponseResourceMetricKey)
-> (MetricKeyDataPoints
    -> Maybe ResponseResourceMetricKey -> MetricKeyDataPoints)
-> Lens
     MetricKeyDataPoints
     MetricKeyDataPoints
     (Maybe ResponseResourceMetricKey)
     (Maybe ResponseResourceMetricKey)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricKeyDataPoints' {Maybe ResponseResourceMetricKey
key :: Maybe ResponseResourceMetricKey
$sel:key:MetricKeyDataPoints' :: MetricKeyDataPoints -> Maybe ResponseResourceMetricKey
key} -> Maybe ResponseResourceMetricKey
key) (\s :: MetricKeyDataPoints
s@MetricKeyDataPoints' {} Maybe ResponseResourceMetricKey
a -> MetricKeyDataPoints
s {$sel:key:MetricKeyDataPoints' :: Maybe ResponseResourceMetricKey
key = Maybe ResponseResourceMetricKey
a} :: MetricKeyDataPoints)

instance Core.FromJSON MetricKeyDataPoints where
  parseJSON :: Value -> Parser MetricKeyDataPoints
parseJSON =
    String
-> (Object -> Parser MetricKeyDataPoints)
-> Value
-> Parser MetricKeyDataPoints
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MetricKeyDataPoints"
      ( \Object
x ->
          Maybe [DataPoint]
-> Maybe ResponseResourceMetricKey -> MetricKeyDataPoints
MetricKeyDataPoints'
            (Maybe [DataPoint]
 -> Maybe ResponseResourceMetricKey -> MetricKeyDataPoints)
-> Parser (Maybe [DataPoint])
-> Parser (Maybe ResponseResourceMetricKey -> MetricKeyDataPoints)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [DataPoint]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DataPoints" Parser (Maybe (Maybe [DataPoint]))
-> Maybe [DataPoint] -> Parser (Maybe [DataPoint])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [DataPoint]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe ResponseResourceMetricKey -> MetricKeyDataPoints)
-> Parser (Maybe ResponseResourceMetricKey)
-> Parser MetricKeyDataPoints
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ResponseResourceMetricKey)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Key")
      )

instance Prelude.Hashable MetricKeyDataPoints

instance Prelude.NFData MetricKeyDataPoints