{-# 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.TimeStreamWrite.Types.Dimension
-- 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.TimeStreamWrite.Types.Dimension 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
import Amazonka.TimeStreamWrite.Types.DimensionValueType

-- | Dimension represents the meta data attributes of the time series. For
-- example, the name and availability zone of an EC2 instance or the name
-- of the manufacturer of a wind turbine are dimensions.
--
-- /See:/ 'newDimension' smart constructor.
data Dimension = Dimension'
  { -- | The data type of the dimension for the time series data point.
    Dimension -> Maybe DimensionValueType
dimensionValueType :: Prelude.Maybe DimensionValueType,
    -- | Dimension represents the meta data attributes of the time series. For
    -- example, the name and availability zone of an EC2 instance or the name
    -- of the manufacturer of a wind turbine are dimensions.
    --
    -- For constraints on Dimension names, see
    -- <https://docs.aws.amazon.com/timestream/latest/developerguide/ts-limits.html#limits.naming Naming Constraints>.
    Dimension -> Text
name :: Prelude.Text,
    -- | The value of the dimension.
    Dimension -> Text
value :: Prelude.Text
  }
  deriving (Dimension -> Dimension -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Dimension -> Dimension -> Bool
$c/= :: Dimension -> Dimension -> Bool
== :: Dimension -> Dimension -> Bool
$c== :: Dimension -> Dimension -> Bool
Prelude.Eq, ReadPrec [Dimension]
ReadPrec Dimension
Int -> ReadS Dimension
ReadS [Dimension]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Dimension]
$creadListPrec :: ReadPrec [Dimension]
readPrec :: ReadPrec Dimension
$creadPrec :: ReadPrec Dimension
readList :: ReadS [Dimension]
$creadList :: ReadS [Dimension]
readsPrec :: Int -> ReadS Dimension
$creadsPrec :: Int -> ReadS Dimension
Prelude.Read, Int -> Dimension -> ShowS
[Dimension] -> ShowS
Dimension -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Dimension] -> ShowS
$cshowList :: [Dimension] -> ShowS
show :: Dimension -> String
$cshow :: Dimension -> String
showsPrec :: Int -> Dimension -> ShowS
$cshowsPrec :: Int -> Dimension -> ShowS
Prelude.Show, forall x. Rep Dimension x -> Dimension
forall x. Dimension -> Rep Dimension x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Dimension x -> Dimension
$cfrom :: forall x. Dimension -> Rep Dimension x
Prelude.Generic)

-- |
-- Create a value of 'Dimension' 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:
--
-- 'dimensionValueType', 'dimension_dimensionValueType' - The data type of the dimension for the time series data point.
--
-- 'name', 'dimension_name' - Dimension represents the meta data attributes of the time series. For
-- example, the name and availability zone of an EC2 instance or the name
-- of the manufacturer of a wind turbine are dimensions.
--
-- For constraints on Dimension names, see
-- <https://docs.aws.amazon.com/timestream/latest/developerguide/ts-limits.html#limits.naming Naming Constraints>.
--
-- 'value', 'dimension_value' - The value of the dimension.
newDimension ::
  -- | 'name'
  Prelude.Text ->
  -- | 'value'
  Prelude.Text ->
  Dimension
newDimension :: Text -> Text -> Dimension
newDimension Text
pName_ Text
pValue_ =
  Dimension'
    { $sel:dimensionValueType:Dimension' :: Maybe DimensionValueType
dimensionValueType = forall a. Maybe a
Prelude.Nothing,
      $sel:name:Dimension' :: Text
name = Text
pName_,
      $sel:value:Dimension' :: Text
value = Text
pValue_
    }

-- | The data type of the dimension for the time series data point.
dimension_dimensionValueType :: Lens.Lens' Dimension (Prelude.Maybe DimensionValueType)
dimension_dimensionValueType :: Lens' Dimension (Maybe DimensionValueType)
dimension_dimensionValueType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Dimension' {Maybe DimensionValueType
dimensionValueType :: Maybe DimensionValueType
$sel:dimensionValueType:Dimension' :: Dimension -> Maybe DimensionValueType
dimensionValueType} -> Maybe DimensionValueType
dimensionValueType) (\s :: Dimension
s@Dimension' {} Maybe DimensionValueType
a -> Dimension
s {$sel:dimensionValueType:Dimension' :: Maybe DimensionValueType
dimensionValueType = Maybe DimensionValueType
a} :: Dimension)

-- | Dimension represents the meta data attributes of the time series. For
-- example, the name and availability zone of an EC2 instance or the name
-- of the manufacturer of a wind turbine are dimensions.
--
-- For constraints on Dimension names, see
-- <https://docs.aws.amazon.com/timestream/latest/developerguide/ts-limits.html#limits.naming Naming Constraints>.
dimension_name :: Lens.Lens' Dimension Prelude.Text
dimension_name :: Lens' Dimension Text
dimension_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Dimension' {Text
name :: Text
$sel:name:Dimension' :: Dimension -> Text
name} -> Text
name) (\s :: Dimension
s@Dimension' {} Text
a -> Dimension
s {$sel:name:Dimension' :: Text
name = Text
a} :: Dimension)

-- | The value of the dimension.
dimension_value :: Lens.Lens' Dimension Prelude.Text
dimension_value :: Lens' Dimension Text
dimension_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Dimension' {Text
value :: Text
$sel:value:Dimension' :: Dimension -> Text
value} -> Text
value) (\s :: Dimension
s@Dimension' {} Text
a -> Dimension
s {$sel:value:Dimension' :: Text
value = Text
a} :: Dimension)

instance Prelude.Hashable Dimension where
  hashWithSalt :: Int -> Dimension -> Int
hashWithSalt Int
_salt Dimension' {Maybe DimensionValueType
Text
value :: Text
name :: Text
dimensionValueType :: Maybe DimensionValueType
$sel:value:Dimension' :: Dimension -> Text
$sel:name:Dimension' :: Dimension -> Text
$sel:dimensionValueType:Dimension' :: Dimension -> Maybe DimensionValueType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DimensionValueType
dimensionValueType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
value

instance Prelude.NFData Dimension where
  rnf :: Dimension -> ()
rnf Dimension' {Maybe DimensionValueType
Text
value :: Text
name :: Text
dimensionValueType :: Maybe DimensionValueType
$sel:value:Dimension' :: Dimension -> Text
$sel:name:Dimension' :: Dimension -> Text
$sel:dimensionValueType:Dimension' :: Dimension -> Maybe DimensionValueType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe DimensionValueType
dimensionValueType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
value

instance Data.ToJSON Dimension where
  toJSON :: Dimension -> Value
toJSON Dimension' {Maybe DimensionValueType
Text
value :: Text
name :: Text
dimensionValueType :: Maybe DimensionValueType
$sel:value:Dimension' :: Dimension -> Text
$sel:name:Dimension' :: Dimension -> Text
$sel:dimensionValueType:Dimension' :: Dimension -> Maybe DimensionValueType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DimensionValueType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DimensionValueType
dimensionValueType,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
value)
          ]
      )