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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTSiteWise.Types.BatchPutAssetPropertyError
import qualified Amazonka.Prelude as Prelude

-- | Contains error information for asset property value entries that are
-- associated with the
-- <https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_BatchPutAssetPropertyValue.html BatchPutAssetPropertyValue>
-- API.
--
-- /See:/ 'newBatchPutAssetPropertyErrorEntry' smart constructor.
data BatchPutAssetPropertyErrorEntry = BatchPutAssetPropertyErrorEntry'
  { -- | The ID of the failed entry.
    BatchPutAssetPropertyErrorEntry -> Text
entryId :: Prelude.Text,
    -- | The list of update property value errors.
    BatchPutAssetPropertyErrorEntry -> [BatchPutAssetPropertyError]
errors :: [BatchPutAssetPropertyError]
  }
  deriving (BatchPutAssetPropertyErrorEntry
-> BatchPutAssetPropertyErrorEntry -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchPutAssetPropertyErrorEntry
-> BatchPutAssetPropertyErrorEntry -> Bool
$c/= :: BatchPutAssetPropertyErrorEntry
-> BatchPutAssetPropertyErrorEntry -> Bool
== :: BatchPutAssetPropertyErrorEntry
-> BatchPutAssetPropertyErrorEntry -> Bool
$c== :: BatchPutAssetPropertyErrorEntry
-> BatchPutAssetPropertyErrorEntry -> Bool
Prelude.Eq, ReadPrec [BatchPutAssetPropertyErrorEntry]
ReadPrec BatchPutAssetPropertyErrorEntry
Int -> ReadS BatchPutAssetPropertyErrorEntry
ReadS [BatchPutAssetPropertyErrorEntry]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchPutAssetPropertyErrorEntry]
$creadListPrec :: ReadPrec [BatchPutAssetPropertyErrorEntry]
readPrec :: ReadPrec BatchPutAssetPropertyErrorEntry
$creadPrec :: ReadPrec BatchPutAssetPropertyErrorEntry
readList :: ReadS [BatchPutAssetPropertyErrorEntry]
$creadList :: ReadS [BatchPutAssetPropertyErrorEntry]
readsPrec :: Int -> ReadS BatchPutAssetPropertyErrorEntry
$creadsPrec :: Int -> ReadS BatchPutAssetPropertyErrorEntry
Prelude.Read, Int -> BatchPutAssetPropertyErrorEntry -> ShowS
[BatchPutAssetPropertyErrorEntry] -> ShowS
BatchPutAssetPropertyErrorEntry -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchPutAssetPropertyErrorEntry] -> ShowS
$cshowList :: [BatchPutAssetPropertyErrorEntry] -> ShowS
show :: BatchPutAssetPropertyErrorEntry -> String
$cshow :: BatchPutAssetPropertyErrorEntry -> String
showsPrec :: Int -> BatchPutAssetPropertyErrorEntry -> ShowS
$cshowsPrec :: Int -> BatchPutAssetPropertyErrorEntry -> ShowS
Prelude.Show, forall x.
Rep BatchPutAssetPropertyErrorEntry x
-> BatchPutAssetPropertyErrorEntry
forall x.
BatchPutAssetPropertyErrorEntry
-> Rep BatchPutAssetPropertyErrorEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchPutAssetPropertyErrorEntry x
-> BatchPutAssetPropertyErrorEntry
$cfrom :: forall x.
BatchPutAssetPropertyErrorEntry
-> Rep BatchPutAssetPropertyErrorEntry x
Prelude.Generic)

-- |
-- Create a value of 'BatchPutAssetPropertyErrorEntry' 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:
--
-- 'entryId', 'batchPutAssetPropertyErrorEntry_entryId' - The ID of the failed entry.
--
-- 'errors', 'batchPutAssetPropertyErrorEntry_errors' - The list of update property value errors.
newBatchPutAssetPropertyErrorEntry ::
  -- | 'entryId'
  Prelude.Text ->
  BatchPutAssetPropertyErrorEntry
