{-# 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.DimensionKeyDescription
-- 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.DimensionKeyDescription where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An array of descriptions and aggregated values for each dimension within
-- a dimension group.
--
-- /See:/ 'newDimensionKeyDescription' smart constructor.
data DimensionKeyDescription = DimensionKeyDescription'
  { -- | If @PartitionBy@ was specified, @PartitionKeys@ contains the dimensions
    -- that were.
    DimensionKeyDescription -> Maybe [Double]
partitions :: Prelude.Maybe [Prelude.Double],
    -- | The aggregated metric value for the dimension(s), over the requested
    -- time range.
    DimensionKeyDescription -> Maybe Double
total :: Prelude.Maybe Prelude.Double,
    -- | A map of name-value pairs for the dimensions in the group.
    DimensionKeyDescription -> Maybe (HashMap Text Text)
dimensions :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (DimensionKeyDescription -> DimensionKeyDescription -> Bool
(DimensionKeyDescription -> DimensionKeyDescription -> Bool)
-> (DimensionKeyDescription -> DimensionKeyDescription -> Bool)
-> Eq DimensionKeyDescription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DimensionKeyDescription -> DimensionKeyDescription -> Bool
$c/= :: DimensionKeyDescription -> DimensionKeyDescription -> Bool
== :: DimensionKeyDescription -> DimensionKeyDescription -> Bool
$c== :: DimensionKeyDescription -> DimensionKeyDescription -> Bool
Prelude.Eq, ReadPrec [DimensionKeyDescription]
ReadPrec DimensionKeyDescription
Int -> ReadS DimensionKeyDescription
ReadS [DimensionKeyDescription]
(Int -> ReadS DimensionKeyDescription)
-> ReadS [DimensionKeyDescription]
-> ReadPrec DimensionKeyDescription
-> ReadPrec [DimensionKeyDescription]
-> Read DimensionKeyDescription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DimensionKeyDescription]
$creadListPrec :: ReadPrec [DimensionKeyDescription]
readPrec :: ReadPrec DimensionKeyDescription
$creadPrec :: ReadPrec DimensionKeyDescription
readList :: ReadS [DimensionKeyDescription]
$creadList :: ReadS [DimensionKeyDescription]
readsPrec :: Int -> ReadS DimensionKeyDescription
$creadsPrec :: Int -> ReadS DimensionKeyDescription
Prelude.Read, Int -> DimensionKeyDescription -> ShowS
[DimensionKeyDescription] -> ShowS
DimensionKeyDescription -> String
(Int -> DimensionKeyDescription -> ShowS)
-> (DimensionKeyDescription -> String)
-> ([DimensionKeyDescription] -> ShowS)
-> Show DimensionKeyDescription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DimensionKeyDescription] -> ShowS
$cshowList :: [DimensionKeyDescription] -> ShowS
show :: DimensionKeyDescription -> String
$cshow :: DimensionKeyDescription -> String
showsPrec :: Int -> DimensionKeyDescription -> ShowS
$cshowsPrec :: Int -> DimensionKeyDescription -> ShowS
Prelude.Show, (forall x.
 DimensionKeyDescription -> Rep DimensionKeyDescription x)
-> (forall x.
    Rep DimensionKeyDescription x -> DimensionKeyDescription)
-> Generic DimensionKeyDescription
forall x. Rep DimensionKeyDescription x -> DimensionKeyDescription
forall x. DimensionKeyDescription -> Rep DimensionKeyDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DimensionKeyDescription x -> DimensionKeyDescription
$cfrom :: forall x. DimensionKeyDescription -> Rep DimensionKeyDescription x
Prelude.Generic)

-- |
-- Create a value of 'DimensionKeyDescription' 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:
--
-- 'partitions', 'dimensionKeyDescription_partitions' - If @PartitionBy@ was specified, @PartitionKeys@ contains the dimensions
-- that were.
--
-- 'total', 'dimensionKeyDescription_total' - The aggregated metric value for the dimension(s), over the requested
-- time range.
--
-- 'dimensions', 'dimensionKeyDescription_dimensions' - A map of name-value pairs for the dimensions in the group.
newDimensionKeyDescription ::
  DimensionKeyDescription
newDimensionKeyDescription :: DimensionKeyDescription
newDimensionKeyDescription =
  DimensionKeyDescription' :: Maybe [Double]
