{-# 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.IotTwinMaker.Types.PropertyValueHistory
-- 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.IotTwinMaker.Types.PropertyValueHistory where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IotTwinMaker.Types.EntityPropertyReference
import Amazonka.IotTwinMaker.Types.PropertyValue
import qualified Amazonka.Prelude as Prelude

-- | The history of values for a time series property.
--
-- /See:/ 'newPropertyValueHistory' smart constructor.
data PropertyValueHistory = PropertyValueHistory'
  { -- | A list of objects that contain information about the values in the
    -- history of a time series property.
    PropertyValueHistory -> Maybe [PropertyValue]
values :: Prelude.Maybe [PropertyValue],
    -- | An object that uniquely identifies an entity property.
    PropertyValueHistory -> EntityPropertyReference
entityPropertyReference :: EntityPropertyReference
  }
  deriving (PropertyValueHistory -> PropertyValueHistory -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PropertyValueHistory -> PropertyValueHistory -> Bool
$c/= :: PropertyValueHistory -> PropertyValueHistory -> Bool
== :: PropertyValueHistory -> PropertyValueHistory -> Bool
$c== :: PropertyValueHistory -> PropertyValueHistory -> Bool
Prelude.Eq, ReadPrec [PropertyValueHistory]
ReadPrec PropertyValueHistory
Int -> ReadS PropertyValueHistory
ReadS [PropertyValueHistory]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PropertyValueHistory]
$creadListPrec :: ReadPrec [PropertyValueHistory]
readPrec :: ReadPrec PropertyValueHistory
$creadPrec :: ReadPrec PropertyValueHistory
readList :: ReadS [PropertyValueHistory]
$creadList :: ReadS [PropertyValueHistory]
readsPrec :: Int -> ReadS PropertyValueHistory
$creadsPrec :: Int -> ReadS PropertyValueHistory
Prelude.Read, Int -> PropertyValueHistory -> ShowS
[PropertyValueHistory] -> ShowS
PropertyValueHistory -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PropertyValueHistory] -> ShowS
$cshowList :: [PropertyValueHistory] -> ShowS
show :: PropertyValueHistory -> String
$cshow :: PropertyValueHistory -> String
showsPrec :: Int -> PropertyValueHistory -> ShowS
$cshowsPrec :: Int -> PropertyValueHistory -> ShowS
Prelude.Show, forall x. Rep PropertyValueHistory x -> PropertyValueHistory
forall x. PropertyValueHistory -> Rep PropertyValueHistory x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PropertyValueHistory x -> PropertyValueHistory
$cfrom :: forall x. PropertyValueHistory -> Rep PropertyValueHistory x
Prelude.Generic)

-- |
-- Create a value of 'PropertyValueHistory' 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:
--
-- 'values', 'propertyValueHistory_values' - A list of objects that contain information about the values in the
-- history of a time series property.
--
-- 'entityPropertyReference', 'propertyValueHistory_entityPropertyReference' - An object that uniquely identifies an entity property.
newPropertyValueHistory ::
  -- | 'entityPropertyReference'
  EntityPropertyReference ->
  PropertyValueHistory
newPropertyValueHistory :: EntityPropertyReference -> PropertyValueHistory
newPropertyValueHistory EntityPropertyReference
pEntityPropertyReference_ =
  PropertyValueHistory'
    { $sel:values:PropertyValueHistory' :: Maybe [PropertyValue]
values = forall a. Maybe a
Prelude.Nothing,
      $sel:entityPropertyReference:PropertyValueHistory' :: EntityPropertyReference
entityPropertyReference = EntityPropertyReference
pEntityPropertyReference_
    }

-- | A list of objects that contain information about the values in the
-- history of a time series property.
propertyValueHistory_values :: Lens.Lens' PropertyValueHistory (Prelude.Maybe [PropertyValue])
propertyValueHistory_values :: Lens' PropertyValueHistory (Maybe [PropertyValue])
propertyValueHistory_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyValueHistory' {Maybe [PropertyValue]
values :: Maybe [PropertyValue]
$sel:values:PropertyValueHistory' :: PropertyValueHistory -> Maybe [PropertyValue]
values} -> Maybe [PropertyValue]
values) (\s :: PropertyValueHistory
s@PropertyValueHistory' {} Maybe [PropertyValue]
a -> PropertyValueHistory
s {$sel:values:PropertyValueHistory' :: Maybe [PropertyValue]
values = Maybe [PropertyValue]
a} :: PropertyValueHistory) 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

-- | An object that uniquely identifies an entity property.
propertyValueHistory_entityPropertyReference :: Lens.Lens' PropertyValueHistory EntityPropertyReference
propertyValueHistory_entityPropertyReference :: Lens' PropertyValueHistory EntityPropertyReference
propertyValueHistory_entityPropertyReference = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyValueHistory' {EntityPropertyReference
entityPropertyReference :: EntityPropertyReference
$sel:entityPropertyReference:PropertyValueHistory' :: PropertyValueHistory -> EntityPropertyReference
entityPropertyReference} -> EntityPropertyReference
entityPropertyReference) (\s :: PropertyValueHistory
s@PropertyValueHistory' {} EntityPropertyReference
a -> PropertyValueHistory
s {$sel:entityPropertyReference:PropertyValueHistory' :: EntityPropertyReference
entityPropertyReference = EntityPropertyReference
a} :: PropertyValueHistory)

instance Data.FromJSON PropertyValueHistory where
  parseJSON :: Value -> Parser PropertyValueHistory
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PropertyValueHistory"
      ( \Object
x ->
          Maybe [PropertyValue]
-> EntityPropertyReference -> PropertyValueHistory
PropertyValueHistory'
            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
"values" 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 a
Data..: Key
"entityPropertyReference")
      )

instance Prelude.Hashable PropertyValueHistory where
  hashWithSalt :: Int -> PropertyValueHistory -> Int
hashWithSalt Int
_salt PropertyValueHistory' {Maybe [PropertyValue]
EntityPropertyReference
entityPropertyReference :: EntityPropertyReference
values :: Maybe [PropertyValue]
$sel:entityPropertyReference:PropertyValueHistory' :: PropertyValueHistory -> EntityPropertyReference
$sel:values:PropertyValueHistory' :: PropertyValueHistory -> Maybe [PropertyValue]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [PropertyValue]
values
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` EntityPropertyReference
entityPropertyReference

instance Prelude.NFData PropertyValueHistory where
  rnf :: PropertyValueHistory -> ()
rnf PropertyValueHistory' {Maybe [PropertyValue]
EntityPropertyReference
entityPropertyReference :: EntityPropertyReference
values :: Maybe [PropertyValue]
$sel:entityPropertyReference:PropertyValueHistory' :: PropertyValueHistory -> EntityPropertyReference
$sel:values:PropertyValueHistory' :: PropertyValueHistory -> Maybe [PropertyValue]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [PropertyValue]
values
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf EntityPropertyReference
entityPropertyReference