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

import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.Types.BatchPutAssetPropertyValueErrorCode
import Amazonka.IoTSiteWise.Types.TimeInNanos
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains error information from updating a batch of asset property
-- values.
--
-- /See:/ 'newBatchPutAssetPropertyError' smart constructor.
data BatchPutAssetPropertyError = BatchPutAssetPropertyError'
  { -- | The error code.
    BatchPutAssetPropertyError -> BatchPutAssetPropertyValueErrorCode
errorCode :: BatchPutAssetPropertyValueErrorCode,
    -- | The associated error message.
    BatchPutAssetPropertyError -> Text
errorMessage :: Prelude.Text,
    -- | A list of timestamps for each error, if any.
    BatchPutAssetPropertyError -> [TimeInNanos]
timestamps :: [TimeInNanos]
  }
  deriving (BatchPutAssetPropertyError -> BatchPutAssetPropertyError -> Bool
(BatchPutAssetPropertyError -> BatchPutAssetPropertyError -> Bool)
-> (BatchPutAssetPropertyError
    -> BatchPutAssetPropertyError -> Bool)
-> Eq BatchPutAssetPropertyError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchPutAssetPropertyError -> BatchPutAssetPropertyError -> Bool
$c/= :: BatchPutAssetPropertyError -> BatchPutAssetPropertyError -> Bool
== :: BatchPutAssetPropertyError -> BatchPutAssetPropertyError -> Bool
$c== :: BatchPutAssetPropertyError -> BatchPutAssetPropertyError -> Bool
Prelude.Eq, ReadPrec [BatchPutAssetPropertyError]
ReadPrec BatchPutAssetPropertyError
Int -> ReadS BatchPutAssetPropertyError
ReadS [BatchPutAssetPropertyError]
(Int -> ReadS BatchPutAssetPropertyError)
-> ReadS [BatchPutAssetPropertyError]
-> ReadPrec BatchPutAssetPropertyError
-> ReadPrec [BatchPutAssetPropertyError]
-> Read BatchPutAssetPropertyError
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchPutAssetPropertyError]
$creadListPrec :: ReadPrec [BatchPutAssetPropertyError]
readPrec :: ReadPrec BatchPutAssetPropertyError
$creadPrec :: ReadPrec BatchPutAssetPropertyError
readList :: ReadS [BatchPutAssetPropertyError]
$creadList :: ReadS [BatchPutAssetPropertyError]
readsPrec :: Int -> ReadS BatchPutAssetPropertyError
$creadsPrec :: Int -> ReadS BatchPutAssetPropertyError
Prelude.Read, Int -> BatchPutAssetPropertyError -> ShowS
[BatchPutAssetPropertyError] -> ShowS
BatchPutAssetPropertyError -> String
(Int -> BatchPutAssetPropertyError -> ShowS)
-> (BatchPutAssetPropertyError -> String)
-> ([BatchPutAssetPropertyError] -> ShowS)
-> Show BatchPutAssetPropertyError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchPutAssetPropertyError] -> ShowS
$cshowList :: [BatchPutAssetPropertyError] -> ShowS
show :: BatchPutAssetPropertyError -> String
$cshow :: BatchPutAssetPropertyError -> String
showsPrec :: Int -> BatchPutAssetPropertyError -> ShowS
$cshowsPrec :: Int -> BatchPutAssetPropertyError -> ShowS
Prelude.Show, (forall x.
 BatchPutAssetPropertyError -> Rep BatchPutAssetPropertyError x)
-> (forall x.
    Rep BatchPutAssetPropertyError x -> BatchPutAssetPropertyError)
-> Generic BatchPutAssetPropertyError
forall x.
Rep BatchPutAssetPropertyError x -> BatchPutAssetPropertyError
forall x.
BatchPutAssetPropertyError -> Rep BatchPutAssetPropertyError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchPutAssetPropertyError x -> BatchPutAssetPropertyError
$cfrom :: forall x.
BatchPutAssetPropertyError -> Rep BatchPutAssetPropertyError x
Prelude.Generic)

