{-# 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.PutAssetPropertyValueEntry
-- 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.PutAssetPropertyValueEntry where

import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.Types.AssetPropertyValue
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains a list of value updates for an asset property in the list of
-- asset entries consumed by the
-- <https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_BatchPutAssetPropertyValue.html BatchPutAssetPropertyValue>
-- API operation.
--
-- /See:/ 'newPutAssetPropertyValueEntry' smart constructor.
data PutAssetPropertyValueEntry = PutAssetPropertyValueEntry'
  { -- | The alias that identifies the property, such as an OPC-UA server data
    -- stream path (for example,
    -- @\/company\/windfarm\/3\/turbine\/7\/temperature@). For more
    -- information, see
    -- <https://docs.aws.amazon.com/iot-sitewise/latest/userguide/connect-data-streams.html Mapping industrial data streams to asset properties>
    -- in the /IoT SiteWise User Guide/.
    PutAssetPropertyValueEntry -> Maybe Text
propertyAlias :: Prelude.Maybe Prelude.Text,
    -- | The ID of the asset property for this entry.
    PutAssetPropertyValueEntry -> Maybe Text
propertyId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the asset to update.
    PutAssetPropertyValueEntry -> Maybe Text
assetId :: Prelude.Maybe Prelude.Text,
    -- | The user specified ID for the entry. You can use this ID to identify
    -- which entries failed.
    PutAssetPropertyValueEntry -> Text
entryId :: Prelude.Text,
    -- | The list of property values to upload. You can specify up to 10
    -- @propertyValues@ array elements.
    PutAssetPropertyValueEntry -> [AssetPropertyValue]
propertyValues :: [AssetPropertyValue]
  }
  deriving (PutAssetPropertyValueEntry -> PutAssetPropertyValueEntry -> Bool
(PutAssetPropertyValueEntry -> PutAssetPropertyValueEntry -> Bool)
-> (PutAssetPropertyValueEntry
    -> PutAssetPropertyValueEntry -> Bool)
-> Eq PutAssetPropertyValueEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutAssetPropertyValueEntry -> PutAssetPropertyValueEntry -> Bool
$c/= :: PutAssetPropertyValueEntry -> PutAssetPropertyValueEntry -> Bool
== :: PutAssetPropertyValueEntry -> PutAssetPropertyValueEntry -> Bool
$c== :: PutAssetPropertyValueEntry -> PutAssetPropertyValueEntry -> Bool
Prelude.Eq, ReadPrec [PutAssetPropertyValueEntry]
ReadPrec PutAssetPropertyValueEntry
Int -> ReadS PutAssetPropertyValueEntry
ReadS [PutAssetPropertyValueEntry]
(Int -> ReadS PutAssetPropertyValueEntry)
-> ReadS [PutAssetPropertyValueEntry]
-> ReadPrec PutAssetPropertyValueEntry
-> ReadPrec [PutAssetPropertyValueEntry]
-> Read PutAssetPropertyValueEntry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutAssetPropertyValueEntry]
$creadListPrec :: ReadPrec [PutAssetPropertyValueEntry]
readPrec :: ReadPrec PutAssetPropertyValueEntry
$creadPrec :: ReadPrec PutAssetPropertyValueEntry
readList :: ReadS [PutAssetPropertyValueEntry]
$creadList :: ReadS [PutAssetPropertyValueEntry]
readsPrec :: Int -> ReadS PutAssetPropertyValueEntry
$creadsPrec :: Int -> ReadS PutAssetPropertyValueEntry
Prelude.Read, Int -> PutAssetPropertyValueEntry -> ShowS
[PutAssetPropertyValueEntry] -> ShowS
PutAssetPropertyValueEntry -> String
(Int -> PutAssetPropertyValueEntry -> ShowS)
-> (PutAssetPropertyValueEntry -> String)
-> ([PutAssetPropertyValueEntry] -> ShowS)
-> Show PutAssetPropertyValueEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutAssetPropertyValueEntry] -> ShowS
$cshowList :: [PutAssetPropertyValueEntry] -> ShowS
show :: PutAssetPropertyValueEntry -> String
$cshow :: PutAssetPropertyValueEntry -> String
showsPrec :: Int -> PutAssetPropertyValueEntry -> ShowS
$cshowsPrec :: Int -> PutAssetPropertyValueEntry -> ShowS
Prelude.Show, (forall x.
 PutAssetPropertyValueEntry -> Rep PutAssetPropertyValueEntry x)
