{-# 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.CloudDirectory.Types.BatchUpdateObjectAttributes
-- 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.CloudDirectory.Types.BatchUpdateObjectAttributes where

import Amazonka.CloudDirectory.Types.ObjectAttributeUpdate
import Amazonka.CloudDirectory.Types.ObjectReference
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents the output of a @BatchUpdate@ operation.
--
-- /See:/ 'newBatchUpdateObjectAttributes' smart constructor.
data BatchUpdateObjectAttributes = BatchUpdateObjectAttributes'
  { -- | Reference that identifies the object.
    BatchUpdateObjectAttributes -> ObjectReference
objectReference :: ObjectReference,
    -- | Attributes update structure.
    BatchUpdateObjectAttributes -> [ObjectAttributeUpdate]
attributeUpdates :: [ObjectAttributeUpdate]
  }
  deriving (BatchUpdateObjectAttributes -> BatchUpdateObjectAttributes -> Bool
(BatchUpdateObjectAttributes
 -> BatchUpdateObjectAttributes -> Bool)
-> (BatchUpdateObjectAttributes
    -> BatchUpdateObjectAttributes -> Bool)
-> Eq BatchUpdateObjectAttributes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchUpdateObjectAttributes -> BatchUpdateObjectAttributes -> Bool
$c/= :: BatchUpdateObjectAttributes -> BatchUpdateObjectAttributes -> Bool
== :: BatchUpdateObjectAttributes -> BatchUpdateObjectAttributes -> Bool
$c== :: BatchUpdateObjectAttributes -> BatchUpdateObjectAttributes -> Bool
Prelude.Eq, ReadPrec [BatchUpdateObjectAttributes]
ReadPrec BatchUpdateObjectAttributes
Int -> ReadS BatchUpdateObjectAttributes
ReadS [BatchUpdateObjectAttributes]
(Int -> ReadS BatchUpdateObjectAttributes)
-> ReadS [BatchUpdateObjectAttributes]
-> ReadPrec BatchUpdateObjectAttributes
-> ReadPrec [BatchUpdateObjectAttributes]
-> Read BatchUpdateObjectAttributes
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchUpdateObjectAttributes]
$creadListPrec :: ReadPrec [BatchUpdateObjectAttributes]
readPrec :: ReadPrec BatchUpdateObjectAttributes
$creadPrec :: ReadPrec BatchUpdateObjectAttributes
readList :: ReadS [BatchUpdateObjectAttributes]
$creadList :: ReadS [BatchUpdateObjectAttributes]
readsPrec :: Int -> ReadS BatchUpdateObjectAttributes
$creadsPrec :: Int -> ReadS BatchUpdateObjectAttributes
Prelude.Read, Int -> BatchUpdateObjectAttributes -> ShowS
[BatchUpdateObjectAttributes] -> ShowS
BatchUpdateObjectAttributes -> String
(Int -> BatchUpdateObjectAttributes -> ShowS)
-> (BatchUpdateObjectAttributes -> String)
-> ([BatchUpdateObjectAttributes] -> ShowS)
-> Show BatchUpdateObjectAttributes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchUpdateObjectAttributes] -> ShowS
$cshowList :: [BatchUpdateObjectAttributes] -> ShowS
show :: BatchUpdateObjectAttributes -> String
$cshow :: BatchUpdateObjectAttributes -> String
showsPrec :: Int -> BatchUpdateObjectAttributes -> ShowS
$cshowsPrec :: Int -> BatchUpdateObjectAttributes -> ShowS
Prelude.Show, (forall x.
 BatchUpdateObjectAttributes -> Rep BatchUpdateObjectAttributes x)
-> (forall x.
    Rep BatchUpdateObjectAttributes x -> BatchUpdateObjectAttributes)
-> Generic BatchUpdateObjectAttributes
forall x.
Rep BatchUpdateObjectAttributes x -> BatchUpdateObjectAttributes
forall x.
BatchUpdateObjectAttributes -> Rep BatchUpdateObjectAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchUpdateObjectAttributes x -> BatchUpdateObjectAttributes
$cfrom :: forall x.
BatchUpdateObjectAttributes -> Rep BatchUpdateObjectAttributes x
Prelude.Generic)

-- |
-- Create a value of 'BatchUpdateObjectAttributes' 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:
--
-- 'objectReference', 'batchUpdateObjectAttributes_objectReference' - Reference that identifies the object.
--
-- 'attributeUpdates', 'batchUpdateObjectAttributes_attributeUpdates' - Attributes update structure.
newBatchUpdateObjectAttributes ::
  -- | 'objectReference'
  ObjectReference ->
  BatchUpdateObjectAttributes
newBatchUpdateObjectAttributes :: ObjectReference -> BatchUpdateObjectAttributes
newBatchUpdateObjectAttributes ObjectReference
pObjectReference_ =
  BatchUpdateObjectAttributes' :: ObjectReference