-- |
-- Create a value of 'BatchPutAssetPropertyError' 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:
--
-- 'errorCode', 'batchPutAssetPropertyError_errorCode' - The error code.
--
-- 'errorMessage', 'batchPutAssetPropertyError_errorMessage' - The associated error message.
--
-- 'timestamps', 'batchPutAssetPropertyError_timestamps' - A list of timestamps for each error, if any.
newBatchPutAssetPropertyError ::
  -- | 'errorCode'
  BatchPutAssetPropertyValueErrorCode ->
  -- | 'errorMessage'
  Prelude.Text ->
  BatchPutAssetPropertyError
newBatchPutAssetPropertyError :: BatchPutAssetPropertyValueErrorCode
-> Text -> BatchPutAssetPropertyError
newBatchPutAssetPropertyError
  BatchPutAssetPropertyValueErrorCode
pErrorCode_
  Text
pErrorMessage_ =
    BatchPutAssetPropertyError' :: BatchPutAssetPropertyValueErrorCode
-> Text -> [TimeInNanos] -> BatchPutAssetPropertyError
BatchPutAssetPropertyError'
      { $sel:errorCode:BatchPutAssetPropertyError' :: BatchPutAssetPropertyValueErrorCode
errorCode =
          BatchPutAssetPropertyValueErrorCode
pErrorCode_,
        $sel:errorMessage:BatchPutAssetPropertyError' :: Text
errorMessage = Text
pErrorMessage_,
        $sel:timestamps:BatchPutAssetPropertyError' :: [TimeInNanos]
timestamps = [TimeInNanos]
forall a. Monoid a => a
Prelude.mempty
      }

-- | The error code.
batchPutAssetPropertyError_errorCode :: Lens.Lens' BatchPutAssetPropertyError BatchPutAssetPropertyValueErrorCode
batchPutAssetPropertyError_errorCode :: (BatchPutAssetPropertyValueErrorCode
 -> f BatchPutAssetPropertyValueErrorCode)
-> BatchPutAssetPropertyError -> f BatchPutAssetPropertyError
batchPutAssetPropertyError_errorCode = (BatchPutAssetPropertyError -> BatchPutAssetPropertyValueErrorCode)
-> (BatchPutAssetPropertyError
    -> BatchPutAssetPropertyValueErrorCode
    -> BatchPutAssetPropertyError)
-> Lens
     BatchPutAssetPropertyError
     BatchPutAssetPropertyError
     BatchPutAssetPropertyValueErrorCode
     BatchPutAssetPropertyValueErrorCode
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchPutAssetPropertyError' {BatchPutAssetPropertyValueErrorCode
errorCode :: BatchPutAssetPropertyValueErrorCode
$sel:errorCode:BatchPutAssetPropertyError' :: BatchPutAssetPropertyError -> BatchPutAssetPropertyValueErrorCode
errorCode} -> BatchPutAssetPropertyValueErrorCode
errorCode) (\s :: BatchPutAssetPropertyError
s@BatchPutAssetPropertyError' {} BatchPutAssetPropertyValueErrorCode
a -> BatchPutAssetPropertyError
s {$sel:errorCode:BatchPutAssetPropertyError' :: BatchPutAssetPropertyValueErrorCode
errorCode = BatchPutAssetPropertyValueErrorCode
a} :: BatchPutAssetPropertyError)

-- | The associated error message.
batchPutAssetPropertyError_errorMessage :: Lens.Lens' BatchPutAssetPropertyError Prelude.Text
batchPutAssetPropertyError_errorMessage :: (Text -> f Text)
-> BatchPutAssetPropertyError -> f BatchPutAssetPropertyError
batchPutAssetPropertyError_errorMessage = (BatchPutAssetPropertyError -> Text)
-> (BatchPutAssetPropertyError
    -> Text -> BatchPutAssetPropertyError)
