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

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

-- | An object that includes the requested dimension key values and
-- aggregated metric values within a dimension group.
--
-- /See:/ 'newDimensionKeyDescription' smart constructor.
data DimensionKeyDescription = DimensionKeyDescription'
  { -- | A map that contains the value for each additional metric.
    DimensionKeyDescription -> Maybe (HashMap Text Double)
additionalMetrics :: Prelude.Maybe (Prelude.HashMap Prelude.Text 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),
    -- | If @PartitionBy@ was specified, @PartitionKeys@ contains the dimensions
    -- that were.
    DimensionKeyDescription -> Maybe [Double]
partitions :: Prelude.Maybe [Prelude.Double],
    -- | The aggregated metric value for the dimensions, over the requested time
    -- range.
    DimensionKeyDescription -> Maybe Double
total :: Prelude.Maybe Prelude.Double
  }
  deriving (DimensionKeyDescription -> DimensionKeyDescription -> Bool
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]
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
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. 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:
--
-- 'additionalMetrics', 'dimensionKeyDescription_additionalMetrics' - A map that contains the value for each additional metric.
--
-- 'dimensions', 'dimensionKeyDescription_dimensions' - A map of name-value pairs for the dimensions in the group.
--
-- 'partitions', 'dimensionKeyDescription_partitions' - If @PartitionBy@ was specified, @PartitionKeys@ contains the dimensions
-- that were.
--
-- 'total', 'dimensionKeyDescription_total' - The aggregated metric value for the dimensions, over the requested time
-- range.
newDimensionKeyDescription ::
  DimensionKeyDescription
newDimensionKeyDescription :: DimensionKeyDescription
newDimensionKeyDescription =
  DimensionKeyDescription'
    { $sel:additionalMetrics:DimensionKeyDescription' :: Maybe (HashMap Text Double)
additionalMetrics =
        forall a. Maybe a
Prelude.Nothing,
      $sel:dimensions:DimensionKeyDescription' :: Maybe (HashMap Text Text)
dimensions = forall a. Maybe a
Prelude.Nothing,
      $sel:partitions:DimensionKeyDescription' :: Maybe [Double]
partitions = forall a. Maybe a
Prelude.Nothing,
      $sel:total:DimensionKeyDescription' :: Maybe Double
total = forall a. Maybe a
Prelude.Nothing
    }

-- | A map that contains the value for each additional metric.
dimensionKeyDescription_additionalMetrics :: Lens.Lens' DimensionKeyDescription (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Double))
dimensionKeyDescription_additionalMetrics :: Lens' DimensionKeyDescription (Maybe (HashMap Text Double))
dimensionKeyDescription_additionalMetrics = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DimensionKeyDescription' {Maybe (HashMap Text Double)
additionalMetrics :: Maybe (HashMap Text Double)
$sel:additionalMetrics:DimensionKeyDescription' :: DimensionKeyDescription -> Maybe (HashMap Text Double)
additionalMetrics} -> Maybe (HashMap Text Double)
additionalMetrics) (\s :: DimensionKeyDescription
s@DimensionKeyDescription' {} Maybe (HashMap Text Double)
a -> DimensionKeyDescription
s {$sel:additionalMetrics:DimensionKeyDescription' :: Maybe (HashMap Text Double)
additionalMetrics = Maybe (HashMap Text Double)
a} :: DimensionKeyDescription) 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

-- | 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 :: Lens' DimensionKeyDescription (Maybe (HashMap Text Text))
dimensionKeyDescription_dimensions = 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) 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

-- | If @PartitionBy@ was specified, @PartitionKeys@ contains the dimensions
-- that were.
dimensionKeyDescription_partitions :: Lens.Lens' DimensionKeyDescription (Prelude.Maybe [Prelude.Double])
dimensionKeyDescription_partitions :: Lens' DimensionKeyDescription (Maybe [Double])
dimensionKeyDescription_partitions = 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) 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 aggregated metric value for the dimensions, over the requested time
-- range.
dimensionKeyDescription_total :: Lens.Lens' DimensionKeyDescription (Prelude.Maybe Prelude.Double)
dimensionKeyDescription_total :: Lens' DimensionKeyDescription (Maybe Double)
dimensionKeyDescription_total = 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)

instance Data.FromJSON DimensionKeyDescription where
  parseJSON :: Value -> Parser DimensionKeyDescription
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DimensionKeyDescription"
      ( \Object
x ->
          Maybe (HashMap Text Double)
-> Maybe (HashMap Text Text)
-> Maybe [Double]
-> Maybe Double
-> DimensionKeyDescription
DimensionKeyDescription'
            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
"AdditionalMetrics"
                            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
"Dimensions" 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
"Partitions" 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
"Total")
      )

instance Prelude.Hashable DimensionKeyDescription where
  hashWithSalt :: Int -> DimensionKeyDescription -> Int
hashWithSalt Int
_salt DimensionKeyDescription' {Maybe Double
Maybe [Double]
Maybe (HashMap Text Double)
Maybe (HashMap Text Text)
total :: Maybe Double
partitions :: Maybe [Double]
dimensions :: Maybe (HashMap Text Text)
additionalMetrics :: Maybe (HashMap Text Double)
$sel:total:DimensionKeyDescription' :: DimensionKeyDescription -> Maybe Double
$sel:partitions:DimensionKeyDescription' :: DimensionKeyDescription -> Maybe [Double]
$sel:dimensions:DimensionKeyDescription' :: DimensionKeyDescription -> Maybe (HashMap Text Text)
$sel:additionalMetrics:DimensionKeyDescription' :: DimensionKeyDescription -> Maybe (HashMap Text Double)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Double)
additionalMetrics
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
dimensions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Double]
partitions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
total

instance Prelude.NFData DimensionKeyDescription where
  rnf :: DimensionKeyDescription -> ()
rnf DimensionKeyDescription' {Maybe Double
Maybe [Double]
Maybe (HashMap Text Double)
Maybe (HashMap Text Text)
total :: Maybe Double
partitions :: Maybe [Double]
dimensions :: Maybe (HashMap Text Text)
additionalMetrics :: Maybe (HashMap Text Double)
$sel:total:DimensionKeyDescription' :: DimensionKeyDescription -> Maybe Double
$sel:partitions:DimensionKeyDescription' :: DimensionKeyDescription -> Maybe [Double]
$sel:dimensions:DimensionKeyDescription' :: DimensionKeyDescription -> Maybe (HashMap Text Text)
$sel:additionalMetrics:DimensionKeyDescription' :: DimensionKeyDescription -> Maybe (HashMap Text Double)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Double)
additionalMetrics
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
dimensions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Double]
partitions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
total