-> (forall x.
    Rep PutAssetPropertyValueEntry x -> PutAssetPropertyValueEntry)
-> Generic PutAssetPropertyValueEntry
forall x.
Rep PutAssetPropertyValueEntry x -> PutAssetPropertyValueEntry
forall x.
PutAssetPropertyValueEntry -> Rep PutAssetPropertyValueEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutAssetPropertyValueEntry x -> PutAssetPropertyValueEntry
$cfrom :: forall x.
PutAssetPropertyValueEntry -> Rep PutAssetPropertyValueEntry x
Prelude.Generic)

-- |
-- Create a value of 'PutAssetPropertyValueEntry' 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:
--
-- 'propertyAlias', 'putAssetPropertyValueEntry_propertyAlias' - The alias that identifies the property, such as an OPC-UA server data
-- stream path (for example,
-- @\/company\/windfarm\/3\/turbine\/7\/temperature@). For more
-- information, see
-- <https://docs.aws.amazon.com/iot-sitewise/latest/userguide/connect-data-streams.html Mapping industrial data streams to asset properties>
-- in the /IoT SiteWise User Guide/.
--
-- 'propertyId', 'putAssetPropertyValueEntry_propertyId' - The ID of the asset property for this entry.
--
-- 'assetId', 'putAssetPropertyValueEntry_assetId' - The ID of the asset to update.
--
-- 'entryId', 'putAssetPropertyValueEntry_entryId' - The user specified ID for the entry. You can use this ID to identify
-- which entries failed.
--
-- 'propertyValues', 'putAssetPropertyValueEntry_propertyValues' - The list of property values to upload. You can specify up to 10
-- @propertyValues@ array elements.
newPutAssetPropertyValueEntry ::
  -- | 'entryId'
  Prelude.Text ->
  PutAssetPropertyValueEntry
newPutAssetPropertyValueEntry :: Text -> PutAssetPropertyValueEntry
newPutAssetPropertyValueEntry Text
pEntryId_ =
  PutAssetPropertyValueEntry' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Text
-> [AssetPropertyValue]
-> PutAssetPropertyValueEntry
PutAssetPropertyValueEntry'
    { $sel:propertyAlias:PutAssetPropertyValueEntry' :: Maybe Text
propertyAlias =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:propertyId:PutAssetPropertyValueEntry' :: Maybe Text
propertyId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:assetId:PutAssetPropertyValueEntry' :: Maybe Text
assetId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:entryId:PutAssetPropertyValueEntry' :: Text
entryId = Text
pEntryId_,
      $sel:propertyValues:PutAssetPropertyValueEntry' :: [AssetPropertyValue]
propertyValues = [AssetPropertyValue]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The alias that identifies the property, such as an OPC-UA server data
-- stream path (for example,
-- @\/company\/windfarm\/3\/turbine\/7\/temperature@). For more
-- information, see
-- <https://docs.aws.amazon.com/iot-sitewise/latest/userguide/connect-data-streams.html Mapping industrial data streams to asset properties>
-- in the /IoT SiteWise User Guide/.
putAssetPropertyValueEntry_propertyAlias :: Lens.Lens' PutAssetPropertyValueEntry (Prelude.Maybe Prelude.Text)
putAssetPropertyValueEntry_propertyAlias :: (Maybe Text -> f (Maybe Text))
-> PutAssetPropertyValueEntry -> f PutAssetPropertyValueEntry
putAssetPropertyValueEntry_propertyAlias = (PutAssetPropertyValueEntry -> Maybe Text)
-> (PutAssetPropertyValueEntry
    -> Maybe Text -> PutAssetPropertyValueEntry)
-> Lens
     PutAssetPropertyValueEntry
     PutAssetPropertyValueEntry
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAssetPropertyValueEntry' {Maybe Text
propertyAlias :: Maybe Text
$sel:propertyAlias:PutAssetPropertyValueEntry' :: PutAssetPropertyValueEntry -> Maybe Text
propertyAlias} -> Maybe Text
propertyAlias) (\s :: PutAssetPropertyValueEntry
s@PutAssetPropertyValueEntry' {} Maybe Text
a -> PutAssetPropertyValueEntry
s {$sel:propertyAlias:PutAssetPropertyValueEntry' :: Maybe Text
propertyAlias = Maybe Text
a} :: PutAssetPropertyValueEntry)

