{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Pi.Types.MetricKeyDataPoints where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 dimensions to which the data points apply.
    MetricKeyDataPoints -> Maybe ResponseResourceMetricKey
key :: Prelude.Maybe ResponseResourceMetricKey
  }
  deriving (MetricKeyDataPoints -> MetricKeyDataPoints -> Bool
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]
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
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. 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 dimensions to which the data points apply.
newMetricKeyDataPoints ::
  MetricKeyDataPoints
newMetricKeyDataPoints :: MetricKeyDataPoints
newMetricKeyDataPoints =
  MetricKeyDataPoints'
    { $sel:dataPoints:MetricKeyDataPoints' :: Maybe [DataPoint]
dataPoints = forall a. Maybe a
Prelude.Nothing,
      $sel:key:MetricKeyDataPoints' :: Maybe ResponseResourceMetricKey
key = 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 :: Lens' MetricKeyDataPoints (Maybe [DataPoint])
metricKeyDataPoints_dataPoints = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The dimensions to which the data points apply.
metricKeyDataPoints_key :: Lens.Lens' MetricKeyDataPoints (Prelude.Maybe ResponseResourceMetricKey)
metricKeyDataPoints_key :: Lens' MetricKeyDataPoints (Maybe ResponseResourceMetricKey)
metricKeyDataPoints_key = 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 Data.FromJSON MetricKeyDataPoints where
  parseJSON :: Value -> Parser MetricKeyDataPoints
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MetricKeyDataPoints"
      ( \Object
x ->
          Maybe [DataPoint]
-> Maybe ResponseResourceMetricKey -> MetricKeyDataPoints
MetricKeyDataPoints'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"DataPoints" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Key")
      )

instance Prelude.Hashable MetricKeyDataPoints where
  hashWithSalt :: Int -> MetricKeyDataPoints -> Int
hashWithSalt Int
_salt MetricKeyDataPoints' {Maybe [DataPoint]
Maybe ResponseResourceMetricKey
key :: Maybe ResponseResourceMetricKey
dataPoints :: Maybe [DataPoint]
$sel:key:MetricKeyDataPoints' :: MetricKeyDataPoints -> Maybe ResponseResourceMetricKey
$sel:dataPoints:MetricKeyDataPoints' :: MetricKeyDataPoints -> Maybe [DataPoint]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [DataPoint]
dataPoints
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ResponseResourceMetricKey
key

instance Prelude.NFData MetricKeyDataPoints where
  rnf :: MetricKeyDataPoints -> ()
rnf MetricKeyDataPoints' {Maybe [DataPoint]
Maybe ResponseResourceMetricKey
key :: Maybe ResponseResourceMetricKey
dataPoints :: Maybe [DataPoint]
$sel:key:MetricKeyDataPoints' :: MetricKeyDataPoints -> Maybe ResponseResourceMetricKey
$sel:dataPoints:MetricKeyDataPoints' :: MetricKeyDataPoints -> Maybe [DataPoint]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [DataPoint]
dataPoints
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ResponseResourceMetricKey
key