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

import Amazonka.CloudDirectory.Types.AttributeKey
import Amazonka.CloudDirectory.Types.LinkAttributeAction
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(LinkAttributeUpdate -> LinkAttributeUpdate -> Bool)
-> (LinkAttributeUpdate -> LinkAttributeUpdate -> Bool)
-> Eq LinkAttributeUpdate
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]
(Int -> ReadS LinkAttributeUpdate)
-> ReadS [LinkAttributeUpdate]
-> ReadPrec LinkAttributeUpdate
-> ReadPrec [LinkAttributeUpdate]
-> Read 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
(Int -> LinkAttributeUpdate -> ShowS)
-> (LinkAttributeUpdate -> String)
-> ([LinkAttributeUpdate] -> ShowS)
-> Show LinkAttributeUpdate
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. LinkAttributeUpdate -> Rep LinkAttributeUpdate x)
-> (forall x. Rep LinkAttributeUpdate x -> LinkAttributeUpdate)
-> Generic LinkAttributeUpdate
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' :: Maybe LinkAttributeAction
-> Maybe AttributeKey -> LinkAttributeUpdate
LinkAttributeUpdate'
    { $sel:attributeAction:LinkAttributeUpdate' :: Maybe LinkAttributeAction
attributeAction =
        Maybe LinkAttributeAction
forall a. Maybe a
Prelude.Nothing,
      $sel:attributeKey:LinkAttributeUpdate' :: Maybe AttributeKey
attributeKey = Maybe 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 :: (Maybe LinkAttributeAction -> f (Maybe LinkAttributeAction))
-> LinkAttributeUpdate -> f LinkAttributeUpdate
linkAttributeUpdate_attributeAction = (LinkAttributeUpdate -> Maybe LinkAttributeAction)
-> (LinkAttributeUpdate
    -> Maybe LinkAttributeAction -> LinkAttributeUpdate)
-> Lens
     LinkAttributeUpdate
     LinkAttributeUpdate
     (Maybe LinkAttributeAction)
     (Maybe LinkAttributeAction)
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 :: (Maybe AttributeKey -> f (Maybe AttributeKey))
-> LinkAttributeUpdate -> f LinkAttributeUpdate
linkAttributeUpdate_attributeKey = (LinkAttributeUpdate -> Maybe AttributeKey)
-> (LinkAttributeUpdate
    -> Maybe AttributeKey -> LinkAttributeUpdate)
-> Lens
     LinkAttributeUpdate
     LinkAttributeUpdate
     (Maybe AttributeKey)
     (Maybe 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

instance Prelude.NFData LinkAttributeUpdate

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AttributeAction" Text -> LinkAttributeAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (LinkAttributeAction -> Pair)
-> Maybe LinkAttributeAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LinkAttributeAction
attributeAction,
            (Text
"AttributeKey" Text -> AttributeKey -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (AttributeKey -> Pair) -> Maybe AttributeKey -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AttributeKey
attributeKey
          ]
      )