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

import Amazonka.CloudDirectory.Types.LinkAttributeUpdate
import Amazonka.CloudDirectory.Types.TypedLinkSpecifier
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Updates a given typed link’s attributes inside a BatchRead operation.
-- Attributes to be updated must not contribute to the typed link’s
-- identity, as defined by its @IdentityAttributeOrder@. For more
-- information, see UpdateLinkAttributes and BatchReadRequest$Operations.
--
-- /See:/ 'newBatchUpdateLinkAttributes' smart constructor.
data BatchUpdateLinkAttributes = BatchUpdateLinkAttributes'
  { -- | Allows a typed link specifier to be accepted as input.
    BatchUpdateLinkAttributes -> TypedLinkSpecifier
typedLinkSpecifier :: TypedLinkSpecifier,
    -- | The attributes update structure.
    BatchUpdateLinkAttributes -> [LinkAttributeUpdate]
attributeUpdates :: [LinkAttributeUpdate]
  }
  deriving (BatchUpdateLinkAttributes -> BatchUpdateLinkAttributes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchUpdateLinkAttributes -> BatchUpdateLinkAttributes -> Bool
$c/= :: BatchUpdateLinkAttributes -> BatchUpdateLinkAttributes -> Bool
== :: BatchUpdateLinkAttributes -> BatchUpdateLinkAttributes -> Bool
$c== :: BatchUpdateLinkAttributes -> BatchUpdateLinkAttributes -> Bool
Prelude.Eq, ReadPrec [BatchUpdateLinkAttributes]
ReadPrec BatchUpdateLinkAttributes
Int -> ReadS BatchUpdateLinkAttributes
ReadS [BatchUpdateLinkAttributes]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchUpdateLinkAttributes]
$creadListPrec :: ReadPrec [BatchUpdateLinkAttributes]
readPrec :: ReadPrec BatchUpdateLinkAttributes
$creadPrec :: ReadPrec BatchUpdateLinkAttributes
readList :: ReadS [BatchUpdateLinkAttributes]
$creadList :: ReadS [BatchUpdateLinkAttributes]
readsPrec :: Int -> ReadS BatchUpdateLinkAttributes
$creadsPrec :: Int -> ReadS BatchUpdateLinkAttributes
Prelude.Read, Int -> BatchUpdateLinkAttributes -> ShowS
[BatchUpdateLinkAttributes] -> ShowS
BatchUpdateLinkAttributes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchUpdateLinkAttributes] -> ShowS
$cshowList :: [BatchUpdateLinkAttributes] -> ShowS
show :: BatchUpdateLinkAttributes -> String
$cshow :: BatchUpdateLinkAttributes -> String
showsPrec :: Int -> BatchUpdateLinkAttributes -> ShowS
$cshowsPrec :: Int -> BatchUpdateLinkAttributes -> ShowS
Prelude.Show, forall x.
Rep BatchUpdateLinkAttributes x -> BatchUpdateLinkAttributes
forall x.
BatchUpdateLinkAttributes -> Rep BatchUpdateLinkAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchUpdateLinkAttributes x -> BatchUpdateLinkAttributes
$cfrom :: forall x.
BatchUpdateLinkAttributes -> Rep BatchUpdateLinkAttributes x
Prelude.Generic)

-- |
-- Create a value of 'BatchUpdateLinkAttributes' 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:
--
-- 'typedLinkSpecifier', 'batchUpdateLinkAttributes_typedLinkSpecifier' - Allows a typed link specifier to be accepted as input.
--
-- 'attributeUpdates', 'batchUpdateLinkAttributes_attributeUpdates' - The attributes update structure.
newBatchUpdateLinkAttributes ::
  -- | 'typedLinkSpecifier'
  TypedLinkSpecifier ->
  BatchUpdateLinkAttributes
newBatchUpdateLinkAttributes :: TypedLinkSpecifier -> BatchUpdateLinkAttributes
newBatchUpdateLinkAttributes TypedLinkSpecifier
pTypedLinkSpecifier_ =
  BatchUpdateLinkAttributes'
    { $sel:typedLinkSpecifier:BatchUpdateLinkAttributes' :: TypedLinkSpecifier
typedLinkSpecifier =
        TypedLinkSpecifier
pTypedLinkSpecifier_,
      $sel:attributeUpdates:BatchUpdateLinkAttributes' :: [LinkAttributeUpdate]
attributeUpdates = forall a. Monoid a => a
Prelude.mempty
    }

