{-# 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.MeasureValue
-- 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.MeasureValue 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.MeasureValueType

-- | MeasureValue represents the data attribute of the time series. For
-- example, the CPU utilization of an EC2 instance or the RPM of a wind
-- turbine are measures. MeasureValue has both name and value.
--
-- MeasureValue is only allowed for type @MULTI@. Using @MULTI@ type, you
-- can pass multiple data attributes associated with the same time series
-- in a single record
--
-- /See:/ 'newMeasureValue' smart constructor.
data MeasureValue = MeasureValue'
  { -- | Name of the MeasureValue.
    --
    -- For constraints on MeasureValue names, refer to
    -- <https://docs.aws.amazon.com/timestream/latest/developerguide/ts-limits.html#limits.naming Naming Constraints>
    -- in the Timestream developer guide.
    MeasureValue -> Text
name :: Prelude.Text,
    -- | Value for the MeasureValue.
    MeasureValue -> Text
value :: Prelude.Text,
    -- | Contains the data type of the MeasureValue for the time series data
    -- point.
    MeasureValue -> MeasureValueType
type' :: MeasureValueType
  }
  deriving (MeasureValue -> MeasureValue -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MeasureValue -> MeasureValue -> Bool
$c/= :: MeasureValue -> MeasureValue -> Bool
== :: MeasureValue -> MeasureValue -> Bool
$c== :: MeasureValue -> MeasureValue -> Bool
Prelude.Eq, ReadPrec [MeasureValue]
ReadPrec MeasureValue
Int -> ReadS MeasureValue
ReadS [MeasureValue]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MeasureValue]
$creadListPrec :: ReadPrec [MeasureValue]
readPrec :: ReadPrec MeasureValue
$creadPrec :: ReadPrec MeasureValue
readList :: ReadS [MeasureValue]
$creadList :: ReadS [MeasureValue]
readsPrec :: Int -> ReadS MeasureValue
$creadsPrec :: Int -> ReadS MeasureValue
Prelude.Read, Int -> MeasureValue -> ShowS
[MeasureValue] -> ShowS
MeasureValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MeasureValue] -> ShowS
$cshowList :: [MeasureValue] -> ShowS
show :: MeasureValue -> String
$cshow :: MeasureValue -> String
showsPrec :: Int -> MeasureValue -> ShowS
$cshowsPrec :: Int -> MeasureValue -> ShowS
Prelude.Show, forall x. Rep MeasureValue x -> MeasureValue
forall x. MeasureValue -> Rep MeasureValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MeasureValue x -> MeasureValue
$cfrom :: forall x. MeasureValue -> Rep MeasureValue x
Prelude.Generic)

-- |
-- Create a value of 'MeasureValue' 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', 'measureValue_name' - Name of the MeasureValue.
--
-- For constraints on MeasureValue names, refer to
-- <https://docs.aws.amazon.com/timestream/latest/developerguide/ts-limits.html#limits.naming Naming Constraints>
-- in the Timestream developer guide.
--
-- 'value', 'measureValue_value' - Value for the MeasureValue.
--
-- 'type'', 'measureValue_type' - Contains the data type of the MeasureValue for the time series data
-- point.
newMeasureValue ::
  -- | 'name'
  Prelude.Text ->
  -- | 'value'
  Prelude.Text ->
  -- | 'type''
  MeasureValueType ->
  MeasureValue
newMeasureValue :: Text -> Text -> MeasureValueType -> MeasureValue
newMeasureValue Text
pName_ Text
pValue_ MeasureValueType
pType_ =
  MeasureValue'
    { $sel:name:MeasureValue' :: Text
name = Text
pName_,
      $sel:value:MeasureValue' :: Text
value = Text
pValue_,
      $sel:type':MeasureValue' :: MeasureValueType
type' = MeasureValueType
pType_
    }

-- | Name of the MeasureValue.
--
-- For constraints on MeasureValue names, refer to
-- <https://docs.aws.amazon.com/timestream/latest/developerguide/ts-limits.html#limits.naming Naming Constraints>
-- in the Timestream developer guide.
measureValue_name :: Lens.Lens' MeasureValue Prelude.Text
measureValue_name :: Lens' MeasureValue Text
measureValue_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MeasureValue' {Text
name :: Text
$sel:name:MeasureValue' :: MeasureValue -> Text
name} -> Text
name) (\s :: MeasureValue
s@MeasureValue' {} Text
a -> MeasureValue
s {$sel:name:MeasureValue' :: Text
name = Text
a} :: MeasureValue)

-- | Value for the MeasureValue.
measureValue_value :: Lens.Lens' MeasureValue Prelude.Text
measureValue_value :: Lens' MeasureValue Text
measureValue_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MeasureValue' {Text
value :: Text
$sel:value:MeasureValue' :: MeasureValue -> Text
value} -> Text
value) (\s :: MeasureValue
s@MeasureValue' {} Text
a -> MeasureValue
s {$sel:value:MeasureValue' :: Text
value = Text
a} :: MeasureValue)

-- | Contains the data type of the MeasureValue for the time series data
-- point.
measureValue_type :: Lens.Lens' MeasureValue MeasureValueType
measureValue_type :: Lens' MeasureValue MeasureValueType
measureValue_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MeasureValue' {MeasureValueType
type' :: MeasureValueType
$sel:type':MeasureValue' :: MeasureValue -> MeasureValueType
type'} -> MeasureValueType
type') (\s :: MeasureValue
s@MeasureValue' {} MeasureValueType
a -> MeasureValue
s {$sel:type':MeasureValue' :: MeasureValueType
type' = MeasureValueType
a} :: MeasureValue)

instance Prelude.Hashable MeasureValue where
  hashWithSalt :: Int -> MeasureValue -> Int
hashWithSalt Int
_salt MeasureValue' {Text
MeasureValueType
type' :: MeasureValueType
value :: Text
name :: Text
$sel:type':MeasureValue' :: MeasureValue -> MeasureValueType
$sel:value:MeasureValue' :: MeasureValue -> Text
$sel:name:MeasureValue' :: MeasureValue -> 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
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` MeasureValueType
type'

instance Prelude.NFData MeasureValue where
  rnf :: MeasureValue -> ()
rnf MeasureValue' {Text
MeasureValueType
type' :: MeasureValueType
value :: Text
name :: Text
$sel:type':MeasureValue' :: MeasureValue -> MeasureValueType
$sel:value:MeasureValue' :: MeasureValue -> Text
$sel:name:MeasureValue' :: MeasureValue -> 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
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf MeasureValueType
type'

instance Data.ToJSON MeasureValue where
  toJSON :: MeasureValue -> Value
toJSON MeasureValue' {Text
MeasureValueType
type' :: MeasureValueType
value :: Text
name :: Text
$sel:type':MeasureValue' :: MeasureValue -> MeasureValueType
$sel:value:MeasureValue' :: MeasureValue -> Text
$sel:name:MeasureValue' :: MeasureValue -> 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),
            forall a. a -> Maybe a
Prelude.Just (Key
"Type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= MeasureValueType
type')
          ]
      )