-- | The ID of the asset property for this entry.
putAssetPropertyValueEntry_propertyId :: Lens.Lens' PutAssetPropertyValueEntry (Prelude.Maybe Prelude.Text)
putAssetPropertyValueEntry_propertyId :: (Maybe Text -> f (Maybe Text))
-> PutAssetPropertyValueEntry -> f PutAssetPropertyValueEntry
putAssetPropertyValueEntry_propertyId = (PutAssetPropertyValueEntry -> Maybe Text)
-> (PutAssetPropertyValueEntry
    -> Maybe Text -> PutAssetPropertyValueEntry)
-> Lens
     PutAssetPropertyValueEntry
     PutAssetPropertyValueEntry
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAssetPropertyValueEntry' {Maybe Text
propertyId :: Maybe Text
$sel:propertyId:PutAssetPropertyValueEntry' :: PutAssetPropertyValueEntry -> Maybe Text
propertyId} -> Maybe Text
propertyId) (\s :: PutAssetPropertyValueEntry
s@PutAssetPropertyValueEntry' {} Maybe Text
a -> PutAssetPropertyValueEntry
s {$sel:propertyId:PutAssetPropertyValueEntry' :: Maybe Text
propertyId = Maybe Text
a} :: PutAssetPropertyValueEntry)

-- | The ID of the asset to update.
putAssetPropertyValueEntry_assetId :: Lens.Lens' PutAssetPropertyValueEntry (Prelude.Maybe Prelude.Text)
putAssetPropertyValueEntry_assetId :: (Maybe Text -> f (Maybe Text))
-> PutAssetPropertyValueEntry -> f PutAssetPropertyValueEntry
putAssetPropertyValueEntry_assetId = (PutAssetPropertyValueEntry -> Maybe Text)
-> (PutAssetPropertyValueEntry
    -> Maybe Text -> PutAssetPropertyValueEntry)
-> Lens
     PutAssetPropertyValueEntry
     PutAssetPropertyValueEntry
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAssetPropertyValueEntry' {Maybe Text
assetId :: Maybe Text
$sel:assetId:PutAssetPropertyValueEntry' :: PutAssetPropertyValueEntry -> Maybe Text
assetId} -> Maybe Text
assetId) (\s :: PutAssetPropertyValueEntry
s@PutAssetPropertyValueEntry' {} Maybe Text
a -> PutAssetPropertyValueEntry
s {$sel:assetId:PutAssetPropertyValueEntry' :: Maybe Text
assetId = Maybe Text
a} :: PutAssetPropertyValueEntry)

-- | The user specified ID for the entry. You can use this ID to identify
-- which entries failed.
putAssetPropertyValueEntry_entryId :: Lens.Lens' PutAssetPropertyValueEntry Prelude.Text
putAssetPropertyValueEntry_entryId :: (Text -> f Text)
-> PutAssetPropertyValueEntry -> f PutAssetPropertyValueEntry
putAssetPropertyValueEntry_entryId = (PutAssetPropertyValueEntry -> Text)
-> (PutAssetPropertyValueEntry
    -> Text -> PutAssetPropertyValueEntry)
-> Lens
     PutAssetPropertyValueEntry PutAssetPropertyValueEntry Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAssetPropertyValueEntry' {Text