-- | Allows a typed link specifier to be accepted as input.
batchUpdateLinkAttributes_typedLinkSpecifier :: Lens.Lens' BatchUpdateLinkAttributes TypedLinkSpecifier
batchUpdateLinkAttributes_typedLinkSpecifier :: Lens' BatchUpdateLinkAttributes TypedLinkSpecifier
batchUpdateLinkAttributes_typedLinkSpecifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchUpdateLinkAttributes' {TypedLinkSpecifier
typedLinkSpecifier :: TypedLinkSpecifier
$sel:typedLinkSpecifier:BatchUpdateLinkAttributes' :: BatchUpdateLinkAttributes -> TypedLinkSpecifier
typedLinkSpecifier} -> TypedLinkSpecifier
typedLinkSpecifier) (\s :: BatchUpdateLinkAttributes
s@BatchUpdateLinkAttributes' {} TypedLinkSpecifier
a -> BatchUpdateLinkAttributes
s {$sel:typedLinkSpecifier:BatchUpdateLinkAttributes' :: TypedLinkSpecifier
typedLinkSpecifier = TypedLinkSpecifier
a} :: BatchUpdateLinkAttributes)

-- | The attributes update structure.
batchUpdateLinkAttributes_attributeUpdates :: Lens.Lens' BatchUpdateLinkAttributes [LinkAttributeUpdate]
batchUpdateLinkAttributes_attributeUpdates :: Lens' BatchUpdateLinkAttributes [LinkAttributeUpdate]
batchUpdateLinkAttributes_attributeUpdates = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchUpdateLinkAttributes' {[LinkAttributeUpdate]
attributeUpdates :: [LinkAttributeUpdate]
$sel:attributeUpdates:BatchUpdateLinkAttributes' :: BatchUpdateLinkAttributes -> [LinkAttributeUpdate]
attributeUpdates} -> [LinkAttributeUpdate]
attributeUpdates) (\s :: BatchUpdateLinkAttributes
s@BatchUpdateLinkAttributes' {} [LinkAttributeUpdate]
a -> BatchUpdateLinkAttributes
s {$sel:attributeUpdates:BatchUpdateLinkAttributes' :: [LinkAttributeUpdate]
attributeUpdates = [LinkAttributeUpdate]
a} :: BatchUpdateLinkAttributes) 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 Prelude.Hashable BatchUpdateLinkAttributes where
  hashWithSalt :: Int -> BatchUpdateLinkAttributes -> Int
hashWithSalt Int
_salt BatchUpdateLinkAttributes' {[LinkAttributeUpdate]
TypedLinkSpecifier
attributeUpdates :: [LinkAttributeUpdate]
typedLinkSpecifier :: TypedLinkSpecifier
$sel:attributeUpdates:BatchUpdateLinkAttributes' :: BatchUpdateLinkAttributes -> [LinkAttributeUpdate]
$sel:typedLinkSpecifier:BatchUpdateLinkAttributes' :: BatchUpdateLinkAttributes -> TypedLinkSpecifier
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` TypedLinkSpecifier
typedLinkSpecifier
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [LinkAttributeUpdate]
attributeUpdates

instance Prelude.NFData BatchUpdateLinkAttributes where
  rnf :: BatchUpdateLinkAttributes -> ()
rnf BatchUpdateLinkAttributes' {[LinkAttributeUpdate]
TypedLinkSpecifier
attributeUpdates :: [LinkAttributeUpdate]
typedLinkSpecifier :: TypedLinkSpecifier
$sel:attributeUpdates:BatchUpdateLinkAttributes' :: BatchUpdateLinkAttributes -> [LinkAttributeUpdate]
$sel:typedLinkSpecifier:BatchUpdateLinkAttributes' :: BatchUpdateLinkAttributes -> TypedLinkSpecifier
..} =
    forall a. NFData a => a -> ()
Prelude.rnf TypedLinkSpecifier
typedLinkSpecifier
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [LinkAttributeUpdate]
attributeUpdates

instance Data.ToJSON BatchUpdateLinkAttributes where
  toJSON :: BatchUpdateLinkAttributes -> Value
toJSON BatchUpdateLinkAttributes' {[LinkAttributeUpdate]
TypedLinkSpecifier
attributeUpdates :: [LinkAttributeUpdate]
typedLinkSpecifier :: TypedLinkSpecifier
$sel:attributeUpdates:BatchUpdateLinkAttributes' :: BatchUpdateLinkAttributes -> [LinkAttributeUpdate]
$sel:typedLinkSpecifier:BatchUpdateLinkAttributes' :: BatchUpdateLinkAttributes -> TypedLinkSpecifier
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"TypedLinkSpecifier" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= TypedLinkSpecifier
typedLinkSpecifier),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"AttributeUpdates" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [LinkAttributeUpdate]
attributeUpdates)
          ]
      )