{-# 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.IoTSiteWise.Types.PropertyType
-- 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.IoTSiteWise.Types.PropertyType where

import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.Types.Attribute
import Amazonka.IoTSiteWise.Types.Measurement
import Amazonka.IoTSiteWise.Types.Metric
import Amazonka.IoTSiteWise.Types.Transform
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains a property type, which can be one of @attribute@,
-- @measurement@, @metric@, or @transform@.
--
-- /See:/ 'newPropertyType' smart constructor.
data PropertyType = PropertyType'
  { -- | Specifies an asset attribute property. An attribute generally contains
    -- static information, such as the serial number of an
    -- <https://en.wikipedia.org/wiki/Internet_of_things#Industrial_applications IIoT>
    -- wind turbine.
    PropertyType -> Maybe Attribute
attribute :: Prelude.Maybe Attribute,
    -- | Specifies an asset transform property. A transform contains a
    -- mathematical expression that maps a property\'s data points from one
    -- form to another, such as a unit conversion from Celsius to Fahrenheit.
    PropertyType -> Maybe Transform
transform :: Prelude.Maybe Transform,
    -- | Specifies an asset metric property. A metric contains a mathematical
    -- expression that uses aggregate functions to process all input data
    -- points over a time interval and output a single data point, such as to
    -- calculate the average hourly temperature.
    PropertyType -> Maybe Metric
metric :: Prelude.Maybe Metric,
    -- | Specifies an asset measurement property. A measurement represents a
    -- device\'s raw sensor data stream, such as timestamped temperature values
    -- or timestamped power values.
    PropertyType -> Maybe Measurement
measurement :: Prelude.Maybe Measurement
  }
  deriving (PropertyType -> PropertyType -> Bool
(PropertyType -> PropertyType -> Bool)
-> (PropertyType -> PropertyType -> Bool) -> Eq PropertyType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PropertyType -> PropertyType -> Bool
$c/= :: PropertyType -> PropertyType -> Bool
== :: PropertyType -> PropertyType -> Bool
$c== :: PropertyType -> PropertyType -> Bool
Prelude.Eq, ReadPrec [PropertyType]
ReadPrec PropertyType
Int -> ReadS PropertyType
ReadS [PropertyType]
(Int -> ReadS PropertyType)
-> ReadS [PropertyType]
-> ReadPrec PropertyType
-> ReadPrec [PropertyType]
-> Read PropertyType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PropertyType]
$creadListPrec :: ReadPrec [PropertyType]
readPrec :: ReadPrec PropertyType
$creadPrec :: ReadPrec PropertyType
readList :: ReadS [PropertyType]
$creadList :: ReadS [PropertyType]
readsPrec :: Int -> ReadS PropertyType
$creadsPrec :: Int -> ReadS PropertyType
Prelude.Read, Int -> PropertyType -> ShowS
[PropertyType] -> ShowS
PropertyType -> String
(Int -> PropertyType -> ShowS)
-> (PropertyType -> String)
-> ([PropertyType] -> ShowS)
-> Show PropertyType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PropertyType] -> ShowS
$cshowList :: [PropertyType] -> ShowS
show :: PropertyType -> String
$cshow :: PropertyType -> String
showsPrec :: Int -> PropertyType -> ShowS
$cshowsPrec :: Int -> PropertyType -> ShowS
Prelude.Show, (forall x. PropertyType -> Rep PropertyType x)
-> (forall x. Rep PropertyType x -> PropertyType)
-> Generic PropertyType
forall x. Rep PropertyType x -> PropertyType
forall x. PropertyType -> Rep PropertyType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PropertyType x -> PropertyType
$cfrom :: forall x. PropertyType -> Rep PropertyType x
Prelude.Generic)