newBatchPutAssetPropertyErrorEntry :: Text -> BatchPutAssetPropertyErrorEntry
newBatchPutAssetPropertyErrorEntry Text
pEntryId_ =
  BatchPutAssetPropertyErrorEntry'
    { $sel:entryId:BatchPutAssetPropertyErrorEntry' :: Text
entryId =
        Text
pEntryId_,
      $sel:errors:BatchPutAssetPropertyErrorEntry' :: [BatchPutAssetPropertyError]
errors = forall a. Monoid a => a
Prelude.mempty
    }

-- | The ID of the failed entry.
batchPutAssetPropertyErrorEntry_entryId :: Lens.Lens' BatchPutAssetPropertyErrorEntry Prelude.Text
batchPutAssetPropertyErrorEntry_entryId :: Lens' BatchPutAssetPropertyErrorEntry Text
batchPutAssetPropertyErrorEntry_entryId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchPutAssetPropertyErrorEntry' {Text
entryId :: Text
$sel:entryId:BatchPutAssetPropertyErrorEntry' :: BatchPutAssetPropertyErrorEntry -> Text
entryId} -> Text
entryId) (\s :: BatchPutAssetPropertyErrorEntry
s@BatchPutAssetPropertyErrorEntry' {} Text
a -> BatchPutAssetPropertyErrorEntry
s {$sel:entryId:BatchPutAssetPropertyErrorEntry' :: Text
entryId = Text
a} :: BatchPutAssetPropertyErrorEntry)

-- | The list of update property value errors.
batchPutAssetPropertyErrorEntry_errors :: Lens.Lens' BatchPutAssetPropertyErrorEntry [BatchPutAssetPropertyError]
batchPutAssetPropertyErrorEntry_errors :: Lens' BatchPutAssetPropertyErrorEntry [BatchPutAssetPropertyError]
batchPutAssetPropertyErrorEntry_errors = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchPutAssetPropertyErrorEntry' {[BatchPutAssetPropertyError]
errors :: [BatchPutAssetPropertyError]
$sel:errors:BatchPutAssetPropertyErrorEntry' :: BatchPutAssetPropertyErrorEntry -> [BatchPutAssetPropertyError]
errors} -> [BatchPutAssetPropertyError]
errors) (\s :: BatchPutAssetPropertyErrorEntry
s@BatchPutAssetPropertyErrorEntry' {} [BatchPutAssetPropertyError]
a -> BatchPutAssetPropertyErrorEntry
s {$sel:errors:BatchPutAssetPropertyErrorEntry' :: [BatchPutAssetPropertyError]
errors = [BatchPutAssetPropertyError]
a} :: BatchPutAssetPropertyErrorEntry) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Data.FromJSON
    BatchPutAssetPropertyErrorEntry
  where
  parseJSON :: Value -> Parser BatchPutAssetPropertyErrorEntry
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BatchPutAssetPropertyErrorEntry"
      ( \Object
x ->
          Text
-> [BatchPutAssetPropertyError] -> BatchPutAssetPropertyErrorEntry
BatchPutAssetPropertyErrorEntry'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"entryId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"errors" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance
  Prelude.Hashable
    BatchPutAssetPropertyErrorEntry
  where
  hashWithSalt :: Int -> BatchPutAssetPropertyErrorEntry -> Int
hashWithSalt
    Int
_salt
    BatchPutAssetPropertyErrorEntry' {[BatchPutAssetPropertyError]
Text
errors :: [BatchPutAssetPropertyError]
entryId :: Text
$sel:errors:BatchPutAssetPropertyErrorEntry' :: BatchPutAssetPropertyErrorEntry -> [BatchPutAssetPropertyError]
$sel:entryId:BatchPutAssetPropertyErrorEntry' :: BatchPutAssetPropertyErrorEntry -> Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
entryId
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [BatchPutAssetPropertyError]
errors

instance
  Prelude.NFData
    BatchPutAssetPropertyErrorEntry
  where
  rnf :: BatchPutAssetPropertyErrorEntry -> ()
rnf BatchPutAssetPropertyErrorEntry' {[BatchPutAssetPropertyError]
Text
errors :: [BatchPutAssetPropertyError]
entryId :: Text
$sel:errors:BatchPutAssetPropertyErrorEntry' :: BatchPutAssetPropertyErrorEntry -> [BatchPutAssetPropertyError]
$sel:entryId:BatchPutAssetPropertyErrorEntry' :: BatchPutAssetPropertyErrorEntry -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
entryId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [BatchPutAssetPropertyError]
errors