-> Maybe Double
-> Maybe (HashMap Text Text)
-> DimensionKeyDescription
DimensionKeyDescription'
    { $sel:partitions:DimensionKeyDescription' :: Maybe [Double]
partitions =
        Maybe [Double]
forall a. Maybe a
Prelude.Nothing,
      $sel:total:DimensionKeyDescription' :: Maybe Double
total = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:dimensions:DimensionKeyDescription' :: Maybe (HashMap Text Text)
dimensions = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | If @PartitionBy@ was specified, @PartitionKeys@ contains the dimensions
-- that were.
dimensionKeyDescription_partitions :: Lens.Lens' DimensionKeyDescription (Prelude.Maybe [Prelude.Double])
dimensionKeyDescription_partitions :: (Maybe [Double] -> f (Maybe [Double]))
-> DimensionKeyDescription -> f DimensionKeyDescription
dimensionKeyDescription_partitions = (DimensionKeyDescription -> Maybe [Double])
-> (DimensionKeyDescription
    -> Maybe [Double] -> DimensionKeyDescription)
-> Lens
     DimensionKeyDescription
     DimensionKeyDescription
     (Maybe [Double])
     (Maybe [Double])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DimensionKeyDescription' {Maybe [Double]
partitions :: Maybe [Double]
$sel:partitions:DimensionKeyDescription' :: DimensionKeyDescription -> Maybe [Double]
partitions} -> Maybe [Double]
partitions) (\s :: DimensionKeyDescription
s@DimensionKeyDescription' {} Maybe [Double]
a -> DimensionKeyDescription
s {$sel:partitions:DimensionKeyDescription' :: Maybe [Double]
partitions = Maybe [Double]
a} :: DimensionKeyDescription) ((Maybe [Double] -> f (Maybe [Double]))
 -> DimensionKeyDescription -> f DimensionKeyDescription)
-> ((Maybe [Double] -> f (Maybe [Double]))
    -> Maybe [Double] -> f (Maybe [Double]))
-> (Maybe [Double] -> f (Maybe [Double]))
-> DimensionKeyDescription
-> f DimensionKeyDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Double] [Double] [Double] [Double]
-> Iso
     (Maybe [Double]) (Maybe [Double]) (Maybe [Double]) (Maybe [Double])
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 [Double] [Double] [Double] [Double]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The aggregated metric value for the dimension(s), over the requested
-- time range.
dimensionKeyDescription_total :: Lens.Lens' DimensionKeyDescription (Prelude.Maybe Prelude.Double)
dimensionKeyDescription_total :: (Maybe Double -> f (Maybe Double))
-> DimensionKeyDescription -> f DimensionKeyDescription
dimensionKeyDescription_total = (DimensionKeyDescription -> Maybe Double)
-> (DimensionKeyDescription
    -> Maybe Double -> DimensionKeyDescription)
-> Lens
     DimensionKeyDescription
     DimensionKeyDescription
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DimensionKeyDescription' {Maybe Double
total :: Maybe Double
$sel:total:DimensionKeyDescription' :: DimensionKeyDescription -> Maybe Double
total} -> Maybe Double
total) (\s :: DimensionKeyDescription
s@DimensionKeyDescription' {} Maybe Double
a -> DimensionKeyDescription
s {$sel:total:DimensionKeyDescription' :: Maybe Double
total = Maybe Double
a} :: DimensionKeyDescription)

-- | A map of name-value pairs for the dimensions in the group.
dimensionKeyDescription_dimensions :: Lens.Lens' DimensionKeyDescription (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
dimensionKeyDescription_dimensions :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> DimensionKeyDescription -> f DimensionKeyDescription
dimensionKeyDescription_dimensions = (DimensionKeyDescription -> Maybe (HashMap Text Text))
-> (DimensionKeyDescription
    -> Maybe (HashMap Text Text) -> DimensionKeyDescription)
-> Lens
     DimensionKeyDescription
     DimensionKeyDescription
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DimensionKeyDescription' {Maybe (HashMap Text Text)
dimensions :: Maybe (HashMap Text Text)
$sel:dimensions:DimensionKeyDescription' :: DimensionKeyDescription -> Maybe (HashMap Text Text)
dimensions} -> Maybe (HashMap Text Text)
dimensions) (\s :: DimensionKeyDescription
s@DimensionKeyDescription' {} Maybe (HashMap Text Text)
a -> DimensionKeyDescription
s {$sel:dimensions:DimensionKeyDescription' :: Maybe (HashMap Text Text)
dimensions = Maybe (HashMap Text Text)
a} :: DimensionKeyDescription) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> DimensionKeyDescription -> f DimensionKeyDescription)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> DimensionKeyDescription
-> f DimensionKeyDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text 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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable DimensionKeyDescription

instance Prelude.NFData DimensionKeyDescription