-- |
-- Create a value of 'PropertyType' 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:
--
-- 'attribute', 'propertyType_attribute' - Specifies an asset attribute property. An attribute generally contains
-- static information, such as the serial number of an
-- <https://en.wikipedia.org/wiki/Internet_of_things#Industrial_applications IIoT>
-- wind turbine.
--
-- 'transform', 'propertyType_transform' - Specifies an asset transform property. A transform contains a
-- mathematical expression that maps a property\'s data points from one
-- form to another, such as a unit conversion from Celsius to Fahrenheit.
--
-- 'metric', 'propertyType_metric' - Specifies an asset metric property. A metric contains a mathematical
-- expression that uses aggregate functions to process all input data
-- points over a time interval and output a single data point, such as to
-- calculate the average hourly temperature.
--
-- 'measurement', 'propertyType_measurement' - Specifies an asset measurement property. A measurement represents a
-- device\'s raw sensor data stream, such as timestamped temperature values
-- or timestamped power values.
newPropertyType ::
  PropertyType
newPropertyType :: PropertyType
newPropertyType =
  PropertyType' :: Maybe Attribute
-> Maybe Transform
-> Maybe Metric
-> Maybe Measurement
-> PropertyType
PropertyType'
    { $sel:attribute:PropertyType' :: Maybe Attribute
attribute = Maybe Attribute
forall a. Maybe a
Prelude.Nothing,
      $sel:transform:PropertyType' :: Maybe Transform
transform = Maybe Transform
forall a. Maybe a
Prelude.Nothing,
      $sel:metric:PropertyType' :: Maybe Metric
metric = Maybe Metric
forall a. Maybe a
Prelude.Nothing,
      $sel:measurement:PropertyType' :: Maybe Measurement
measurement = Maybe Measurement
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies an asset attribute property. An attribute generally contains
-- static information, such as the serial number of an
-- <https://en.wikipedia.org/wiki/Internet_of_things#Industrial_applications IIoT>
-- wind turbine.
propertyType_attribute :: Lens.Lens' PropertyType (Prelude.Maybe Attribute)
propertyType_attribute :: (Maybe Attribute -> f (Maybe Attribute))
-> PropertyType -> f PropertyType
propertyType_attribute = (PropertyType -> Maybe Attribute)
-> (PropertyType -> Maybe Attribute -> PropertyType)
-> Lens
     PropertyType PropertyType (Maybe Attribute) (Maybe Attribute)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyType' {Maybe Attribute
attribute :: Maybe Attribute
$sel:attribute:PropertyType' :: PropertyType -> Maybe Attribute
attribute} -> Maybe Attribute
attribute) (\s :: PropertyType
s@PropertyType' {} Maybe Attribute
a -> PropertyType
s {$sel:attribute:PropertyType' :: Maybe Attribute
attribute = Maybe Attribute
a} :: PropertyType)

-- | Specifies an asset transform property. A transform contains a
-- mathematical expression that maps a property\'s data points from one
-- form to another, such as a unit conversion from Celsius to Fahrenheit.
propertyType_transform :: Lens.Lens' PropertyType (Prelude.Maybe Transform)
propertyType_transform :: (Maybe Transform -> f (Maybe Transform))
-> PropertyType -> f PropertyType
propertyType_transform = (PropertyType -> Maybe Transform)
-> (PropertyType -> Maybe Transform -> PropertyType)
-> Lens
     PropertyType PropertyType (Maybe Transform) (Maybe Transform)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyType' {Maybe Transform
transform :: Maybe Transform
$sel:transform:PropertyType' :: PropertyType -> Maybe Transform
transform} -> Maybe Transform
transform) (\s :: PropertyType
s@PropertyType' {} Maybe Transform
a -> PropertyType
s {$sel:transform:PropertyType' :: Maybe Transform
transform = Maybe Transform
a} :: PropertyType)

-- | Specifies an asset metric property. A metric contains a mathematical
-- expression that uses aggregate functions to process all input data
-- points over a time interval and output a single data point, such as to
-- calculate the average hourly temperature.
propertyType_metric :: Lens.Lens' PropertyType (Prelude.Maybe Metric)
propertyType_metric :: (Maybe Metric -> f (Maybe Metric))
-> PropertyType -> f PropertyType
propertyType_metric = (PropertyType -> Maybe Metric)
-> (PropertyType -> Maybe Metric -> PropertyType)
-> Lens PropertyType PropertyType (Maybe Metric) (Maybe Metric)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyType' {Maybe Metric
metric :: Maybe Metric
$sel:metric:PropertyType' :: PropertyType -> Maybe Metric
metric} -> Maybe Metric
metric) (\s :: PropertyType
s@PropertyType' {} Maybe Metric
a -> PropertyType
s {$sel:metric:PropertyType' :: Maybe Metric
metric = Maybe Metric
a} :: PropertyType)

