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

import Amazonka.CloudDirectory.Types.AttributeKey
import Amazonka.CloudDirectory.Types.LinkAttributeAction
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

-- | Structure that contains attribute update information.
--
-- /See:/ 'newLinkAttributeUpdate' smart constructor.
data LinkAttributeUpdate = LinkAttributeUpdate'
  { -- | The action to perform as part of the attribute update.
    LinkAttributeUpdate -> Maybe LinkAttributeAction
attributeAction :: Prelude.Maybe LinkAttributeAction,
    -- | The key of the attribute being updated.
    LinkAttributeUpdate -> Maybe AttributeKey
attributeKey :: Prelude.Maybe AttributeKey
  }
  deriving (LinkAttributeUpdate -> LinkAttributeUpdate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LinkAttributeUpdate -> LinkAttributeUpdate -> Bool
$c/= :: LinkAttributeUpdate -> LinkAttributeUpdate -> Bool
== :: LinkAttributeUpdate -> LinkAttributeUpdate -> Bool
$c== :: LinkAttributeUpdate -> LinkAttributeUpdate -> Bool
Prelude.Eq, ReadPrec [LinkAttributeUpdate]
ReadPrec LinkAttributeUpdate
Int -> ReadS LinkAttributeUpdate
ReadS [LinkAttributeUpdate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LinkAttributeUpdate]
$creadListPrec :: ReadPrec [LinkAttributeUpdate]
readPrec :: ReadPrec LinkAttributeUpdate
$creadPrec :: ReadPrec LinkAttributeUpdate
readList :: ReadS [LinkAttributeUpdate]
$creadList :: ReadS [LinkAttributeUpdate]
readsPrec :: Int -> ReadS LinkAttributeUpdate
$creadsPrec :: Int -> ReadS LinkAttributeUpdate
Prelude.Read, Int -> LinkAttributeUpdate -> ShowS
[LinkAttributeUpdate] -> ShowS
LinkAttributeUpdate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LinkAttributeUpdate] -> ShowS
$cshowList :: [LinkAttributeUpdate] -> ShowS
show :: LinkAttributeUpdate -> String
$cshow :: LinkAttributeUpdate -> String
showsPrec :: Int -> LinkAttributeUpdate -> ShowS
$cshowsPrec :: Int -> LinkAttributeUpdate -> ShowS
Prelude.Show, forall x. Rep LinkAttributeUpdate x -> LinkAttributeUpdate
forall x. LinkAttributeUpdate -> Rep LinkAttributeUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LinkAttributeUpdate x -> LinkAttributeUpdate
$cfrom :: forall x. LinkAttributeUpdate -> Rep LinkAttributeUpdate x
Prelude.Generic)

-- |
-- Create a value of 'LinkAttributeUpdate' 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:
--
-- 'attributeAction', 'linkAttributeUpdate_attributeAction' - The action to perform as part of the attribute update.
--
-- 'attributeKey', 'linkAttributeUpdate_attributeKey' - The key of the attribute being updated.
newLinkAttributeUpdate ::
  LinkAttributeUpdate
newLinkAttributeUpdate :: LinkAttributeUpdate
newLinkAttributeUpdate =
  LinkAttributeUpdate'
    { $sel:attributeAction:LinkAttributeUpdate' :: Maybe LinkAttributeAction
attributeAction =
        forall a. Maybe a
Prelude.Nothing,
      $sel:attributeKey:LinkAttributeUpdate' :: Maybe AttributeKey
attributeKey = forall a. Maybe a
Prelude.Nothing
    }

-- | The action to perform as part of the attribute update.
linkAttributeUpdate_attributeAction :: Lens.Lens' LinkAttributeUpdate (Prelude.Maybe LinkAttributeAction)
linkAttributeUpdate_attributeAction :: Lens' LinkAttributeUpdate (Maybe LinkAttributeAction)
linkAttributeUpdate_attributeAction = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LinkAttributeUpdate' {Maybe LinkAttributeAction
attributeAction :: Maybe LinkAttributeAction
$sel:attributeAction:LinkAttributeUpdate' :: LinkAttributeUpdate -> Maybe LinkAttributeAction
attributeAction} -> Maybe LinkAttributeAction
attributeAction) (\s :: LinkAttributeUpdate
s@LinkAttributeUpdate' {} Maybe LinkAttributeAction
a -> LinkAttributeUpdate
s {$sel:attributeAction:LinkAttributeUpdate' :: Maybe LinkAttributeAction
attributeAction = Maybe LinkAttributeAction
a} :: LinkAttributeUpdate)

-- | The key of the attribute being updated.
linkAttributeUpdate_attributeKey :: Lens.Lens' LinkAttributeUpdate (Prelude.Maybe AttributeKey)
linkAttributeUpdate_attributeKey :: Lens' LinkAttributeUpdate (Maybe AttributeKey)
linkAttributeUpdate_attributeKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LinkAttributeUpdate' {Maybe AttributeKey
attributeKey :: Maybe AttributeKey
$sel:attributeKey:LinkAttributeUpdate' :: LinkAttributeUpdate -> Maybe AttributeKey
attributeKey} -> Maybe AttributeKey
attributeKey) (\s :: LinkAttributeUpdate
s@LinkAttributeUpdate' {} Maybe AttributeKey
a -> LinkAttributeUpdate
s {$sel:attributeKey:LinkAttributeUpdate' :: Maybe AttributeKey
attributeKey = Maybe AttributeKey
a} :: LinkAttributeUpdate)

instance Prelude.Hashable LinkAttributeUpdate where
  hashWithSalt :: Int -> LinkAttributeUpdate -> Int
hashWithSalt Int
_salt LinkAttributeUpdate' {Maybe AttributeKey
Maybe LinkAttributeAction
attributeKey :: Maybe AttributeKey
attributeAction :: Maybe LinkAttributeAction
$sel:attributeKey:LinkAttributeUpdate' :: LinkAttributeUpdate -> Maybe AttributeKey
$sel:attributeAction:LinkAttributeUpdate' :: LinkAttributeUpdate -> Maybe LinkAttributeAction
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe LinkAttributeAction
attributeAction
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AttributeKey
attributeKey

instance Prelude.NFData LinkAttributeUpdate where
  rnf :: LinkAttributeUpdate -> ()
rnf LinkAttributeUpdate' {Maybe AttributeKey
Maybe LinkAttributeAction
attributeKey :: Maybe AttributeKey
attributeAction :: Maybe LinkAttributeAction
$sel:attributeKey:LinkAttributeUpdate' :: LinkAttributeUpdate -> Maybe AttributeKey
$sel:attributeAction:LinkAttributeUpdate' :: LinkAttributeUpdate -> Maybe LinkAttributeAction
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe LinkAttributeAction
attributeAction
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe AttributeKey
attributeKey

instance Data.ToJSON LinkAttributeUpdate where
  toJSON :: LinkAttributeUpdate -> Value
toJSON LinkAttributeUpdate' {Maybe AttributeKey
Maybe LinkAttributeAction
attributeKey :: Maybe AttributeKey
attributeAction :: Maybe LinkAttributeAction
$sel:attributeKey:LinkAttributeUpdate' :: LinkAttributeUpdate -> Maybe AttributeKey
$sel:attributeAction:LinkAttributeUpdate' :: LinkAttributeUpdate -> Maybe LinkAttributeAction
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AttributeAction" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LinkAttributeAction
attributeAction,
            (Key
"AttributeKey" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AttributeKey
attributeKey
          ]
      )