-> Lens
     BatchPutAssetPropertyError BatchPutAssetPropertyError Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchPutAssetPropertyError' {Text
errorMessage :: Text
$sel:errorMessage:BatchPutAssetPropertyError' :: BatchPutAssetPropertyError -> Text
errorMessage} -> Text
errorMessage) (\s :: BatchPutAssetPropertyError
s@BatchPutAssetPropertyError' {} Text
a -> BatchPutAssetPropertyError
s {$sel:errorMessage:BatchPutAssetPropertyError' :: Text
errorMessage = Text
a} :: BatchPutAssetPropertyError)

-- | A list of timestamps for each error, if any.
batchPutAssetPropertyError_timestamps :: Lens.Lens' BatchPutAssetPropertyError [TimeInNanos]
batchPutAssetPropertyError_timestamps :: ([TimeInNanos] -> f [TimeInNanos])
-> BatchPutAssetPropertyError -> f BatchPutAssetPropertyError
batchPutAssetPropertyError_timestamps = (BatchPutAssetPropertyError -> [TimeInNanos])
-> (BatchPutAssetPropertyError
    -> [TimeInNanos] -> BatchPutAssetPropertyError)
-> Lens
     BatchPutAssetPropertyError
     BatchPutAssetPropertyError
     [TimeInNanos]
     [TimeInNanos]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchPutAssetPropertyError' {[TimeInNanos]
timestamps :: [TimeInNanos]
$sel:timestamps:BatchPutAssetPropertyError' :: BatchPutAssetPropertyError -> [TimeInNanos]
timestamps} -> [TimeInNanos]
timestamps) (\s :: BatchPutAssetPropertyError
s@BatchPutAssetPropertyError' {} [TimeInNanos]
a -> BatchPutAssetPropertyError
s {$sel:timestamps:BatchPutAssetPropertyError' :: [TimeInNanos]
timestamps = [TimeInNanos]
a} :: BatchPutAssetPropertyError) (([TimeInNanos] -> f [TimeInNanos])
 -> BatchPutAssetPropertyError -> f BatchPutAssetPropertyError)
-> (([TimeInNanos] -> f [TimeInNanos])
    -> [TimeInNanos] -> f [TimeInNanos])
-> ([TimeInNanos] -> f [TimeInNanos])
-> BatchPutAssetPropertyError
-> f BatchPutAssetPropertyError
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([TimeInNanos] -> f [TimeInNanos])
-> [TimeInNanos] -> f [TimeInNanos]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON BatchPutAssetPropertyError where
  parseJSON :: Value -> Parser BatchPutAssetPropertyError
parseJSON =
    String
-> (Object -> Parser BatchPutAssetPropertyError)
-> Value
-> Parser BatchPutAssetPropertyError
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BatchPutAssetPropertyError"
      ( \Object
x ->
          BatchPutAssetPropertyValueErrorCode
-> Text -> [TimeInNanos] -> BatchPutAssetPropertyError
BatchPutAssetPropertyError'
            (BatchPutAssetPropertyValueErrorCode
 -> Text -> [TimeInNanos] -> BatchPutAssetPropertyError)
-> Parser BatchPutAssetPropertyValueErrorCode
-> Parser (Text -> [TimeInNanos] -> BatchPutAssetPropertyError)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser BatchPutAssetPropertyValueErrorCode
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"errorCode")
            Parser (Text -> [TimeInNanos] -> BatchPutAssetPropertyError)
-> Parser Text
-> Parser ([TimeInNanos] -> BatchPutAssetPropertyError)
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
"errorMessage")
            Parser ([TimeInNanos] -> BatchPutAssetPropertyError)
-> Parser [TimeInNanos] -> Parser BatchPutAssetPropertyError
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe [TimeInNanos])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"timestamps" Parser (Maybe [TimeInNanos])
-> [TimeInNanos] -> Parser [TimeInNanos]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [TimeInNanos]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable BatchPutAssetPropertyError

instance Prelude.NFData BatchPutAssetPropertyError