-- | Specifies an asset measurement property. A measurement represents a
-- device\'s raw sensor data stream, such as timestamped temperature values
-- or timestamped power values.
propertyType_measurement :: Lens.Lens' PropertyType (Prelude.Maybe Measurement)
propertyType_measurement :: (Maybe Measurement -> f (Maybe Measurement))
-> PropertyType -> f PropertyType
propertyType_measurement = (PropertyType -> Maybe Measurement)
-> (PropertyType -> Maybe Measurement -> PropertyType)
-> Lens
     PropertyType PropertyType (Maybe Measurement) (Maybe Measurement)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyType' {Maybe Measurement
measurement :: Maybe Measurement
$sel:measurement:PropertyType' :: PropertyType -> Maybe Measurement
measurement} -> Maybe Measurement
measurement) (\s :: PropertyType
s@PropertyType' {} Maybe Measurement
a -> PropertyType
s {$sel:measurement:PropertyType' :: Maybe Measurement
measurement = Maybe Measurement
a} :: PropertyType)

instance Core.FromJSON PropertyType where
  parseJSON :: Value -> Parser PropertyType
parseJSON =
    String
-> (Object -> Parser PropertyType) -> Value -> Parser PropertyType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PropertyType"
      ( \Object
x ->
          Maybe Attribute
-> Maybe Transform
-> Maybe Metric
-> Maybe Measurement
-> PropertyType
PropertyType'
            (Maybe Attribute
 -> Maybe Transform
 -> Maybe Metric
 -> Maybe Measurement
 -> PropertyType)
-> Parser (Maybe Attribute)
-> Parser
     (Maybe Transform
      -> Maybe Metric -> Maybe Measurement -> PropertyType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Attribute)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"attribute")
            Parser
  (Maybe Transform
   -> Maybe Metric -> Maybe Measurement -> PropertyType)
-> Parser (Maybe Transform)
-> Parser (Maybe Metric -> Maybe Measurement -> PropertyType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Transform)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"transform")
            Parser (Maybe Metric -> Maybe Measurement -> PropertyType)
-> Parser (Maybe Metric)
-> Parser (Maybe Measurement -> PropertyType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Metric)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"metric")
            Parser (Maybe Measurement -> PropertyType)
-> Parser (Maybe Measurement) -> Parser PropertyType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Measurement)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"measurement")
      )

instance Prelude.Hashable PropertyType

instance Prelude.NFData PropertyType

instance Core.ToJSON PropertyType where
  toJSON :: PropertyType -> Value
toJSON PropertyType' {Maybe Attribute
Maybe Measurement
Maybe Transform
Maybe Metric
measurement :: Maybe Measurement
metric :: Maybe Metric
transform :: Maybe Transform
attribute :: Maybe Attribute
$sel:measurement:PropertyType' :: PropertyType -> Maybe Measurement
$sel:metric:PropertyType' :: PropertyType -> Maybe Metric
$sel:transform:PropertyType' :: PropertyType -> Maybe Transform
$sel:attribute:PropertyType' :: PropertyType -> Maybe Attribute
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"attribute" Text -> Attribute -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Attribute -> Pair) -> Maybe Attribute -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Attribute
attribute,
            (Text
"transform" Text -> Transform -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Transform -> Pair) -> Maybe Transform -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Transform
transform,
            (Text
"metric" Text -> Metric -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Metric -> Pair) -> Maybe Metric -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Metric
metric,
            (Text
"measurement" Text -> Measurement -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Measurement -> Pair) -> Maybe Measurement -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Measurement
measurement
          ]
      )