{-# 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.IoT.Types.TimestreamDimension
-- 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.IoT.Types.TimestreamDimension 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

-- | Metadata attributes of the time series that are written in each measure
-- record.
--
-- /See:/ 'newTimestreamDimension' smart constructor.
data TimestreamDimension = TimestreamDimension'
  { -- | The metadata dimension name. This is the name of the column in the
    -- Amazon Timestream database table record.
    --
    -- Dimensions cannot be named: @measure_name@, @measure_value@, or @time@.
    -- These names are reserved. Dimension names cannot start with @ts_@ or
    -- @measure_value@ and they cannot contain the colon (@:@) character.
    TimestreamDimension -> Text
name :: Prelude.Text,
    -- | The value to write in this column of the database record.
    TimestreamDimension -> Text
value :: Prelude.Text
  }
  deriving (TimestreamDimension -> TimestreamDimension -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimestreamDimension -> TimestreamDimension -> Bool
$c/= :: TimestreamDimension -> TimestreamDimension -> Bool
== :: TimestreamDimension -> TimestreamDimension -> Bool
$c== :: TimestreamDimension -> TimestreamDimension -> Bool
Prelude.Eq, ReadPrec [TimestreamDimension]
ReadPrec TimestreamDimension
Int -> ReadS TimestreamDimension
ReadS [TimestreamDimension]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TimestreamDimension]
$creadListPrec :: ReadPrec [TimestreamDimension]
readPrec :: ReadPrec TimestreamDimension
$creadPrec :: ReadPrec TimestreamDimension
readList :: ReadS [TimestreamDimension]
$creadList :: ReadS [TimestreamDimension]
readsPrec :: Int -> ReadS TimestreamDimension
$creadsPrec :: Int -> ReadS TimestreamDimension
Prelude.Read, Int -> TimestreamDimension -> ShowS
[TimestreamDimension] -> ShowS
TimestreamDimension -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TimestreamDimension] -> ShowS
$cshowList :: [TimestreamDimension] -> ShowS
show :: TimestreamDimension -> String
$cshow :: TimestreamDimension -> String
showsPrec :: Int -> TimestreamDimension -> ShowS
$cshowsPrec :: Int -> TimestreamDimension -> ShowS
Prelude.Show, forall x. Rep TimestreamDimension x -> TimestreamDimension
forall x. TimestreamDimension -> Rep TimestreamDimension x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TimestreamDimension x -> TimestreamDimension
$cfrom :: forall x. TimestreamDimension -> Rep TimestreamDimension x
Prelude.Generic)

-- |
-- Create a value of 'TimestreamDimension' 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:
--
-- 'name', 'timestreamDimension_name' - The metadata dimension name. This is the name of the column in the
-- Amazon Timestream database table record.
--
-- Dimensions cannot be named: @measure_name@, @measure_value@, or @time@.
-- These names are reserved. Dimension names cannot start with @ts_@ or
-- @measure_value@ and they cannot contain the colon (@:@) character.
--
-- 'value', 'timestreamDimension_value' - The value to write in this column of the database record.
newTimestreamDimension ::
  -- | 'name'
  Prelude.Text ->
  -- | 'value'
  Prelude.Text ->
  TimestreamDimension
newTimestreamDimension :: Text -> Text -> TimestreamDimension
newTimestreamDimension Text
pName_ Text
pValue_ =
  TimestreamDimension'
    { $sel:name:TimestreamDimension' :: Text
name = Text
pName_,
      $sel:value:TimestreamDimension' :: Text
value = Text
pValue_
    }

-- | The metadata dimension name. This is the name of the column in the
-- Amazon Timestream database table record.
--
-- Dimensions cannot be named: @measure_name@, @measure_value@, or @time@.
-- These names are reserved. Dimension names cannot start with @ts_@ or
-- @measure_value@ and they cannot contain the colon (@:@) character.
timestreamDimension_name :: Lens.Lens' TimestreamDimension Prelude.Text
timestreamDimension_name :: Lens' TimestreamDimension Text
timestreamDimension_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimestreamDimension' {Text
name :: Text
$sel:name:TimestreamDimension' :: TimestreamDimension -> Text
name} -> Text
name) (\s :: TimestreamDimension
s@TimestreamDimension' {} Text
a -> TimestreamDimension
s {$sel:name:TimestreamDimension' :: Text
name = Text
a} :: TimestreamDimension)

-- | The value to write in this column of the database record.
timestreamDimension_value :: Lens.Lens' TimestreamDimension Prelude.Text
timestreamDimension_value :: Lens' TimestreamDimension Text
timestreamDimension_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimestreamDimension' {Text
value :: Text
$sel:value:TimestreamDimension' :: TimestreamDimension -> Text
value} -> Text
value) (\s :: TimestreamDimension
s@TimestreamDimension' {} Text
a -> TimestreamDimension
s {$sel:value:TimestreamDimension' :: Text
value = Text
a} :: TimestreamDimension)

instance Data.FromJSON TimestreamDimension where
  parseJSON :: Value -> Parser TimestreamDimension
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TimestreamDimension"
      ( \Object
x ->
          Text -> Text -> TimestreamDimension
TimestreamDimension'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"value")
      )

instance Prelude.Hashable TimestreamDimension where
  hashWithSalt :: Int -> TimestreamDimension -> Int
hashWithSalt Int
_salt TimestreamDimension' {Text
value :: Text
name :: Text
$sel:value:TimestreamDimension' :: TimestreamDimension -> Text
$sel:name:TimestreamDimension' :: TimestreamDimension -> Text
..} =
    Int
_salt
      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 TimestreamDimension where
  rnf :: TimestreamDimension -> ()
rnf TimestreamDimension' {Text
value :: Text
name :: Text
$sel:value:TimestreamDimension' :: TimestreamDimension -> Text
$sel:name:TimestreamDimension' :: TimestreamDimension -> Text
..} =
    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 TimestreamDimension where
  toJSON :: TimestreamDimension -> Value
toJSON TimestreamDimension' {Text
value :: Text
name :: Text
$sel:value:TimestreamDimension' :: TimestreamDimension -> Text
$sel:name:TimestreamDimension' :: TimestreamDimension -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ 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)
          ]
      )