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

import Amazonka.CloudDirectory.Types.LinkAttributeUpdate
import Amazonka.CloudDirectory.Types.TypedLinkSpecifier
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(BatchUpdateLinkAttributes -> BatchUpdateLinkAttributes -> Bool)
-> (BatchUpdateLinkAttributes -> BatchUpdateLinkAttributes -> Bool)
-> Eq BatchUpdateLinkAttributes
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]
(Int -> ReadS BatchUpdateLinkAttributes)
-> ReadS [BatchUpdateLinkAttributes]
-> ReadPrec BatchUpdateLinkAttributes
-> ReadPrec [BatchUpdateLinkAttributes]
-> Read 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
(Int -> BatchUpdateLinkAttributes -> ShowS)
-> (BatchUpdateLinkAttributes -> String)
-> ([BatchUpdateLinkAttributes] -> ShowS)
-> Show BatchUpdateLinkAttributes
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.
 BatchUpdateLinkAttributes -> Rep BatchUpdateLinkAttributes x)
-> (forall x.
    Rep BatchUpdateLinkAttributes x -> BatchUpdateLinkAttributes)
-> Generic BatchUpdateLinkAttributes
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' :: TypedLinkSpecifier
-> [LinkAttributeUpdate] -> BatchUpdateLinkAttributes
BatchUpdateLinkAttributes'
    { $sel:typedLinkSpecifier:BatchUpdateLinkAttributes' :: TypedLinkSpecifier
typedLinkSpecifier =
        TypedLinkSpecifier
pTypedLinkSpecifier_,
      $sel:attributeUpdates:BatchUpdateLinkAttributes' :: [LinkAttributeUpdate]
attributeUpdates = [LinkAttributeUpdate]
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 :: (TypedLinkSpecifier -> f TypedLinkSpecifier)
-> BatchUpdateLinkAttributes -> f BatchUpdateLinkAttributes
batchUpdateLinkAttributes_typedLinkSpecifier = (BatchUpdateLinkAttributes -> TypedLinkSpecifier)
-> (BatchUpdateLinkAttributes
    -> TypedLinkSpecifier -> BatchUpdateLinkAttributes)
-> Lens
     BatchUpdateLinkAttributes
     BatchUpdateLinkAttributes
     TypedLinkSpecifier
     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 :: ([LinkAttributeUpdate] -> f [LinkAttributeUpdate])
-> BatchUpdateLinkAttributes -> f BatchUpdateLinkAttributes
batchUpdateLinkAttributes_attributeUpdates = (BatchUpdateLinkAttributes -> [LinkAttributeUpdate])
-> (BatchUpdateLinkAttributes
    -> [LinkAttributeUpdate] -> BatchUpdateLinkAttributes)
-> Lens
     BatchUpdateLinkAttributes
     BatchUpdateLinkAttributes
     [LinkAttributeUpdate]
     [LinkAttributeUpdate]
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) (([LinkAttributeUpdate] -> f [LinkAttributeUpdate])
 -> BatchUpdateLinkAttributes -> f BatchUpdateLinkAttributes)
-> (([LinkAttributeUpdate] -> f [LinkAttributeUpdate])
    -> [LinkAttributeUpdate] -> f [LinkAttributeUpdate])
-> ([LinkAttributeUpdate] -> f [LinkAttributeUpdate])
-> BatchUpdateLinkAttributes
-> f BatchUpdateLinkAttributes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([LinkAttributeUpdate] -> f [LinkAttributeUpdate])
-> [LinkAttributeUpdate] -> f [LinkAttributeUpdate]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable BatchUpdateLinkAttributes

instance Prelude.NFData BatchUpdateLinkAttributes

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"TypedLinkSpecifier" Text -> TypedLinkSpecifier -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TypedLinkSpecifier
typedLinkSpecifier),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"AttributeUpdates" Text -> [LinkAttributeUpdate] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [LinkAttributeUpdate]
attributeUpdates)
          ]
      )