{-# 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.Connect.Types.HistoricalMetricResult
-- 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.Connect.Types.HistoricalMetricResult where

import Amazonka.Connect.Types.Dimensions
import Amazonka.Connect.Types.HistoricalMetricData
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the historical metrics retrieved.
--
-- /See:/ 'newHistoricalMetricResult' smart constructor.
data HistoricalMetricResult = HistoricalMetricResult'
  { -- | The set of metrics.
    HistoricalMetricResult -> Maybe [HistoricalMetricData]
collections :: Prelude.Maybe [HistoricalMetricData],
    -- | The dimension for the metrics.
    HistoricalMetricResult -> Maybe Dimensions
dimensions :: Prelude.Maybe Dimensions
  }
  deriving (HistoricalMetricResult -> HistoricalMetricResult -> Bool
(HistoricalMetricResult -> HistoricalMetricResult -> Bool)
-> (HistoricalMetricResult -> HistoricalMetricResult -> Bool)
-> Eq HistoricalMetricResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HistoricalMetricResult -> HistoricalMetricResult -> Bool
$c/= :: HistoricalMetricResult -> HistoricalMetricResult -> Bool
== :: HistoricalMetricResult -> HistoricalMetricResult -> Bool
$c== :: HistoricalMetricResult -> HistoricalMetricResult -> Bool
Prelude.Eq, ReadPrec [HistoricalMetricResult]
ReadPrec HistoricalMetricResult
Int -> ReadS HistoricalMetricResult
ReadS [HistoricalMetricResult]
(Int -> ReadS HistoricalMetricResult)
-> ReadS [HistoricalMetricResult]
-> ReadPrec HistoricalMetricResult
-> ReadPrec [HistoricalMetricResult]
-> Read HistoricalMetricResult
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HistoricalMetricResult]
$creadListPrec :: ReadPrec [HistoricalMetricResult]
readPrec :: ReadPrec HistoricalMetricResult
$creadPrec :: ReadPrec HistoricalMetricResult
readList :: ReadS [HistoricalMetricResult]
$creadList :: ReadS [HistoricalMetricResult]
readsPrec :: Int -> ReadS HistoricalMetricResult
$creadsPrec :: Int -> ReadS HistoricalMetricResult
Prelude.Read, Int -> HistoricalMetricResult -> ShowS
[HistoricalMetricResult] -> ShowS
HistoricalMetricResult -> String
(Int -> HistoricalMetricResult -> ShowS)
-> (HistoricalMetricResult -> String)
-> ([HistoricalMetricResult] -> ShowS)
-> Show HistoricalMetricResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HistoricalMetricResult] -> ShowS
$cshowList :: [HistoricalMetricResult] -> ShowS
show :: HistoricalMetricResult -> String
$cshow :: HistoricalMetricResult -> String
showsPrec :: Int -> HistoricalMetricResult -> ShowS
$cshowsPrec :: Int -> HistoricalMetricResult -> ShowS
Prelude.Show, (forall x. HistoricalMetricResult -> Rep HistoricalMetricResult x)
-> (forall x.
    Rep HistoricalMetricResult x -> HistoricalMetricResult)
-> Generic HistoricalMetricResult
forall x. Rep HistoricalMetricResult x -> HistoricalMetricResult
forall x. HistoricalMetricResult -> Rep HistoricalMetricResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HistoricalMetricResult x -> HistoricalMetricResult
$cfrom :: forall x. HistoricalMetricResult -> Rep HistoricalMetricResult x
Prelude.Generic)

-- |
-- Create a value of 'HistoricalMetricResult' 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:
--
-- 'collections', 'historicalMetricResult_collections' - The set of metrics.
--
-- 'dimensions', 'historicalMetricResult_dimensions' - The dimension for the metrics.
newHistoricalMetricResult ::
  HistoricalMetricResult
newHistoricalMetricResult :: HistoricalMetricResult
newHistoricalMetricResult =
  HistoricalMetricResult' :: Maybe [HistoricalMetricData]
