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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(TimestreamDimension -> TimestreamDimension -> Bool)
-> (TimestreamDimension -> TimestreamDimension -> Bool)
-> Eq TimestreamDimension
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]
(Int -> ReadS TimestreamDimension)
-> ReadS [TimestreamDimension]
-> ReadPrec TimestreamDimension
-> ReadPrec [TimestreamDimension]
-> Read 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
(Int -> TimestreamDimension -> ShowS)
-> (TimestreamDimension -> String)
-> ([TimestreamDimension] -> ShowS)
-> Show TimestreamDimension
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. TimestreamDimension -> Rep TimestreamDimension x)
-> (forall x. Rep TimestreamDimension x -> TimestreamDimension)
-> Generic TimestreamDimension
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' :: Text -> Text -> TimestreamDimension
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 :: (Text -> f Text) -> TimestreamDimension -> f TimestreamDimension
timestreamDimension_name = (TimestreamDimension -> Text)
-> (TimestreamDimension -> Text -> TimestreamDimension)
-> Lens TimestreamDimension TimestreamDimension Text Text
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 :: (Text -> f Text) -> TimestreamDimension -> f TimestreamDimension
timestreamDimension_value = (TimestreamDimension -> Text)
-> (TimestreamDimension -> Text -> TimestreamDimension)
-> Lens TimestreamDimension TimestreamDimension Text Text
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 Core.FromJSON TimestreamDimension where
  parseJSON :: Value -> Parser TimestreamDimension
parseJSON =
    String
-> (Object -> Parser TimestreamDimension)
-> Value
-> Parser TimestreamDimension
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TimestreamDimension"
      ( \Object
x ->
          Text -> Text -> TimestreamDimension
TimestreamDimension'
            (Text -> Text -> TimestreamDimension)
-> Parser Text -> Parser (Text -> TimestreamDimension)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"name") Parser (Text -> TimestreamDimension)
-> Parser Text -> Parser TimestreamDimension
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"value")
      )

instance Prelude.Hashable TimestreamDimension

instance Prelude.NFData TimestreamDimension

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"value" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
value)
          ]
      )