entryId :: Text
$sel:entryId:PutAssetPropertyValueEntry' :: PutAssetPropertyValueEntry -> Text
entryId} -> Text
entryId) (\s :: PutAssetPropertyValueEntry
s@PutAssetPropertyValueEntry' {} Text
a -> PutAssetPropertyValueEntry
s {$sel:entryId:PutAssetPropertyValueEntry' :: Text
entryId = Text
a} :: PutAssetPropertyValueEntry)

-- | The list of property values to upload. You can specify up to 10
-- @propertyValues@ array elements.
putAssetPropertyValueEntry_propertyValues :: Lens.Lens' PutAssetPropertyValueEntry [AssetPropertyValue]
putAssetPropertyValueEntry_propertyValues :: ([AssetPropertyValue] -> f [AssetPropertyValue])
-> PutAssetPropertyValueEntry -> f PutAssetPropertyValueEntry
putAssetPropertyValueEntry_propertyValues = (PutAssetPropertyValueEntry -> [AssetPropertyValue])
-> (PutAssetPropertyValueEntry
    -> [AssetPropertyValue] -> PutAssetPropertyValueEntry)
-> Lens
     PutAssetPropertyValueEntry
     PutAssetPropertyValueEntry
     [AssetPropertyValue]
     [AssetPropertyValue]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAssetPropertyValueEntry' {[AssetPropertyValue]
propertyValues :: [AssetPropertyValue]
$sel:propertyValues:PutAssetPropertyValueEntry' :: PutAssetPropertyValueEntry -> [AssetPropertyValue]
propertyValues} -> [AssetPropertyValue]
propertyValues) (\s :: PutAssetPropertyValueEntry
s@PutAssetPropertyValueEntry' {} [AssetPropertyValue]
a -> PutAssetPropertyValueEntry
s {$sel:propertyValues:PutAssetPropertyValueEntry' :: [AssetPropertyValue]
propertyValues = [AssetPropertyValue]
a} :: PutAssetPropertyValueEntry) (([AssetPropertyValue] -> f [AssetPropertyValue])
 -> PutAssetPropertyValueEntry -> f PutAssetPropertyValueEntry)
-> (([AssetPropertyValue] -> f [AssetPropertyValue])
    -> [AssetPropertyValue] -> f [AssetPropertyValue])
-> ([AssetPropertyValue] -> f [AssetPropertyValue])
-> PutAssetPropertyValueEntry
-> f PutAssetPropertyValueEntry
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([AssetPropertyValue] -> f [AssetPropertyValue])
-> [AssetPropertyValue] -> f [AssetPropertyValue]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable PutAssetPropertyValueEntry

instance Prelude.NFData PutAssetPropertyValueEntry

instance Core.ToJSON PutAssetPropertyValueEntry where
  toJSON :: PutAssetPropertyValueEntry -> Value
toJSON PutAssetPropertyValueEntry' {[AssetPropertyValue]
Maybe Text
Text
propertyValues :: [AssetPropertyValue]
entryId :: Text
assetId :: Maybe Text
propertyId :: Maybe Text
propertyAlias :: Maybe Text
$sel:propertyValues:PutAssetPropertyValueEntry' :: PutAssetPropertyValueEntry -> [AssetPropertyValue]
$sel:entryId:PutAssetPropertyValueEntry' :: PutAssetPropertyValueEntry -> Text
$sel:assetId:PutAssetPropertyValueEntry' :: PutAssetPropertyValueEntry -> Maybe Text
$sel:propertyId:PutAssetPropertyValueEntry' :: PutAssetPropertyValueEntry -> Maybe Text
$sel:propertyAlias:PutAssetPropertyValueEntry' :: PutAssetPropertyValueEntry -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"propertyAlias" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
propertyAlias,
            (Text
"propertyId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
propertyId,
            (Text
"assetId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
assetId,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"entryId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
entryId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"propertyValues" Text -> [AssetPropertyValue] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [AssetPropertyValue]
propertyValues)
          ]
      )