-> [ObjectAttributeUpdate] -> BatchUpdateObjectAttributes
BatchUpdateObjectAttributes'
    { $sel:objectReference:BatchUpdateObjectAttributes' :: ObjectReference
objectReference =
        ObjectReference
pObjectReference_,
      $sel:attributeUpdates:BatchUpdateObjectAttributes' :: [ObjectAttributeUpdate]
attributeUpdates = [ObjectAttributeUpdate]
forall a. Monoid a => a
Prelude.mempty
    }

-- | Reference that identifies the object.
batchUpdateObjectAttributes_objectReference :: Lens.Lens' BatchUpdateObjectAttributes ObjectReference
batchUpdateObjectAttributes_objectReference :: (ObjectReference -> f ObjectReference)
-> BatchUpdateObjectAttributes -> f BatchUpdateObjectAttributes
batchUpdateObjectAttributes_objectReference = (BatchUpdateObjectAttributes -> ObjectReference)
-> (BatchUpdateObjectAttributes
    -> ObjectReference -> BatchUpdateObjectAttributes)
-> Lens
     BatchUpdateObjectAttributes
     BatchUpdateObjectAttributes
     ObjectReference
     ObjectReference
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchUpdateObjectAttributes' {ObjectReference
objectReference :: ObjectReference
$sel:objectReference:BatchUpdateObjectAttributes' :: BatchUpdateObjectAttributes -> ObjectReference
objectReference} -> ObjectReference
objectReference) (\s :: BatchUpdateObjectAttributes
s@BatchUpdateObjectAttributes' {} ObjectReference
a -> BatchUpdateObjectAttributes
s {$sel:objectReference:BatchUpdateObjectAttributes' :: ObjectReference
objectReference = ObjectReference
a} :: BatchUpdateObjectAttributes)

-- | Attributes update structure.
batchUpdateObjectAttributes_attributeUpdates :: Lens.Lens' BatchUpdateObjectAttributes [ObjectAttributeUpdate]
batchUpdateObjectAttributes_attributeUpdates :: ([ObjectAttributeUpdate] -> f [ObjectAttributeUpdate])
-> BatchUpdateObjectAttributes -> f BatchUpdateObjectAttributes
batchUpdateObjectAttributes_attributeUpdates = (BatchUpdateObjectAttributes -> [ObjectAttributeUpdate])
-> (BatchUpdateObjectAttributes
    -> [ObjectAttributeUpdate] -> BatchUpdateObjectAttributes)
-> Lens
     BatchUpdateObjectAttributes
     BatchUpdateObjectAttributes
     [ObjectAttributeUpdate]
     [ObjectAttributeUpdate]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchUpdateObjectAttributes' {[ObjectAttributeUpdate]
attributeUpdates :: [ObjectAttributeUpdate]
$sel:attributeUpdates:BatchUpdateObjectAttributes' :: BatchUpdateObjectAttributes -> [ObjectAttributeUpdate]
attributeUpdates} -> [ObjectAttributeUpdate]
attributeUpdates) (\s :: BatchUpdateObjectAttributes
s@BatchUpdateObjectAttributes' {} [ObjectAttributeUpdate]
a -> BatchUpdateObjectAttributes
s {$sel:attributeUpdates:BatchUpdateObjectAttributes' :: [ObjectAttributeUpdate]
attributeUpdates = [ObjectAttributeUpdate]
a} :: BatchUpdateObjectAttributes) (([ObjectAttributeUpdate] -> f [ObjectAttributeUpdate])
 -> BatchUpdateObjectAttributes -> f BatchUpdateObjectAttributes)
-> (([ObjectAttributeUpdate] -> f [ObjectAttributeUpdate])
    -> [ObjectAttributeUpdate] -> f [ObjectAttributeUpdate])
-> ([ObjectAttributeUpdate] -> f [ObjectAttributeUpdate])
-> BatchUpdateObjectAttributes
-> f BatchUpdateObjectAttributes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ObjectAttributeUpdate] -> f [ObjectAttributeUpdate])
-> [ObjectAttributeUpdate] -> f [ObjectAttributeUpdate]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable BatchUpdateObjectAttributes

instance Prelude.NFData BatchUpdateObjectAttributes

instance Core.ToJSON BatchUpdateObjectAttributes where
  toJSON :: BatchUpdateObjectAttributes -> Value
toJSON BatchUpdateObjectAttributes' {[ObjectAttributeUpdate]
ObjectReference
attributeUpdates :: [ObjectAttributeUpdate]
objectReference :: ObjectReference
$sel:attributeUpdates:BatchUpdateObjectAttributes' :: BatchUpdateObjectAttributes -> [ObjectAttributeUpdate]
$sel:objectReference:BatchUpdateObjectAttributes' :: BatchUpdateObjectAttributes -> ObjectReference
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ObjectReference" Text -> ObjectReference -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ObjectReference
objectReference),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"AttributeUpdates" Text -> [ObjectAttributeUpdate] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [ObjectAttributeUpdate]
attributeUpdates)
          ]
      )