-> Maybe Dimensions -> HistoricalMetricResult
HistoricalMetricResult'
    { $sel:collections:HistoricalMetricResult' :: Maybe [HistoricalMetricData]
collections =
        Maybe [HistoricalMetricData]
forall a. Maybe a
Prelude.Nothing,
      $sel:dimensions:HistoricalMetricResult' :: Maybe Dimensions
dimensions = Maybe Dimensions
forall a. Maybe a
Prelude.Nothing
    }

-- | The set of metrics.
historicalMetricResult_collections :: Lens.Lens' HistoricalMetricResult (Prelude.Maybe [HistoricalMetricData])
historicalMetricResult_collections :: (Maybe [HistoricalMetricData] -> f (Maybe [HistoricalMetricData]))
-> HistoricalMetricResult -> f HistoricalMetricResult
historicalMetricResult_collections = (HistoricalMetricResult -> Maybe [HistoricalMetricData])
-> (HistoricalMetricResult
    -> Maybe [HistoricalMetricData] -> HistoricalMetricResult)
-> Lens
     HistoricalMetricResult
     HistoricalMetricResult
     (Maybe [HistoricalMetricData])
     (Maybe [HistoricalMetricData])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HistoricalMetricResult' {Maybe [HistoricalMetricData]
collections :: Maybe [HistoricalMetricData]
$sel:collections:HistoricalMetricResult' :: HistoricalMetricResult -> Maybe [HistoricalMetricData]
collections} -> Maybe [HistoricalMetricData]
collections) (\s :: HistoricalMetricResult
s@HistoricalMetricResult' {} Maybe [HistoricalMetricData]
a -> HistoricalMetricResult
s {$sel:collections:HistoricalMetricResult' :: Maybe [HistoricalMetricData]
collections = Maybe [HistoricalMetricData]
a} :: HistoricalMetricResult) ((Maybe [HistoricalMetricData] -> f (Maybe [HistoricalMetricData]))
 -> HistoricalMetricResult -> f HistoricalMetricResult)
-> ((Maybe [HistoricalMetricData]
     -> f (Maybe [HistoricalMetricData]))
    -> Maybe [HistoricalMetricData]
    -> f (Maybe [HistoricalMetricData]))
-> (Maybe [HistoricalMetricData]
    -> f (Maybe [HistoricalMetricData]))
-> HistoricalMetricResult
-> f HistoricalMetricResult
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [HistoricalMetricData]
  [HistoricalMetricData]
  [HistoricalMetricData]
  [HistoricalMetricData]
-> Iso
     (Maybe [HistoricalMetricData])
     (Maybe [HistoricalMetricData])
     (Maybe [HistoricalMetricData])
     (Maybe [HistoricalMetricData])
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
  [HistoricalMetricData]
  [HistoricalMetricData]
  [HistoricalMetricData]
  [HistoricalMetricData]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The dimension for the metrics.
historicalMetricResult_dimensions :: Lens.Lens' HistoricalMetricResult (Prelude.Maybe Dimensions)
historicalMetricResult_dimensions :: (Maybe Dimensions -> f (Maybe Dimensions))
-> HistoricalMetricResult -> f HistoricalMetricResult
historicalMetricResult_dimensions = (HistoricalMetricResult -> Maybe Dimensions)
-> (HistoricalMetricResult
    -> Maybe Dimensions -> HistoricalMetricResult)
-> Lens
     HistoricalMetricResult
     HistoricalMetricResult
     (Maybe Dimensions)
     (Maybe Dimensions)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HistoricalMetricResult' {Maybe Dimensions
dimensions :: Maybe Dimensions
$sel:dimensions:HistoricalMetricResult' :: HistoricalMetricResult -> Maybe Dimensions
dimensions} -> Maybe Dimensions
dimensions) (\s :: HistoricalMetricResult
s@HistoricalMetricResult' {} Maybe Dimensions
a -> HistoricalMetricResult
s {$sel:dimensions:HistoricalMetricResult' :: Maybe Dimensions
dimensions = Maybe Dimensions
a} :: HistoricalMetricResult)

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

instance Prelude.Hashable HistoricalMetricResult

instance Prelude.NFData HistoricalMetricResult